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;
|
||||
List<OperationErrorMsgVO> liErrMsg = null;
|
||||
try {
|
||||
rcs.forEach(it -> {
|
||||
Long ddpRowId = null;
|
||||
if (is21) {
|
||||
//选出直发包
|
||||
ddpRowId = getZFBBomRowId(rcs);
|
||||
}
|
||||
for (BomNewPbomChildEntity it : rcs) {
|
||||
BomNewPbomParentEntity cp = getParent(it);
|
||||
children.add(convert(cp, it, root.getMaterialNo(), false));
|
||||
if (Objects.nonNull(cp)) {
|
||||
Long ddpRowId = null;
|
||||
if (is21) {
|
||||
buildChildrenForSap(ddpRowId, cp, it, false);
|
||||
} else {
|
||||
//选出直发包
|
||||
List<BomNewPbomChildEntity> cpsc = getChildren(cp);
|
||||
if (CollUtil.isNotEmpty(cpsc)) {
|
||||
for (BomNewPbomChildEntity cptt : cpsc) {
|
||||
if (Objects.equals(cptt.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) {
|
||||
BomNewPbomParentEntity cpttp = getParent(cptt);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
ddpRowId = getZFBBomRowId(cpsc);
|
||||
buildChildrenForSap(ddpRowId, cp, it, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
ImportSapParamDTO sapDto = new ImportSapParamDTO();
|
||||
sapDto.setZID(RandomUtil.randomNumbers(5));
|
||||
if (StrUtil.equals(root.getFacCode(), EBomConstant.MAIN_FACTORY_CODE_1010)) {
|
||||
|
|
@ -129,6 +126,22 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
|||
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) {
|
||||
bomNewSapErrorMsgService.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewSapErrorMsgEntity.class)
|
||||
.eq(BomNewSapErrorMsgEntity::getTargetRowId, rootBomRowId));
|
||||
|
|
@ -255,16 +268,43 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
|
|||
.one();
|
||||
}
|
||||
|
||||
// private List<BomNewPbomChildEntity> getChildren(List<BomNewPbomParentEntity> parents) {
|
||||
// return bomNewPbomChildService.lambdaQuery()
|
||||
// .in(BomNewPbomChildEntity::getParentRowId, parents.stream().map(BomNewPbomParentEntity::getRowId).collect(Collectors.toSet()))
|
||||
// .list();
|
||||
// }
|
||||
/**
|
||||
* 根据直发包编号导入上级物料到SAP
|
||||
* @param materialNo 直发包编号
|
||||
*/
|
||||
@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) {
|
||||
// return bomNewPbomParentService.lambdaQuery()
|
||||
// .in(BomNewPbomParentEntity::getMaterialNo, children.stream().map(BomNewPbomChildEntity::getMaterialNo).collect(Collectors.toSet()))
|
||||
// .eq(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
|
||||
// .list();
|
||||
// }
|
||||
pfhbs.forEach(pfhb -> {
|
||||
List<OperationErrorMsgVO> errorMsgVOS = export(pfhb.getRowId());
|
||||
if (CollUtil.isNotEmpty(errorMsgVOS)) {
|
||||
//如果导入SAP出错了,得将该bom提升为用户根节点,以便用户手动尝试导入到SAP去
|
||||
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");
|
||||
|
||||
List<OperationErrorMsgVO> export(Long rootBomRowId);
|
||||
|
||||
/**
|
||||
* 根据直发包编号导入上级物料到SAP
|
||||
* @param materialNo 直发包编号
|
||||
*/
|
||||
void exportFromZFB(String materialNo);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue