转pbom处理-2
This commit is contained in:
parent
57aa6603ce
commit
1e392b6a46
|
|
@ -111,10 +111,6 @@ public class EBomToPBom extends EBomToPbomBase {
|
|||
if(BooleanEnum.TRUE.equals(vo.getNoConvertToPBomIs()) ){
|
||||
continue;
|
||||
}
|
||||
//构建变更明细
|
||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||
|
||||
//子级
|
||||
List<BomNewEbomParentVO> child = result.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId()) && !childDelMaterialNos.contains(u.getMaterialNo())).distinct().collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> mergeChild=child;
|
||||
|
|
@ -126,8 +122,10 @@ public class EBomToPBom extends EBomToPbomBase {
|
|||
if(Objects.isNull(parentEnt)){
|
||||
continue;
|
||||
}
|
||||
//处理子级BOM
|
||||
mergeChild= handlerArtPackage(parentEnt,mergeChild,facCode,parentList);
|
||||
//子级
|
||||
if (CollUtil.isNotEmpty(child)) {
|
||||
if (CollUtil.isNotEmpty(mergeChild)) {
|
||||
//合并子级
|
||||
for (BomNewEbomParentVO eb : mergeChild) {
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
|
|
|
|||
|
|
@ -111,10 +111,6 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
|||
if (BooleanEnum.TRUE.equals(vo.getNoConvertToPBomIs())) {
|
||||
continue;
|
||||
}
|
||||
//构建变更明细
|
||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE);
|
||||
// buildUpgradeChangeDetail(vo, VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE);
|
||||
|
||||
//子级
|
||||
List<BomNewEbomParentVO> child = facBomDataMp.get(facCode).stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId()) && !childDelMaterialNos.contains(u.getMaterialNo())).distinct().collect(Collectors.toList());
|
||||
List<BomNewEbomParentVO> mergeChild=child;
|
||||
|
|
@ -122,17 +118,14 @@ public class EBomToPBomFor31 extends EBomToPbomBase {
|
|||
if(!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(vo.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(vo.getVirtualPartType())){
|
||||
mergeChild = mergeChild(child);
|
||||
}
|
||||
|
||||
// if(compareContentIsSame(vo, mergeChild, facCode) && !vo.getMaterialNo().equals(parent.getMaterialNo())){
|
||||
// continue;
|
||||
// }
|
||||
BomNewPbomParentEntity parentEnt = buildPBomParent(vo, facCode, parentList);
|
||||
if (Objects.isNull(parentEnt)) {
|
||||
continue;
|
||||
}
|
||||
//处理bom子级
|
||||
mergeChild= handlerArtPackage(parentEnt,mergeChild,facCode,parentList);
|
||||
//子级
|
||||
if (CollUtil.isNotEmpty(child)) {
|
||||
//合并子级
|
||||
if (CollUtil.isNotEmpty(mergeChild)) {
|
||||
for (BomNewEbomParentVO eb : mergeChild) {
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(eb, childEnt, "sourceRowId");
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nflg.product.bomnew.service.domain.EBom;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
|
|
@ -205,84 +206,78 @@ public abstract class EBomToPbomBase {
|
|||
return null;
|
||||
|
||||
} else { //pbom-处于正式表
|
||||
//Ebom为已发布时则直接跳过 (直发包,发货前装配包是则需对比Bom明细,一致则跳过,否则升级)
|
||||
|
||||
return buildParentEntity(parentVo, facCode, oldParent, VersionUtil.getNextVersionForSmallVersion(oldParent.getCurrentVersion()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理PBOM-正式包含工艺包时:
|
||||
* 1、将工艺包迁移过来。
|
||||
* 2、建BOM中新增物料-迁移过来
|
||||
* 3、将修改过的物料编码,项目类别,数量 复制过来。
|
||||
*
|
||||
*/
|
||||
private void handlerPBom(BomNewPbomParentEntity oldParent , List<BomNewEbomParentVO> newBomChildren){
|
||||
|
||||
List<BomNewPbomParentVO> oldChildren = SpringUtil.getBean(BomNewPbomParentService.class).getChild(oldParent.getRowId(), 1);
|
||||
//PBOM手动添加的迁移过来
|
||||
List<BomNewPbomParentVO> pBomCreateChildren = oldChildren.stream().filter(u -> PbomSourceStatusEnum.PBOM.equalsValue(u.getSourceStatus())).collect(Collectors.toList());
|
||||
//Pbom新增的工艺包
|
||||
List<BomNewPbomParentVO> pBomCreateArtPackage = pBomCreateChildren.stream().filter(u -> BomConstant.ART_PACKAGE_MATERIAL_CATEGORY_CODE.equals(u.getMaterialCategoryCode())).collect(Collectors.toList());
|
||||
for (BomNewPbomParentVO pBomCreateArtPackageItem : pBomCreateArtPackage) {
|
||||
if()
|
||||
}
|
||||
private BomNewPbomChildEntity buildPBomAddChild(BomNewPbomParentEntity parent, String facCode, BomNewPbomParentVO oldChild){
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(oldChild, childEnt, "sourceRowId");
|
||||
childEnt.setRowId(IdWorker.getId());
|
||||
childEnt.setParentRowId(parent.getRowId());
|
||||
childEnt.setFacCode(facCode);
|
||||
childEnt.setIdentityNo(StrUtil.join("-", parent.getMaterialNo(), oldChild.getMaterialNo()));
|
||||
childEnt.setCreatedTime(LocalDateTime.now());
|
||||
childEnt.setCreatedBy(SessionUtil.getUserCode());
|
||||
|
||||
this.pBomChildResult.add(childEnt);
|
||||
return childEnt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理PBOM新增物料
|
||||
*/
|
||||
private void handlerArtPackage(List<BomNewPbomParentVO> oldChildren , List<BomNewEbomParentVO> newBomChildren ,String facCode ,List<BomNewEbomParentVO> parentList){
|
||||
List<BomNewEbomParentVO> resultAdd=new ArrayList<>();
|
||||
//pbom 新增物料
|
||||
List<BomNewPbomParentVO> oldPBomCreateChildren = oldChildren.stream().filter(u -> StrUtil.isBlank(u.getOriginalMaterialNo())).collect(Collectors.toList());
|
||||
Map<String, BomNewEbomParentVO> newBomChildrenMap = newBomChildren.stream().collect(Collectors.toMap(BomNewEbomParentVO::getMaterialNo, u -> u));
|
||||
//Pbom新增的工艺包
|
||||
for (BomNewPbomParentVO oldPBomCreateArtPackageItem : oldPBomCreateChildren) {
|
||||
//新的不包含虚拟包:1、将该虚拟包加在该物料下,
|
||||
// 2、将虚拟包中的物料从该BOM中移除
|
||||
if(!newBomChildrenMap.containsKey(oldPBomCreateArtPackageItem.getMaterialNo())){
|
||||
BomNewEbomParentVO artChild=new BomNewEbomParentVO();
|
||||
BeanUtil.copyProperties(oldPBomCreateArtPackageItem,artChild);
|
||||
protected List<BomNewEbomParentVO> handlerArtPackage(BomNewPbomParentEntity parent , List<BomNewEbomParentVO> newBomChildren ,String facCode ,List<BomNewEbomParentVO> parentList){
|
||||
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||
.eq(BomNewPbomParentEntity::getFacCode, facCode).last(" order by current_version desc limit 1").one();
|
||||
List<String> delResult=new ArrayList<>();
|
||||
//pBom为已发布时
|
||||
if(Objects.nonNull(oldParent) && PBomStatusEnum.PUBLISH.getValue()<= oldParent.getStatus()) {
|
||||
List<BomNewPbomParentVO> oldChildren=SpringUtil.getBean(BomNewPbomParentService.class).getChild(oldParent.getRowId(),1);
|
||||
|
||||
BomNewPbomParentEntity artParent = buildPBomParent(artChild, facCode, parentList);
|
||||
//old 工艺包子级
|
||||
List<BomNewPbomParentVO> oldArtChildren = SpringUtil.getBean(BomNewPbomParentService.class).getChild(oldPBomCreateArtPackageItem.getBomRowId(), 1);
|
||||
if()
|
||||
//pBom 手工新增物料
|
||||
List<BomNewPbomParentVO> oldPBomAddChildren = oldChildren.stream().filter(u -> StrUtil.isBlank(u.getOriginalMaterialNo())).collect(Collectors.toList());
|
||||
Map<String, BomNewEbomParentVO> newBomChildrenMap = newBomChildren.stream().collect(Collectors.toMap(BomNewEbomParentVO::getMaterialNo, u -> u));
|
||||
|
||||
resultAdd.add(artChild);
|
||||
for (BomNewPbomParentVO oldPBomAddItem : oldPBomAddChildren) {
|
||||
//加入当前BOM明细中
|
||||
buildPBomAddChild(parent, facCode, oldPBomAddItem);
|
||||
|
||||
//
|
||||
//如为工艺包,且在当前BOM中不存在
|
||||
if (BomConstant.ART_PACKAGE_MATERIAL_CATEGORY_CODE.equals(oldPBomAddItem.getMaterialCategoryCode()) && !newBomChildrenMap.containsKey(oldPBomAddItem.getMaterialNo())) {
|
||||
//创建工艺包版本
|
||||
BomNewPbomParentEntity artParent = buildPBomParent(Convert.convert(BomNewEbomParentVO.class, oldPBomAddItem), facCode, parentList);
|
||||
//old 工艺包子级
|
||||
List<BomNewPbomParentVO> oldArtChildren = SpringUtil.getBean(BomNewPbomParentService.class).getChild(oldPBomAddItem.getBomRowId(), 1);
|
||||
for (BomNewPbomParentVO oldArtChild : oldArtChildren) {
|
||||
//工艺包新增
|
||||
if (StrUtil.isBlank(oldArtChild.getOriginalMaterialNo()) || newBomChildren.contains(oldArtChild.getOriginalMaterialNo())) {
|
||||
buildPBomAddChild(artParent, facCode, oldArtChild);
|
||||
if(StrUtil.isNotBlank(oldArtChild.getOriginalMaterialNo())) {
|
||||
delResult.add(oldArtChild.getOriginalMaterialNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//pBom中修改过的
|
||||
List<BomNewPbomParentVO> oldPBomUpdateChildren = oldChildren.stream().filter(u -> StrUtil.isNotBlank(u.getOriginalMaterialNo())).collect(Collectors.toList());
|
||||
for (BomNewPbomParentVO oldPBomUpdateChild : oldPBomUpdateChildren) {
|
||||
if (!oldPBomUpdateChild.getOriginalMaterialNo().equals(oldPBomUpdateChild.getMaterialNo()) || !oldPBomUpdateChild.getOriginalProjectType().equals(oldPBomUpdateChild.getProjectType()) || !oldPBomUpdateChild.getOriginalNum().equals(oldPBomUpdateChild.getNum())) {
|
||||
List<BomNewEbomParentVO> upEnts = newBomChildren.stream().filter(u -> u.getMaterialNo().equals(oldPBomUpdateChild.getOriginalMaterialNo())
|
||||
&& u.getProjectType().equals(oldPBomUpdateChild.getOriginalProjectType()) && u.getNum().equals(oldPBomUpdateChild.getOriginalNum())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(upEnts)) {
|
||||
buildPBomAddChild(parent, facCode, oldPBomUpdateChild);
|
||||
newBomChildren.remove(upEnts.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
return newBomChildren.stream().filter(u->!delResult.contains(u.getMaterialNo())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* T项外-是否一致
|
||||
* @param oldChildren
|
||||
* @param newChildren
|
||||
* @return
|
||||
*/
|
||||
private boolean pBomSameIs(List<BomNewPbomParentVO> oldChildren ,List<BomNewPbomParentVO> newChildren){
|
||||
//旧bom除T项之外
|
||||
List<BomNewPbomParentVO> oldBomNoTChildren = oldChildren.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
|
||||
//新BOM 除T项外
|
||||
List<BomNewPbomParentVO> newBomNoTChildren = newChildren.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList());
|
||||
if(oldBomNoTChildren.size()!=newBomNoTChildren.size()){
|
||||
return false;
|
||||
}
|
||||
|
||||
Set<String> oldSet = oldBomNoTChildren.stream().map(u -> u.getMaterialNoAndNumAndProjectType()).collect(Collectors.toSet());
|
||||
Set<String> newSet = newChildren.stream().map(u -> u.getMaterialNoAndNumAndProjectType()).collect(Collectors.toSet());
|
||||
if(oldSet.equals(newSet)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return newBomChildren;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ public class EBomToPBomForFormal31New extends FormalEBomToPbomBase {
|
|||
if(Objects.isNull(parentEnt)){
|
||||
continue;
|
||||
}
|
||||
//处理子级
|
||||
mergeChild=handlerArtPackage(parentEnt,mergeChild,facCode,parentList);
|
||||
//检查是否用户跟用户节点()
|
||||
if(parentEnt.getMaterialNo().equals(parent.getMaterialNo())) {
|
||||
List<String> childMaterialNos = SpringUtil.getBean(BomNewPbomParentMapper.class).getPBomExistMaterialInChildForWorkList(parent.getMaterialNo());
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ public class EBomToPBomForFormalNew extends FormalEBomToPbomBase {
|
|||
if(Objects.isNull(parentEnt)){
|
||||
continue;
|
||||
}
|
||||
//处理子级
|
||||
mergeChild=handlerArtPackage(parentEnt,mergeChild,facCode,parentList);
|
||||
//检查是否用户跟用户节点()
|
||||
if(parentEnt.getMaterialNo().equals(parent.getMaterialNo())) {
|
||||
List<String> childMaterialNos = SpringUtil.getBean(BomNewPbomParentMapper.class).getPBomExistMaterialInChildForWorkList(parent.getMaterialNo());
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nflg.product.bomnew.service.domain.EBom.topbomnew;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
|
|
@ -214,6 +215,74 @@ public abstract class FormalEBomToPbomBase {
|
|||
|
||||
}
|
||||
|
||||
private BomNewPbomChildEntity buildPBomAddChild(BomNewPbomParentEntity parent, String facCode, BomNewPbomParentVO oldChild){
|
||||
BomNewPbomChildEntity childEnt = new BomNewPbomChildEntity();
|
||||
BeanUtil.copyProperties(oldChild, childEnt, "sourceRowId");
|
||||
childEnt.setRowId(IdWorker.getId());
|
||||
childEnt.setParentRowId(parent.getRowId());
|
||||
childEnt.setFacCode(facCode);
|
||||
childEnt.setIdentityNo(StrUtil.join("-", parent.getMaterialNo(), oldChild.getMaterialNo()));
|
||||
childEnt.setCreatedTime(LocalDateTime.now());
|
||||
childEnt.setCreatedBy(SessionUtil.getUserCode());
|
||||
|
||||
this.pBomChildResult.add(childEnt);
|
||||
return childEnt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理PBOM新增物料
|
||||
*/
|
||||
protected List<BomNewEbomParentVO> handlerArtPackage(BomNewPbomParentEntity parent , List<BomNewEbomParentVO> newBomChildren ,String facCode ,List<BomNewEbomParentVO> parentList){
|
||||
BomNewPbomParentEntity oldParent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
||||
.eq(BomNewPbomParentEntity::getFacCode, facCode).last(" order by current_version desc limit 1").one();
|
||||
List<String> delResult=new ArrayList<>();
|
||||
//pBom为已发布时
|
||||
if(Objects.nonNull(oldParent) && PBomStatusEnum.PUBLISH.getValue()<= oldParent.getStatus()) {
|
||||
List<BomNewPbomParentVO> oldChildren=SpringUtil.getBean(BomNewPbomParentService.class).getChild(oldParent.getRowId(),1);
|
||||
|
||||
//pBom 手工新增物料
|
||||
List<BomNewPbomParentVO> oldPBomAddChildren = oldChildren.stream().filter(u -> StrUtil.isBlank(u.getOriginalMaterialNo())).collect(Collectors.toList());
|
||||
Map<String, BomNewEbomParentVO> newBomChildrenMap = newBomChildren.stream().collect(Collectors.toMap(BomNewEbomParentVO::getMaterialNo, u -> u));
|
||||
|
||||
for (BomNewPbomParentVO oldPBomAddItem : oldPBomAddChildren) {
|
||||
//加入当前BOM明细中
|
||||
buildPBomAddChild(parent, facCode, oldPBomAddItem);
|
||||
|
||||
//如为工艺包,且在当前BOM中不存在
|
||||
if (BomConstant.ART_PACKAGE_MATERIAL_CATEGORY_CODE.equals(oldPBomAddItem.getMaterialCategoryCode()) && !newBomChildrenMap.containsKey(oldPBomAddItem.getMaterialNo())) {
|
||||
//创建工艺包版本
|
||||
BomNewPbomParentEntity artParent = buildPBomParent(Convert.convert(BomNewEbomParentVO.class, oldPBomAddItem), facCode, parentList);
|
||||
//old 工艺包子级
|
||||
List<BomNewPbomParentVO> oldArtChildren = SpringUtil.getBean(BomNewPbomParentService.class).getChild(oldPBomAddItem.getBomRowId(), 1);
|
||||
for (BomNewPbomParentVO oldArtChild : oldArtChildren) {
|
||||
//工艺包新增
|
||||
if (StrUtil.isBlank(oldArtChild.getOriginalMaterialNo()) || newBomChildren.contains(oldArtChild.getOriginalMaterialNo())) {
|
||||
buildPBomAddChild(artParent, facCode, oldArtChild);
|
||||
if(StrUtil.isNotBlank(oldArtChild.getOriginalMaterialNo())) {
|
||||
delResult.add(oldArtChild.getOriginalMaterialNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//pBom中修改过的
|
||||
List<BomNewPbomParentVO> oldPBomUpdateChildren = oldChildren.stream().filter(u -> StrUtil.isNotBlank(u.getOriginalMaterialNo())).collect(Collectors.toList());
|
||||
for (BomNewPbomParentVO oldPBomUpdateChild : oldPBomUpdateChildren) {
|
||||
if (!oldPBomUpdateChild.getOriginalMaterialNo().equals(oldPBomUpdateChild.getMaterialNo()) || !oldPBomUpdateChild.getOriginalProjectType().equals(oldPBomUpdateChild.getProjectType()) || !oldPBomUpdateChild.getOriginalNum().equals(oldPBomUpdateChild.getNum())) {
|
||||
List<BomNewEbomParentVO> upEnts = newBomChildren.stream().filter(u -> u.getMaterialNo().equals(oldPBomUpdateChild.getOriginalMaterialNo())
|
||||
&& u.getProjectType().equals(oldPBomUpdateChild.getOriginalProjectType()) && u.getNum().equals(oldPBomUpdateChild.getOriginalNum())).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(upEnts)) {
|
||||
buildPBomAddChild(parent, facCode, oldPBomUpdateChild);
|
||||
newBomChildren.remove(upEnts.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
return newBomChildren.stream().filter(u->!delResult.contains(u.getMaterialNo())).collect(Collectors.toList());
|
||||
}
|
||||
return newBomChildren;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Pbom-下一个版本(只是项目类别发生变化则生成小版本,否则大版本)
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue