From 6b6c1588fc095809c4ab8b021bdd30f2f682c2a8 Mon Sep 17 00:00:00 2001 From: 10002327 Date: Thu, 17 Oct 2024 15:44:56 +0800 Subject: [PATCH 1/6] =?UTF-8?q?BOM=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/api/user/BomReportApi.java | 2 +- .../nflg/product/bomnew/api/user/EbomApi.java | 22 ++- .../nflg/product/bomnew/api/user/PBomApi.java | 8 + .../bomnew/constant/EBomSourceEnum.java | 3 +- .../bomnew/constant/PbomSourceEnum.java | 3 +- .../constant/ProjectTypeInputTypeEnum.java | 3 +- .../dto/sap/impart2/ImportSapParamDTO.java | 3 + .../bomnew/pojo/dto/sap/impart2/T3DTO.java | 13 ++ .../bomnew/pojo/vo/BomNewEbomParentVO.java | 5 + .../bomnew/service/BomNewEbomExportToSAP.java | 19 ++ .../service/BomNewEbomParentService.java | 162 ++++++++++++++++-- .../service/BomNewPbomParentService.java | 99 +++++++++++ .../bomnew/service/SapOpUtilService.java | 10 +- .../domain/EBom/CheckEBomException.java | 4 + .../service/domain/EBom/EBomToPbomBase.java | 3 +- 15 files changed, 333 insertions(+), 26 deletions(-) create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/sap/impart2/T3DTO.java diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BomReportApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BomReportApi.java index e1522629..e014d8a6 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BomReportApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BomReportApi.java @@ -173,7 +173,7 @@ public class BomReportApi extends BaseApi { return ResultVO.error("查无数据~"); } if(CollUtil.isNotEmpty(r.getChildNodes())){ - Set materialNoSet = r.getChildNodes().stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toSet()); + Set materialNoSet = r.getChildNodes().stream().filter(m -> StrUtil.isNotBlank(m.getMaterialNo())).map(BaseMaterialVO::getMaterialNo).collect(Collectors.toSet()); List materialMainList = materialMainService.list(Wrappers.lambdaQuery().in(MaterialMainEntity::getMaterialNo,materialNoSet)); Map materialMainMap = materialMainList.stream().collect(Collectors.toMap(MaterialMainEntity::getMaterialNo,MaterialMainEntity::getMaterialDesc,(k1, k2)->k1)); r.getChildNodes().forEach(c -> c.setMaterialDesc(materialMainMap.getOrDefault(c.getMaterialNo(),c.getMaterialDesc()))); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 0841bdf5..f0a998f2 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -35,6 +35,7 @@ import nflg.product.common.constant.STATE; import nflg.product.common.vo.ResultVO; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.ttzero.excel.entity.ListSheet; @@ -391,6 +392,11 @@ public class EbomApi extends BaseApi { && dto.getDelDatas().stream().anyMatch(it -> Objects.equals(it.getSource(), EBomSourceEnum.FROM_MDM.getValue()) && !Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue()))) .throwMessage("要删除发货包请在生成发货包页面取消选中"); + //校验当前BOM中如果只有一行“BOM已删除”标记行时,不让删除保存 + List delBomList = dto.getDelDatas().stream().filter(b-> Objects.equals(b.getProjectType(),"K")).collect(Collectors.toList()); + if(!delBomList.isEmpty()){ + VUtils.isTure(dto.getDatas().isEmpty()).throwMessage("当前BOM没有其他下级物料时,“BOM删除”标记行不能删除"); + } if(CollUtil.isNotEmpty(dto.getDelDatas()) && CollUtil.isNotEmpty(dto.getDatas())){ List delList=dto.getDelDatas().stream().map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); @@ -568,7 +574,6 @@ public class EbomApi extends BaseApi { return ResultVO.success(true); } - @GetMapping("byHome") public ResultVO>> byHome(){ Map> mp = Maps.newHashMap(); @@ -599,5 +604,20 @@ public class EbomApi extends BaseApi { return ResultVO.success(mp); } + @GetMapping("bomDelete") + @ApiOperation("BOM删除") + @LogRecord(success = "Ebom-BOM删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}", type = "Ebom-BOM删除") + public ResultVO bomDelete(@RequestParam("bomRowId") Long bomRowId) { + return ResultVO.success(bomNewEbomParentService.bomDelete(bomRowId)); + } + + @GetMapping("changeBomDelete") + @ApiOperation("BOM变更后BOM删除 ") + @LogRecord(success = "Ebom-BOM变更后删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}", type = "Ebom-BOM变更后删除") + public ResultVO changeBomDelete(@RequestParam("bomRowId") Long bomRowId){ + bomNewEbomParentService.changeBomDelete(bomRowId); + return ResultVO.success(); + } + } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index 95b2ca91..775bb838 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -360,6 +360,14 @@ public class PBomApi extends BaseApi { } } + @GetMapping("bomDelete") + @ApiOperation("BOM删除") + @LogRecord(success = "PBom删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "BOM删除") + public ResultVO bomDelete(@RequestParam("bomRowId") Long bomRowId) { + bomNewPbomParentService.bomDelete(bomRowId); + return ResultVO.success(true); + } + @Resource MaterialService materialService; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomSourceEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomSourceEnum.java index a74f62fd..7c1cc6f4 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomSourceEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomSourceEnum.java @@ -13,7 +13,8 @@ public enum EBomSourceEnum implements ValueEnum { FROM_EXCE(2, "EXCE导入"), FROM_MDM(3, "MDM创建"), FROM_SAP(4, "从SAP导入"), - FROM_CHANGE(5, "变更"); + FROM_CHANGE(5, "变更"), + FROM_DELETE(6, "BOM删除"); private final Integer value; private final String description; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PbomSourceEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PbomSourceEnum.java index c5a52119..734727ca 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PbomSourceEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PbomSourceEnum.java @@ -15,7 +15,8 @@ public enum PbomSourceEnum implements ValueEnum { FROM_DQBOM(2, "DQBOM转换"), FROM_SAP(3, "从SAP导入"), FROM_COPY(4, "复制"), - FROM_CHANGE(5, "变更"); + FROM_CHANGE(5, "变更"), + FROM_DELETE(6, "BOM删除"); private final Integer value; private final String description; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java index 37d7c7a7..ac04d466 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/ProjectTypeInputTypeEnum.java @@ -37,7 +37,8 @@ public enum ProjectTypeInputTypeEnum implements ValueEnum { TYPE_Q("Q", "清点项"), TYPE_F("F", "直发包"), TYPE_Z("Z", "发货前装配包"), - TYPE_L("L", "普通物料"); + TYPE_L("L", "普通物料"), + TYPE_K("K", "BOM删除"); private final String value; private final String description; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/sap/impart2/ImportSapParamDTO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/sap/impart2/ImportSapParamDTO.java index ecb7053a..d4a3a4be 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/sap/impart2/ImportSapParamDTO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/sap/impart2/ImportSapParamDTO.java @@ -32,4 +32,7 @@ public class ImportSapParamDTO { @ApiModelProperty("详情") private List T1; + + @ApiModelProperty("删除物料") + private List T3; } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/sap/impart2/T3DTO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/sap/impart2/T3DTO.java new file mode 100644 index 00000000..b14acd8f --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/sap/impart2/T3DTO.java @@ -0,0 +1,13 @@ +package com.nflg.product.bomnew.pojo.dto.sap.impart2; + + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class T3DTO { + + @ApiModelProperty("父级物料") + protected String MATNR = ""; +} + diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewEbomParentVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewEbomParentVO.java index 9cd552de..9a2a342b 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewEbomParentVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewEbomParentVO.java @@ -85,6 +85,11 @@ public class BomNewEbomParentVO extends BaseMaterialVO implements Serializable { @ApiModelProperty(value = "数量") private BigDecimal num; + + public BigDecimal getNum() { + return num==null?null:num.stripTrailingZeros(); + } + /** * 来源1-原BOM转换 2-EXCE导入 3-MDM创建 */ diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java index 8f7934d3..a53a3c51 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -16,6 +17,7 @@ import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum; import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO; import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO; import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1ExtDTO; +import com.nflg.product.bomnew.pojo.dto.sap.impart2.T3DTO; import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity; @@ -23,6 +25,7 @@ import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO; import com.nflg.product.bomnew.util.SapErrorMsgUtil; import com.nflg.product.bomnew.util.VUtils; import nflg.product.common.constant.STATE; +import org.apache.commons.compress.utils.Lists; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,6 +80,22 @@ public class BomNewEbomExportToSAP { sapDto.setI_STLAN("2"); sapDto.setI_EMPNO(root.getCreatedBy()); sapDto.setT1(Convert.toList(T1DTO.class, this.children.stream().filter(c -> !c.isIgnore()).collect(Collectors.toList()))); + //BOM的子表仅有一行【BOM删除】项目类别为K的数据 by 10002327 241017 +// Map> t1Map = this.children.stream().collect(Collectors.groupingBy(T1ExtDTO::getMATNR)); +// List t3List = Lists.newArrayList(); +// t1Map.forEach((k,v) -> { +// if(CollUtil.isNotEmpty(v) && v.size() == 1){ +// if(StrUtil.equalsIgnoreCase("K",Optional.ofNullable(v.get(0)).map(T1ExtDTO::getPOSTP).orElse(""))){ +// T3DTO t3DTO = new T3DTO(); +// t3DTO.setMATNR(k); +// t3List.add(t3DTO); +// } +// } +// }); +// if(!t3List.isEmpty()){ +// sapDto.setT3(t3List); +// } + liErrMsg = SpringUtil.getBean(SapOpUtilService.class).importToSapV2(sapDto, null); if (CollUtil.isEmpty(liErrMsg)) { state = SapStatusEnum.PUB_SUCCESS; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 2ca0f652..6d872e81 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -1,4 +1,6 @@ package com.nflg.product.bomnew.service; +import com.sap.conn.jco.JCoParameterList; +import com.google.common.collect.Maps; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; @@ -25,6 +27,8 @@ import com.nflg.product.bomnew.mapper.master.BomNewEbomParentMapper; import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper; import com.nflg.product.bomnew.mapper.master.MaterialMainMapper; import com.nflg.product.bomnew.pojo.dto.*; +import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams; +import com.nflg.product.bomnew.pojo.dto.sap.SapResult; import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO; import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO; import com.nflg.product.bomnew.pojo.entity.*; @@ -124,6 +128,9 @@ public class BomNewEbomParentService extends ServiceImpl getParentChild( Long rowId) { return this.getBaseMapper().getParentChild(rowId); @@ -1019,14 +1026,6 @@ public class BomNewEbomParentService extends ServiceImpl ebomParentIdList = pbomParent.stream().map(BomNewPbomParentEntity::getSourceRowId).collect(Collectors.toList()); -// this.delBatch(ebomParentIdList); -// //4、删掉ebom 子级的数据 -// ebomChildService.remove(Wrappers.lambdaQuery().in(BomNewEbomChildEntity::getParentRowId,ebomParentIdList)); -// } - //3、判断parent下是否有子级,排除电控系统和仙桃的,如果没有的话,把parent给删除了 物料****因下级全部是F项,仅保存EBOM,未生成PBOM数据 仙桃) List emptyChildParentList = eBomToPBom.getPBomParentResult().stream() .filter(p -> !p.getMaterialDesc().contains("电控系统") && !p.getMaterialDesc().contains("仙桃)") && !eBomToPBom.getPBomChildResult().stream().map(BomNewPbomChildEntity::getParentRowId).collect(Collectors.toList()).contains(p.getRowId()) ) @@ -1051,17 +1050,23 @@ public class BomNewEbomParentService extends ServiceImpl { -// OperationErrorMsgVO oem = new OperationErrorMsgVO(); -// oem.setPrimaryKey(m); -// oem.msg = String.format("物料%s因下级全部是F项,仅保存EBOM,未生成PBOM数据",m); -// return oem; -// }).collect(Collectors.toList()); eBomToPBom.getPBomParentResult().removeAll(emptyChildParentList); } + //3、如果ebom的子表只有一条项目类别为【K】的数据,则不发布到PBOM中 + List kParentList = eBomToPBom.getPBomChildResult().stream().filter(child -> StrUtil.equalsIgnoreCase("K",child.getProjectType())) + .map(BomNewPbomChildEntity::getParentRowId).distinct().collect(Collectors.toList()); + List delPbomList = eBomToPBom.getPBomParentResult().stream() + .filter(b -> kParentList.contains(b.getRowId())).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(delPbomList)) { + delPbomList.forEach(pbom -> { + List pbomChildList = eBomToPBom.getPBomChildResult().stream().filter(child -> Objects.equals(child.getParentRowId(),pbom.getRowId())).collect(Collectors.toList()); + if(CollUtil.isNotEmpty(pbomChildList) && pbomChildList.size() == 1 && StrUtil.equalsIgnoreCase("K",pbomChildList.get(0).getProjectType())){ + eBomToPBom.getPBomParentResult().remove(pbom); + eBomToPBom.getPBomChildResult().removeAll(pbomChildList); + } + }); + } } - if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) { //将物料标记为用户跟节点 List rootParent = eBomToPBom.getPBomParentResult().stream().filter(u -> u.getMaterialNo().equals(parent.getMaterialNo())).collect(Collectors.toList()); @@ -1475,6 +1480,128 @@ public class BomNewEbomParentService extends ServiceImpl existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo()) + .lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list(); + Set existMaterialNos = existEnt.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); + VUtils.isTure(CollUtil.isNotEmpty(existMaterialNos)).throwMessage(StrUtil.join(",", existMaterialNos, "存在发布前版本。")); + List parentResult = new ArrayList<>(); + //1、生成一个新版本号的空BOM + LogRecordContext.putVariable("bom", parent); + BomNewEbomParentEntity newParent = new BomNewEbomParentEntity(); + BeanUtil.copyProperties(parent, newParent); + newParent.setRowId(IdWorker.getId()); + newParent.setLastVersionIs(1); + newParent.setCurrentVersion(VersionUtil.getNextVersion(parent.getCurrentVersion())); + newParent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); + newParent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue()); + newParent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); + newParent.setDeptRowId(SessionUtil.getDepartRowId()); + newParent.setDeptName(SessionUtil.getDepartName()); + newParent.setDeviseName(SessionUtil.getRealName()); + newParent.setDeviseUserCode(SessionUtil.getUserCode()); + newParent.setRemark(""); + newParent.setSource(EBomSourceEnum.FROM_DELETE.getValue()); + newParent.setConvertToEbomTime(null); + newParent.setReleaseUserName(null); + newParent.setReleaseTime(null); + newParent.setRevertDesc(null); + newParent.setRevertTime(null); + newParent.setRevertUserName(null); + newParent.setAuditUserName(null); + newParent.setAuditTime(null); + newParent.setRootIs(1); + newParent.setUserRootIs(1); + newParent.setSapState(1); + newParent.setSapTime(null); + newParent.setModifyTime(null); + newParent.setCreatedTime(LocalDateTime.now()); + newParent.setCreatedBy(SessionUtil.getUserCode()); + newParent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue()); + parent.setLastVersionIs(0); + parentResult.add(newParent); + parentResult.add(parent); + //2、子表增加一行项目类别为K,标识删除 + BomNewEbomChildEntity newChild = new BomNewEbomChildEntity(); + newChild.setRowId(IdWorker.getId()); + newChild.setParentRowId(newParent.getRowId()); + newChild.setIdentityNo(newParent.getRowId() + "_" + newChild.getRowId()); + newChild.setOrderNumber("001"); + newChild.setProjectType(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_K.getValue()); + newChild.setProjectTypeInputType(0); + newChild.setCreatedBy(SessionUtil.getUserCode()); + newChild.setVirtualPartIs(1); + newChild.setCreatedTime(LocalDateTime.now()); + newChild.setModifyTime(LocalDateTime.now()); + newChild.setEditStatus(1); + newChild.setExceptionStatus(1); + newChild.setSource(EBomSourceEnum.FROM_DELETE.getValue()); + + //3、调用SAP接口删除BOM + SapReqParams sapReqParams = new SapReqParams(); + sapReqParams.setFunName("ZRFC_PP_005"); + Map inputParam = Maps.newHashMap(); + inputParam.put("I_LCBT","主数据平台"); + inputParam.put("I_ACT","X"); + inputParam.put("ZID",RandomUtil.randomNumbers(5)); + inputParam.put("I_WERKS","1"); + inputParam.put("I_STLAN","2"); + inputParam.put("I_EMPNO",SessionUtil.getUserCode()); + sapReqParams.setInputParams(inputParam); + Map>> inputTables = new HashMap<>(); + List> parentMapList = Lists.newArrayList(); + Map parentMap = Maps.newHashMap(); + parentMap.put("MATNR", newParent.getMaterialNo()); + parentMapList.add(parentMap); + inputTables.put("T3", parentMapList); + sapReqParams.setInputTables(inputTables); + + SapResult sapResult = sapService.doSapFun(sapReqParams); + if (!sapResult.isSuccess()) { + throw new NflgBusinessException(STATE.RouteServiceError, sapResult.getMsg()); + } + this.saveOrUpdateBatch(parentResult); + ebomChildService.save(newChild); + return true; + } + + /** + * BOM变更后 BOM删除 by 10002327 241015 + * @param bomRowId + */ + @Transactional(rollbackFor = Exception.class) + public void changeBomDelete(Long bomRowId){ + BomNewEbomParentEntity parent = this.getById(bomRowId); + VUtils.isTure(parent == null).throwMessage(StrUtil.join(",", bomRowId, "不存在~")); + VUtils.isTure(!Objects.equals(parent.getSource(),EBomSourceEnum.FROM_CHANGE.getValue())).throwMessage(StrUtil.join(",", parent.getMaterialNo(), "删除失败,仅支持变更后的BOM删除")); + //1、删除旧的子表数据 + ebomChildService.remove(Wrappers.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId,bomRowId)); + //2、子表增加一行项目类别为K,标识删除 + BomNewEbomChildEntity newChild = new BomNewEbomChildEntity(); + newChild.setRowId(IdWorker.getId()); + newChild.setParentRowId(bomRowId); + newChild.setIdentityNo(bomRowId + "_" + newChild.getRowId()); + newChild.setOrderNumber("001"); + newChild.setProjectType(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_K.getValue()); + newChild.setProjectTypeInputType(0); + newChild.setCreatedBy(SessionUtil.getUserCode()); + newChild.setVirtualPartIs(1); + newChild.setCreatedTime(LocalDateTime.now()); + newChild.setModifyTime(LocalDateTime.now()); + newChild.setEditStatus(1); + newChild.setExceptionStatus(1); + newChild.setSource(EBomSourceEnum.FROM_DELETE.getValue()); + ebomChildService.save(newChild); + } + public void editExportBom(EbomEditExportDTO param, OutputStream response) throws IOException { List result = param.getList(); @@ -2420,6 +2547,9 @@ public class BomNewEbomParentService extends ServiceImpl delChildList = SpringUtil.getBean(BomNewEbomChildService.class).list(queryChildWrapper); List delTagList = new ArrayList<>(); + //“BOM已删除”标记行删除,项目类别为K by 10002327 241016 + delTagList.addAll(delChildList.stream().filter(b -> Objects.equals(b.getProjectType(),"K")).collect(Collectors.toList())); + //检查原始bom里过来数据是否包含正常数据 // List check1List = delChildList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index 06a7f25c..40b345c1 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -22,6 +22,8 @@ import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.bomnew.constant.*; import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper; import com.nflg.product.bomnew.pojo.dto.*; +import com.nflg.product.bomnew.pojo.dto.sap.SapReqParams; +import com.nflg.product.bomnew.pojo.dto.sap.SapResult; import com.nflg.product.bomnew.pojo.dto.sap.impart2.ImportSapParamDTO; import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1DTO; import com.nflg.product.bomnew.pojo.entity.*; @@ -1360,8 +1362,105 @@ public class BomNewPbomParentService extends ServiceImpl waitPublishList = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery() + .eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo()) + .eq(BomNewPbomParentEntity::getFacCode, parent.getFacCode()) + .lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()).list(); + VUtils.isTure(CollUtil.isNotEmpty(waitPublishList)).throwMessage(parent.getMaterialNo() + "存在待发布的版本,无法删除"); + BomNewPbomParentVO rootVo = Convert.convert(BomNewPbomParentVO.class, parent); + rootVo.setBomRowId(rootVo.getRowId()); + //1、parent增加一行大版本号记录 + BomNewPbomParentEntity pbomParent = new BomNewPbomParentEntity(); + List parentList = Lists.newArrayList(); + BeanUtil.copyProperties(rootVo, pbomParent); + pbomParent.setRowId(IdWorker.getId()); + pbomParent.setCreatedTime(LocalDateTime.now()); + pbomParent.setCreatedBy(SessionUtil.getUserCode()); + pbomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue()); + pbomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue()); + //获取大版本号 + pbomParent.setCurrentVersion(VersionUtil.getNextVersion(rootVo.getCurrentVersion())); + pbomParent.setDeptRowId(SessionUtil.getDepartRowId()); + pbomParent.setDeptName(SessionUtil.getDepartName()); + pbomParent.setDeviseName(SessionUtil.getRealName()); + pbomParent.setDeviseUserCode(SessionUtil.getUserCode()); + pbomParent.setTechnologyUserName(SessionUtil.getUserName()); + pbomParent.setTechnologyUserCode(SessionUtil.getUserCode()); + pbomParent.setRemark(""); + pbomParent.setSource(PbomSourceEnum.FROM_DELETE.getValue()); + pbomParent.setReleaseTime(null); + pbomParent.setReleaseUserName(null); + pbomParent.setSapState(1); + pbomParent.setSapTime(null); + pbomParent.setModifyTime(null); + pbomParent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue()); + pbomParent.setRootIs(1); + pbomParent.setUserRootIs(1); + pbomParent.setLastVersionIs(1); + //设置旧版本 + parent.setLastVersionIs(0); + parentList.add(pbomParent); + parentList.add(parent); + //2、子表新增一行项目类别为K的标识行 + BomNewPbomChildEntity child = new BomNewPbomChildEntity(); + child.setRowId(IdWorker.getId()); + child.setParentRowId(pbomParent.getRowId()); + child.setFacCode(pbomParent.getFacCode()); + child.setProjectType(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_K.getValue()); + child.setOrderNumber("001"); + child.setNum(new BigDecimal(1)); + child.setIdentityNo(pbomParent.getRowId() + "_" + child.getRowId()); + child.setCreatedTime(LocalDateTime.now()); + child.setCreatedBy(SessionUtil.getUserCode()); + child.setModifyTime(null); + child.setSource(PbomSourceEnum.FROM_DELETE.getValue()); + child.setRemark(""); + + //调用SAP接口 删除pbom + SapReqParams sapReqParams = new SapReqParams(); + sapReqParams.setFunName("ZRFC_PP_005"); + Map inputParam = Maps.newHashMap(); + inputParam.put("I_LCBT","主数据平台"); + inputParam.put("I_ACT","X"); + inputParam.put("ZID",RandomUtil.randomNumbers(5)); + inputParam.put("I_WERKS","1"); + if (StrUtil.equals(parent.getFacCode(), EBomConstant.XIAN_TAO_FACTORY_CODE_1020)) { + inputParam.put("I_WERKS","2"); + } + inputParam.put("I_STLAN","1"); + inputParam.put("I_EMPNO",SessionUtil.getUserCode()); + sapReqParams.setInputParams(inputParam); + Map>> inputTables = new HashMap<>(); + List> parentMapList = org.apache.commons.compress.utils.Lists.newArrayList(); + Map parentMap = Maps.newHashMap(); + parentMap.put("MATNR", parent.getMaterialNo()); + parentMapList.add(parentMap); + inputTables.put("T3", parentMapList); + sapReqParams.setInputTables(inputTables); + SapResult sapResult = sapService.doSapFun(sapReqParams); + if (!sapResult.isSuccess()) { + throw new NflgBusinessException(STATE.RouteServiceError, sapResult.getMsg()); + } + this.saveOrUpdateBatch(parentList); + pbomChildService.save(child); } private void resetBomExist(Long rowId) { diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/SapOpUtilService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/SapOpUtilService.java index d3c8adcf..6d74dc0a 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/SapOpUtilService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/SapOpUtilService.java @@ -6,6 +6,7 @@ import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.TypeReference; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; +import com.google.common.collect.Lists; import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.bomnew.constant.BomConstant; import com.nflg.product.bomnew.pojo.dto.sap.ImportToSapDTO; @@ -180,14 +181,15 @@ public class SapOpUtilService { Map>> outTablesMap = sapResult.getOutTablesMap(); log.info("导入到SAP--返回值:" + JSON.toJSONString(outTablesMap)); List> tOut = outTablesMap.get("T1"); - List list = null; + List list = Lists.newArrayList(); if (!CollectionUtils.isEmpty(tOut)) { list = Convert.convert(new TypeReference>() { }, tOut); } - if (CollUtil.isEmpty(list)) { - throw new NflgBusinessException(STATE.BusinessError, "获取sap返回数据转换异常"); - } + //BOM删除 新增项目类别K,没有返回 +// if (CollUtil.isEmpty(list)) { +// throw new NflgBusinessException(STATE.BusinessError, "获取sap返回数据转换异常"); +// } if (!Objects.isNull(backList)) { backList.addAll(list); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java index 168c6560..7d0bb228 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java @@ -120,6 +120,10 @@ public class CheckEBomException { && unCheckExcept.contains(vo.getExceptionStatus())) { continue; } + //项目类别为K 不做检查 10002327 241016 + if(Objects.equals(vo.getProjectType(),"K")){ + continue; + } vo.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); if (StrUtil.equals(BomConstant.PROJECT_TYPE_TEMPORARY, vo.getProjectType(), true)) { if (StrUtil.isBlank(vo.getMaterialDesc())) { diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java index 6204683e..f51b33cc 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java @@ -795,7 +795,8 @@ public abstract class EBomToPbomBase { if (oldChildList.size() != newChildList.size()) { return false; } - Map> oldChildMap = oldChildList.stream().collect(Collectors.groupingBy(u -> StrUtil.join("", u.getMaterialNo(), u.getProjectType(), u.getNum()))); + Map> oldChildMap = oldChildList.stream().collect( + Collectors.groupingBy(u -> StrUtil.join("", u.getMaterialNo(), u.getProjectType(), u.getNum()))); for (BomNewEbomParentVO newChild : newChildList) { String key = MyStrUtil.joinStr(newChild.getMaterialNo(), newChild.getProjectType(), newChild.getNum()); if (!oldChildMap.containsKey(key)) { From a32372b5ce07db728adab0cea2b4c2826e3a78a9 Mon Sep 17 00:00:00 2001 From: 10002327 Date: Fri, 18 Oct 2024 15:11:09 +0800 Subject: [PATCH 2/6] =?UTF-8?q?BOM=E5=88=A0=E9=99=A42?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bomnew/service/BomNewPbomParentService.java | 10 ++++++++++ .../bomnew/service/domain/PBom/PBomDetailTask.java | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index ef256c59..b4ec5c1b 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -593,6 +593,12 @@ public class BomNewPbomParentService extends ServiceImpl childList = pbomChildService.getBaseMapper().selectBatchIds(paramDTO.getRowIdList()); List childListVO = Convert.toList(BomNewPbomParentVO.class, childList); materialMainService.intiMaterialInfo(childListVO); + //校验当前BOM中如果只有一行“BOM已删除”标记行时,不让删除保存 + List kChildList = childList.stream().filter(c -> Objects.equals("K",c.getProjectType())).collect(Collectors.toList()); + if(kChildList.size() > 0){ + int cnt = pbomChildService.count(Wrappers.lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId,paramDTO.getBomRowId())); + VUtils.isTure(cnt == childList.size()).throwMessage("当前BOM中有一行“BOM已删除”标记行时,不能全部删除~"); + } // 判断是否是工艺包 List technologypackages = childListVO.stream() @@ -1316,6 +1322,7 @@ public class BomNewPbomParentService extends ServiceImpl oldBomDetail = this.getBaseMapper().getParentChild(oldParent.getRowId()); List oldBomNoTChildren = oldBomDetail.stream().filter(u -> !EBomConstant.PROJECT_TYPE_T.equalsIgnoreCase(u.getProjectType())).collect(Collectors.toList()); @@ -1481,6 +1488,8 @@ public class BomNewPbomParentService extends ServiceImpl materialNos = pbomChildService.lambdaQuery() .select(BomNewPbomChildEntity::getMaterialNo) .eq(BomNewPbomChildEntity::getParentRowId, bom.getBomRowId()) + .apply(" material_no != '' ") .list() .stream() .map(BomNewPbomChildEntity::getMaterialNo) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/PBomDetailTask.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/PBomDetailTask.java index 7e07abd8..526920a7 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/PBomDetailTask.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/PBomDetailTask.java @@ -52,6 +52,18 @@ public class PBomDetailTask extends RecursiveTask> { */ public void handlerChildBomVersionDetail() { List materialNos = bomDetail.stream().filter(u -> StrUtil.isNotBlank(u.getMaterialNo())).map(BomNewPbomParentVO::getMaterialNo).collect(Collectors.toList()); + //项目列表为K项时,没有物料编码,相关属性取parent值 by 10002327 241018 +// List kList = bomDetail.stream().filter(u -> Objects.equals(u.getProjectType(),"K")).collect(Collectors.toList()); +// kList.forEach(k -> { +// BomNewPbomParentEntity parent = SpringUtil.getBean(BomNewPbomParentService.class).lambdaQuery().eq(BomNewPbomParentEntity::getRowId, k.getParentRowId()).one(); +// k.setDeviseUserCode(parent.getDeviseUserCode()); +// k.setDeviseName(parent.getDeviseName()); +// k.setDeptName(parent.getDeptName()); +// k.setDeptRowId(parent.getDeptRowId()); +// k.setStatus(parent.getStatus()); +// k.setEditStatus(parent.getEditStatus()); +// k.setVirtualPackageIs(parent.getVirtualPackageIs()); +// }); if (CollUtil.isNotEmpty(materialNos)) { From 04480c3b04ae0d6b8d0ffcacf650ac8f2cf871ce Mon Sep 17 00:00:00 2001 From: 10002327 Date: Mon, 21 Oct 2024 14:13:45 +0800 Subject: [PATCH 3/6] =?UTF-8?q?BOM=E5=88=A0=E9=99=A4=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 5 +-- .../nflg/product/bomnew/api/user/PBomApi.java | 5 +-- .../service/BomNewEbomParentService.java | 35 ++++++++++++++++--- .../service/BomNewPbomParentService.java | 34 +++++++++++++++--- 4 files changed, 65 insertions(+), 14 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 4dc35dea..47b71bdf 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -615,8 +615,9 @@ public class EbomApi extends BaseApi { @GetMapping("bomDelete") @ApiOperation("BOM删除") @LogRecord(success = "Ebom-BOM删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}", type = "Ebom-BOM删除") - public ResultVO bomDelete(@RequestParam("bomRowId") Long bomRowId) { - return ResultVO.success(bomNewEbomParentService.bomDelete(bomRowId)); + public ResultVO bomDelete(@RequestParam("bomRowId") Long bomRowId, + @RequestParam("childBomRowId") Long childBomRowId) { + return ResultVO.success(bomNewEbomParentService.bomDelete(bomRowId,childBomRowId)); } @GetMapping("changeBomDelete") diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index 52e2f7c3..3f428c88 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -365,8 +365,9 @@ public class PBomApi extends BaseApi { @GetMapping("bomDelete") @ApiOperation("BOM删除") @LogRecord(success = "PBom删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "BOM删除") - public ResultVO bomDelete(@RequestParam("bomRowId") Long bomRowId) { - bomNewPbomParentService.bomDelete(bomRowId); + public ResultVO bomDelete(@RequestParam("bomRowId") Long bomRowId, + @RequestParam("childBomRowId") Long childBomRowId) { + bomNewPbomParentService.bomDelete(bomRowId,childBomRowId); return ResultVO.success(true); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index bc29abe1..fd6e6127 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -1488,10 +1488,11 @@ public class BomNewEbomParentService extends ServiceImpl existMaterialNos = existEnt.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); VUtils.isTure(CollUtil.isNotEmpty(existMaterialNos)).throwMessage(StrUtil.join(",", existMaterialNos, "存在发布前版本。")); + //如果bom 有且只有一条 [BOM已删除] 标记行时,提示已删除,无须重复删除 + List ebomChildEntityList = ebomChildService.list(Wrappers.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId,bomRowId)); + List kChildEntityList = ebomChildEntityList.stream().filter(c -> Objects.equals("K",c.getProjectType())).collect(Collectors.toList()); + VUtils.isTure(ebomChildEntityList.size() == 1 && kChildEntityList.size() == 1).throwMessage(StrUtil.join(",", bomRowId, "BOM已删除,无须重复删除~")); + List parentResult = new ArrayList<>(); - //1、生成一个新版本号的空BOM + //1、生成一个新版本号的空BOM,直接变更为正式版 LogRecordContext.putVariable("bom", parent); BomNewEbomParentEntity newParent = new BomNewEbomParentEntity(); BeanUtil.copyProperties(parent, newParent); @@ -1508,8 +1514,8 @@ public class BomNewEbomParentService extends ServiceImpl childEntityList = Lists.newArrayList(); + BomNewEbomChildEntity oldBomChild = ebomChildService.getById(childBomRowId); + BomNewEbomChildEntity newBomChild = new BomNewEbomChildEntity(); + BeanUtil.copyProperties(oldBomChild, newBomChild); + newBomChild.setRowId(IdWorker.getId()); + newBomChild.setIdentityNo(newBomChild.getParentRowId() + "_" + newBomChild.getRowId()); + newBomChild.setBomVersionRowId(newParent.getRowId()); + newBomChild.setSource(EBomSourceEnum.FROM_DELETE.getValue()); + childEntityList.add(newBomChild); + //2、子表增加一行项目类别为K,标识删除 BomNewEbomChildEntity newChild = new BomNewEbomChildEntity(); newChild.setRowId(IdWorker.getId()); newChild.setParentRowId(newParent.getRowId()); newChild.setIdentityNo(newParent.getRowId() + "_" + newChild.getRowId()); newChild.setOrderNumber("001"); + newChild.setMaterialDesc("[BOM已删除]"); newChild.setProjectType(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_K.getValue()); newChild.setProjectTypeInputType(0); newChild.setCreatedBy(SessionUtil.getUserCode()); @@ -1551,6 +1569,7 @@ public class BomNewEbomParentService extends ServiceImpl addRowIds = com.google.common.collect.Lists.newArrayList(newParent.getRowId()); + List delRowIds = com.google.common.collect.Lists.newArrayList(bomRowId); + eBomToFormal(addRowIds, delRowIds); return true; } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index b4ec5c1b..88d380ef 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -1444,7 +1444,7 @@ public class BomNewPbomParentService extends ServiceImpl childEntityList = pbomChildService.list(Wrappers.lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId,bomRowId)); + List kEntityList = childEntityList.stream().filter(c -> Objects.equals("K",c.getProjectType())).collect(Collectors.toList()); + VUtils.isTure(childEntityList.size() == 1 && kEntityList.size() == 1).throwMessage("BOM已删除,无须重复删除~"); + BomNewPbomParentVO rootVo = Convert.convert(BomNewPbomParentVO.class, parent); rootVo.setBomRowId(rootVo.getRowId()); - //1、parent增加一行大版本号记录 + //1、parent增加一行大版本号记录 直接变更为正式版 BomNewPbomParentEntity pbomParent = new BomNewPbomParentEntity(); List parentList = Lists.newArrayList(); BeanUtil.copyProperties(rootVo, pbomParent); pbomParent.setRowId(IdWorker.getId()); pbomParent.setCreatedTime(LocalDateTime.now()); pbomParent.setCreatedBy(SessionUtil.getUserCode()); - pbomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue()); - pbomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue()); + pbomParent.setStatus(PBomStatusEnum.FACTORY_CONFIRM.getValue()); + pbomParent.setEditStatus(PBomEditStatusEnum.HANDLER_FINISHED.getValue()); //获取大版本号 pbomParent.setCurrentVersion(VersionUtil.getNextVersion(rootVo.getCurrentVersion())); pbomParent.setDeptRowId(SessionUtil.getDepartRowId()); @@ -1495,6 +1500,17 @@ public class BomNewPbomParentService extends ServiceImpl newChildEntityList = Lists.newArrayList(); + BomNewPbomChildEntity oldBomChild = pbomChildService.getById(childBomRowId); + BomNewPbomChildEntity newBomChild = new BomNewPbomChildEntity(); + BeanUtil.copyProperties(oldBomChild, newBomChild); + newBomChild.setRowId(IdWorker.getId()); + newBomChild.setBomVersionRowId(pbomParent.getRowId()); + newBomChild.setSource(PbomSourceEnum.FROM_DELETE.getValue()); + newChildEntityList.add(newBomChild); + + //2、子表新增一行项目类别为K的标识行 BomNewPbomChildEntity child = new BomNewPbomChildEntity(); child.setRowId(IdWorker.getId()); @@ -1502,6 +1518,7 @@ public class BomNewPbomParentService extends ServiceImpl exceptRowIds = Lists.newArrayList(pbomParent.getRowId()); + List parentMaterialNos =Lists.newArrayList(pbomParent.getMaterialNo()); + //历史版本转移到formal正式工作表 + pBomToFormal(exceptRowIds, parentMaterialNos, parent.getFacCode()); } private void resetBomExist(Long rowId) { From 31b25008e0083af6d5ad291e8fb1a952dbca33d3 Mon Sep 17 00:00:00 2001 From: 10002327 Date: Mon, 21 Oct 2024 16:15:55 +0800 Subject: [PATCH 4/6] =?UTF-8?q?PBOM=E5=88=97=E8=A1=A8=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E5=9C=B0=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/PBomApi.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index 3f428c88..c5193134 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -80,18 +80,18 @@ public class PBomApi extends BaseApi { public ResultVO> workDetailsListByPage(@RequestBody BomNewPbomParentQuery query) { IPage r = bomNewPbomParentService.workDetailsListByPage(query); //添加仓库地点 by 10002327 0830 - if(!r.getRecords().isEmpty()){ - List materialNoList = Lists.newArrayList(); - List facList = Lists.newArrayList(); - - this.get(r.getRecords(),materialNoList,facList); - List> lgproList = sapService.lgproByList(materialNoList,facList); - Map lgproMap = lgproList.stream().collect(Collectors.toMap(m-> - String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS")) - ,m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1)); - this.set(r.getRecords(),lgproMap); - - } +// if(!r.getRecords().isEmpty()){ +// List materialNoList = Lists.newArrayList(); +// List facList = Lists.newArrayList(); +// +// this.get(r.getRecords(),materialNoList,facList); +// List> lgproList = sapService.lgproByList(materialNoList,facList); +// Map lgproMap = lgproList.stream().collect(Collectors.toMap(m-> +// String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS")) +// ,m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1)); +// this.set(r.getRecords(),lgproMap); +// +// } return ResultVO.success(r); } From a4966b897a9f526ede7c3a667edb6725ba3d500e Mon Sep 17 00:00:00 2001 From: 10002327 Date: Wed, 23 Oct 2024 08:15:10 +0800 Subject: [PATCH 5/6] =?UTF-8?q?1=E3=80=81bug=E4=BF=AE=E5=A4=8D=202?= =?UTF-8?q?=E3=80=81=E7=89=A9=E6=96=99=E6=98=AF=E5=86=BB=E7=BB=93=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E8=AE=A9=E5=88=A0BOM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 2 +- .../nflg/product/bomnew/api/user/PBomApi.java | 2 +- .../service/BomNewEbomParentService.java | 44 ++++++++++----- .../service/BomNewPbomParentService.java | 55 ++++++++++++------- 4 files changed, 67 insertions(+), 36 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 47b71bdf..b45990c7 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -616,7 +616,7 @@ public class EbomApi extends BaseApi { @ApiOperation("BOM删除") @LogRecord(success = "Ebom-BOM删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}", type = "Ebom-BOM删除") public ResultVO bomDelete(@RequestParam("bomRowId") Long bomRowId, - @RequestParam("childBomRowId") Long childBomRowId) { + @RequestParam(value = "childBomRowId",required = false) Long childBomRowId) { return ResultVO.success(bomNewEbomParentService.bomDelete(bomRowId,childBomRowId)); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index c5193134..b8cd7686 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -366,7 +366,7 @@ public class PBomApi extends BaseApi { @ApiOperation("BOM删除") @LogRecord(success = "PBom删除,操作结果:{{#_ret}}", bizNo = "{{#bomRowId}}",type = "BOM删除") public ResultVO bomDelete(@RequestParam("bomRowId") Long bomRowId, - @RequestParam("childBomRowId") Long childBomRowId) { + @RequestParam(value = "childBomRowId",required = false) Long childBomRowId) { bomNewPbomParentService.bomDelete(bomRowId,childBomRowId); return ResultVO.success(true); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index fd6e6127..1f950737 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -56,6 +56,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.math.BigDecimal; +import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.ExecutionException; @@ -1495,6 +1496,15 @@ public class BomNewEbomParentService extends ServiceImpl mList = materialMainService.list(Wrappers.lambdaQuery() + .eq(MaterialMainEntity::getMaterialNo,parent.getMaterialNo()) + .eq(MaterialMainEntity::getMaterialState, MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())); + if(CollUtil.isNotEmpty(mList)){ + VUtils.isTure(true).throwMessage(StrUtil.join(",", Optional.ofNullable(mList).map(l->l.get(0)) + .map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结中无法删除~")); + } + //检查是否存在发布前的版本,有则不能发起 BOM删除 List existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo()) .lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list(); @@ -1523,8 +1533,6 @@ public class BomNewEbomParentService extends ServiceImpl childEntityList = Lists.newArrayList(); - BomNewEbomChildEntity oldBomChild = ebomChildService.getById(childBomRowId); - BomNewEbomChildEntity newBomChild = new BomNewEbomChildEntity(); - BeanUtil.copyProperties(oldBomChild, newBomChild); - newBomChild.setRowId(IdWorker.getId()); - newBomChild.setIdentityNo(newBomChild.getParentRowId() + "_" + newBomChild.getRowId()); - newBomChild.setBomVersionRowId(newParent.getRowId()); - newBomChild.setSource(EBomSourceEnum.FROM_DELETE.getValue()); - childEntityList.add(newBomChild); + if(childBomRowId != null){ + BomNewEbomChildEntity oldBomChild = ebomChildService.getById(childBomRowId); + if(oldBomChild != null){ + BomNewEbomChildEntity newBomChild = new BomNewEbomChildEntity(); + BeanUtil.copyProperties(oldBomChild, newBomChild); + newBomChild.setRowId(IdWorker.getId()); + newBomChild.setIdentityNo(newBomChild.getParentRowId() + "_" + newBomChild.getRowId()); + newBomChild.setBomVersionRowId(newParent.getRowId()); + newBomChild.setSource(EBomSourceEnum.FROM_DELETE.getValue()); + childEntityList.add(newBomChild); + } + } + //2、子表增加一行项目类别为K,标识删除 BomNewEbomChildEntity newChild = new BomNewEbomChildEntity(); @@ -1595,8 +1612,9 @@ public class BomNewEbomParentService extends ServiceImpl addRowIds = com.google.common.collect.Lists.newArrayList(newParent.getRowId()); List delRowIds = com.google.common.collect.Lists.newArrayList(bomRowId); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index 88d380ef..405f4258 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -284,14 +284,14 @@ public class BomNewPbomParentService extends ServiceImpl(query.getPage(), query.getPageSize()), query); } //添加仓库地点 by 10002327 0830 - if(!result.getRecords().isEmpty()){ - List> lgproList = sapService.lgproByList(result.getRecords().stream().map(BaseMaterialVO::getMaterialNo).distinct().collect(Collectors.toList()), - result.getRecords().stream().map(BomNewPbomParentVO::getFacCode).distinct().collect(Collectors.toList())); - Map lgproMap = lgproList.stream().collect(Collectors.toMap(m-> { - return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS")); - },m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1)); - result.getRecords().forEach(r -> r.setLgpro(lgproMap.get(StrUtil.padPre(r.getMaterialNo(),18,"0") +r.getFacCode()))); - } +// if(!result.getRecords().isEmpty()){ +// List> lgproList = sapService.lgproByList(result.getRecords().stream().map(BaseMaterialVO::getMaterialNo).distinct().collect(Collectors.toList()), +// result.getRecords().stream().map(BomNewPbomParentVO::getFacCode).distinct().collect(Collectors.toList())); +// Map lgproMap = lgproList.stream().collect(Collectors.toMap(m-> { +// return String.valueOf(m.get("MATNR")) + String.valueOf(m.get("WERKS")); +// },m->String.valueOf(m.get("LGPRO")),(k1,k2)->k1)); +// result.getRecords().forEach(r -> r.setLgpro(lgproMap.get(StrUtil.padPre(r.getMaterialNo(),18,"0") +r.getFacCode()))); +// } materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); return result; } @@ -1447,6 +1447,14 @@ public class BomNewPbomParentService extends ServiceImpl mList = materialMainService.list(Wrappers.lambdaQuery() + .eq(MaterialMainEntity::getMaterialNo,parent.getMaterialNo()) + .eq(MaterialMainEntity::getMaterialState, MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())); + if(CollUtil.isNotEmpty(mList)){ + VUtils.isTure(true).throwMessage(StrUtil.join(",", Optional.ofNullable(mList).map(l->l.get(0)) + .map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结中无法删除~")); + } VUtils.isTure(parent.getStatus() < PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM,才能删除"); //检查当前用户是否有该工厂权限 if(!userRoleService.getUserOfFactory().contains(parent.getFacCode())){ @@ -1484,9 +1492,7 @@ public class BomNewPbomParentService extends ServiceImpl newChildEntityList = Lists.newArrayList(); - BomNewPbomChildEntity oldBomChild = pbomChildService.getById(childBomRowId); - BomNewPbomChildEntity newBomChild = new BomNewPbomChildEntity(); - BeanUtil.copyProperties(oldBomChild, newBomChild); - newBomChild.setRowId(IdWorker.getId()); - newBomChild.setBomVersionRowId(pbomParent.getRowId()); - newBomChild.setSource(PbomSourceEnum.FROM_DELETE.getValue()); - newChildEntityList.add(newBomChild); + if(childBomRowId != null){ + BomNewPbomChildEntity oldBomChild = pbomChildService.getById(childBomRowId); + if(oldBomChild!= null){ + BomNewPbomChildEntity newBomChild = new BomNewPbomChildEntity(); + BeanUtil.copyProperties(oldBomChild, newBomChild); + newBomChild.setRowId(IdWorker.getId()); + newBomChild.setBomVersionRowId(pbomParent.getRowId()); + newBomChild.setSource(PbomSourceEnum.FROM_DELETE.getValue()); + newChildEntityList.add(newBomChild); + } + } //2、子表新增一行项目类别为K的标识行 @@ -1555,8 +1567,9 @@ public class BomNewPbomParentService extends ServiceImpl exceptRowIds = Lists.newArrayList(pbomParent.getRowId()); List parentMaterialNos =Lists.newArrayList(pbomParent.getMaterialNo()); //历史版本转移到formal正式工作表 From 99d45f5c17fa6dc8a94b621be8e840ce7dd90907 Mon Sep 17 00:00:00 2001 From: 10002327 Date: Wed, 23 Oct 2024 17:54:45 +0800 Subject: [PATCH 6/6] =?UTF-8?q?BOM=E5=88=A0=E9=99=A4=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/service/BomNewEbomParentService.java | 5 +++-- .../nflg/product/bomnew/service/BomNewPbomParentService.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 1f950737..61b5fee7 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -1499,10 +1499,10 @@ public class BomNewEbomParentService extends ServiceImpl mList = materialMainService.list(Wrappers.lambdaQuery() .eq(MaterialMainEntity::getMaterialNo,parent.getMaterialNo()) - .eq(MaterialMainEntity::getMaterialState, MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())); + .in(MaterialMainEntity::getMaterialState, com.google.common.collect.Lists.newArrayList(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue(),MaterialGetEnum.MaterialStateEnum.STATE_NO_5.getValue()))); if(CollUtil.isNotEmpty(mList)){ VUtils.isTure(true).throwMessage(StrUtil.join(",", Optional.ofNullable(mList).map(l->l.get(0)) - .map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结中无法删除~")); + .map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结编码无法编辑删除BOM~")); } //检查是否存在发布前的版本,有则不能发起 BOM删除 @@ -1640,6 +1640,7 @@ public class BomNewEbomParentService extends ServiceImpl mList = materialMainService.list(Wrappers.lambdaQuery() .eq(MaterialMainEntity::getMaterialNo,parent.getMaterialNo()) - .eq(MaterialMainEntity::getMaterialState, MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue())); + .in(MaterialMainEntity::getMaterialState, com.google.common.collect.Lists.newArrayList(MaterialGetEnum.MaterialStateEnum.STATE_NO_4.getValue(),MaterialGetEnum.MaterialStateEnum.STATE_NO_5.getValue()))); if(CollUtil.isNotEmpty(mList)){ VUtils.isTure(true).throwMessage(StrUtil.join(",", Optional.ofNullable(mList).map(l->l.get(0)) - .map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结中无法删除~")); + .map(MaterialMainEntity::getMaterialNo).orElse(String.valueOf(bomRowId)), "冻结编码无法编辑删除BOM~")); } VUtils.isTure(parent.getStatus() < PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM,才能删除"); //检查当前用户是否有该工厂权限