fix(pbom): 修复因child表物料分类编码与主物料的物料分类编码不一致导致导入到SAP的排序号错误的问题

This commit is contained in:
曹鹏飞 2024-11-11 12:19:25 +08:00
parent 8c3384f053
commit 00a6d47e32
1 changed files with 26 additions and 4 deletions

View File

@ -18,6 +18,7 @@ import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1ExtDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO;
import com.nflg.product.bomnew.util.BomUtil;
import com.nflg.product.bomnew.util.SapErrorMsgUtil;
@ -55,6 +56,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
private final BomNewPbomParentService bomNewPbomParentService = SpringUtil.getBean(BomNewPbomParentService.class);
private final BomNewPbomChildService bomNewPbomChildService = SpringUtil.getBean(BomNewPbomChildService.class);
private final BomNewSapErrorMsgService bomNewSapErrorMsgService = SpringUtil.getBean(BomNewSapErrorMsgService.class);
private final MaterialMainService materialMainService = SpringUtil.getBean(MaterialMainService.class);
private final SapErrorMsgUtil sapErrorMsgUtil = SpringUtil.getBean(SapErrorMsgUtil.class);
public BomNewPbomExportToSAPImpl(boolean isForSale) {
@ -66,10 +68,10 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
BomNewPbomParentEntity root = bomNewPbomParentService.getById(rootBomRowId);
is21 = root.getMaterialNo().startsWith("21");
is31 = root.getMaterialNo().startsWith("31");
List<BomNewPbomChildEntity> rcs = bomNewPbomChildService.lambdaQuery()
List<BomNewPbomChildEntity> rcs = syncMaterial(bomNewPbomChildService.lambdaQuery()
.eq(BomNewPbomChildEntity::getParentRowId, root.getRowId())
.orderByAsc(BomNewPbomChildEntity::getOrderNumber)
.list();
.list());
// if (root.getMaterialNo().startsWith("31")) {
// List<BomNewPbomChildEntity> unVirtualParts = rcs.stream()
// .filter(c -> Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue())
@ -354,7 +356,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
}
private List<BomNewPbomChildEntity> getChildren(BomNewPbomParentEntity parent) {
return bomNewPbomChildService.lambdaQuery()
return syncMaterial(bomNewPbomChildService.lambdaQuery()
.select(BomNewPbomChildEntity::getMaterialNo, BomNewPbomChildEntity::getNum
, BomNewPbomChildEntity::getMaterialUnit, BomNewPbomChildEntity::getMaterialDesc
, BomNewPbomChildEntity::getVirtualPartType, BomNewPbomChildEntity::getProjectType
@ -363,7 +365,27 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
,BomNewPbomChildEntity::getSourceParentMaterialNo)
.eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId())
.orderByAsc(BomNewPbomChildEntity::getOrderNumber)
.list();
.list());
}
private List<BomNewPbomChildEntity> syncMaterial(List<BomNewPbomChildEntity> children) {
if (CollUtil.isNotEmpty(children)) {
List<BaseMaterialVO> materialVOS = materialMainService.getMaterialBaseInfo(children.stream()
.filter(f -> !StrUtil.equalsIgnoreCase(BomConstant.PROJECT_TYPE_TEMPORARY, f.getProjectType()))
.map(BomNewPbomChildEntity::getMaterialNo).collect(Collectors.toList()));
children.forEach(c -> {
if (!StrUtil.equalsIgnoreCase(BomConstant.PROJECT_TYPE_TEMPORARY, c.getProjectType())) {
BaseMaterialVO materialVO = materialVOS.stream()
.filter(m -> StrUtil.equals(m.getMaterialNo(), c.getMaterialNo()))
.findFirst()
.orElse(null);
if (Objects.nonNull(materialVO)) {
c.setMaterialCategoryCode(materialVO.getMaterialCategoryCode());
}
}
});
}
return children;
}
private BomNewPbomParentEntity getParent(BomNewPbomChildEntity child) {