feat(ebom): 解决导入sap的物料总数与实际不符的问题
This commit is contained in:
parent
66b63234e7
commit
2163f7ad82
|
|
@ -90,66 +90,71 @@ public class BomNewEbomExportToSAP {
|
|||
}
|
||||
boolean isEmpty = false;
|
||||
for (BomNewEbomChildEntity it : cc) {
|
||||
if (Objects.nonNull(c) && Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||
if (Objects.nonNull(cRowId)) {
|
||||
if (cRowId == 0L) {
|
||||
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
||||
children.add(convert(it, p.getMaterialNo(), false));
|
||||
isEmpty = handlerItem(cRowId, it, p, c, ignore, isEmpty);
|
||||
}
|
||||
LOGGER.debug("children数量:" + children.size());
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
private boolean handlerItem(Long cRowId, BomNewEbomChildEntity it, BomNewEbomParentEntity p, BomNewEbomChildEntity c, boolean ignore, boolean isEmpty) {
|
||||
if (Objects.nonNull(c) && Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||
if (Objects.nonNull(cRowId)) {
|
||||
if (cRowId == 0L) {
|
||||
LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc());
|
||||
children.add(convert(it, p.getMaterialNo(), false));
|
||||
} else {
|
||||
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 {
|
||||
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());
|
||||
}
|
||||
//合并计算数量
|
||||
cct.setMENGE(new BigDecimal(cct.getMENGE()).add(it.getNum()).toString());
|
||||
LOGGER.debug("{} 物料提层到上级发货包且合并 编号:{},父级编号:{},数量:{},合并后总数:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), cct.getMENGE(), it.getMaterialDesc());
|
||||
}
|
||||
}
|
||||
isEmpty = true;
|
||||
} else if (!Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||
}
|
||||
isEmpty = true;
|
||||
} 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));
|
||||
}
|
||||
if (it.getVirtualPartType() > VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue()
|
||||
&& !Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue())) {
|
||||
cRowId = null;
|
||||
}
|
||||
BomNewEbomParentEntity cp = getParent(it);
|
||||
if (Objects.nonNull(cp)) {
|
||||
List<BomNewEbomChildEntity> pcs = getChildren(cp);
|
||||
if (CollUtil.isNotEmpty(pcs)) {
|
||||
BomNewEbomChildEntity zfc = pcs.stream()
|
||||
.filter(pt -> Objects.equals(pt.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.nonNull(zfc)) {
|
||||
BomNewEbomParentEntity zfp = getParent(zfc);
|
||||
VUtils.isTure(Objects.isNull(zfp)).throwMessage(StrUtil.format("直发包({})对应的parent丢失", zfc.getMaterialNo()));
|
||||
cRowId = zfp.getRowId();
|
||||
cmap.put(cRowId, new ArrayList<>());
|
||||
LOGGER.debug("{} 直发包 rowId:{},编号:{},描述:{}", TAG, cRowId, zfc.getMaterialNo(), zfc.getMaterialDesc());
|
||||
}
|
||||
}
|
||||
if (!ignore && cp.getUserRootIs() == 1) {
|
||||
ignore = true;
|
||||
}
|
||||
boolean b = buildChildrenForSap(cRowId, cp, it, ignore);
|
||||
if (!b && 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));
|
||||
}
|
||||
if (it.getVirtualPartType() > VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue()
|
||||
&& !Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue())) {
|
||||
cRowId = null;
|
||||
}
|
||||
BomNewEbomParentEntity cp = getParent(it);
|
||||
if (Objects.nonNull(cp)) {
|
||||
List<BomNewEbomChildEntity> pcs = getChildren(cp);
|
||||
if (CollUtil.isNotEmpty(pcs)) {
|
||||
BomNewEbomChildEntity zfc = pcs.stream()
|
||||
.filter(pt -> Objects.equals(pt.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.nonNull(zfc)) {
|
||||
BomNewEbomParentEntity zfp = getParent(zfc);
|
||||
VUtils.isTure(Objects.isNull(zfp)).throwMessage(StrUtil.format("直发包({})对应的parent丢失", zfc.getMaterialNo()));
|
||||
cRowId = zfp.getRowId();
|
||||
cmap.put(cRowId, new ArrayList<>());
|
||||
LOGGER.debug("{} 直发包 rowId:{},编号:{},描述:{}", TAG, cRowId, zfc.getMaterialNo(), zfc.getMaterialDesc());
|
||||
}
|
||||
}
|
||||
if (!ignore && cp.getUserRootIs() == 1) {
|
||||
ignore = true;
|
||||
}
|
||||
boolean b = buildChildrenForSap(cRowId, cp, it, ignore);
|
||||
if (!b && 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
LOGGER.debug("children数量:" + children.size());
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue