1.生成虚拟包
This commit is contained in:
parent
350c68897b
commit
cbf02496eb
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.product.bomnew.api.user;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
|
@ -8,6 +9,8 @@ import com.nflg.product.base.core.api.BaseApi;
|
|||
import com.nflg.product.bomnew.pojo.dto.BomNewEBomCreateDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewEBomImportExcelDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewOriginalExcelDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.VirtualPackageParamDto;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
|
||||
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
|
|
@ -15,6 +18,8 @@ import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
|||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import com.nflg.product.bomnew.service.BomNewOriginalParentService;
|
||||
import com.nflg.product.bomnew.service.MaterialMainService;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageBase;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageFor31;
|
||||
import com.nflg.product.bomnew.util.EecExcelUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -77,6 +82,17 @@ public class EbomApi extends BaseApi {
|
|||
|
||||
}
|
||||
|
||||
@PostMapping("generateVirtualPackage")
|
||||
@ApiOperation("生成虚拟包")
|
||||
public ResultVO<Boolean> generateVirtualPackage(@RequestBody VirtualPackageParamDto paramDto) {
|
||||
VUtils.isTure(CollUtil.isEmpty(paramDto.getVirtualPackageValue())).throwMessage("请选择要生成的虚拟包");
|
||||
bomNewEbomParentService.generateVirtualPackage(paramDto);
|
||||
VUtils.isTure(true).throwMessage("请选择30开头的或200401类型的物料");
|
||||
return ResultVO.success(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("exportBom")
|
||||
@ApiOperation("导出")
|
||||
public void exportBom(@RequestBody List<Long> bomRowIds, HttpServletResponse response) throws IOException {
|
||||
|
|
@ -88,7 +104,7 @@ public class EbomApi extends BaseApi {
|
|||
@GetMapping("createBomDownExcelTmp")
|
||||
@ApiOperation("创建EBOM-导入时模版下载")
|
||||
public void createBomDownExcelTmp(HttpServletResponse response) throws IOException {
|
||||
EecExcelUtil.setResponseExcelHeader(response, "eBom-create-template");
|
||||
EecExcelUtil.setResponseExcelHeader(response, "eBom导入模版");
|
||||
new Workbook("eBom-create-template", "").addSheet(new ListSheet<>("sheet1", ImmutableList.of(new BomNewEBomImportExcelDTO()))).writeTo(response.getOutputStream());
|
||||
}
|
||||
|
||||
|
|
@ -112,8 +128,8 @@ public class EbomApi extends BaseApi {
|
|||
VUtils.isTure(CollUtil.isEmpty(createDTO.getDatas())).throwMessage("子级不能为空");
|
||||
List<BomNewEBomImportExcelDTO> noMaterialList = createDTO.getDatas().stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||
VUtils.isTure(CollUtil.isNotEmpty(noMaterialList)).throwMessage("子级存在物料编码为空的数据");
|
||||
bomNewEbomParentService.createBom(createDTO);
|
||||
return ResultVO.success(true);
|
||||
bomNewEbomParentService.createBom(createDTO);
|
||||
return ResultVO.success(true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.nflg.product.bomnew.constant;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum EbomEditStatusEnum implements ValueEnum<Integer> {
|
||||
|
||||
HANDLER_CREATED(1, "待处理 "),
|
||||
HANDLER_FINISHED(2, "处理完成");
|
||||
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.product.bomnew.constant;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum VirtualPackageTypeEnum implements ValueEnum<Integer>{
|
||||
//1-发货包 2-制作包 4-直发包 8-发货前装配包
|
||||
DELIVERY_PACKAGE(1,"发货包","发货" ,"201101"),
|
||||
MAKING_PACKAGE(2,"制作包","制作","201101"),
|
||||
DIRECT_DELIVERY_PACKAGE(4,"直发包","直发","201101"),
|
||||
PRE_ASSEMBLY_PACKAGE(8,"发货前装配包","发货前装配","201201");
|
||||
|
||||
private final Integer value;
|
||||
private final String description;
|
||||
private final String conMaterialName;
|
||||
private final String materialCategoryCode;
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
|
|||
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.MaterialHistoryProjectTypeVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -36,4 +37,6 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
|
|||
List<BomNewEbomParentVO> getParentChild(@Param("rowId") Long rowId);
|
||||
|
||||
List<BomNewEbomParentVO> getParentChildBatch(@Param("rowIds") List<Long> rowIds);
|
||||
|
||||
MaterialHistoryProjectTypeVO getMaterialHistoryProjectType(@Param("materialNo")String materialNo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.nflg.product.bomnew.pojo.dto;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 虚拟包装参数
|
||||
*/
|
||||
@Data
|
||||
public class VirtualPackageParamDto {
|
||||
|
||||
@ApiModelProperty("物料BOM行ID")
|
||||
private Long bomRowId;
|
||||
|
||||
@ApiModelProperty("虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包")
|
||||
private List<Integer> virtualPackageValue;
|
||||
|
||||
}
|
||||
|
|
@ -200,6 +200,10 @@ public class BomNewEbomParentEntity implements Serializable {
|
|||
@ApiModelProperty(value = "异常状态:1=正常、2=冻结/完全弃用异常、3=递归异常、4=数据不完整异常、5=超级物料异常、6=重复异常")
|
||||
private Integer exceptionStatus;
|
||||
|
||||
@TableField(value = "virtual_package_is")
|
||||
@ApiModelProperty("是否虚拟包 0-否 1-是")
|
||||
private Integer virtualPackageIs;
|
||||
|
||||
/**
|
||||
* 来源行ID(原始BOM中的行ID)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable {
|
|||
|
||||
|
||||
@ApiModelProperty("物料BOM版本ID")
|
||||
private Long bomRowId;
|
||||
private Long bomRowId=0L;
|
||||
|
||||
@ApiModelProperty("父级行ID")
|
||||
private Long parentRowId;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.nflg.product.bomnew.pojo.vo;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 物料统计历史项目类别
|
||||
*/
|
||||
@Data
|
||||
public class MaterialHistoryProjectTypeVO {
|
||||
|
||||
@ApiModelProperty("项目类别")
|
||||
private String projectType;
|
||||
|
||||
@ApiModelProperty("项目类别使用次数")
|
||||
private Integer projectCount;
|
||||
}
|
||||
|
|
@ -10,11 +10,14 @@ import cn.hutool.core.util.StrUtil;
|
|||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.constant.*;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewEbomParentMapper;
|
||||
import com.nflg.product.bomnew.pojo.dto.BomNewEBomCreateDTO;
|
||||
import com.nflg.product.bomnew.pojo.dto.VirtualPackageParamDto;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity;
|
||||
|
|
@ -25,11 +28,16 @@ import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
|||
import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.EbomExcelVO;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.EBomDetailTask;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.EbomInitProjectType;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageBase;
|
||||
import com.nflg.product.bomnew.service.domain.EBom.VirtualPackageFor31;
|
||||
import com.nflg.product.bomnew.service.domain.OriginalBom.OriginalBomDetailTask;
|
||||
import com.nflg.product.bomnew.util.EecExcelUtil;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import nflg.product.common.constant.STATE;
|
||||
import nflg.product.common.vo.ResultVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.bouncycastle.cert.dane.DANECertificateFetcher;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
|
|
@ -46,11 +54,11 @@ import java.util.concurrent.ExecutionException;
|
|||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.ForkJoinTask;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
/**
|
||||
* t_bom_new_ebom_parent 表服务实现类
|
||||
*
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-11-17 16:55:11
|
||||
|
|
@ -71,6 +79,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -88,7 +97,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
* @param rowId
|
||||
* @return
|
||||
*/
|
||||
public List<BomNewEbomParentVO> getChild( Long rowId) {
|
||||
public List<BomNewEbomParentVO> getChild(Long rowId) {
|
||||
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(rowId);
|
||||
List<BomNewEbomParentVO> parentChild = this.getBaseMapper().getParentChild(rowId);
|
||||
materialMainService.intiMaterialInfo(parentChild);
|
||||
|
|
@ -130,17 +139,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
}
|
||||
|
||||
public List<BomNewEbomParentVO> getChildBatch( List<Long> rowIds){
|
||||
List<BomNewEbomParentVO> result=new ArrayList<>();
|
||||
public List<BomNewEbomParentVO> getChildBatch(List<Long> rowIds) {
|
||||
List<BomNewEbomParentVO> result = new ArrayList<>();
|
||||
for (Long bomRowId : rowIds) {
|
||||
result.addAll(getChild(bomRowId));
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取整个BOM树
|
||||
*
|
||||
* @param rowId
|
||||
* @return
|
||||
* @throws ExecutionException
|
||||
|
|
@ -159,50 +169,87 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
/**
|
||||
* 初始化-项目类别
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void projectTypeInit(List<Long> bomRowIds) throws ExecutionException, InterruptedException {
|
||||
public void projectTypeInit(List<Long> bomRowIds) throws ExecutionException, InterruptedException {
|
||||
|
||||
for ( Long bomRowId: bomRowIds) {
|
||||
List<BomNewEbomParentVO> data=getBomTree(bomRowId);
|
||||
for (Long bomRowId : bomRowIds) {
|
||||
List<BomNewEbomParentVO> data = getBomTree(bomRowId);
|
||||
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId));
|
||||
//初始化物料信息
|
||||
materialMainService.intiMaterialInfo(data);
|
||||
projectTypeInitDo(data);
|
||||
|
||||
productTypeInitDo(parent, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void projectTypeInitDo(List<BomNewEbomParentVO> data){
|
||||
List<BomNewEbomParentVO> parentBom = data.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
|
||||
for ( BomNewEbomParentVO item: parentBom) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void productTypeInitDo(BomNewEbomParentVO parent, List<BomNewEbomParentVO> data) {
|
||||
EbomInitProjectType task = new EbomInitProjectType(parent, data);
|
||||
task.initProjectType();
|
||||
List<BomNewEbomParentVO> allList = task.getAllChild();
|
||||
List<BomNewEbomParentVO> parentResult = allList.stream().filter(u -> u.getParentRowId() > 0 && StrUtil.isNotBlank(u.getProjectType())).collect(Collectors.toList());
|
||||
List<BomNewEbomParentEntity> parents = new ArrayList<>();
|
||||
List<BomNewEbomChildEntity> child = new ArrayList<>();
|
||||
parentResult.forEach(u -> {
|
||||
BomNewEbomParentEntity parentEntity = new BomNewEbomParentEntity();
|
||||
parentEntity.setRowId(u.getParentRowId());
|
||||
parentEntity.setProjectType(u.getProjectType());
|
||||
parentEntity.setProjectTypeInputType(u.getProjectTypeInputType());
|
||||
parents.add(parentEntity);
|
||||
});
|
||||
|
||||
List<BomNewEbomParentVO> childs= data.stream().filter(u->u.getParentRowId().equals(item.getBomRowId())).collect(Collectors.toList());
|
||||
for (BomNewEbomParentVO child: childs) {
|
||||
if(StrUtil.isNotBlank(child.getMaterialCategoryCode()) && ProjectTypeInputTypeEnum.AUTO_MATCH.equalsValue(child.getProjectTypeInputType()) ){
|
||||
if(child.getMaterialCategoryCode().equals("1013") || child.getMaterialCategoryCode().equals("100601")) {
|
||||
child.setProjectType("F");
|
||||
}
|
||||
if(child.getMaterialCategoryCode().equals("2005") && child.getMaterialName().contains("溜管")) {
|
||||
child.setProjectType("Q");
|
||||
}
|
||||
if(child.getMaterialCategoryCode().equals("20") && child.getMaterialName().contains("清点")) {
|
||||
child.setProjectType("Q");
|
||||
}
|
||||
if(child.getMaterialCategoryCode().equals("2009") || child.getMaterialCategoryCode().equals("2005")|| child.getMaterialCategoryCode().equals("2006")) {
|
||||
child.setProjectType("Q");
|
||||
}
|
||||
List<BomNewEbomParentVO> childntResult = allList.stream().filter(u -> u.getBomRowId() > 0 && StrUtil.isNotBlank(u.getProjectType())).collect(Collectors.toList());
|
||||
parentResult.forEach(u -> {
|
||||
BomNewEbomChildEntity childEntity = new BomNewEbomChildEntity();
|
||||
childEntity.setRowId(u.getRowId());
|
||||
childEntity.setProjectType(u.getProjectType());
|
||||
childEntity.setProjectTypeInputType(u.getProjectTypeInputType());
|
||||
child.add(childEntity);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(parents)) {
|
||||
this.updateBatchById(parents);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(child)) {
|
||||
ebomChildService.updateBatchById(child);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成虚拟包
|
||||
*
|
||||
* @param paramDto
|
||||
*/
|
||||
public void generateVirtualPackage(VirtualPackageParamDto paramDto) {
|
||||
try {
|
||||
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(paramDto.getBomRowId()));
|
||||
materialMainService.intiMaterialInfo(ImmutableList.of(parent), BomNewEbomParentVO::getMaterialNo);
|
||||
if (parent.getMaterialCategoryCode().startsWith("30") || parent.getMaterialCategoryCode().equals("200401")) {
|
||||
VirtualPackageBase generate;
|
||||
if (parent.getMaterialCategoryCode().startsWith("30")) {
|
||||
generate = new VirtualPackageFor31(paramDto.getBomRowId(), paramDto.getVirtualPackageValue());
|
||||
} else {
|
||||
generate = new VirtualPackageFor31(paramDto.getBomRowId(), paramDto.getVirtualPackageValue());
|
||||
}
|
||||
if(StrUtil.isNotBlank(item.getMaterialCategoryCode()) && item.getMaterialCategoryCode().equals("200501")){
|
||||
child.setProjectType("L");
|
||||
generate.generateVirtualPackage();
|
||||
|
||||
if (CollUtil.isNotEmpty(generate.getParentResult())) {
|
||||
this.saveOrUpdateBatch(generate.getParentResult());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(generate.getChildResult())) {
|
||||
ebomChildService.saveOrUpdateBatch(generate.getChildResult());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
List<BomNewEbomChildEntity> childsUp = data.stream().filter(u -> StrUtil.isNotBlank(u.getProjectType())).map(u -> new BomNewEbomChildEntity().setRowId(u.getRowId()).setProjectType(u.getProjectType())).collect(Collectors.toList());
|
||||
//保存
|
||||
ebomChildService.saveOrUpdateBatch(childsUp);
|
||||
|
||||
catch (Exception ex){
|
||||
throw new NflgBusinessException (STATE.BusinessError,ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void exportBom(List<Long> bomRowIds , HttpServletResponse response) throws IOException {
|
||||
|
||||
public void exportBom(List<Long> bomRowIds, HttpServletResponse response) throws IOException {
|
||||
|
||||
final ListSheet<EbomExcelVO> listSheet = new ListSheet<EbomExcelVO>() {
|
||||
@Override
|
||||
|
|
@ -212,15 +259,16 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
return Convert.toList(EbomExcelVO.class, child);
|
||||
}
|
||||
};
|
||||
EecExcelUtil.eecExcel("bom列表", listSheet ,response);
|
||||
EecExcelUtil.eecExcel("bom列表", listSheet, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手工创建EBOM
|
||||
*
|
||||
* @param createDTO
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createBom(BomNewEBomCreateDTO createDTO){
|
||||
public void createBom(BomNewEBomCreateDTO createDTO) {
|
||||
//物料编码
|
||||
List<String> materialNos = createDTO.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
|
||||
materialNos.add(createDTO.getMaterialNo());
|
||||
|
|
@ -233,13 +281,13 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
|
||||
|
||||
Set<String> difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos));
|
||||
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",",difference)+"在物料档案中不存在");
|
||||
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在");
|
||||
|
||||
Map<String, BaseMaterialVO> materialVOMap = ListCommonUtil.listToMap(materialBaseInfo, BaseMaterialVO::getMaterialNo);
|
||||
|
||||
BomNewEbomParentEntity parent=new BomNewEbomParentEntity();
|
||||
BaseMaterialVO material=materialVOMap.get(createDTO.getMaterialNo());
|
||||
String batchNo= IdUtil.simpleUUID();
|
||||
BomNewEbomParentEntity parent = new BomNewEbomParentEntity();
|
||||
BaseMaterialVO material = materialVOMap.get(createDTO.getMaterialNo());
|
||||
String batchNo = IdUtil.simpleUUID();
|
||||
parent.setRowId(IdWorker.getId());
|
||||
parent.setBatchNo(batchNo);
|
||||
parent.setDrawingNo(material.getDrawingNo());
|
||||
|
|
@ -258,15 +306,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
parent.setEditStatus(createDTO.getOpType());
|
||||
|
||||
List<BomNewEbomChildEntity> bomNewEbomChildEntities = Convert.toList(BomNewEbomChildEntity.class, createDTO.getDatas());
|
||||
for (BomNewEbomChildEntity ebomChild:bomNewEbomChildEntities) {
|
||||
BaseMaterialVO cmaterial=materialVOMap.get(ebomChild.getMaterialNo());
|
||||
BeanUtil.copyProperties(cmaterial,ebomChild);
|
||||
for (BomNewEbomChildEntity ebomChild : bomNewEbomChildEntities) {
|
||||
BaseMaterialVO cmaterial = materialVOMap.get(ebomChild.getMaterialNo());
|
||||
BeanUtil.copyProperties(cmaterial, ebomChild);
|
||||
ebomChild.setRowId(IdWorker.getId());
|
||||
ebomChild.setParentRowId(parent.getRowId());
|
||||
ebomChild.setTotalWeight(NumberUtil.mul(ebomChild.getUnitWeight(),ebomChild.getNum()));
|
||||
ebomChild.setTotalWeight(NumberUtil.mul(ebomChild.getUnitWeight(), ebomChild.getNum()));
|
||||
ebomChild.setProjectTypeInputType(1);
|
||||
ebomChild.setEditStatus(createDTO.getOpType());
|
||||
ebomChild.setIdentityNo(StrUtil.join("-",parent.getRowId(),ebomChild.getRowId()));
|
||||
ebomChild.setIdentityNo(StrUtil.join("-", parent.getRowId(), ebomChild.getRowId()));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,21 @@ package com.nflg.product.bomnew.service.domain.EBom;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
|
||||
import com.nflg.product.bomnew.mapper.master.BomNewEbomParentMapper;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.pojo.vo.MaterialHistoryProjectTypeVO;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 初始化项目类别
|
||||
|
|
@ -21,30 +28,35 @@ public class EbomInitProjectType {
|
|||
|
||||
private BomNewEbomParentVO firstParent;
|
||||
|
||||
@Getter
|
||||
private List<BomNewEbomParentVO> allChild;
|
||||
|
||||
public EbomInitProjectType(BomNewEbomParentVO inFirstParent, List<BomNewEbomParentVO> inAllChild) {
|
||||
this.firstParent = inFirstParent;
|
||||
this.allChild = inAllChild;
|
||||
allChild.add(firstParent);
|
||||
initProjectType(allChild);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化项目类别
|
||||
*
|
||||
* @param data
|
||||
* @param
|
||||
*/
|
||||
private void initProjectType(List<BomNewEbomParentVO> data) {
|
||||
|
||||
for (BomNewEbomParentVO child : data) {
|
||||
public void initProjectType() {
|
||||
|
||||
for (BomNewEbomParentVO child : allChild) {
|
||||
if (StrUtil.isBlank(child.getMaterialCategoryCode())) {
|
||||
continue;
|
||||
}
|
||||
String materialProjectType = child.getProjectType();
|
||||
child.setProjectType("");
|
||||
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.AUTO_MATCH.getValue());
|
||||
if (StrUtil.isNotBlank(child.getMaterialCategoryCode()) && !ProjectTypeInputTypeEnum.MANUAL_INPUT.equalsValue(child.getProjectTypeInputType())) {
|
||||
if (child.getMaterialCategoryCode().startsWith("1013") || child.getMaterialCategoryCode().startsWith("100601")) {
|
||||
child.setProjectType("F");
|
||||
|
||||
continue;
|
||||
}
|
||||
if (child.getMaterialCategoryCode().startsWith("2011")) {
|
||||
|
|
@ -81,72 +93,105 @@ public class EbomInitProjectType {
|
|||
continue;
|
||||
}
|
||||
//7
|
||||
if (child.getMaterialCategoryCode().startsWith("2009")) {
|
||||
//获取同层物料
|
||||
if (child.getParentRowId() > 0) {
|
||||
List<BomNewEbomParentVO> sameLevleChilds = getChilds(child.getParentRowId());
|
||||
List<BomNewEbomParentVO> sResult = sameLevleChilds.stream().filter(u -> u.getMaterialCategoryCode().startsWith("2005") || u.getMaterialCategoryCode().startsWith("2006")).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(sResult)) {
|
||||
List<BomNewEbomParentVO> noProjectTypeList = sResult.stream().filter(u -> StrUtil.isBlank(u.getProjectType())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(noProjectTypeList)) {
|
||||
initProjectType(noProjectTypeList);
|
||||
}
|
||||
List<String> projectType = sResult.stream().map(u -> u.getProjectType()).distinct().collect(Collectors.toList());
|
||||
if(projectType.size()==1 && projectType.get(0).equals("Q")){
|
||||
child.setProjectType("Q");
|
||||
}
|
||||
|
||||
}
|
||||
continue;
|
||||
|
||||
}
|
||||
//8
|
||||
if(child.getMaterialCategoryCode().startsWith("20") && !child.getMaterialCategoryCode().startsWith("2005") && !child.getMaterialName().contains("清点")
|
||||
&& !child.getMaterialCategoryCode().startsWith("2011")){
|
||||
child.setProjectType(materialProjectType);
|
||||
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MATERIAL_MAIN_DATA.getValue());
|
||||
continue;
|
||||
}
|
||||
//9
|
||||
if(child.getMaterialCategoryCode().startsWith("1004")){
|
||||
//同层物料
|
||||
List<BomNewEbomParentVO> sameLevelChild = getChilds(child.getParentRowId());
|
||||
//除紧固件外的其他物料
|
||||
List<BomNewEbomParentVO> sResult = sameLevelChild.stream().filter(u -> !u.getMaterialCategoryCode().startsWith("1004")).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(sResult)) {
|
||||
List<BomNewEbomParentVO> noProjectTypeList = sResult.stream().filter(u -> StrUtil.isBlank(u.getProjectType())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(noProjectTypeList)) {
|
||||
initProjectType(noProjectTypeList);
|
||||
}
|
||||
List<String> projectType = sResult.stream().map(u -> u.getProjectType()).distinct().collect(Collectors.toList());
|
||||
Sets.newHashSet("");
|
||||
|
||||
}
|
||||
}
|
||||
//10
|
||||
BomNewEbomParentVO parent = getParent(child.getParentRowId());
|
||||
if(Objects.nonNull(parent) && parent.getProjectType().equals("Q")){
|
||||
List<BomNewEbomParentVO> subChild= getChilds(child.getBomRowId());
|
||||
List<BomNewEbomParentVO> collect = subChild.stream().filter(u -> u.getMaterialCategoryCode().startsWith("1004")).collect(Collectors.toList());
|
||||
collect.forEach(u->u.setProjectType("L"));
|
||||
}
|
||||
|
||||
//8
|
||||
if (child.getMaterialCategoryCode().startsWith("20") && !child.getMaterialCategoryCode().startsWith("2005") && !child.getMaterialName().contains("清点")
|
||||
&& !child.getMaterialCategoryCode().startsWith("2011")) {
|
||||
child.setProjectType(materialProjectType);
|
||||
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MATERIAL_MAIN_DATA.getValue());
|
||||
continue;
|
||||
}
|
||||
//9
|
||||
|
||||
//10
|
||||
BomNewEbomParentVO parent = getParent(child.getParentRowId());
|
||||
if (Objects.nonNull(parent) && parent.getProjectType().equals("Q")) {
|
||||
List<BomNewEbomParentVO> subChild = getChilds(child.getBomRowId());
|
||||
List<BomNewEbomParentVO> collect = subChild.stream().filter(u -> u.getMaterialCategoryCode().startsWith("1004")).collect(Collectors.toList());
|
||||
collect.forEach(u -> u.setProjectType("L"));
|
||||
}
|
||||
|
||||
//11
|
||||
if ((child.getMaterialCategoryCode().startsWith("10") || child.getMaterialCategoryCode().startsWith("40")) && !child.getMaterialCategoryCode().startsWith("1013") && !child.getMaterialCategoryCode().startsWith("100601")
|
||||
{
|
||||
MaterialHistoryProjectTypeVO materialHistoryProjectType = SpringUtil.getBean(BomNewEbomParentMapper.class).getMaterialHistoryProjectType(child.getMaterialNo());
|
||||
if (Objects.nonNull(materialHistoryProjectType)) {
|
||||
child.setProjectType(materialHistoryProjectType.getProjectType());
|
||||
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.HISTORY_STATISTICS.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (StrUtil.isNotBlank(child.getMaterialCategoryCode()) && child.getMaterialCategoryCode().equals("200501")) {
|
||||
child.setProjectType("L");
|
||||
|
||||
}
|
||||
//7
|
||||
List<BomNewEbomParentVO> list2009 = allChild.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialCategoryCode()) && u.getMaterialCategoryCode().startsWith("2009")).collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> sameLevelChild = new ArrayList<>();
|
||||
List<BomNewEbomParentVO> sResult = new ArrayList<>();
|
||||
for (BomNewEbomParentVO child : list2009) {
|
||||
sameLevelChild = getChilds(child.getParentRowId());
|
||||
sResult = sameLevelChild.stream().filter(u -> u.getMaterialCategoryCode().startsWith("2005") || u.getMaterialCategoryCode().startsWith("2006")).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(sResult)) {
|
||||
List<String> projectType = sResult.stream().map(u -> u.getProjectType()).distinct().collect(Collectors.toList());
|
||||
if (projectType.size() == 1 && projectType.get(0).equals("Q")) {
|
||||
child.setProjectType("Q");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//9
|
||||
List<BomNewEbomParentVO> list1004 = allChild.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialCategoryCode()) && u.getMaterialCategoryCode().startsWith("1004")).collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> sameLevelChild1004 = new ArrayList<>();
|
||||
List<BomNewEbomParentVO> sResult1004 = new ArrayList<>();
|
||||
List<BomNewEbomParentVO> sResultProjectL = new ArrayList<>();
|
||||
for (BomNewEbomParentVO child : list1004) {
|
||||
//同层物料
|
||||
sameLevelChild1004 = getChilds(child.getParentRowId());
|
||||
//除紧固件外的其他物料
|
||||
sResult1004 = sameLevelChild.stream().filter(u -> !u.getMaterialCategoryCode().startsWith("1004")).collect(Collectors.toList());
|
||||
Integer resultNo1004 = 1;
|
||||
if (CollUtil.isNotEmpty(sResult1004)) {
|
||||
resultNo1004 = resultNo1004 & projectTypeEquals(sResult1004, Sets.newHashSet("F", "Q"));
|
||||
}
|
||||
|
||||
sResultProjectL = sameLevelChild1004.stream().filter(u -> u.getProjectType().equals("L")).collect(Collectors.toList());
|
||||
|
||||
int lResult = 1;
|
||||
for (BomNewEbomParentVO v : sResultProjectL) {
|
||||
lResult = lResult & projectTypeEquals(getChilds(v.getBomRowId()), Sets.newHashSet("F", "Q"));
|
||||
}
|
||||
if ((resultNo1004 & lResult) == 1) {
|
||||
child.setProjectType("F");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断项目类型是否一致
|
||||
*
|
||||
* @param list
|
||||
* @param projectTypes
|
||||
* @return
|
||||
*/
|
||||
private int projectTypeEquals(List<BomNewEbomParentVO> list, Set<String> projectTypes) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return 0;
|
||||
}
|
||||
Set<String> collect = list.stream().filter(u -> projectTypes.contains(u.getProjectType())).map(u -> u.getProjectType()).collect(Collectors.toSet());
|
||||
if (collect.size() == projectTypes.size()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取父级
|
||||
*
|
||||
* @param rowId
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -155,10 +200,6 @@ public class EbomInitProjectType {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取子节点
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.bomnew.constant.EBomSourceEnum;
|
||||
import com.nflg.product.bomnew.constant.EbomEditStatusEnum;
|
||||
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
|
||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import com.nflg.product.bomnew.service.MaterialService;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import sun.security.krb5.internal.PAData;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 生成虚拟包基类
|
||||
*/
|
||||
public abstract class VirtualPackageBase {
|
||||
|
||||
|
||||
@Getter
|
||||
protected List<BomNewEbomParentEntity> parentResult=new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
protected List<BomNewEbomChildEntity> childResult=new ArrayList<>();
|
||||
|
||||
@ApiModelProperty("物料bom行ID")
|
||||
protected Long bomRowId;
|
||||
|
||||
@ApiModelProperty("虚拟包 1-发货包 2-制作包 4-直发包 8-发货前装配包")
|
||||
protected List<Integer> virtualPackageValue;
|
||||
|
||||
protected BomNewEbomParentEntity buildParentVirtualPackage(String drawingNo, String materialName, VirtualPackageTypeEnum virtualPackageType) throws IOException {
|
||||
//申请物料
|
||||
String vDrawingNo = String.join("",drawingNo,"(",virtualPackageType.getConMaterialName(),")" );
|
||||
BomNewEbomParentEntity oldParent= SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().eq(BomNewEbomParentEntity::getDrawingNo, vDrawingNo).eq(BomNewEbomParentEntity::getLastVersionIs,1).one();
|
||||
if(Objects.nonNull(oldParent)){
|
||||
oldParent.setLastVersionIs(0);
|
||||
this.parentResult.add(oldParent);
|
||||
}
|
||||
String materialNo = SpringUtil.getBean(MaterialService.class).addMaterial(drawingNo, materialName, virtualPackageType.getMaterialCategoryCode());
|
||||
BomNewEbomParentEntity parent =new BomNewEbomParentEntity();
|
||||
parent.setRowId(IdWorker.getId());
|
||||
parent.setOrderNumber("001");
|
||||
parent.setDrawingNo(vDrawingNo );
|
||||
parent.setMaterialNo(materialNo);
|
||||
parent.setMaterialName(StrUtil.join("",materialName,"(",virtualPackageType.getConMaterialName(),")"));
|
||||
parent.setMaterialDesc(StrUtil.join("", drawingNo ," ", materialName,"(",virtualPackageType.getConMaterialName(),")"));
|
||||
parent.setCurrentVersion(VersionUtil.getNextVersion(Objects.nonNull(oldParent)?oldParent.getCurrentVersion():""));
|
||||
parent.setVirtualPackageIs(1);
|
||||
parent.setProjectType("L");
|
||||
parent.setProjectTypeInputType(ProjectTypeInputTypeEnum.AUTO_MATCH.getValue());
|
||||
parent.setShouldBomExist(1);
|
||||
parent.setBomExist(1);
|
||||
parent.setSourceRowId(0L);
|
||||
parent.setLastVersionIs(1);
|
||||
parent.setDeviseName(SessionUtil.getUserCode());
|
||||
parent.setDeviseName(SessionUtil.getRealName());
|
||||
parent.setCreatedBy(SessionUtil.getUserCode());
|
||||
parent.setDeptName(SessionUtil.getDepartName());
|
||||
|
||||
this.parentResult.add(parent);
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建子级
|
||||
* @return
|
||||
*/
|
||||
protected BomNewEbomChildEntity buildChild(BomNewEbomParentEntity parent, Long parentRowId, String orderNo,VirtualPackageTypeEnum virtualPackageTypeEnum){
|
||||
BomNewEbomChildEntity childEntity =new BomNewEbomChildEntity();
|
||||
BeanUtil.copyProperties(parent,childEntity);
|
||||
childEntity.setRowId(IdWorker.getId());
|
||||
childEntity.setParentRowId(parentRowId);
|
||||
childEntity.setIdentityNo(parent.getRowId().toString());
|
||||
childEntity.setOrderNumber(orderNo);
|
||||
childEntity.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
|
||||
childEntity.setSource(EBomSourceEnum.FROM_MDM.getValue());
|
||||
this.childResult.add(childEntity);
|
||||
return childEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子级
|
||||
* @return
|
||||
*/
|
||||
protected List<BomNewEbomParentVO> getChild(){
|
||||
return SpringUtil.getBean(BomNewEbomParentService.class).getChild(bomRowId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成虚拟包
|
||||
*/
|
||||
public abstract void generateVirtualPackage() throws IOException;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import nflg.product.common.constant.STATE;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 31物料生成虚拟包
|
||||
*/
|
||||
public class VirtualPackageFor21 extends VirtualPackageBase {
|
||||
|
||||
|
||||
/**
|
||||
* @param bomRowId 物料BOM-行ID
|
||||
* @param virtualPackageValue 要生成的虚拟包
|
||||
*/
|
||||
public VirtualPackageFor21(Long bomRowId, List<Integer> virtualPackageValue) {
|
||||
this.bomRowId = bomRowId;
|
||||
this.virtualPackageValue = virtualPackageValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 31物料生成虚拟包
|
||||
*/
|
||||
@Override
|
||||
public void generateVirtualPackage() throws IOException {
|
||||
|
||||
BomNewEbomParentEntity parent = SpringUtil.getBean(BomNewEbomParentService.class).lambdaQuery().eq(BomNewEbomParentEntity::getRowId, bomRowId).one();
|
||||
//构建构建发货包下制作包
|
||||
BomNewEbomParentEntity makingPackage = buildParentVirtualPackage(parent.getDrawingNo(), parent.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE);
|
||||
//构建构建发货包下直发
|
||||
BomNewEbomParentEntity directDeliveryPackage = buildParentVirtualPackage(parent.getDrawingNo(), parent.getMaterialName(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
|
||||
|
||||
//构建产品-子级为制作包合直发包
|
||||
buildChild(makingPackage, bomRowId, "001", VirtualPackageTypeEnum.MAKING_PACKAGE);
|
||||
buildChild(directDeliveryPackage, bomRowId, "002", VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
|
||||
//构建构建发货前装配包
|
||||
BomNewEbomParentEntity preAssemblyPackage = buildParentVirtualPackage(parent.getDrawingNo(), parent.getMaterialName(), VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||
|
||||
buildChild(preAssemblyPackage, makingPackage.getRowId(), "001", VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||
|
||||
List<BomNewEbomParentVO> child = getChild();
|
||||
//将产品子级放制作包下
|
||||
for (BomNewEbomParentVO item : child) {
|
||||
|
||||
BomNewEbomChildEntity itemUp = new BomNewEbomChildEntity();
|
||||
itemUp.setRowId(item.getRowId());
|
||||
itemUp.setParentRowId(makingPackage.getRowId());
|
||||
this.childResult.add(itemUp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package com.nflg.product.bomnew.service.domain.EBom;
|
||||
|
||||
import com.nflg.product.base.core.exception.NflgBusinessException;
|
||||
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
|
||||
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
|
||||
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
|
||||
import com.nflg.product.bomnew.util.EnumUtils;
|
||||
import nflg.product.common.constant.STATE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 31物料生成虚拟包
|
||||
*/
|
||||
public class VirtualPackageFor31 extends VirtualPackageBase {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bomRowId 物料BOM-行ID
|
||||
* @param virtualPackageValue 要生成的虚拟包
|
||||
*/
|
||||
public VirtualPackageFor31(Long bomRowId ,List<Integer> virtualPackageValue){
|
||||
this.bomRowId=bomRowId;
|
||||
this.virtualPackageValue=virtualPackageValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 31物料生成虚拟包
|
||||
*/
|
||||
@Override
|
||||
public void generateVirtualPackage() {
|
||||
List<BomNewEbomParentVO> child = getChild();
|
||||
try {
|
||||
for (BomNewEbomParentVO item : child) {
|
||||
//构建发货包
|
||||
BomNewEbomParentEntity deliveryPackage = buildParentVirtualPackage(item.getDrawingNo(), item.getMaterialName(), VirtualPackageTypeEnum.DELIVERY_PACKAGE);
|
||||
//构建构建发货包下制作包
|
||||
BomNewEbomParentEntity makingPackage = buildParentVirtualPackage(item.getDrawingNo(), item.getMaterialName(), VirtualPackageTypeEnum.MAKING_PACKAGE);
|
||||
//构建构建发货包下直发
|
||||
BomNewEbomParentEntity directDeliveryPackage = buildParentVirtualPackage(item.getDrawingNo(), item.getMaterialName(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
|
||||
//构建-产品下发货包-子级
|
||||
buildChild(deliveryPackage, bomRowId,"001",VirtualPackageTypeEnum.DELIVERY_PACKAGE);
|
||||
|
||||
//构建发货包-子级
|
||||
buildChild(makingPackage,deliveryPackage.getRowId(),"001",VirtualPackageTypeEnum.MAKING_PACKAGE);
|
||||
buildChild(directDeliveryPackage,deliveryPackage.getRowId(),"002",VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
|
||||
|
||||
BomNewEbomChildEntity itemUp=new BomNewEbomChildEntity();
|
||||
itemUp.setRowId(item.getRowId());
|
||||
itemUp.setParentRowId(makingPackage.getRowId());
|
||||
this.childResult.add(itemUp);
|
||||
|
||||
}
|
||||
}catch (Exception ex) {
|
||||
throw new NflgBusinessException(STATE.BusinessError, ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.nflg.product.bomnew.util;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
|
||||
|
||||
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
public class MyBeanUtil extends BeanUtil {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@
|
|||
<result column="status" property="status" jdbcType="INTEGER"/>
|
||||
<result column="user_root_is" property="userRootIs" jdbcType="INTEGER"/>
|
||||
<result column="exception_status" property="exceptionStatus" jdbcType="INTEGER"/>
|
||||
<result column="virtual_package_is" property="virtualPackageIs" jdbcType="INTEGER"/>
|
||||
<result column="source_row_id" property="sourceRowId" jdbcType="BIGINT"/>
|
||||
<result column="devise_user_code" property="deviseUserCode" jdbcType="VARCHAR"/>
|
||||
<result column="devise_name" property="deviseName" jdbcType="VARCHAR"/>
|
||||
|
|
@ -54,7 +55,7 @@
|
|||
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
row_id, batch_no, drawing_no, material_no, order_number, material_name, material_desc, material_texture, material_unit, unit_weight, total_weight, current_version, num, source, project_type, project_type_input_type, root_is, should_bom_exist, super_material_status, bom_exist, last_version_is, edit_status, status, user_root_is, exception_status, source_row_id, devise_user_code, devise_name, created_by, created_time, created_job, audit_time, audit_user_name, release_time, release_user_name, revert_time, revert_user_name, expire_end_time, convert_to_ebom_time, remark, dept_name, level_num, change_desc, notice_nums, modify_time </sql>
|
||||
row_id, batch_no, drawing_no, material_no, order_number, material_name, material_desc, material_texture, material_unit, unit_weight, total_weight, current_version, num, source, project_type, project_type_input_type, root_is, should_bom_exist, super_material_status, bom_exist, last_version_is, edit_status, status, user_root_is, exception_status,virtual_package_is, source_row_id, devise_user_code, devise_name, created_by, created_time, created_job, audit_time, audit_user_name, release_time, release_user_name, revert_time, revert_user_name, expire_end_time, convert_to_ebom_time, remark, dept_name, level_num, change_desc, notice_nums, modify_time </sql>
|
||||
|
||||
<sql id="whr">
|
||||
<if test="query.drawingNo!=null and query.drawingNo!=''">
|
||||
|
|
@ -99,4 +100,12 @@
|
|||
</foreach>
|
||||
|
||||
</select>
|
||||
<!--统计物料历史项目类别-->
|
||||
<select id="getMaterialHistoryProjectType" resultType="com.nflg.product.bomnew.pojo.vo.MaterialHistoryProjectTypeVO">
|
||||
select b.project_type, COUNT(1) projectCount from t_bom_new_ebom_parent a
|
||||
join t_bom_new_ebom_child b on a.row_id=b.parent_row_id and a.last_version_is=1
|
||||
where b.material_no=#{materialNo} group by b.project_type order by projectCount limit 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue