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