From fcc3947d3cdbbcdd21187930c34bbe406ee475f6 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Thu, 14 Nov 2024 10:13:51 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=89=B9=E9=87=8F=E6=9B=BF=E4=BB=A3?= =?UTF-8?q?=E3=80=91=E7=89=88=E6=9C=AC=E5=8F=B7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bomnew/constant/EBomSourceEnum.java | 3 ++- .../bomnew/constant/PbomSourceEnum.java | 3 ++- .../bomnew/service/BatchBomService.java | 25 +++++++++++-------- .../product/bomnew/util/SapErrorMsgUtil.java | 6 +++++ 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomSourceEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomSourceEnum.java index 7c1cc6f4..85548ac1 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomSourceEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomSourceEnum.java @@ -14,7 +14,8 @@ public enum EBomSourceEnum implements ValueEnum { FROM_MDM(3, "MDM创建"), FROM_SAP(4, "从SAP导入"), FROM_CHANGE(5, "变更"), - FROM_DELETE(6, "BOM删除"); + FROM_DELETE(6, "BOM删除"), + FROM_BATCH(7, "批量变更"); private final Integer value; private final String description; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PbomSourceEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PbomSourceEnum.java index 734727ca..39e635c7 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PbomSourceEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/PbomSourceEnum.java @@ -16,7 +16,8 @@ public enum PbomSourceEnum implements ValueEnum { FROM_SAP(3, "从SAP导入"), FROM_COPY(4, "复制"), FROM_CHANGE(5, "变更"), - FROM_DELETE(6, "BOM删除"); + FROM_DELETE(6, "BOM删除"), + FROM_BATCH(7, "批量变更"); private final Integer value; private final String description; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BatchBomService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BatchBomService.java index de62556d..336e6aac 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BatchBomService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BatchBomService.java @@ -186,7 +186,7 @@ public class BatchBomService { baseBomVO.setNewMaterialNo(batchBomQuery.getNewMaterialNo()); baseBomVO.setNewNum(newReplaceTimes.divide(replaceTimes, decimalScale, RoundingMode.HALF_UP).multiply(baseBomVO.getNum())); baseBomVO.setNewUnit(batchBomQuery.getNewMaterialUnit()); - baseBomVO.setNewVersion(VersionUtil.getNextVersion(baseBomVO.getParentVersion())); + baseBomVO.setNewVersion(VersionUtil.getPBomUpgradNextVersion(baseBomVO.getParentVersion())); resultList.add(baseBomVO); } } @@ -338,6 +338,7 @@ public class BatchBomService { // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) newParent.setCreatedTime(now); newParent.setModifyTime(now); + newParent.setSource(EBomSourceEnum.FROM_BATCH.getValue()); newParent.setSapState(SapStatusEnum.UNPUB_SAP.getValue()); newParent.setSapTime(null); newParent.setDeptRowId(SessionUtil.getDepartRowId()); @@ -358,6 +359,7 @@ public class BatchBomService { newChild.setCreatedTime(now); newChild.setModifyTime(now); newChild.setCreatedBy(SessionUtil.getUserCode()); + newChild.setSource(EBomSourceEnum.FROM_BATCH.getValue()); newChildList.add(newChild); }); BomNewEbomChildEntity newReplaceChild = new BomNewEbomChildEntity(); @@ -379,6 +381,7 @@ public class BatchBomService { newReplaceChild.setModifyTime(now); newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); + newReplaceChild.setSource(EBomSourceEnum.FROM_BATCH.getValue()); newChildList.add(newReplaceChild); bomNewEbomParentService.save(newParent); bomNewEbomChildService.saveBatch(newChildList); @@ -395,7 +398,7 @@ public class BatchBomService { // 转移后删除 bomNewEbomParentService.delEBomHistory(delRowIds); } - // TODO 如果有草稿中数据,草稿版本+1 + // TODO 如果有草稿中数据,草稿大版本+1 for (BaseBomVO baseBomVO: baseBomVOList) { BomNewEbomParentEntity draftParent = bomNewEbomParentService.lambdaQuery() .eq(BomNewEbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo()) @@ -433,6 +436,7 @@ public class BatchBomService { newReplaceChild.setModifyTime(now); newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); + newReplaceChild.setSource(EBomSourceEnum.FROM_BATCH.getValue()); } bomNewEbomChildService.updateBatchById(replaceChildren); } @@ -471,7 +475,7 @@ public class BatchBomService { BomNewPbomChildEntity replaceChild = collect.get(0); // 其他子级 List otherChildren = pbomChildEntities.stream().filter(item -> !item.getRowId().equals(baseBomVO.getChildRowId())).collect(Collectors.toList()); - // 构建新版的父级规则:大版本号+1(如果该BOM还有编辑中的草稿版本,则草稿版本号也+1) + // 构建新版的父级规则:小小版本号+1(如果该BOM还有编辑中的草稿版本,则草稿小小版本号也+1) BomNewPbomParentEntity newParent = new BomNewPbomParentEntity(); BeanUtil.copyProperties(pbomParentEntity, newParent); newParent.setRowId(IdWorker.getId()); @@ -479,6 +483,7 @@ public class BatchBomService { // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) newParent.setCreatedTime(now); newParent.setModifyTime(now); + newParent.setSource(PbomSourceEnum.FROM_BATCH.getValue()); newParent.setSapState(SapStatusEnum.UNPUB_SAP.getValue()); newParent.setSapTime(null); newParent.setDeptRowId(SessionUtil.getDepartRowId()); @@ -499,6 +504,7 @@ public class BatchBomService { newChild.setCreatedTime(now); newChild.setModifyTime(now); newChild.setCreatedBy(SessionUtil.getUserCode()); + newChild.setSource(PbomSourceEnum.FROM_BATCH.getValue()); newChildList.add(newChild); }); BomNewPbomChildEntity newReplaceChild = new BomNewPbomChildEntity(); @@ -520,6 +526,7 @@ public class BatchBomService { newReplaceChild.setModifyTime(now); newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); + newReplaceChild.setSource(PbomSourceEnum.FROM_BATCH.getValue()); newChildList.add(newReplaceChild); bomNewPbomParentService.save(newParent); bomNewPbomChildService.saveBatch(newChildList); @@ -536,7 +543,7 @@ public class BatchBomService { // 转移后删除 bomNewPbomParentService.delPBom(delRowIds); } - // TODO 如果有草稿中数据,草稿版本+1 + // TODO 如果有草稿中数据,草稿小小版本+1 for (BaseBomVO baseBomVO: baseBomVOList) { BomNewPbomParentEntity draftParent = bomNewPbomParentService.lambdaQuery() .eq(BomNewPbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo()) @@ -544,13 +551,8 @@ public class BatchBomService { .lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) .one(); if (ObjectUtil.isNotEmpty(draftParent)) { - // 草稿版本 A01 -> A02,A01.1 -> A02.1 - String[] currentVersionArr = draftParent.getCurrentVersion().split("\\."); - String newVersion = VersionUtil.getNextVersion(currentVersionArr[0]); - if (currentVersionArr.length > 1) { - newVersion += "." + currentVersionArr[1]; - } - draftParent.setCurrentVersion(newVersion); + // 草稿数据小小版本+1(因为草稿的小小版本号已经被批量替代这个版本占用) + draftParent.setCurrentVersion(VersionUtil.getPBomUpgradNextVersion(draftParent.getCurrentVersion())); draftParent.setModifyTime(LocalDateTime.now()); bomNewPbomParentService.updateById(draftParent); // 子级有原物料号,也要替代成新物料号 @@ -575,6 +577,7 @@ public class BatchBomService { newReplaceChild.setModifyTime(now); newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); + newReplaceChild.setSource(PbomSourceEnum.FROM_BATCH.getValue()); } bomNewPbomChildService.updateBatchById(replaceChildren); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/SapErrorMsgUtil.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/SapErrorMsgUtil.java index a38343cc..2488bd5f 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/SapErrorMsgUtil.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/util/SapErrorMsgUtil.java @@ -54,6 +54,12 @@ public class SapErrorMsgUtil { errMsg.msg = materialNo + "物料状态可能为冻结,实际为:" + materialNoStateMap.get(materialNo); } }); + // SAP报错信息,这个提示语,'Z0'转义为:状态为冻结 + liErrMsg.forEach(errMsg -> { + if (ObjectUtil.isNotEmpty(errMsg.msg) && errMsg.msg.contains("'Z0'")) { + errMsg.msg = errMsg.msg.replaceAll("'Z0'", "状态为冻结"); + } + }); } }