feat: 根据直发包编号导入上级物料到SAP
This commit is contained in:
parent
452e50a550
commit
6ebeb26432
|
|
@ -75,28 +75,25 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
||||||
SapStatusEnum state = SapStatusEnum.PUB_ERROR_ALL;
|
SapStatusEnum state = SapStatusEnum.PUB_ERROR_ALL;
|
||||||
List<OperationErrorMsgVO> liErrMsg = null;
|
List<OperationErrorMsgVO> liErrMsg = null;
|
||||||
try {
|
try {
|
||||||
rcs.forEach(it -> {
|
Long ddpRowId = null;
|
||||||
|
if (is21) {
|
||||||
|
//选出直发包
|
||||||
|
ddpRowId = getZFBBomRowId(rcs);
|
||||||
|
}
|
||||||
|
for (BomNewPbomChildEntity it : rcs) {
|
||||||
BomNewPbomParentEntity cp = getParent(it);
|
BomNewPbomParentEntity cp = getParent(it);
|
||||||
children.add(convert(cp, it, root.getMaterialNo(), false));
|
children.add(convert(cp, it, root.getMaterialNo(), false));
|
||||||
if (Objects.nonNull(cp)) {
|
if (Objects.nonNull(cp)) {
|
||||||
Long ddpRowId = null;
|
if (is21) {
|
||||||
//选出直发包
|
buildChildrenForSap(ddpRowId, cp, it, false);
|
||||||
List<BomNewPbomChildEntity> cpsc = getChildren(cp);
|
} else {
|
||||||
if (CollUtil.isNotEmpty(cpsc)) {
|
//选出直发包
|
||||||
for (BomNewPbomChildEntity cptt : cpsc) {
|
List<BomNewPbomChildEntity> cpsc = getChildren(cp);
|
||||||
if (Objects.equals(cptt.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
ddpRowId = getZFBBomRowId(cpsc);
|
||||||
BomNewPbomParentEntity cpttp = getParent(cptt);
|
buildChildrenForSap(ddpRowId, cp, it, false);
|
||||||
VUtils.isTure(Objects.isNull(cpttp)).throwMessage(StrUtil.format("顶层直发包({})对应的parent丢失", cptt.getMaterialNo()));
|
|
||||||
ddpRowId = cpttp.getRowId();
|
|
||||||
cmap.put(ddpRowId, new ArrayList<>());
|
|
||||||
LOGGER.debug("{} 直发包 rowId:{},编号:{},描述:{}", TAG, ddpRowId, cpttp.getMaterialNo(), cpttp.getMaterialDesc());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
buildChildrenForSap(ddpRowId, cp, it, false);
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
||||||
sapDto.setZID(RandomUtil.randomNumbers(5));
|
sapDto.setZID(RandomUtil.randomNumbers(5));
|
||||||
if (StrUtil.equals(root.getFacCode(), EBomConstant.MAIN_FACTORY_CODE_1010)) {
|
if (StrUtil.equals(root.getFacCode(), EBomConstant.MAIN_FACTORY_CODE_1010)) {
|
||||||
|
|
@ -129,6 +126,22 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
||||||
return liErrMsg;
|
return liErrMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Long getZFBBomRowId(List<BomNewPbomChildEntity> children) {
|
||||||
|
Long ddpRowId = null;
|
||||||
|
BomNewPbomChildEntity czfb = children.stream()
|
||||||
|
.filter(c -> Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
if (Objects.nonNull(czfb)) {
|
||||||
|
BomNewPbomParentEntity cpttp = getParent(czfb);
|
||||||
|
VUtils.isTure(Objects.isNull(cpttp)).throwMessage(StrUtil.format("顶层直发包({})对应的parent丢失", czfb.getMaterialNo()));
|
||||||
|
ddpRowId = cpttp.getRowId();
|
||||||
|
cmap.put(ddpRowId, new ArrayList<>());
|
||||||
|
LOGGER.debug("{} 直发包 rowId:{},编号:{},描述:{}", TAG, ddpRowId, cpttp.getMaterialNo(), cpttp.getMaterialDesc());
|
||||||
|
}
|
||||||
|
return ddpRowId;
|
||||||
|
}
|
||||||
|
|
||||||
private void saveSapErrorMsg(Long rootBomRowId, List<OperationErrorMsgVO> liErrMsg) {
|
private void saveSapErrorMsg(Long rootBomRowId, List<OperationErrorMsgVO> liErrMsg) {
|
||||||
bomNewSapErrorMsgService.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewSapErrorMsgEntity.class)
|
bomNewSapErrorMsgService.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewSapErrorMsgEntity.class)
|
||||||
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rootBomRowId));
|
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rootBomRowId));
|
||||||
|
|
@ -255,16 +268,43 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
||||||
.one();
|
.one();
|
||||||
}
|
}
|
||||||
|
|
||||||
// private List<BomNewPbomChildEntity> getChildren(List<BomNewPbomParentEntity> parents) {
|
/**
|
||||||
// return bomNewPbomChildService.lambdaQuery()
|
* 根据直发包编号导入上级物料到SAP
|
||||||
// .in(BomNewPbomChildEntity::getParentRowId, parents.stream().map(BomNewPbomParentEntity::getRowId).collect(Collectors.toSet()))
|
* @param materialNo 直发包编号
|
||||||
// .list();
|
*/
|
||||||
// }
|
@Override
|
||||||
|
public void exportFromZFB(String materialNo) {
|
||||||
|
List<BomNewPbomParentEntity> pfhbs = bomNewPbomParentService.lambdaQuery()
|
||||||
|
.eq(BomNewPbomParentEntity::getMaterialNo, materialNo)
|
||||||
|
.ge(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
|
||||||
|
.list();
|
||||||
|
VUtils.isTure(Objects.isNull(pfhbs)).throwMessage("没有需要导入的数据");
|
||||||
|
|
||||||
// private List<BomNewPbomParentEntity> getParents(List<BomNewPbomChildEntity> children) {
|
pfhbs.forEach(pfhb -> {
|
||||||
// return bomNewPbomParentService.lambdaQuery()
|
List<OperationErrorMsgVO> errorMsgVOS = export(pfhb.getRowId());
|
||||||
// .in(BomNewPbomParentEntity::getMaterialNo, children.stream().map(BomNewPbomChildEntity::getMaterialNo).collect(Collectors.toSet()))
|
if (CollUtil.isNotEmpty(errorMsgVOS)) {
|
||||||
// .eq(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
|
//如果导入SAP出错了,得将该bom提升为用户根节点,以便用户手动尝试导入到SAP去
|
||||||
// .list();
|
pfhb.setUserRootIs(1);
|
||||||
// }
|
pfhb.setModifyTime(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pfhbs.removeIf(p -> Objects.equals(p.getLastVersionIs(), 0));
|
||||||
|
if (CollUtil.isNotEmpty(pfhbs)) {
|
||||||
|
bomNewPbomParentService.updateBatchById(pfhbs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildChildrenForSap1(BomNewPbomParentEntity p) {
|
||||||
|
List<BomNewPbomChildEntity> cc = getChildren(p);
|
||||||
|
for (BomNewPbomChildEntity it : cc) {
|
||||||
|
BomNewPbomParentEntity cp = getParent(it);
|
||||||
|
children.add(convert(cp, it, p.getMaterialNo(), false));
|
||||||
|
if (Objects.nonNull(cp)) {
|
||||||
|
if (cp.getUserRootIs() == 0) {
|
||||||
|
buildChildrenForSap1(cp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,10 @@ public interface IBomNewPbomExportToSAP {
|
||||||
// String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
// String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
|
||||||
|
|
||||||
List<OperationErrorMsgVO> export(Long rootBomRowId);
|
List<OperationErrorMsgVO> export(Long rootBomRowId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据直发包编号导入上级物料到SAP
|
||||||
|
* @param materialNo 直发包编号
|
||||||
|
*/
|
||||||
|
void exportFromZFB(String materialNo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue