From b995a19db8e3e6470fd2cf01f4b785ca4622f0fb Mon Sep 17 00:00:00 2001 From: 10002327 Date: Tue, 24 Sep 2024 18:32:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90PBOM=E6=97=B6=EF=BC=8Cbom?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=AD=90=E9=A1=B9=E7=9A=84=E8=AF=9D=EF=BC=8C?= =?UTF-8?q?=E4=BB=85=E7=94=9F=E6=88=90EBOM=E6=AD=A3=E5=BC=8F=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E7=94=9F=E6=88=90PBOM=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 8 +-- .../service/BomNewEbomParentService.java | 64 ++++++++++++++++--- .../bomnew/service/MaterialMainService.java | 20 +++++- 3 files changed, 79 insertions(+), 13 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 68af4923..0841bdf5 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 @@ -175,10 +175,9 @@ public class EbomApi extends BaseApi { VUtils.isTure(CollUtil.isEmpty(paramDto.getBomRowIds())).throwMessage("请选择要转换的物料"); VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂"); VUtils.isTure(Objects.isNull(paramDto.getConvertMode())).throwMessage("转换模式不能为空"); - bomNewEbomParentService.convertToPBom(paramDto); - //导入到sap List errorMsgVOS = new ArrayList<>(); + errorMsgVOS.addAll(bomNewEbomParentService.convertToPBom(paramDto)); paramDto.getBomRowIds().forEach(rootRowId -> { BomNewEbomExportToSAP exportToSAP = new BomNewEbomExportToSAP(); errorMsgVOS.addAll(exportToSAP.export(rootRowId)); @@ -187,6 +186,7 @@ public class EbomApi extends BaseApi { return ResultVO.success(errorMsgVOS); } + @PostMapping("convertToPBomForFormalEBom") @ApiOperation("EBom正式版转PBom") @LogRecord(success = "转PBom:物料编码:{{#CToPbom.materialNo}} 版本:{{#CToPbom.currentVersion}},操作结果:{{#_ret}}", @@ -195,9 +195,9 @@ public class EbomApi extends BaseApi { VUtils.isTure(CollUtil.isEmpty(paramDto.getBomRowIds())).throwMessage("请选择要转换的物料"); VUtils.isTure(CollUtil.isEmpty(paramDto.getFacCodes())).throwMessage("请选择要转换的工厂"); VUtils.isTure(Objects.isNull(paramDto.getConvertMode())).throwMessage("转换模式不能为空"); - bomNewEbomParentService.convertToPBomForFormalEBom(paramDto); - return ResultVO.success(Collections.emptyList()); + + return ResultVO.success(bomNewEbomParentService.convertToPBomForFormalEBom(paramDto)); } @PostMapping("upgradeChanges") 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 79c2a889..d4b44d47 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 @@ -38,6 +38,7 @@ import com.nflg.product.bomnew.util.*; import lombok.extern.slf4j.Slf4j; import nflg.product.common.constant.STATE; import nflg.product.common.vo.ResultVO; +import org.apache.commons.compress.utils.Lists; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @@ -964,7 +965,8 @@ public class BomNewEbomParentService extends ServiceImpl convertToPBom(EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException { + List rList = Lists.newArrayList(); //31 码 须有虚拟包 List parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds()); @@ -1004,12 +1006,27 @@ public class BomNewEbomParentService extends ServiceImpl pbomParent.stream().map(BomNewPbomParentEntity::getRowId).collect(Collectors.toList()).contains(c.getParentRowId())) .collect(Collectors.toList()); eBomToPBom.getPBomChildResult().removeAll(pbomChild); - if(!pbomParent.isEmpty()){ - //3、删掉ebom 父级的数据 - List ebomParentIdList = pbomParent.stream().map(BomNewPbomParentEntity::getSourceRowId).collect(Collectors.toList()); - this.delBatch(ebomParentIdList); - //4、删掉ebom 子级的数据 - ebomChildService.remove(Wrappers.lambdaQuery().in(BomNewEbomChildEntity::getParentRowId,ebomParentIdList)); + //仅删除PBOM 保留EBOM的数据 +// if(!pbomParent.isEmpty()){ +// //3、删掉ebom 父级的数据 +// List 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 -> !eBomToPBom.getPBomChildResult().stream().map(BomNewPbomChildEntity::getParentRowId).collect(Collectors.toList()).contains(p.getRowId()) ) + .collect(Collectors.toList()); + if(!emptyChildParentList.isEmpty()){ + rList = emptyChildParentList.stream().map(BomNewPbomParentEntity::getMaterialNo).distinct() + .map(m -> { + 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); } } @@ -1092,6 +1109,7 @@ public class BomNewEbomParentService extends ServiceImpl rowIds){ @@ -1106,7 +1124,8 @@ public class BomNewEbomParentService extends ServiceImpl convertToPBomForFormalEBom(EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException { + List rList = Lists.newArrayList(); //31 码 须有虚拟包 List parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds()); @@ -1149,6 +1168,34 @@ public class BomNewEbomParentService extends ServiceImpl pbomParent = eBomToPBom.getPBomParentResult().stream().filter(p -> (p.getMaterialDesc().contains("电控系统") && p.getMaterialDesc().contains("直发")) || + (p.getMaterialDesc().contains("电控系统") && p.getMaterialDesc().contains("制作"))).collect(Collectors.toList()); + eBomToPBom.getPBomParentResult().removeAll(pbomParent); + //2、删掉pbom 子级的数据 + List pbomChild = eBomToPBom.getPBomChildResult().stream() + .filter(c -> pbomParent.stream().map(BomNewPbomParentEntity::getRowId).collect(Collectors.toList()).contains(c.getParentRowId())) + .collect(Collectors.toList()); + eBomToPBom.getPBomChildResult().removeAll(pbomChild); + //3、判断parent下是否有子级,如果没有的话,把parent给删除了 物料****因下级全部是F项,仅保存EBOM,未生成PBOM数据 + List emptyChildParentList = eBomToPBom.getPBomParentResult().stream() + .filter(p -> !eBomToPBom.getPBomChildResult().stream().map(BomNewPbomChildEntity::getParentRowId).collect(Collectors.toList()).contains(p.getRowId()) ) + .collect(Collectors.toList()); + if(!emptyChildParentList.isEmpty()){ + rList = emptyChildParentList.stream().map(BomNewPbomParentEntity::getMaterialNo).distinct() + .map(m -> { + 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); + } + + } + if (CollUtil.isNotEmpty(eBomToPBom.getPBomParentResult())) { pBomParentService.saveOrUpdateBatch(eBomToPBom.getPBomParentResult()); @@ -1158,6 +1205,7 @@ public class BomNewEbomParentService extends ServiceImpl importToSAP(Long rootBomRowId) { diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialMainService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialMainService.java index b302c2b7..b06f885a 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialMainService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/MaterialMainService.java @@ -5,14 +5,18 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.TypeReference; import cn.hutool.core.util.StrUtil; +import cn.hutool.core.util.TypeUtil; import cn.hutool.extra.spring.SpringUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.nflg.product.bomnew.constant.MateiralStateEnum; import com.nflg.product.bomnew.constant.MaterialGetEnum; import com.nflg.product.bomnew.constant.OriginalConstant; +import com.nflg.product.bomnew.mapper.master.BomNewPbomParentMapper; import com.nflg.product.bomnew.mapper.master.MaterialMainMapper; +import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity; import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity; import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; +import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO; import com.nflg.product.bomnew.pojo.vo.MaterialMateVO; import com.nflg.product.bomnew.util.ListCommonUtil; import com.nflg.product.bomnew.util.VUtils; @@ -22,6 +26,7 @@ import org.springframework.stereotype.Service; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Function; import java.util.regex.Pattern; @@ -65,8 +70,21 @@ public class MaterialMainService extends ServiceImpl void checkMaterialFreeze(List data){ intiMaterialState(data); + List freeZeMaterialNos = data.stream().filter(u -> MateiralStateEnum.FREEZE.equalsValue(u.getMaterialState())).map(u -> u.getMaterialNo()).collect(Collectors.toList()); - VUtils.isTure(CollUtil.isNotEmpty(freeZeMaterialNos)).throwMessage("以下物料被冻结:"+StrUtil.join(",", freeZeMaterialNos)); + String errMsg = "以下物料被冻结:"+StrUtil.join(",", freeZeMaterialNos); + //BomNewPbomParentVO 如果是 pbmo发布的话 提示【父级物料BOM 中的物料冻结】 by 10002327 0924 + if(CollUtil.isNotEmpty(freeZeMaterialNos) && data.get(0) instanceof BomNewPbomParentVO){ + List pList = data.stream().filter(d -> freeZeMaterialNos.contains(d.getMaterialNo())) + .map(m -> Convert.convert(BomNewPbomParentVO.class,m)).collect(Collectors.toList()); + Set parentIdSet = pList.stream().map(BomNewPbomParentVO::getParentRowId).collect(Collectors.toSet()); + List parentEntityList = SpringUtil.getBean(BomNewPbomParentService.class).listByIds(parentIdSet); + Map parentMap = parentEntityList.stream().collect(Collectors.toMap(BomNewPbomParentEntity::getRowId,BomNewPbomParentEntity::getMaterialNo)); + errMsg = pList.stream().map(p -> String.format("%d、父级物料%s下的%s被冻结了",pList.indexOf(p) + 1 + ,parentMap.getOrDefault(p.getParentRowId(),""),p.getMaterialNo())) + .collect(Collectors.joining(",")); + } + VUtils.isTure(CollUtil.isNotEmpty(freeZeMaterialNos)).throwMessage(errMsg); }