From 591ed8b39067a090a5ae28526a1756bcbeb8ac2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=B1=B3?= <470431449@qq.com> Date: Thu, 11 Jan 2024 18:54:39 +0800 Subject: [PATCH] =?UTF-8?q?BUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/PBomApi.java | 12 +++ .../service/BomNewEbomParentService.java | 14 +-- .../service/BomNewPbomParentService.java | 41 +++++++-- .../bomnew/service/UserRoleService.java | 14 +-- .../domain/EBom/CheckEBomException.java | 27 +++--- .../service/domain/EBom/EBomDetailTask.java | 2 + .../OriginalBom/OriginalBomToEBomConvert.java | 3 + .../service/domain/PBom/PBomUpgrade.java | 86 +++++++++++++++++++ .../mapper/master/BomNewEbomParentMapper.xml | 2 +- 9 files changed, 168 insertions(+), 33 deletions(-) create mode 100644 nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/PBomUpgrade.java 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 00d059b1..f25a4d1d 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 @@ -213,6 +213,18 @@ public class PBomApi extends BaseApi { } + @GetMapping("upgrade") + @ApiOperation("发起变更") + public ResultVO upgrade(@RequestParam("bomRowId") Long bomRowId) { + try { + bomNewPbomParentService.upgrade(bomRowId); + return ResultVO.success(true); + }catch (Exception ex){ + return ResultVO.error("变更失败"+ex.getMessage()); + } + } + + 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 bc1e50f6..7e1436eb 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 @@ -820,9 +820,9 @@ public class BomNewEbomParentService extends ServiceImpl computeLevelNumAndRootState()); + //不要异步 + computeLevelNumAndRootState(); +// ThreadUtil.execAsync(() -> computeLevelNumAndRootState()); } @@ -1272,7 +1272,9 @@ public class BomNewEbomParentService extends ServiceImpl computeLevelNumAndRootState()); + //不要异步 + ebomChildService.getBaseMapper().updateEBomMaterialUse(); +// ThreadUtil.execAsync(() -> computeLevelNumAndRootState()); return true; } @@ -1343,8 +1345,8 @@ public class BomNewEbomParentService extends ServiceImpl computeLevelNumAndRootState()); +// ebomChildService.getBaseMapper().updateEBomMaterialUse(); +// ThreadUtil.execAsync(() -> computeLevelNumAndRootState()); 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 eb78f7d9..03313904 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 @@ -1,12 +1,14 @@ package com.nflg.product.bomnew.service; +import cn.hutool.core.bean.BeanUtil; 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 com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.ImmutableList; @@ -19,10 +21,7 @@ import com.nflg.product.bomnew.pojo.dto.*; import com.nflg.product.bomnew.pojo.entity.*; import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery; import com.nflg.product.bomnew.pojo.vo.*; -import com.nflg.product.bomnew.service.domain.PBom.BomCopy; -import com.nflg.product.bomnew.service.domain.PBom.ConvertToMBom; -import com.nflg.product.bomnew.service.domain.PBom.PBomDetailTask; -import com.nflg.product.bomnew.service.domain.PBom.TechnologyPackageParamBuilder; +import com.nflg.product.bomnew.service.domain.PBom.*; import com.nflg.product.bomnew.util.*; import nflg.product.common.constant.STATE; import org.springframework.beans.factory.annotation.Qualifier; @@ -36,6 +35,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; @@ -107,6 +107,7 @@ public class BomNewPbomParentService extends ServiceImpl parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo).stream().collect(Collectors.toList()); + parentMaterialByMaterialNo.add(materialNo); if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { List parents = this.getBaseMapper().getParentForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory())?userRoleService.getUserFactory():query.getFacCode(),parentMaterialByMaterialNo ); List childs = this.getBaseMapper().getChildForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory())?userRoleService.getUserFactory():query.getFacCode(),parentMaterialByMaterialNo, materialNo); @@ -514,12 +515,13 @@ public class BomNewPbomParentService extends ServiceImpl relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list(); StringBuilder relPattern = new StringBuilder(); List result = new ArrayList<>(); - Boolean match = true; + for (BomNewPbomParentVO child : childrenVO) { if (StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType())) { continue; } for (BomFactorySplitRuleEntity role : relList) { + Boolean match = true; if (StrUtil.isNotBlank(role.getMaterialCategoryCode())) { match = match & (StrUtil.isNotBlank(child.getMaterialCategoryCode()) && role.getMaterialCategoryCode().equals(child.getMaterialCategoryCode())); } @@ -528,7 +530,7 @@ public class BomNewPbomParentService extends ServiceImpl allBom = getAllBom(bomRowId, 0); List bomRowIds = allBom.stream().filter(u -> PBomStatusEnum.WAIT_PUBLISH.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList()); - Integer state = parent.getMaterialNo().startsWith("31") ? 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(); bomRowIds.add(bomRowId); this.getBaseMapper().bomRelease(state, SessionUtil.getUserName(), bomRowIds); //保存订单号 @@ -647,4 +649,25 @@ public class BomNewPbomParentService extends ServiceImpl0){ -// return ""; -// }else { -// return SessionUtil.getFullDeptName().contains("仙桃公司")?EBomConstant.XIAN_TAO_FACTORY_CODE_1020:EBomConstant.MAIN_FACTORY_CODE_1010; -// } +// return ""; + if(userMultiplantFacRoleCount>0){ + return ""; + }else { + return SessionUtil.getFullDeptName().contains("仙桃公司")?EBomConstant.XIAN_TAO_FACTORY_CODE_1020:EBomConstant.MAIN_FACTORY_CODE_1010; + } } @@ -82,4 +82,6 @@ public class UserRoleService { return SessionUtil.getFullDeptName().contains("仙桃公司")? ImmutableList.of(EBomConstant.XIAN_TAO_FACTORY_CODE_1020) : ImmutableList.of(EBomConstant.MAIN_FACTORY_CODE_1010) ; } } + + } 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 5eb75f66..ffdd9c73 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 @@ -153,7 +153,8 @@ public class CheckEBomException { // }); // } //是否存在重复物料 - Map> childMaterialMap = ListCommonUtil.listGroupMap(child, BomNewEbomParentVO::getMaterialNo); + List hasMaterialNoList = child.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList()); + Map> childMaterialMap = ListCommonUtil.listGroupMap(hasMaterialNoList, BomNewEbomParentVO::getMaterialNo); for (String key : childMaterialMap.keySet()) { List materialGroupList = childMaterialMap.get(key); if (materialGroupList.size() > 1) { @@ -196,25 +197,29 @@ public class CheckEBomException { if (CollUtil.isEmpty(exceptionList)) { return; } - for (BomNewEbomParentVO exItem : list) { - List warnList = allBomDetail.stream().filter(u -> u.getBomRowId() > 0 && u.getLevelNumber().compareTo(exItem.getLevelNumber().setScale(0, RoundingMode.FLOOR))>=0 && u.getRowId()!=exItem.getRowId() && u.getLevelNumber().compareTo(exItem.getLevelNumber()) < 0 && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList()); - warnList.forEach(k -> { + for (BomNewEbomParentVO exItem : exceptionList) { + List parentByLevel = getParentByLevel(exItem.getLevelNo()); + List warnList = allBomDetail.stream().filter(u -> u.getBomRowId() > 0 && parentByLevel.contains(u.getLevelNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList()); + for (BomNewEbomParentVO k :warnList) { k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()); - }); - + } } List root = allBomDetail.stream().filter(u -> u.getLevelNumber().compareTo(BigDecimal.ZERO) == 0 && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList()); root.forEach(k->{ k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()); }); + } -// List allErrorParent = SpringUtil.getBean(BomNewEbomParentService.class).getBatchParentMaterialByMaterialNo(exceptionMaterialNos); -// List warnList = allBomDetail.stream().filter(u -> allErrorParent.contains(u.getMaterialNo()) && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList()); -// warnList.forEach(k->{ -// k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()); -// }); + private List getParentByLevel(String levelNo){ + List result=new ArrayList<>(); + String[] parts = levelNo.split("-"); + for (int i=parts.length;i> { detailVO.setDeviseUserCode(ebomParentEntity.getDeviseUserCode()); detailVO.setDeptName(ebomParentEntity.getDeptName()); detailVO.setDeviseName(ebomParentEntity.getDeviseName()); + detailVO.setBomExist(ebomParentEntity.getBomExist()); + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OriginalBom/OriginalBomToEBomConvert.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OriginalBom/OriginalBomToEBomConvert.java index 5b2e6a6a..9a83d5bb 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OriginalBom/OriginalBomToEBomConvert.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OriginalBom/OriginalBomToEBomConvert.java @@ -252,6 +252,9 @@ public class OriginalBomToEBomConvert extends BaseConvert { parentEntity.setMaterialUnit("KG"); parentEntity.setNum(parentEntity.getTotalWeight()); } + else { + parentEntity.setMaterialDesc(parentEntity.getMaterialName()); + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/PBomUpgrade.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/PBomUpgrade.java new file mode 100644 index 00000000..bceb172c --- /dev/null +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/PBom/PBomUpgrade.java @@ -0,0 +1,86 @@ +package com.nflg.product.bomnew.service.domain.PBom; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.convert.Convert; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.nflg.product.base.core.conmon.util.SessionUtil; +import com.nflg.product.bomnew.constant.PBomStatusEnum; +import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity; +import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity; +import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO; +import com.nflg.product.bomnew.util.VersionUtil; +import lombok.Getter; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 升级变更 + */ +public class PBomUpgrade { + + private BomNewPbomParentEntity root; + + private List allBom; + + @Getter + private List parentResult; + + @Getter + private List childResult; + + + public PBomUpgrade (BomNewPbomParentEntity root,List allBom) { + this.root = root; + this.allBom = allBom; + BomNewPbomParentVO rootVo = Convert.convert(BomNewPbomParentVO.class, root); + rootVo.setBomRowId(rootVo.getRowId()); + allBom.add(rootVo); + + } + + public void upgrade(){ + // + for (BomNewPbomParentVO parentEnt :allBom) { + if( parentEnt.getStatus()>=PBomStatusEnum.PUBLISH.getValue()) { + buildParent(parentEnt); + } + } + } + + private void buildParent(BomNewPbomParentVO parentVO){ + BomNewPbomParentEntity pbomParent=new BomNewPbomParentEntity(); + BeanUtil.copyProperties(parentVO,pbomParent); + pbomParent.setRowId(IdWorker.getId()); + pbomParent.setCreatedTime(LocalDateTime.now()); + pbomParent.setCreatedBy(SessionUtil.getRealName()); + pbomParent.setModifyTime(LocalDateTime.now()); + pbomParent.setStatus(PBomStatusEnum.WAIT_PUBLISH.getValue()); + pbomParent.setCurrentVersion(VersionUtil.getNextVersion(parentVO.getCurrentVersion())); + this.parentResult.add(pbomParent); + + buildChild(parentVO,pbomParent); + } + + private void buildChild(BomNewPbomParentVO oldParent, BomNewPbomParentEntity newParent){ + + List chilren = allBom.stream().filter(u -> u.getParentRowId().equals(oldParent.getBomRowId())).collect(Collectors.toList()); + for (BomNewPbomParentVO childVO : chilren) { + BomNewPbomChildEntity child=new BomNewPbomChildEntity(); + BeanUtil.copyProperties(childVO,child); + child.setRowId(IdWorker.getId()); + child.setParentRowId(newParent.getRowId()); + child.setCreatedTime(LocalDateTime.now()); + child.setCreatedBy(SessionUtil.getRealName()); + child.setModifyTime(LocalDateTime.now()); + + this.childResult.add(child); + } + + + } + + + +} diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml index 6ec2cfde..fd4ca34d 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml @@ -117,7 +117,7 @@