1.转Ebom
This commit is contained in:
parent
42169c4bf1
commit
c7ff541d4d
|
|
@ -32,7 +32,7 @@ public class MaterialMateCache {
|
|||
}
|
||||
Pattern p = Pattern.compile(namePattern);
|
||||
Pattern p2 = Pattern.compile(texturePattern);
|
||||
if(p.matcher(materialName).find() && p2.matcher(materialTexture).find()){
|
||||
if(p.matcher(materialName).find() && p2.matcher(StrUtil.isBlank(materialTexture)?"":materialTexture ).find()){
|
||||
return mate;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class EbomInitProjectType {
|
|||
public EbomInitProjectType(BomNewEbomParentVO inFirstParent, List<BomNewEbomParentVO> inAllChild) {
|
||||
this.firstParent = inFirstParent;
|
||||
this.allChild = inAllChild;
|
||||
allChild.add(firstParent);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.nflg.product.bomnew.pojo.vo.MaterialMateVO;
|
|||
import com.nflg.product.bomnew.service.BomNewEbomParentService;
|
||||
import com.nflg.product.bomnew.service.MaterialMainService;
|
||||
import com.nflg.product.bomnew.service.UserRoleService;
|
||||
import com.nflg.product.bomnew.service.cache.MaterialMateCache;
|
||||
import com.nflg.product.bomnew.util.ListCommonUtil;
|
||||
import com.nflg.product.bomnew.util.VUtils;
|
||||
import com.nflg.product.bomnew.util.VersionUtil;
|
||||
|
|
@ -131,19 +132,20 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
|
||||
}
|
||||
} else {
|
||||
if (parentEnt.getShouldBomExist().equals(1)) { //应该有BOM
|
||||
// if (parentEnt.getShouldBomExist().equals(1)) { //应该有BOM
|
||||
if (CollUtil.isNotEmpty(parentChild)) { // 有子级
|
||||
|
||||
List<BomOriginalListVO> mergeResult = mergeBOM(parentChild);
|
||||
Long parentRowId = buildEBomParent(parentEnt);
|
||||
// buildEBomChild(mergeResult, parentRowId);
|
||||
parentEnt.setEBomRowId(parentRowId);
|
||||
handlerChild(parentEnt, mergeResult);
|
||||
|
||||
} else { //无子级
|
||||
//一板零部件
|
||||
if (parentEnt.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE)) {
|
||||
//通过名称找子级
|
||||
BaseMaterialVO materialBaseInfo = getComSub(parentEnt);
|
||||
BaseMaterialVO materialBaseInfo = getCommonMaterialByRel(parentEnt);
|
||||
if (Objects.nonNull(materialBaseInfo)) {
|
||||
|
||||
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEnt.getMaterialNo());
|
||||
|
|
@ -157,9 +159,9 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
this.eBomChildResult.add(newChild);
|
||||
}
|
||||
} else {
|
||||
buildEBomParent(parentEnt);
|
||||
// newChild.setParentRowId(parentRowId);
|
||||
// this.eBomChildResult.add(newChild);
|
||||
Long parentRowId= buildEBomParent(parentEnt);
|
||||
newChild.setParentRowId(parentRowId);
|
||||
this.eBomChildResult.add(newChild);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
@ -169,7 +171,7 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
buildEBomParent(parentEnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +187,7 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainMapper.class).getMaterialBaseInfoByName(parentEnt.getMaterialName());
|
||||
List<BaseMaterialVO> material = materialBaseInfo.stream().filter(u -> !u.getMaterialNo().equals(parentEnt.getMaterialNo())).collect(Collectors.toList());
|
||||
VUtils.isTure(material.size() > 1).throwMessage("一般零部件:" + parentEnt.getMaterialName() + "在主数据中存在多条数据");
|
||||
return CollUtil.isNotEmpty(material)? material.get(0):null;
|
||||
return CollUtil.isNotEmpty(material) ? material.get(0) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -199,11 +201,12 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
for (BomOriginalListVO childVo : parentChild) {
|
||||
if (StrUtil.isBlank(childVo.getMaterialNo())) {
|
||||
handlerCommonMaterialForReplace(childVo);
|
||||
} else if (StrUtil.isNotBlank(childVo.getMaterialNo()) && StrUtil.isNotBlank(childVo.getMaterialCategoryCode()) && childVo.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE)) {
|
||||
}
|
||||
else if (StrUtil.isNotBlank(childVo.getMaterialNo()) && StrUtil.isNotBlank(childVo.getMaterialCategoryCode()) && childVo.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE)) {
|
||||
|
||||
//找到对应物料
|
||||
|
||||
BaseMaterialVO materialBaseInfo = getComSub(childVo);
|
||||
BaseMaterialVO materialBaseInfo = getCommonMaterialByRel(childVo);
|
||||
if (Objects.nonNull(materialBaseInfo)) {
|
||||
|
||||
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEntity.getMaterialNo());
|
||||
|
|
@ -217,43 +220,60 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
this.eBomChildResult.add(newChild);
|
||||
}
|
||||
} else {
|
||||
// Long parentRowId = buildEBomParent(childVo);
|
||||
buildEBomChild(childVo, parentEntity.getRowId());
|
||||
Long parentRowId = buildEBomParent(childVo);
|
||||
childVo.setEBomRowId(parentRowId);
|
||||
BomNewEbomChildEntity childEntity = buildCommonEbomChildEntity(materialBaseInfo, childVo);
|
||||
this.eBomChildResult.add(childEntity);
|
||||
}
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
buildEBomChild(childVo, parentEntity.getRowId());
|
||||
buildEBomChild(childVo, parentEntity.getEBomRowId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void handlerCommonMaterialForReplace(BomOriginalListVO parentEntity) {
|
||||
//通过规则获取物料编码
|
||||
MaterialMateVO materialMate = getMaterialByRel(parentEntity);
|
||||
//找到对应物料
|
||||
if (Objects.nonNull(materialMate)) {
|
||||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainMapper.class).getMaterialBaseInfo(ImmutableList.of(materialMate.getMaterialNo()));
|
||||
if (CollUtil.isNotEmpty(materialBaseInfo)) {
|
||||
//根据物料编码-
|
||||
BaseMaterialVO baseMaterialVO = materialBaseInfo.get(0);
|
||||
parentEntity.setMaterialNo(baseMaterialVO.getMaterialNo());
|
||||
parentEntity.setMaterialName(baseMaterialVO.getMaterialName());
|
||||
parentEntity.setMaterialDesc(baseMaterialVO.getMaterialDesc());
|
||||
parentEntity.setMaterialTexture(baseMaterialVO.getMaterialTexture());
|
||||
}
|
||||
|
||||
BaseMaterialVO baseMaterialVO = getCommonMaterialByRel(parentEntity);
|
||||
if (Objects.nonNull(baseMaterialVO)) {
|
||||
//根据物料编码-
|
||||
parentEntity.setMaterialNo(baseMaterialVO.getMaterialNo());
|
||||
parentEntity.setMaterialName(baseMaterialVO.getMaterialName());
|
||||
parentEntity.setMaterialDesc(baseMaterialVO.getMaterialDesc());
|
||||
parentEntity.setMaterialTexture(baseMaterialVO.getMaterialTexture());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private BaseMaterialVO getCommonMaterialByRel(BomOriginalListVO parentEntity) {
|
||||
//通过规则获取物料编码
|
||||
MaterialMateVO materialMate = getMaterialByRelForToEBom(parentEntity);
|
||||
//找到对应物料
|
||||
if (Objects.nonNull(materialMate)) {
|
||||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainMapper.class).getMaterialBaseInfo(ImmutableList.of(materialMate.getMaterialNo()));
|
||||
return materialBaseInfo.get(0);
|
||||
|
||||
}
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private MaterialMateVO getMaterialByRelForToEBom(BaseMaterialVO originalPlmBomVO) {
|
||||
MaterialMateCache mateCache = new MaterialMateCache();
|
||||
MaterialMateVO materialMate = mateCache.findMaterialByNameOrmaterialTexture(originalPlmBomVO.getMaterialName(), originalPlmBomVO.getMaterialTexture());
|
||||
return materialMate;
|
||||
}
|
||||
|
||||
|
||||
protected BomNewEbomChildEntity buildCommonEbomChildEntity(BaseMaterialVO material, BomOriginalListVO parent) {
|
||||
BomNewEbomChildEntity childEntity = new BomNewEbomChildEntity();
|
||||
childEntity.setParentRowId(parent.getRowId());
|
||||
childEntity.setParentRowId(parent.getEBomRowId()>0?parent.getEBomRowId(): parent.getRowId());
|
||||
childEntity.setOrderNumber("001");
|
||||
childEntity.setIdentityNo(StrUtil.join("-", parent.getMaterialNo(), material.getMaterialNo()));
|
||||
childEntity.setDrawingNo(material.getDrawingNo());
|
||||
childEntity.setMaterialNo(material.getMaterialNo());
|
||||
childEntity.setMaterialName(material.getMaterialName());
|
||||
|
|
@ -339,6 +359,7 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
*/
|
||||
private List<BomOriginalListVO> mergeBOM(List<BomOriginalListVO> list) {
|
||||
List<BomOriginalListVO> result = new ArrayList();
|
||||
result.addAll(list.stream().filter(u->StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList()));
|
||||
list = list.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||
Map<String, List<BomOriginalListVO>> mateiralNoMp = ListCommonUtil.listGroupMap(list, BomOriginalListVO::getMaterialNo);
|
||||
for (Map.Entry<String, List<BomOriginalListVO>> entry : mateiralNoMp.entrySet()) {
|
||||
|
|
@ -354,6 +375,7 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
one.setTotalWeight(totalWeightResult);
|
||||
result.add(one);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue