From 84bf563dfee5a98d7450c2f322d41e91e9934c6f Mon Sep 17 00:00:00 2001 From: 10002327 Date: Tue, 15 Oct 2024 11:39:32 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81EBOM=E5=88=97=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=89=88=E6=9C=AC=E5=8F=B7=E8=AF=B4=E6=98=8E=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=202=E3=80=81EBOM=20>=20=E5=8F=98=E6=9B=B4=E5=BD=B1?= =?UTF-8?q?=E5=93=8D=E6=A0=87=E7=AD=BE=E9=A1=B5=E5=A2=9E=E5=8A=A0=E5=BE=BD?= =?UTF-8?q?=E7=AB=A0=E5=BD=93=E5=89=8D=E7=99=BB=E5=BD=95=E4=BA=BA=E7=9A=84?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E5=BD=B1=E5=93=8D=E6=95=B0=E9=87=8F=203?= =?UTF-8?q?=E3=80=81BOM=E5=AE=8C=E6=95=B4=E6=80=A7=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=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 | 8 ++ .../service/BomNewPbomParentService.java | 84 +++++++++++++++++-- 2 files changed, 85 insertions(+), 7 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 0841bdf5..3a2fe244 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 @@ -20,6 +20,7 @@ import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.bomnew.constant.*; import com.nflg.product.bomnew.pojo.dto.*; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; +import com.nflg.product.bomnew.pojo.entity.BomNewEbomUpgradeChangeEntity; import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity; import com.nflg.product.bomnew.pojo.query.BomExceptionQuery; import com.nflg.product.bomnew.pojo.query.BomNewEbomMaterialQuery; @@ -106,6 +107,13 @@ public class EbomApi extends BaseApi { public ResultVO> changeImpact(@RequestBody BomNewEbomParentQuery query) { return ResultVO.success(bomNewEbomParentService.getUpgradeChangeList(query)); } + @GetMapping("changeImpactCntByUser") + @ApiOperation("当前登录人的变更影响数量") + public ResultVO changeImpactCntByUser(){ + return ResultVO.success(upgradeChangeService.count(Wrappers.lambdaQuery() + .eq(BomNewEbomUpgradeChangeEntity::getStatus,0) + .eq(BomNewEbomUpgradeChangeEntity::getDeviseName,SessionUtil.getRealName()))); + } @PostMapping("delChangeImpact") @ApiOperation("变更影响-删除") 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..5afdecb4 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 @@ -6,6 +6,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.thread.ThreadFactoryBuilder; import cn.hutool.core.util.*; import cn.hutool.extra.spring.SpringUtil; import com.alibaba.fastjson.JSON; @@ -49,9 +50,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.*; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ForkJoinPool; -import java.util.concurrent.ForkJoinTask; +import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BinaryOperator; import java.util.function.Function; @@ -123,6 +122,7 @@ public class BomNewPbomParentService extends ServiceImpl getChildByCheckBom(BomNewPbomParentEntity parent, Integer type){ + List parentChild = this.getBaseMapper().getParentChild(parent.getRowId()); + if (CollUtil.isNotEmpty(parentChild)) { + materialMainService.intiMaterialInfo(parentChild, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); + List materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(materialNos)) { + List list = this.lambdaQuery().in(BomNewPbomParentEntity::getMaterialNo, materialNos) + .eq(type.equals(0), BomNewPbomParentEntity::getLastVersionIs, 1) + .ge(type.equals(1), BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) + .eq(BomNewPbomParentEntity::getFacCode,parent.getFacCode()) + .list(); + + Map bomListMap= list.parallelStream() + .collect(Collectors.toMap( + BomNewPbomParentEntity::getMaterialNo, // key: DrawingNo + Function.identity(), + BinaryOperator.maxBy(Comparator.comparing(BomNewPbomParentEntity::getCurrentVersion)) + )); + for (BomNewPbomParentVO child : parentChild) { + if (bomListMap.containsKey(child.getMaterialNo())) { + BomNewPbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo()); + if (parentEntity.getShouldBomExist() == 1 && parentEntity.getBomExist() == 0) { + child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION); + } else { + child.setCurrentVersion(parentEntity.getCurrentVersion()); + } +// if (parentEntity.getBomExist() == 1) { + child.setBomRowId(parentEntity.getRowId()); +// } + child.setSourceRowId(parentEntity.getSourceRowId()); + child.setBomExist(parentEntity.getBomExist()); + child.setShouldBomExist(parentEntity.getShouldBomExist()); + if ((type == 0 || parent.getStatus() < PBomStatusEnum.PUBLISH.getValue()) + && parentEntity.getStatus() >= PBomStatusEnum.PUBLISH.getValue()) { + child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue()); + } + } else { //无BOM-版本时 确定版本号 + //child.setSource(Objects.nonNull(parent) ? parent.getSource() : EBomSourceEnum.FROM_BOM.getValue()); + child.setBomRowId(0L); + // 10、40、50、60、70大类以及200201小类这些不需要BOM的物料,版本号显示B00 by 10002327 241012 + if(MaterialshouldBomExistUtil.checkNoNeedBom(child)){ + child.setCurrentVersion(OriginalConstant.NO_NEED_BOM); + }else if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) { + child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION); + } else { + child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION); + } + if (type == 0 && child.getStatus() >= EBomStatusEnum.PUBLISHED.getValue()) { + child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue()); + } + } + } + } + } + return parentChild; + } + /** * 编辑暂存 * @@ -2039,7 +2102,7 @@ public class BomNewPbomParentService extends ServiceImpl checkBomList ,BomNewPbomParentEntity parent, Integer type,int currLevel,String currNos){ - List cList = getChild(parent,type); + List cList = getChildByCheckBom(parent,type); List bomRowIdList = cList.stream().filter(c -> c.getBomRowId() > 0).map(BomNewPbomParentVO::getBomRowId).distinct().collect(Collectors.toList()); List pList = Lists.newArrayList(); Map pMap = Maps.newHashMap(); @@ -2059,13 +2122,20 @@ public class BomNewPbomParentService extends ServiceImpl " + finalPMap.get(c.getBomRowId()).getMaterialNo()); + //checkChild(checkBomList,finalPMap.get(c.getBomRowId()),type, finalCurrLevel.get(),currNos + " > " + finalPMap.get(c.getBomRowId()).getMaterialNo()); + CompletableFuture.runAsync(()-> checkChild(checkBomList,finalPMap.get(c.getBomRowId()),type, finalCurrLevel.get(),currNos + " > " + finalPMap.get(c.getBomRowId()).getMaterialNo())).join(); +// try { +// CompletableFuture.runAsync(()-> checkChild(checkBomList,finalPMap.get(c.getBomRowId()),type, finalCurrLevel.get(),currNos + " > " + finalPMap.get(c.getBomRowId()).getMaterialNo())).get(); +// } catch (Exception e) { +// log.error(e.getMessage()); +// } } }); + } /**