fix: 导入sap优化

This commit is contained in:
曹鹏飞 2024-06-04 10:01:37 +08:00
parent 925dc231cf
commit ae1d544aa1
2 changed files with 34 additions and 28 deletions

View File

@ -212,6 +212,7 @@ public class BomNewEbomExportToSAP {
, BomNewEbomChildEntity::getMaterialUnit, BomNewEbomChildEntity::getMaterialDesc
, BomNewEbomChildEntity::getVirtualPartType, BomNewEbomChildEntity::getProjectType)
.eq(BomNewEbomChildEntity::getParentRowId, parent.getRowId())
.orderByAsc(BomNewEbomChildEntity::getOrderNumber)
.list();
}

View File

@ -162,35 +162,39 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
return;
}
for (BomNewPbomChildEntity it : cc) {
if (Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
if (Objects.nonNull(cRowId)) {
T1ExtDTO cct = cmap.get(cRowId).stream()
.filter(ct -> (StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getPOTX1(), it.getMaterialDesc()))
|| (!StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getIDNRK(), it.getMaterialNo())))
.findFirst()
.orElse(null);
if (Objects.isNull(cct)) {
LOGGER.debug("{} 物料提层到顶级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
cct = convert(it, p.getMaterialNo(), false);
cmap.get(cRowId).add(cct);
children.add(cct);
} else {
//合并计算数量
cct.setMENGE(new BigDecimal(cct.getMENGE()).add(it.getNum()).toString());
LOGGER.debug("{} 物料提层到顶级发货包且合并 编号:{},父级编号:{},数量:{},合并后总数:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), cct.getMENGE(), it.getMaterialDesc());
}
handlerItem(cRowId, it, p, c, ignore);
}
}
private void handlerItem(Long cRowId, BomNewPbomChildEntity it, BomNewPbomParentEntity p, BomNewPbomChildEntity c, boolean ignore) {
if (Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
if (Objects.nonNull(cRowId)) {
T1ExtDTO cct = cmap.get(cRowId).stream()
.filter(ct -> (StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getPOTX1(), it.getMaterialDesc()))
|| (!StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getIDNRK(), it.getMaterialNo())))
.findFirst()
.orElse(null);
if (Objects.isNull(cct)) {
LOGGER.debug("{} 物料提层到顶级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
cct = convert(it, p.getMaterialNo(), false);
cmap.get(cRowId).add(cct);
children.add(cct);
} else {
//合并计算数量
cct.setMENGE(new BigDecimal(cct.getMENGE()).add(it.getNum()).toString());
LOGGER.debug("{} 物料提层到顶级发货包且合并 编号:{},父级编号:{},数量:{},合并后总数:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), cct.getMENGE(), it.getMaterialDesc());
}
} else if (!Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
children.add(convert(it, p.getMaterialNo(), ignore));
}
BomNewPbomParentEntity cp = getParent(it);
if (!ignore && cp.getUserRootIs() == 1) {
ignore = true;
}
if (Objects.nonNull(cp)) {
buildChildrenForSap(cRowId, cp, it, ignore);
}
} else if (!Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
children.add(convert(it, p.getMaterialNo(), ignore));
}
BomNewPbomParentEntity cp = getParent(it);
if (!ignore && cp.getUserRootIs() == 1) {
ignore = true;
}
if (Objects.nonNull(cp)) {
buildChildrenForSap(cRowId, cp, it, ignore);
}
}
@ -200,6 +204,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
, BomNewPbomChildEntity::getMaterialUnit, BomNewPbomChildEntity::getMaterialDesc
, BomNewPbomChildEntity::getVirtualPartType, BomNewPbomChildEntity::getProjectType)
.eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId())
.orderByAsc(BomNewPbomChildEntity::getOrderNumber)
.list();
}
@ -207,7 +212,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
return bomNewPbomParentService.lambdaQuery()
.eq(BomNewPbomParentEntity::getMaterialNo, child.getMaterialNo())
.eq(!is21, BomNewPbomParentEntity::getStatus, PBomStatusEnum.FACTORY_CONFIRM.getValue())
.eq(is21, BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.ge(is21, BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.eq(BomNewPbomParentEntity::getFacCode, child.getFacCode())
.ne(BomNewPbomParentEntity::getCreatedBy, "admin")
.orderByDesc(BomNewPbomParentEntity::getCurrentVersion)