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> getMaterialBaseInfo(@Param("materialNos") List<String> materialNos);
|
||||||
|
|
||||||
|
List<BaseMaterialVO> getMaterialBaseInfoByName(@Param("materialName") String materialName);
|
||||||
|
|
||||||
|
|
||||||
List<MaterialMateVO> getMateialMate();
|
List<MaterialMateVO> getMateialMate();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,12 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
||||||
|
|
||||||
public void convert() {
|
public void convert() {
|
||||||
checkData();
|
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(ImmutableList.of(parent));
|
||||||
SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(bomDetail);
|
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());
|
List<BomOriginalListVO> parentChildNoMaterilaNoList = parentChild.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList());
|
||||||
//无编码
|
//无编码
|
||||||
if (StrUtil.isBlank(parentEnt.getMaterialNo())) {
|
if (StrUtil.isBlank(parentEnt.getMaterialNo())) {
|
||||||
|
//通过规则替换
|
||||||
|
handlerCommonMaterialForReplace(parentEnt);
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(parentChild)) {
|
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);
|
// List<BomOriginalListVO> mergeResult = mergeBOM(parentChild);
|
||||||
Long parentRowId = buildEBomParent(parentEnt);
|
Long parentRowId = buildEBomParent(parentEnt);
|
||||||
// buildEBomChild(parentChild, parentRowId);
|
// buildEBomChild(parentChild, parentRowId);
|
||||||
handlerChild(parentEnt,parentChild);
|
handlerChild(parentEnt, parentChild);
|
||||||
} else { //无子级
|
} else { //无子级
|
||||||
|
|
||||||
MaterialMateVO materialByRel = getMaterialByRel(parent.getMaterialName(), parent.getMaterialTexture());
|
MaterialMateVO materialByRel = getMaterialByRel(parent.getMaterialName(), parent.getMaterialTexture());
|
||||||
|
|
@ -133,35 +136,32 @@ public class OriginalBomToEBomConvert extends BaseConvert {
|
||||||
|
|
||||||
List<BomOriginalListVO> mergeResult = mergeBOM(parentChild);
|
List<BomOriginalListVO> mergeResult = mergeBOM(parentChild);
|
||||||
Long parentRowId = buildEBomParent(parentEnt);
|
Long parentRowId = buildEBomParent(parentEnt);
|
||||||
// buildEBomChild(mergeResult, parentRowId);
|
// buildEBomChild(mergeResult, 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)) {
|
||||||
//通过规则获取物料编码
|
//通过名称找子级
|
||||||
MaterialMateVO materialByRel = getMaterialByRel(parentEnt);
|
BaseMaterialVO materialBaseInfo = getComSub(parentEnt);
|
||||||
//找到对应物料
|
if (Objects.nonNull(materialBaseInfo)) {
|
||||||
if (Objects.nonNull(materialByRel)) {
|
|
||||||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainMapper.class).getMaterialBaseInfo(ImmutableList.of(materialByRel.getMaterialNo()));
|
|
||||||
if (CollUtil.isNotEmpty(materialBaseInfo)) {
|
|
||||||
|
|
||||||
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEnt.getMaterialNo());
|
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEnt.getMaterialNo());
|
||||||
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo.get(0), parentEnt);
|
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo, parentEnt);
|
||||||
//存在旧版本
|
//存在旧版本
|
||||||
if (CollUtil.isNotEmpty(oldParenChild)) {
|
if (CollUtil.isNotEmpty(oldParenChild)) {
|
||||||
//结构是否相同
|
//结构是否相同
|
||||||
if (!isSameEBom(oldParenChild, ImmutableList.of(newChild))) {
|
if (!isSameEBom(oldParenChild, ImmutableList.of(newChild))) {
|
||||||
Long parentRowId = buildEBomParent(parentEnt);
|
|
||||||
newChild.setParentRowId(parentRowId);
|
|
||||||
this.eBomChildResult.add(newChild);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Long parentRowId = buildEBomParent(parentEnt);
|
Long parentRowId = buildEBomParent(parentEnt);
|
||||||
newChild.setParentRowId(parentRowId);
|
newChild.setParentRowId(parentRowId);
|
||||||
this.eBomChildResult.add(newChild);
|
this.eBomChildResult.add(newChild);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
buildEBomParent(parentEnt);
|
||||||
|
// newChild.setParentRowId(parentRowId);
|
||||||
|
// this.eBomChildResult.add(newChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
buildEBomParent(parentEnt);
|
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) {
|
private void handlerChild(BomOriginalListVO parentEntity, List<BomOriginalListVO> parentChild) {
|
||||||
|
|
||||||
for (BomOriginalListVO childVo : parentChild) {
|
for (BomOriginalListVO childVo : parentChild) {
|
||||||
//一般零部件
|
if (StrUtil.isBlank(childVo.getMaterialNo())) {
|
||||||
if (StrUtil.isNotBlank(childVo.getMaterialCategoryCode()) && childVo.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE)) {
|
handlerCommonMaterialForReplace(childVo);
|
||||||
MaterialMateVO materialByRel = getMaterialByRel(childVo);
|
} else if (StrUtil.isNotBlank(childVo.getMaterialNo()) && StrUtil.isNotBlank(childVo.getMaterialCategoryCode()) && childVo.getMaterialCategoryCode().equals(OriginalConstant.COMMON_MATERIAL_CATEGORY_CODE)) {
|
||||||
//找到对应物料
|
|
||||||
if (Objects.nonNull(materialByRel)) {
|
|
||||||
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainMapper.class).getMaterialBaseInfo(ImmutableList.of(materialByRel.getMaterialNo()));
|
|
||||||
if (CollUtil.isNotEmpty(materialBaseInfo)) {
|
|
||||||
|
|
||||||
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEntity.getMaterialNo());
|
//找到对应物料
|
||||||
//存在旧版本
|
|
||||||
if (CollUtil.isNotEmpty(oldParenChild)) {
|
BaseMaterialVO materialBaseInfo = getComSub(childVo);
|
||||||
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo.get(0), parentEntity);
|
if (Objects.nonNull(materialBaseInfo)) {
|
||||||
//结构是否相同
|
|
||||||
if (!isSameEBom(oldParenChild, ImmutableList.of(newChild))) {
|
List<BomNewEbomChildEntity> oldParenChild = SpringUtil.getBean(BomNewEbomChildMapper.class).getChildByMaterialNo(parentEntity.getMaterialNo());
|
||||||
Long parentRowId = buildEBomParent(childVo);
|
//存在旧版本
|
||||||
newChild.setParentRowId(parentRowId);
|
if (CollUtil.isNotEmpty(oldParenChild)) {
|
||||||
this.eBomChildResult.add(newChild);
|
BomNewEbomChildEntity newChild = buildCommonEbomChildEntity(materialBaseInfo, parentEntity);
|
||||||
}
|
//结构是否相同
|
||||||
} else {
|
if (!isSameEBom(oldParenChild, ImmutableList.of(newChild))) {
|
||||||
Long parentRowId = buildEBomParent(childVo);
|
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) {
|
protected BomNewEbomChildEntity buildCommonEbomChildEntity(BaseMaterialVO material, BomOriginalListVO parent) {
|
||||||
BomNewEbomChildEntity childEntity = new BomNewEbomChildEntity();
|
BomNewEbomChildEntity childEntity = new BomNewEbomChildEntity();
|
||||||
childEntity.setParentRowId(parent.getRowId());
|
childEntity.setParentRowId(parent.getRowId());
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,14 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</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 id="getMateialMate" resultType="com.nflg.product.bomnew.pojo.vo.MaterialMateVO">
|
||||||
select * from t_material_mate
|
select * from t_material_mate
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue