From b3b9a85b5f683da702b466498a5c2c792d2ff110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=B1=B3?= <470431449@qq.com> Date: Thu, 18 Jan 2024 11:15:57 +0800 Subject: [PATCH] =?UTF-8?q?1020=E5=88=86=E5=B7=A5=E5=8E=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BomNewPbomParentService.java | 35 ++++++++++++++++++- .../service/domain/PBom/ConvertToMBom.java | 29 +++++++++++---- 2 files changed, 56 insertions(+), 8 deletions(-) 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 7a4891f4..af069b2e 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 @@ -699,7 +699,7 @@ public class BomNewPbomParentService extends ServiceImpl noProductionFactoryCodeList = allChild.stream().filter(u -> StrUtil.isBlank(u.getProductionFactoryCode())).map(u -> u.getMaterialNo()).collect(Collectors.toList()); VUtils.isTure(CollUtil.isNotEmpty(noProductionFactoryCodeList)).throwMessage(StrUtil.join(",", noProductionFactoryCodeList) + "物料暂未分工厂,请分完工厂再进行发布"); ConvertToMBom convertToMBom = new ConvertToMBom(rootParent, allChild); - convertToMBom.convertToMBom(); + convertToMBom.convertToMBom(true,true); if (CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())) { mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult()); } @@ -720,6 +720,39 @@ public class BomNewPbomParentService extends ServiceImpl allChild = getAllBom(bomRowId, 0); + + if (StrUtil.isBlank(rootParent.getOrderNo())) { + String orderNo = crmService.getOrderNo(rootParent.getMaterialNo()); + rootParent.setOrderNo(orderNo); + } + VUtils.isTure(StrUtil.isBlank(rootParent.getOrderNo())).throwMessage("没有获取到订单号"); + + List noProductionFactoryCodeList = allChild.stream().filter(u -> StrUtil.isBlank(u.getProductionFactoryCode())).map(u -> u.getMaterialNo()).collect(Collectors.toList()); + VUtils.isTure(CollUtil.isNotEmpty(noProductionFactoryCodeList)).throwMessage(StrUtil.join(",", noProductionFactoryCodeList) + "物料暂未分工厂,请分完工厂再进行发布"); + ConvertToMBom convertToMBom = new ConvertToMBom(rootParent, allChild); + convertToMBom.convertToMBom(false,true); + if (CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())) { + mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult()); + } + if (CollUtil.isNotEmpty(convertToMBom.getMBomDetailResult())) { + mBomDetailService.saveOrUpdateBatch(convertToMBom.getMBomDetailResult()); + } + return true; + } + + /** * 发布Pbom * diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/ConvertToMBom.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/ConvertToMBom.java index 1551b792..91092c30 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/ConvertToMBom.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/ConvertToMBom.java @@ -9,14 +9,17 @@ import cn.hutool.extra.spring.SpringUtil; import com.alibaba.excel.enums.BooleanEnum; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.bomnew.constant.EBomConstant; +import com.nflg.product.bomnew.constant.MBomConstantEnum; import com.nflg.product.bomnew.constant.ProductionFactoryCodeInputTypeEnum; import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum; import com.nflg.product.bomnew.pojo.entity.BomNewMbomDetailEntity; import com.nflg.product.bomnew.pojo.entity.BomNewMbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity; import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO; +import com.nflg.product.bomnew.service.BomNewMbomDetailService; import com.nflg.product.bomnew.service.BomNewMbomParentService; import com.nflg.product.bomnew.service.BomNewPbomParentService; import com.nflg.product.bomnew.util.CTreePBomUtils; @@ -68,12 +71,16 @@ public class ConvertToMBom { /** * 转换MBom */ - public void convertToMBom() { + public void convertToMBom(Boolean convert1010 ,Boolean convert1020) { //handler1010(); - handler1020(); + if(convert1020) { + handler1020(); + buildMBom(EBomConstant.XIAN_TAO_FACTORY_CODE_1020); + } + if(convert1010) { + buildMBom(EBomConstant.MAIN_FACTORY_CODE_1010); + } - buildMBom(EBomConstant.MAIN_FACTORY_CODE_1010); - buildMBom(EBomConstant.XIAN_TAO_FACTORY_CODE_1020); } /** @@ -87,9 +94,17 @@ public class ConvertToMBom { BomNewMbomParentEntity oldParent = SpringUtil.getBean(BomNewMbomParentService.class).lambdaQuery().eq(BomNewMbomParentEntity::getMaterialNo, parent.getMaterialNo()) .eq(BomNewMbomParentEntity::getLastVersionIs, 1).eq(BomNewMbomParentEntity::getFacCode, facCode).one(); if (Objects.nonNull(oldParent)) { - mBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion())); - oldParent.setLastVersionIs(0); - this.mBomParentResult.add(oldParent); + if(MBomConstantEnum.MBomStatusEnum.PUB_SAP.equalsValue(oldParent.getStatus()) ) { + + mBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion())); + oldParent.setLastVersionIs(0); + this.mBomParentResult.add(oldParent); + } + else { + SpringUtil.getBean(BomNewMbomDetailService.class).getBaseMapper().deleteByMap(ImmutableMap.of("bom_row_id", oldParent.getRowId())); + SpringUtil.getBean(BomNewMbomParentService.class).getBaseMapper().deleteById(oldParent.getRowId()); + mBomParent.setCurrentVersion(oldParent.getCurrentVersion()); + } } else { mBomParent.setCurrentVersion(VersionUtil.getNextVersion("")); }