From 36d810252f61cbc8924318017da63f31e942a453 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 10:53:22 +0800 Subject: [PATCH 1/4] =?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 | 2 +- .../service/BomNewEbomParentService.java | 44 ++++++++++--------- .../service/BomNewPbomParentService.java | 14 +++--- 3 files changed, 32 insertions(+), 28 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 79557406..58d339eb 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 @@ -197,7 +197,7 @@ public class PBomApi extends BaseApi { public ResultVO convertToMBom(@RequestParam("bomRowId") Long bomRowId) throws ExecutionException, InterruptedException { BomNewPbomParentEntity parent = bomNewPbomParentService.getById(bomRowId); VUtils.isTure(!parent.getMaterialNo().startsWith("31")).throwMessage("只有31开头的物料才可以发布"); - VUtils.isTure(parent.getStatus()> PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM才能生成MBom"); + VUtils.isTure(parent.getStatus()< PBomStatusEnum.PUBLISH.getValue()).throwMessage("只有已发布的BOM才能生成MBom"); // VUtils.isTure(!parent.getFacCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)).throwMessage("只有1010工厂BOM才能进行分工厂"); return ResultVO.success(bomNewPbomParentService.convertToMBom(bomRowId)); 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 2cb26233..6b172bc5 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 @@ -681,31 +681,33 @@ public class BomNewEbomParentService extends ServiceImpl list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, paramDTO.getBomRowIds()).list(); List notConvertToPbom = list.stream().filter(u -> u.getStatus() < EBomStatusEnum.PUBLISHED.getValue()).map(u -> u.getMaterialNo()).collect(Collectors.toList()); VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom) + "未转PBom,不能发起变更"); + List parentResult = new ArrayList<>(); List childResult = new ArrayList<>(); for (Long bomRowId : paramDTO.getBomRowIds()) { BomNewEbomParentEntity parent = this.getById(bomRowId); - List child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list(); - - BomNewEbomParentEntity newParent = new BomNewEbomParentEntity(); - BeanUtil.copyProperties(parent, newParent); - newParent.setRowId(IdWorker.getId()); - newParent.setLastVersionIs(1); - newParent.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(parent.getCurrentVersion())); - newParent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_11.getValue()); - newParent.setChangeDesc(paramDTO.getChangeDesc()); - newParent.setNoticeNums(paramDTO.getNoticeNums()); - parent.setLastVersionIs(0); - parentResult.add(newParent); - parentResult.add(parent); - - - for (BomNewEbomChildEntity childEnt : child) { - BomNewEbomChildEntity newChild = new BomNewEbomChildEntity(); - BeanUtil.copyProperties(childEnt, newChild); - newChild.setRowId(IdWorker.getId()); - newChild.setParentRowId(newParent.getRowId()); - childResult.add(newChild); + List existEnt = this.lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, parent.getMaterialNo()).lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list(); + //含发布前版本则无需升级 + if(CollUtil.isEmpty(existEnt)) { + List child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list(); + BomNewEbomParentEntity newParent = new BomNewEbomParentEntity(); + BeanUtil.copyProperties(parent, newParent); + newParent.setRowId(IdWorker.getId()); + newParent.setLastVersionIs(1); + newParent.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(parent.getCurrentVersion())); + newParent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_11.getValue()); + newParent.setChangeDesc(paramDTO.getChangeDesc()); + newParent.setNoticeNums(paramDTO.getNoticeNums()); + parent.setLastVersionIs(0); + parentResult.add(newParent); + parentResult.add(parent); + for (BomNewEbomChildEntity childEnt : child) { + BomNewEbomChildEntity newChild = new BomNewEbomChildEntity(); + BeanUtil.copyProperties(childEnt, newChild); + newChild.setRowId(IdWorker.getId()); + newChild.setParentRowId(newParent.getRowId()); + childResult.add(newChild); + } } } 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 8d782e58..7a4891f4 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 @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.excel.enums.BooleanEnum; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -556,16 +557,16 @@ public class BomNewPbomParentService extends ServiceImpl childrenVO = getAllBom(params.getBomRowId(), 0); + List childrenVO = getAllBom(params.getBomRowId(), 0,true); materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); List relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list(); StringBuilder relPattern = new StringBuilder(); List result = new ArrayList<>(); for (BomNewPbomParentVO child : childrenVO) { - if (StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType())) { - continue; - } +// if (StrUtil.isNotBlank(child.getProductionFactoryCode()) && ProductionFactoryCodeInputTypeEnum.MANUAL.equalsValue(child.getProductionFactoryCodeInputType())) { +// continue; +// } for (BomFactorySplitRuleEntity role : relList) { Boolean match = true; if (StrUtil.isNotBlank(role.getMaterialCategoryCode())) { @@ -655,8 +656,9 @@ public class BomNewPbomParentService extends ServiceImpl child , String facCode){ - String zero ="1"+ StrUtil.padAfter("0", parentVO.getLevelNum().toString().split(".")[1].length(), "0"); - BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(), new BigDecimal(1).divide(NumberUtil.div ( new BigDecimal(1) , new BigDecimal(zero))) ); + String[] numSplit = parentVO.getLevelNumber().toString().split("."); + String zero ="1"+ StrUtil.padAfter("0", (numSplit.length>1? numSplit[1].length():0), "0"); + BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(),(NumberUtil.div ( new BigDecimal(1) , new BigDecimal(zero))) ); List subNodes = child.stream().filter(u -> u.getLevelNumber().compareTo(parentVO.getLevelNumber()) > 0 && u.getLevelNumber().compareTo(bNodeLevel) < 0).collect(Collectors.toList()); for (BomNewPbomParentVO node : subNodes) { node.setProductionFactoryCode(facCode); 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 2/4] =?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("")); } From ba9787289753b1ee638c7dcb4abf472829692b2c 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:39:30 +0800 Subject: [PATCH 3/4] =?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 | 147 ++++++++++-------- 1 file changed, 79 insertions(+), 68 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 af069b2e..3e839f76 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 @@ -116,8 +116,8 @@ 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); + 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); List data = new ArrayList<>(); data.addAll(parents); data.addAll(childs); @@ -125,7 +125,7 @@ public class BomNewPbomParentService extends ServiceImpl() ; + return new Page(); } else { Page result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory()); materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); @@ -160,6 +160,7 @@ public class BomNewPbomParentService extends ServiceImpl result = this.getBaseMapper().workDetailsExcel(userRoleService.getUserFactory()); - materialMainService.intiMaterialInfo(result,BomNewPbomWorkExcelVO::getMaterialNo,EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); + materialMainService.intiMaterialInfo(result, BomNewPbomWorkExcelVO::getMaterialNo, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); new Workbook().addSheet(result).writeTo(response.getOutputStream()); } /** * 导出正式工作表 + * * @param query * @param response * @throws IOException @@ -222,7 +224,7 @@ public class BomNewPbomParentService extends ServiceImpl result = this.getBaseMapper().releaseListExcel(query); - materialMainService.intiMaterialInfo(result,BomNewPbomWorkExcelVO::getMaterialNo,EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); + materialMainService.intiMaterialInfo(result, BomNewPbomWorkExcelVO::getMaterialNo, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); new Workbook().addSheet(result).writeTo(response.getOutputStream()); } @@ -444,13 +446,13 @@ public class BomNewPbomParentService extends ServiceImpl copyBomCheck(Long sourceBomRowId, String targetFacCode,Long rowId) throws ExecutionException, InterruptedException { + public List copyBomCheck(Long sourceBomRowId, String targetFacCode, Long rowId) throws ExecutionException, InterruptedException { BomNewPbomParentEntity root = this.getById(sourceBomRowId); VUtils.isTure(root.getMaterialNo().startsWith("31")).throwMessage("31码物料不能进行复制"); BomNewPbomChildEntity child = pbomChildService.getById(rowId); - if(child.getVirtualPartRootMaterialNo().startsWith("31") && child.getVirtualPartType()>0){ + if (child.getVirtualPartRootMaterialNo().startsWith("31") && child.getVirtualPartType() > 0) { VUtils.isTure(true).throwMessage("31下的虚拟包不能删除"); } @@ -487,7 +489,7 @@ public class BomNewPbomParentService extends ServiceImpl getAllBom(Long rowId, Integer countLevelNum ) throws ExecutionException, InterruptedException { + public List getAllBom(Long rowId, Integer countLevelNum) throws ExecutionException, InterruptedException { List bomDetail = this.getBaseMapper().getParentChild(rowId); AtomicInteger levelNum = new AtomicInteger(1); PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum); @@ -498,7 +500,7 @@ public class BomNewPbomParentService extends ServiceImpl getAllBom(Long rowId, Integer countLevelNum ,Boolean generateDrawingNumberFalg) throws ExecutionException, InterruptedException { + public List getAllBom(Long rowId, Integer countLevelNum, Boolean generateDrawingNumberFalg) throws ExecutionException, InterruptedException { List bomDetail = this.getBaseMapper().getParentChild(rowId); AtomicInteger levelNum = new AtomicInteger(1); PBomDetailTask detailTask = new PBomDetailTask(bomDetail, countLevelNum, levelNum); @@ -506,13 +508,14 @@ public class BomNewPbomParentService extends ServiceImpl result = submit.join(); - if(generateDrawingNumberFalg){ - generateDrawingNo(result,rowId,""); + if (generateDrawingNumberFalg) { + generateDrawingNo(result, rowId, ""); } return result; } - public void generateDrawingNo(List saveBomDetailParamDTO, Long bomRowID, String parentDrawingNo) { + + public void generateDrawingNo(List saveBomDetailParamDTO, Long bomRowID, String parentDrawingNo) { List firstLevelBoms = saveBomDetailParamDTO.stream().filter(u -> u.getParentRowId().equals(bomRowID)).collect(Collectors.toList()); parentDrawingNo = StrUtil.isNotBlank(parentDrawingNo) ? parentDrawingNo : ""; Integer gNo = 1; @@ -557,7 +560,7 @@ public class BomNewPbomParentService extends ServiceImpl childrenVO = getAllBom(params.getBomRowId(), 0,true); + List childrenVO = getAllBom(params.getBomRowId(), 0, true); materialMainService.intiMaterialInfo(childrenVO, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); List relList = bomFactorySplitRuleService.lambdaQuery().eq(BomFactorySplitRuleEntity::getRuleGroupCode, params.getRuleGroupCode()).list(); StringBuilder relPattern = new StringBuilder(); @@ -604,11 +607,19 @@ public class BomNewPbomParentService extends ServiceImpl qList = childrenVO.stream().filter(u -> u.getProjectType().equals("Q")).collect(Collectors.toList()); + { + for (BomNewPbomParentVO qVo : qList) { + intiQFac(qVo, childrenVO); + } + } + //非Q + List noQList = childrenVO.stream().filter(u -> !u.getProjectType().equals("Q")).collect(Collectors.toList()); + { + for (BomNewPbomParentVO noQVo : noQList) { + intiNotQFac(noQVo, childrenVO); } } if (CollUtil.isNotEmpty(result)) { @@ -617,37 +628,38 @@ public class BomNewPbomParentService extends ServiceImpl child){ + private void intiQFac(BomNewPbomParentVO parentVO, List child) { - setSubNodeFac(parentVO, child,parentVO.getProductionFactoryCode() ); + setSubNodeFac(parentVO, child, parentVO.getProductionFactoryCode()); } + //非Q - private void intiNotQFac(BomNewPbomParentVO parentVO, List child){ + private void intiNotQFac(BomNewPbomParentVO parentVO, List child) { //当为1020时 ,子级为1020 - if(parentVO.getProductionFactoryCode().equals(EBomConstant.XIAN_TAO_FACTORY_CODE_1020)){ + if (parentVO.getProductionFactoryCode().equals(EBomConstant.XIAN_TAO_FACTORY_CODE_1020)) { - setSubNodeFac(parentVO,child, EBomConstant.XIAN_TAO_FACTORY_CODE_1020); + setSubNodeFac(parentVO, child, EBomConstant.XIAN_TAO_FACTORY_CODE_1020); } - if(parentVO.getProductionFactoryCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)){ + if (parentVO.getProductionFactoryCode().equals(EBomConstant.MAIN_FACTORY_CODE_1010)) { //父级 - setParentFac(parentVO,child,EBomConstant.MAIN_FACTORY_CODE_1010); + setParentFac(parentVO, child, EBomConstant.MAIN_FACTORY_CODE_1010); //子级 - setSubNodeFac(parentVO,child, EBomConstant.MAIN_FACTORY_CODE_1010); + setSubNodeFac(parentVO, child, EBomConstant.MAIN_FACTORY_CODE_1010); } - } - private void setParentFac(BomNewPbomParentVO parentVO, List child , String facCode){ + private void setParentFac(BomNewPbomParentVO parentVO, List child, String facCode) { List parentByLevel = BomLevelUtil.getParentByLevel(parentVO.getLevelNo()); - for ( String level: parentByLevel) { + for (String level : parentByLevel) { List parents = child.stream().filter(u -> u.getLevelNo().equals(level) && u.getVirtualPartIs().equals(0)).collect(Collectors.toList()); - if(CollUtil.isNotEmpty(parents)){ + if (CollUtil.isNotEmpty(parents)) { parents.get(0).setProductionFactoryCode(facCode); parents.get(0).setProductionFactoryCodeInputType(ProductionFactoryCodeInputTypeEnum.RULE_MATCH.getValue()); } @@ -655,20 +667,18 @@ public class BomNewPbomParentService extends ServiceImpl child , String facCode){ + private void setSubNodeFac(BomNewPbomParentVO parentVO, List child, String facCode) { String[] numSplit = parentVO.getLevelNumber().toString().split("."); - String zero ="1"+ StrUtil.padAfter("0", (numSplit.length>1? numSplit[1].length():0), "0"); - BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(),(NumberUtil.div ( new BigDecimal(1) , new BigDecimal(zero))) ); + String zero = "1" + StrUtil.padAfter("0", (numSplit.length > 1 ? numSplit[1].length() : 0), "0"); + BigDecimal bNodeLevel = NumberUtil.add(parentVO.getLevelNumber(), (NumberUtil.div(new BigDecimal(1), new BigDecimal(zero)))); List subNodes = child.stream().filter(u -> u.getLevelNumber().compareTo(parentVO.getLevelNumber()) > 0 && u.getLevelNumber().compareTo(bNodeLevel) < 0).collect(Collectors.toList()); - for (BomNewPbomParentVO node : subNodes) { + for (BomNewPbomParentVO node : subNodes) { node.setProductionFactoryCode(facCode); node.setProductionFactoryCodeInputType(ProductionFactoryCodeInputTypeEnum.RULE_MATCH.getValue()); } } - - public void reConvertToMBom(Long bomRowId, List backRowId) { @@ -699,7 +709,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(true,true); + convertToMBom.convertToMBom(true, true); if (CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())) { mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult()); } @@ -722,6 +732,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(false,true); + convertToMBom.convertToMBom(false, true); if (CollUtil.isNotEmpty(convertToMBom.getMBomParentResult())) { mBomParentService.saveOrUpdateBatch(convertToMBom.getMBomParentResult()); } @@ -768,8 +779,8 @@ public class BomNewPbomParentService extends ServiceImpl childResult=new ArrayList<>(); - ImportToSapChildDTO childEnt =new ImportToSapChildDTO(); + List childResult = new ArrayList<>(); + ImportToSapChildDTO childEnt = new ImportToSapChildDTO(); childEnt.setIDNRK("1100021745"); childEnt.setPOSNR("045"); childEnt.setPOSTP("F"); @@ -803,35 +814,35 @@ public class BomNewPbomParentService extends ServiceImpl sapParams=new ArrayList<>(); + List sapParams = new ArrayList<>(); sapParams.add(result); ResultVO syncResult = sapOpUtilService.importPBomToSap(sapParams); - VUtils.isTure(!syncResult.getState().equals(STATE.Success)).throwMessage("同步SAP失败:"+syncResult.getMsg()); + VUtils.isTure(!syncResult.getState().equals(STATE.Success)).throwMessage("同步SAP失败:" + syncResult.getMsg()); } - private void importSap(BomNewPbomParentEntity parent, List children){ + private void importSap(BomNewPbomParentEntity parent, List children) { List pbom = children.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()); List parentChild = children.stream().filter(u -> u.getParentRowId().equals(parent.getRowId())).collect(Collectors.toList()); - List sapParams=new ArrayList<>(); + List sapParams = new ArrayList<>(); sapParams.add(buildSapBom(Convert.convert(BomNewPbomParentVO.class, parent), parentChild)); - for (BomNewPbomParentVO pt :pbom) { + for (BomNewPbomParentVO pt : pbom) { List pChild = children.stream().filter(u -> u.getParentRowId().equals(pt.getBomRowId())).collect(Collectors.toList()); sapParams.add(buildSapBom(Convert.convert(BomNewPbomParentVO.class, parent), pChild)); } - if(CollUtil.isNotEmpty(sapParams)) { + if (CollUtil.isNotEmpty(sapParams)) { ResultVO booleanResultVO = sapOpUtilService.importPBomToSap(sapParams); - VUtils.isTure(!booleanResultVO.getState().equals(STATE.Success)).throwMessage("同步SAP失败:"+booleanResultVO.getMsg()); + VUtils.isTure(!booleanResultVO.getState().equals(STATE.Success)).throwMessage("同步SAP失败:" + booleanResultVO.getMsg()); } } - private ImportToSapDTO buildSapBom(BomNewPbomParentVO parentVO, List children){ + private ImportToSapDTO buildSapBom(BomNewPbomParentVO parentVO, List children) { - ImportToSapDTO result=new ImportToSapDTO(); - ImportToSapParentDTO sapParent=new ImportToSapParentDTO(); + ImportToSapDTO result = new ImportToSapDTO(); + ImportToSapParentDTO sapParent = new ImportToSapParentDTO(); DateTimeFormatter ymd = DateTimeFormatter.ofPattern("yyyyMMdd"); sapParent.setWERKS(parentVO.getFacCode()); sapParent.setMATNR(parentVO.getMaterialNo()); @@ -839,11 +850,11 @@ public class BomNewPbomParentService extends ServiceImpl childResult=new ArrayList<>(); - for (BomNewPbomParentVO child :children) { - ImportToSapChildDTO childEnt =new ImportToSapChildDTO(); + List childResult = new ArrayList<>(); + for (BomNewPbomParentVO child : children) { + ImportToSapChildDTO childEnt = new ImportToSapChildDTO(); childEnt.setIDNRK(child.getMaterialNo()); childEnt.setPOSNR(child.getOrderNumber()); childEnt.setPOSTP(child.getProjectType()); @@ -858,7 +869,6 @@ public class BomNewPbomParentService extends ServiceImpl Date: Thu, 18 Jan 2024 11:51:38 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E9=9D=9EQ=20=E7=9A=84=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bomnew/service/BomNewPbomParentService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 3e839f76..e7b0fd42 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 @@ -616,12 +616,12 @@ public class BomNewPbomParentService extends ServiceImpl noQList = childrenVO.stream().filter(u -> !u.getProjectType().equals("Q")).collect(Collectors.toList()); - { - for (BomNewPbomParentVO noQVo : noQList) { - intiNotQFac(noQVo, childrenVO); - } - } +// List noQList = childrenVO.stream().filter(u -> !u.getProjectType().equals("Q")).collect(Collectors.toList()); +// { +// for (BomNewPbomParentVO noQVo : noQList) { +// intiNotQFac(noQVo, childrenVO); +// } +// } if (CollUtil.isNotEmpty(result)) { pbomChildService.saveOrUpdateBatch(result); }