1.转Ebom
This commit is contained in:
parent
5f8dcf5907
commit
898f9fa5b1
|
|
@ -24,6 +24,8 @@ public interface MaterialMainMapper extends BaseMapper<MaterialMainEntity> {
|
|||
*/
|
||||
List<BaseMaterialVO> getMaterialBaseInfo(@Param("materialNos") List<String> materialNos);
|
||||
|
||||
List<BaseMaterialVO> getMaterialBaseInfoByName(@Param("materialName") String materialName);
|
||||
|
||||
|
||||
List<MaterialMateVO> getMateialMate();
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,12 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
|
||||
public void convert() {
|
||||
checkData();
|
||||
List<BomOriginalListVO> data = new ArrayList<>();
|
||||
data.add(parent);
|
||||
data.addAll(bomDetail);
|
||||
//图号匹配
|
||||
List<BomOriginalListVO> noMaterialNo = data.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||
SpringUtil.getBean(MaterialMainService.class).initMaterialForDrawdingNo(noMaterialNo, BomOriginalListVO::getDrawingNo, BomOriginalListVO::setMaterialNo, BomOriginalListVO::setMaterialName);
|
||||
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(ImmutableList.of(parent));
|
||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(bomDetail);
|
||||
|
|
@ -100,19 +106,16 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
List<BomOriginalListVO> parentChildNoMaterilaNoList = parentChild.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||
//无编码
|
||||
if (StrUtil.isBlank(parentEnt.getMaterialNo())) {
|
||||
//通过规则替换
|
||||
handlerCommonMaterialForReplace(parentEnt);
|
||||
|
||||
if (CollUtil.isNotEmpty(parentChild)) {
|
||||
//父级初化物料编码
|
||||
if (StrUtil.isNotBlank(parentEnt.getDrawingNo())) {
|
||||
SpringUtil.getBean(MaterialMainService.class).initMaterialForDrawdingNo(ImmutableList.of(parentEnt), BomOriginalListVO::getDrawingNo, BomOriginalListVO::setMaterialNo, BomOriginalListVO::setMaterialName);
|
||||
//子级初始化物料编码
|
||||
SpringUtil.getBean(MaterialMainService.class).initMaterialForDrawdingNo(parentChildNoMaterilaNoList, BomOriginalListVO::getDrawingNo, BomOriginalListVO::setMaterialNo, BomOriginalListVO::setMaterialName);
|
||||
}
|
||||
|
||||
//合并相同编码的物料
|
||||
// List<BomOriginalListVO> mergeResult = mergeBOM(parentChild);
|
||||
Long parentRowId = buildEBomParent(parentEnt);
|
||||
// buildEBomChild(parentChild, parentRowId);
|
||||
handlerChild(parentEnt,parentChild);
|
||||
// buildEBomChild(parentChild, parentRowId);
|
||||
handlerChild(parentEnt, parentChild);
|
||||
} else { //无子级
|
||||
|
||||
MaterialMateVO materialByRel = getMaterialByRel(parent.getMaterialName(), parent.getMaterialTexture());
|
||||
|
|
@ -133,35 +136,32 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
|
||||
List<BomOriginalListVO> mergeResult = mergeBOM(parentChild);
|
||||
Long parentRowId = buildEBomParent(parentEnt);
|
||||
// buildEBomChild(mergeResult, parentRowId);
|
||||
handlerChild(parentEnt,mergeResult);
|
||||
// buildEBomChild(mergeResult, parentRowId);
|
||||
handlerChild(parentEnt, mergeResult);
|
||||
|
||||
} else { //无子级
|
||||
//一板零部件
|
||||
if (parentEnt.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE)) {
|
||||
//通过规则获取物料编码
|
||||
MaterialMateVO materialByRel = getMaterialByRel(parentEnt);
|
||||
//找到对应物料
|
||||
if (Objects.nonNull(materialByRel)) {
|
||||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainMapper.class).getMaterialBaseInfo(ImmutableList.of(materialByRel.getMaterialNo()));
|
||||
if (CollUtil.isNotEmpty(materialBaseInfo)) {
|
||||
//通过名称找子级
|
||||
BaseMaterialVO materialBaseInfo = getComSub(parentEnt);
|
||||
if (Objects.nonNull(materialBaseInfo)) {
|
||||
|
||||
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEnt.getMaterialNo());
|
||||
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo.get(0), parentEnt);
|
||||
//存在旧版本
|
||||
if (CollUtil.isNotEmpty(oldParenChild)) {
|
||||
//结构是否相同
|
||||
if (!isSameEBom(oldParenChild, ImmutableList.of(newChild))) {
|
||||
Long parentRowId = buildEBomParent(parentEnt);
|
||||
newChild.setParentRowId(parentRowId);
|
||||
this.eBomChildResult.add(newChild);
|
||||
}
|
||||
} else {
|
||||
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEnt.getMaterialNo());
|
||||
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo, parentEnt);
|
||||
//存在旧版本
|
||||
if (CollUtil.isNotEmpty(oldParenChild)) {
|
||||
//结构是否相同
|
||||
if (!isSameEBom(oldParenChild, ImmutableList.of(newChild))) {
|
||||
Long parentRowId = buildEBomParent(parentEnt);
|
||||
newChild.setParentRowId(parentRowId);
|
||||
this.eBomChildResult.add(newChild);
|
||||
}
|
||||
} else {
|
||||
buildEBomParent(parentEnt);
|
||||
// newChild.setParentRowId(parentRowId);
|
||||
// this.eBomChildResult.add(newChild);
|
||||
}
|
||||
|
||||
} else {
|
||||
buildEBomParent(parentEnt);
|
||||
}
|
||||
|
|
@ -175,6 +175,19 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一般零部件子级
|
||||
*
|
||||
* @param parentEnt
|
||||
* @return
|
||||
*/
|
||||
private BaseMaterialVO getComSub(BomOriginalListVO parentEnt) {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理子级
|
||||
*
|
||||
|
|
@ -184,37 +197,59 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
|||
private void handlerChild(BomOriginalListVO parentEntity, List<BomOriginalListVO> parentChild) {
|
||||
|
||||
for (BomOriginalListVO childVo : parentChild) {
|
||||
//一般零部件
|
||||
if (StrUtil.isNotBlank(childVo.getMaterialCategoryCode()) && childVo.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE)) {
|
||||
MaterialMateVO materialByRel = getMaterialByRel(childVo);
|
||||
//找到对应物料
|
||||
if (Objects.nonNull(materialByRel)) {
|
||||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainMapper.class).getMaterialBaseInfo(ImmutableList.of(materialByRel.getMaterialNo()));
|
||||
if (CollUtil.isNotEmpty(materialBaseInfo)) {
|
||||
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)) {
|
||||
|
||||
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEntity.getMaterialNo());
|
||||
//存在旧版本
|
||||
if (CollUtil.isNotEmpty(oldParenChild)) {
|
||||
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo.get(0), parentEntity);
|
||||
//结构是否相同
|
||||
if (!isSameEBom(oldParenChild, ImmutableList.of(newChild))) {
|
||||
Long parentRowId = buildEBomParent(childVo);
|
||||
newChild.setParentRowId(parentRowId);
|
||||
this.eBomChildResult.add(newChild);
|
||||
}
|
||||
} else {
|
||||
//找到对应物料
|
||||
|
||||
BaseMaterialVO materialBaseInfo = getComSub(childVo);
|
||||
if (Objects.nonNull(materialBaseInfo)) {
|
||||
|
||||
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEntity.getMaterialNo());
|
||||
//存在旧版本
|
||||
if (CollUtil.isNotEmpty(oldParenChild)) {
|
||||
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo, parentEntity);
|
||||
//结构是否相同
|
||||
if (!isSameEBom(oldParenChild, ImmutableList.of(newChild))) {
|
||||
Long parentRowId = buildEBomParent(childVo);
|
||||
buildEBomChild(childVo, parentRowId);
|
||||
newChild.setParentRowId(parentRowId);
|
||||
this.eBomChildResult.add(newChild);
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
// Long parentRowId = buildEBomParent(childVo);
|
||||
buildEBomChild(childVo, parentEntity.getRowId());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
buildEBomChild(childVo,parentEntity.getRowId());
|
||||
buildEBomChild(childVo, parentEntity.getRowId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected BomNewEbomChildEntity buildCommonEbomChildEntity(BaseMaterialVO material, BomOriginalListVO parent) {
|
||||
BomNewEbomChildEntity childEntity = new BomNewEbomChildEntity();
|
||||
childEntity.setParentRowId(parent.getRowId());
|
||||
|
|
|
|||
|
|
@ -79,6 +79,14 @@
|
|||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="getMaterialBaseInfoByName" resultType="com.nflg.product.bomnew.pojo.vo.BaseMaterialVO">
|
||||
select a.row_id as materialRowId, material_no, material_name, material_desc, procure_type, project_type, material_state,drawing_no,a.material_category_code ,material_get_type,drawing_no
|
||||
,material_texture as material ,material_texture , b.rel_category_code,b.category_name
|
||||
from t_material_main a join t_material_category b on a.material_category_code=b.category_code
|
||||
where material_name =#{materialName}
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getMateialMate" resultType="com.nflg.product.bomnew.pojo.vo.MaterialMateVO">
|
||||
select * from t_material_mate
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue