optimize: 导入SAP优化

This commit is contained in:
曹鹏飞 2024-05-31 14:33:46 +08:00
parent 0a2901f0c0
commit a809862b54
5 changed files with 21 additions and 9 deletions

View File

@ -283,10 +283,9 @@ public class PBomApi extends BaseApi {
@PostMapping("realesePbom")
@ApiOperation("发布Pbom")
@LogRecord(success = "发布PBom物料编码{{#bom.materialNo}}-版本:{{#bom.currentVersion}} 操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "发布PBom")
public ResultVO<Boolean> realesePbom(@Valid @RequestBody @NotNull PbomImportToSAPQuery query) {
public ResultVO<List<OperationErrorMsgVO>> realesePbom(@Valid @RequestBody @NotNull PbomImportToSAPQuery query) {
bomNewPbomParentService.realesePbom(query.getRootBomRowId());
bomNewPbomParentService.importToSAP2(query);
return ResultVO.success();
return ResultVO.success(bomNewPbomParentService.importToSAP2(query));
}

View File

@ -206,7 +206,8 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
private BomNewPbomParentEntity getParent(BomNewPbomChildEntity child) {
return bomNewPbomParentService.lambdaQuery()
.eq(BomNewPbomParentEntity::getMaterialNo, child.getMaterialNo())
.eq(BomNewPbomParentEntity::getStatus, PBomStatusEnum.FACTORY_CONFIRM.getValue())
.eq(!is21, BomNewPbomParentEntity::getStatus, PBomStatusEnum.FACTORY_CONFIRM.getValue())
.eq(is21, BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue())
.eq(BomNewPbomParentEntity::getFacCode, child.getFacCode())
.ne(BomNewPbomParentEntity::getCreatedBy, "admin")
.orderByDesc(BomNewPbomParentEntity::getCurrentVersion)

View File

@ -1018,7 +1018,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
List<String> parentMaterialNos = allBom.stream().filter(u -> PBomStatusEnum.WAIT_PUBLISH.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u->u.getMaterialNo()).collect(Collectors.toList());
parentMaterialNos.add(parent.getMaterialNo());
Integer state = (parent.getMaterialNo().startsWith("31") && parent.getFacCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)) ? PBomStatusEnum.WAIT_FACTORY.getValue() : PBomStatusEnum.PUBLISH.getValue();
//Integer state = (parent.getMaterialNo().startsWith("31") && parent.getFacCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)) ? PBomStatusEnum.WAIT_FACTORY.getValue() : PBomStatusEnum.PUBLISH.getValue();
Integer state = parent.getMaterialNo().startsWith("31") ? PBomStatusEnum.FACTORY_CONFIRM.getValue() : PBomStatusEnum.PUBLISH.getValue();
bomRowIds.add(bomRowId);
this.getBaseMapper().bomRelease(state, SessionUtil.getUserName(), bomRowIds);
//同步sap

View File

@ -331,12 +331,14 @@ public class EBomImportService {
}
for (EbomExcelDTO data : datas) {
buildChild(children, materialBaseInfos, data
, parents.stream().filter(p -> p.getMaterialNo().equals(data.getParentMaterialNo())).findFirst().get());
, parents.stream().filter(p -> p.getMaterialNo().equals(data.getParentMaterialNo())).findFirst().get(),
parents);
}
return Pair.of(parents, children);
}
private void buildChild(List<BomNewEbomChildEntity> children, List<BaseMaterialVO> materialBaseInfos, EbomExcelDTO data, BomNewEbomParentEntity p) {
private void buildChild(List<BomNewEbomChildEntity> children, List<BaseMaterialVO> materialBaseInfos
, EbomExcelDTO data, BomNewEbomParentEntity p, List<BomNewEbomParentEntity> parents) {
BomNewEbomChildEntity child = new BomNewEbomChildEntity();
child.setRowId(IdWorker.getId());
child.setParentRowId(p.getRowId());
@ -379,8 +381,17 @@ public class EBomImportService {
child.setCreatedBy(SessionUtil.getUserCode());
child.setRemark(data.getRemark());
child.setSource(EBomSourceEnum.FROM_EXCE.getValue());
child.setVirtualPartType(VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue());
setVirtualPackageType(child);
children.add(child);
//如果是虚拟包且没有parent则需要补上
if (!Objects.equals(child.getVirtualPartType(), VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue())
&& parents.stream().noneMatch(pt -> Objects.equals(pt.getMaterialNo(), child.getMaterialNo()))) {
BomNewEbomParentEntity cp = buildParent(materialBaseInfos, data);
cp.setMaterialNo(child.getMaterialNo());
cp.setMaterialDesc(child.getMaterialDesc());
parents.add(cp);
}
}
private BomNewEbomParentEntity buildParent(List<BaseMaterialVO> materialBaseInfos, EbomExcelDTO data) {

View File

@ -36,7 +36,7 @@ public class SapOpUtilService {
@Resource
SapService sapService;
private final static Pattern PATTERN = Pattern.compile("\\b\\d{10}\\b");
private final static Pattern PATTERN = Pattern.compile("\\d{10}");
/**
* sap 创建
@ -203,7 +203,7 @@ public class SapOpUtilService {
errorMsgVOS.add(OperationErrorMsgVO.create(matcher.group(), it.getSTATUS()));
}
} else {
OperationErrorMsgVO.create(buildErrCol1(it), it.getSTATUS());
errorMsgVOS.add(OperationErrorMsgVO.create(buildErrCol1(it), it.getSTATUS()));
}
});