From 34da50be58148bae09ab70daabde8ce3c7a4fa1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=B1=B3?= <470431449@qq.com> Date: Thu, 21 Dec 2023 18:01:48 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=8F=91=E8=B5=B7=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 10 ++++ .../service/BomNewEbomParentService.java | 43 +++++++++++++++ .../domain/EBom/CheckEBomException.java | 3 ++ .../nflg/product/bomnew/util/VersionUtil.java | 52 +++++++++++++++++++ 4 files changed, 108 insertions(+) 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 224101f1..808715dc 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 @@ -126,6 +126,16 @@ public class EbomApi extends BaseApi { return ResultVO.success(true); + } + + @PostMapping("upgradeChanges") + @ApiOperation("发起变更") + public ResultVO upgradeChanges(@RequestBody List bomRowIds) { + VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要发起变更的物料"); + bomNewEbomParentService.upgradeChanges(bomRowIds); + return ResultVO.success(true); + + } @PostMapping("exportBom") 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 d1f789cf..593747ea 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 @@ -446,6 +446,49 @@ public class BomNewEbomParentService extends ServiceImpl bomRowIds){ + List list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, bomRowIds).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 : bomRowIds) { + 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())); + + 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); + } + } + + if(CollUtil.isNotEmpty(parentResult)){ + this.saveOrUpdateBatch(parentResult); + } + if(CollUtil.isNotEmpty(childResult)){ + ebomChildService.saveOrUpdateBatch(childResult); + } + + } + public void exportBom(List bomRowIds, HttpServletResponse response) throws IOException { 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 7eb5e4af..43a54c8b 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 @@ -67,6 +67,9 @@ public class CheckEBomException { } else if (StrUtil.isBlank(vo.getProjectType())) { vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue()); } + else if (StrUtil.isBlank(vo.getNoticeNums())){ + vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_11.getValue()); + } } checkOther(); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/VersionUtil.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/VersionUtil.java index 2842f5d9..0d62a562 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/VersionUtil.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/VersionUtil.java @@ -4,6 +4,10 @@ package com.nflg.product.bomnew.util; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.Objects; + /** * 版本 工具类 * @@ -14,6 +18,9 @@ public class VersionUtil { static final String versionPrefix = "A"; + /** + * 获取下一个版本号(大版本) + */ public static String getNextVersion(String preVersion) { if (StrUtil.isBlank(preVersion)) { return versionPrefix + "00"; @@ -22,4 +29,49 @@ public class VersionUtil { Integer versionNum = Convert.toInt(StrUtil.replace(preVersion, "A", "")) + 1; return versionPrefix + StrUtil.padPre(versionNum.toString(), 2, '0'); } + + + /** + * 获取下一个小版本号(小版本) + */ + public static String getNextVersionForSmallVersion(String preVersion) { + + if (StrUtil.isBlank(preVersion)) { + return versionPrefix + "00"; + } + return versionPrefix + generateNextVersion(preVersion); + } + + + private static String generateNextVersion(String previousVersion) { + // Split the previous version number into its components + String[] previousComponents = previousVersion.replace(versionPrefix, "").split("\\."); + + int previousMajor = Integer.parseInt(previousComponents[0]); + int previousMinor = previousComponents.length < 2 ? 0 : Integer.parseInt(previousComponents[1]); + + // Generate the next version number by incrementing the minor version number + int nextMinor = previousMinor + 1; + int nextMajor = previousMajor; + + // Determine if the next version will be a major release + boolean isMajorRelease = false; + if (nextMinor >= 10 && previousComponents.length > 2) { + isMajorRelease = true; + nextMajor = previousMajor + 1; + nextMinor = 0; + } + + // Build the next version number components + String nextVersion = StrUtil.padPre(String.valueOf(nextMajor), 2, "0") + "." + nextMinor; + + // Append any additional components for a major release + if (isMajorRelease && previousComponents.length > 2) { + String[] additionalComponents = Arrays.copyOfRange(previousComponents, 2, previousComponents.length); + nextVersion += additionalComponents; + } + + return nextVersion; + } + }