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 1/2] =?UTF-8?q?=E3=80=90=E6=89=B9=E9=87=8F=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3=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'", "状态为冻结"); + } + }); } } From 8a1da3768c751b62e965a628ce55eb924fd9b2d4 Mon Sep 17 00:00:00 2001 From: 10001392 <1055202292@qq.com> Date: Thu, 14 Nov 2024 11:35:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=90=E6=89=B9=E9=87=8F=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3=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 --- .../product/bomnew/api/user/BatchBomApi.java | 3 + .../product/bomnew/constant/BomConstant.java | 1 + .../product/bomnew/pojo/vo/UpdateLogVO.java | 3 +- .../bomnew/service/BatchBomService.java | 176 +++++++++--------- .../bomnew/service/ForwardReportService.java | 5 + .../mapper/master/BomNewPbomParentMapper.xml | 4 +- 6 files changed, 103 insertions(+), 89 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BatchBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BatchBomApi.java index 30044fa4..b8c90ad7 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BatchBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/BatchBomApi.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.mzt.logapi.starter.annotation.LogRecord; import com.nflg.product.base.core.api.BaseApi; import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.bomnew.constant.EBomConstant; @@ -65,6 +66,7 @@ public class BatchBomApi extends BaseApi { @PostMapping("updateEBom") @ApiOperation("更新EBOM并导入SAP") + @LogRecord(success = "更新EBOM并导入SAP,操作结果:{{#_ret}}", bizNo = "",type = "更新EBOM并导入SAP") public ResultVO> updateEBom(@RequestBody List baseBomVOList) { List addRowIds = batchBomService.updateEBom(baseBomVOList); List errorMsgVOS = new ArrayList<>(); @@ -80,6 +82,7 @@ public class BatchBomApi extends BaseApi { @PostMapping("updatePBom") @ApiOperation("更新PBOM并导入SAP") + @LogRecord(success = "更新PBOM并导入SAP,操作结果:{{#_ret}}", bizNo = "",type = "更新PBOM并导入SAP") public ResultVO> updatePBom(@RequestBody List baseBomVOList) { List addRowIds = batchBomService.updatePBom(baseBomVOList); List errorMsgVOS = new ArrayList<>(); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/BomConstant.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/BomConstant.java index 5012cfbd..41312796 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/BomConstant.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/BomConstant.java @@ -23,4 +23,5 @@ public class BomConstant { public static final String ADD="新增"; public static final String UP="修改"; public static final String DEL="删除"; + public static final String BATCH="批量替代"; } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/UpdateLogVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/UpdateLogVO.java index 71c72567..4741d045 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/UpdateLogVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/UpdateLogVO.java @@ -49,5 +49,6 @@ public class UpdateLogVO { @ApiModelProperty("旧版或新版 0-旧版 1-新版") private Integer oldOrNewVersion=0; - + @ApiModelProperty(value = "来源") + private Integer source; } 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 336e6aac..2137cd75 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 @@ -319,6 +319,53 @@ public class BatchBomService { List delRowIds = new ArrayList<>(baseBomVOList.size()); // 需要从正式表删除的父级BOM ID LocalDateTime now = LocalDateTime.now(); int createdJob = userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue(); + + // TODO 如果有草稿中数据,草稿大版本+1(先改草稿中的版本,否则会报错:Duplicate entry 'xxx-A00.0a-1010' for key 'uniq_material_no_version') + for (BaseBomVO baseBomVO: baseBomVOList) { + BomNewEbomParentEntity draftParent = bomNewEbomParentService.lambdaQuery() + .eq(BomNewEbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo()) + .lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.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); + draftParent.setModifyTime(LocalDateTime.now()); + bomNewEbomParentService.updateById(draftParent); + // 子级有原物料号,也要替代成新物料号 + List draftChildren = bomNewEbomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, draftParent.getRowId()).list(); + if (CollectionUtil.isNotEmpty(draftChildren)) { + List replaceChildren = draftChildren.stream().filter(child -> baseBomVO.getMaterialNo().equals(child.getMaterialNo())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(replaceChildren)) { + for (BomNewEbomChildEntity newReplaceChild: replaceChildren) { + newReplaceChild.setRowId(IdWorker.getId()); + newReplaceChild.setIdentityNo(draftParent.getRowId() + "_" + newReplaceChild.getRowId()); + newReplaceChild.setMaterialNo(baseBomVO.getNewMaterialNo()); // 新物料编码 + newReplaceChild.setDrawingNo(newMaterialInfo.getDrawingNo()); + newReplaceChild.setMaterialName(newMaterialInfo.getMaterialName()); + newReplaceChild.setMaterialDesc(newMaterialInfo.getMaterialDesc()); // 新物料描述 + newReplaceChild.setMaterialTexture(newMaterialInfo.getMaterialTexture()); + newReplaceChild.setMaterialUnit(baseBomVO.getNewUnit()); // 新单位 + newReplaceChild.setNum(baseBomVO.getNewNum()); // 新数量 + newReplaceChild.setMaterialCategoryCode(newMaterialInfo.getMaterialCategoryCode()); + // TODO 新单重?新总重?要不要更新 + // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) + newReplaceChild.setCreatedTime(now); + newReplaceChild.setModifyTime(now); + newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); + newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); + newReplaceChild.setSource(EBomSourceEnum.FROM_BATCH.getValue()); + } + bomNewEbomChildService.updateBatchById(replaceChildren); + } + } + } + } + for (BaseBomVO baseBomVO: baseBomVOList) { // 找到父级 BomNewEbomParentEntity ebomParentEntity = bomNewEbomParentService.lambdaQuery().eq(BomNewEbomParentEntity::getRowId, baseBomVO.getParentRowId()).one(); @@ -398,51 +445,6 @@ public class BatchBomService { // 转移后删除 bomNewEbomParentService.delEBomHistory(delRowIds); } - // TODO 如果有草稿中数据,草稿大版本+1 - for (BaseBomVO baseBomVO: baseBomVOList) { - BomNewEbomParentEntity draftParent = bomNewEbomParentService.lambdaQuery() - .eq(BomNewEbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo()) - .lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.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); - draftParent.setModifyTime(LocalDateTime.now()); - bomNewEbomParentService.updateById(draftParent); - // 子级有原物料号,也要替代成新物料号 - List draftChildren = bomNewEbomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, baseBomVO.getParentRowId()).list(); - if (CollectionUtil.isNotEmpty(draftChildren)) { - List replaceChildren = draftChildren.stream().filter(child -> baseBomVO.getMaterialNo().equals(child.getMaterialNo())).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(replaceChildren)) { - for (BomNewEbomChildEntity newReplaceChild: replaceChildren) { - newReplaceChild.setRowId(IdWorker.getId()); - newReplaceChild.setIdentityNo(draftParent.getRowId() + "_" + newReplaceChild.getRowId()); - newReplaceChild.setMaterialNo(baseBomVO.getNewMaterialNo()); // 新物料编码 - newReplaceChild.setDrawingNo(newMaterialInfo.getDrawingNo()); - newReplaceChild.setMaterialName(newMaterialInfo.getMaterialName()); - newReplaceChild.setMaterialDesc(newMaterialInfo.getMaterialDesc()); // 新物料描述 - newReplaceChild.setMaterialTexture(newMaterialInfo.getMaterialTexture()); - newReplaceChild.setMaterialUnit(baseBomVO.getNewUnit()); // 新单位 - newReplaceChild.setNum(baseBomVO.getNewNum()); // 新数量 - newReplaceChild.setMaterialCategoryCode(newMaterialInfo.getMaterialCategoryCode()); - // TODO 新单重?新总重?要不要更新 - // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) - newReplaceChild.setCreatedTime(now); - newReplaceChild.setModifyTime(now); - newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); - newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); - newReplaceChild.setSource(EBomSourceEnum.FROM_BATCH.getValue()); - } - bomNewEbomChildService.updateBatchById(replaceChildren); - } - } - } - } return addRowIds; } @@ -464,6 +466,49 @@ public class BatchBomService { List delRowIds = new ArrayList<>(baseBomVOList.size()); // 需要从正式表删除的父级BOM ID LocalDateTime now = LocalDateTime.now(); int createdJob = userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue(); + + // TODO 如果有草稿中数据,草稿小小版本+1(先改草稿中的版本,否则会报错:Duplicate entry 'xxx-A00.0a-1010' for key 'uniq_material_no_version') + for (BaseBomVO baseBomVO: baseBomVOList) { + BomNewPbomParentEntity draftParent = bomNewPbomParentService.lambdaQuery() + .eq(BomNewPbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo()) + .eq(BomNewPbomParentEntity::getFacCode, baseBomVO.getFactory()) + .lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) + .one(); + if (ObjectUtil.isNotEmpty(draftParent)) { + // 草稿数据小小版本+1(因为草稿的小小版本号已经被批量替代这个版本占用) + draftParent.setCurrentVersion(VersionUtil.getPBomUpgradNextVersion(draftParent.getCurrentVersion())); + draftParent.setModifyTime(LocalDateTime.now()); + bomNewPbomParentService.updateById(draftParent); + // 子级有原物料号,也要替代成新物料号 + List draftChildren = bomNewPbomChildService.lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId, draftParent.getRowId()).list(); + if (CollectionUtil.isNotEmpty(draftChildren)) { + List replaceChildren = draftChildren.stream().filter(child -> baseBomVO.getMaterialNo().equals(child.getMaterialNo())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(replaceChildren)) { + for (BomNewPbomChildEntity newReplaceChild: replaceChildren) { + newReplaceChild.setRowId(IdWorker.getId()); + newReplaceChild.setIdentityNo(draftParent.getRowId() + "_" + newReplaceChild.getRowId()); + newReplaceChild.setMaterialNo(baseBomVO.getNewMaterialNo()); // 新物料编码 + newReplaceChild.setDrawingNo(newMaterialInfo.getDrawingNo()); + newReplaceChild.setMaterialName(newMaterialInfo.getMaterialName()); + newReplaceChild.setMaterialDesc(newMaterialInfo.getMaterialDesc()); // 新物料描述 + newReplaceChild.setMaterialTexture(newMaterialInfo.getMaterialTexture()); + newReplaceChild.setMaterialUnit(baseBomVO.getNewUnit()); // 新单位 + newReplaceChild.setNum(baseBomVO.getNewNum()); // 新数量 + newReplaceChild.setMaterialCategoryCode(newMaterialInfo.getMaterialCategoryCode()); + // TODO 新单重?新总重?要不要更新 + // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) + newReplaceChild.setCreatedTime(now); + newReplaceChild.setModifyTime(now); + newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); + newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); + newReplaceChild.setSource(PbomSourceEnum.FROM_BATCH.getValue()); + } + bomNewPbomChildService.updateBatchById(replaceChildren); + } + } + } + } + for (BaseBomVO baseBomVO: baseBomVOList) { // 找到父级 BomNewPbomParentEntity pbomParentEntity = bomNewPbomParentService.lambdaQuery().eq(BomNewPbomParentEntity::getRowId, baseBomVO.getParentRowId()).one(); @@ -543,47 +588,6 @@ public class BatchBomService { // 转移后删除 bomNewPbomParentService.delPBom(delRowIds); } - // TODO 如果有草稿中数据,草稿小小版本+1 - for (BaseBomVO baseBomVO: baseBomVOList) { - BomNewPbomParentEntity draftParent = bomNewPbomParentService.lambdaQuery() - .eq(BomNewPbomParentEntity::getMaterialNo, baseBomVO.getParentMaterialNo()) - .eq(BomNewPbomParentEntity::getFacCode, baseBomVO.getFactory()) - .lt(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) - .one(); - if (ObjectUtil.isNotEmpty(draftParent)) { - // 草稿数据小小版本+1(因为草稿的小小版本号已经被批量替代这个版本占用) - draftParent.setCurrentVersion(VersionUtil.getPBomUpgradNextVersion(draftParent.getCurrentVersion())); - draftParent.setModifyTime(LocalDateTime.now()); - bomNewPbomParentService.updateById(draftParent); - // 子级有原物料号,也要替代成新物料号 - List draftChildren = bomNewPbomChildService.lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId, baseBomVO.getParentRowId()).list(); - if (CollectionUtil.isNotEmpty(draftChildren)) { - List replaceChildren = draftChildren.stream().filter(child -> baseBomVO.getMaterialNo().equals(child.getMaterialNo())).collect(Collectors.toList()); - if (CollectionUtil.isNotEmpty(replaceChildren)) { - for (BomNewPbomChildEntity newReplaceChild: replaceChildren) { - newReplaceChild.setRowId(IdWorker.getId()); - newReplaceChild.setIdentityNo(draftParent.getRowId() + "_" + newReplaceChild.getRowId()); - newReplaceChild.setMaterialNo(baseBomVO.getNewMaterialNo()); // 新物料编码 - newReplaceChild.setDrawingNo(newMaterialInfo.getDrawingNo()); - newReplaceChild.setMaterialName(newMaterialInfo.getMaterialName()); - newReplaceChild.setMaterialDesc(newMaterialInfo.getMaterialDesc()); // 新物料描述 - newReplaceChild.setMaterialTexture(newMaterialInfo.getMaterialTexture()); - newReplaceChild.setMaterialUnit(baseBomVO.getNewUnit()); // 新单位 - newReplaceChild.setNum(baseBomVO.getNewNum()); // 新数量 - newReplaceChild.setMaterialCategoryCode(newMaterialInfo.getMaterialCategoryCode()); - // TODO 新单重?新总重?要不要更新 - // 新版本创建时间要更新,创建人要不要更新待定(根据权限管理考虑) - newReplaceChild.setCreatedTime(now); - newReplaceChild.setModifyTime(now); - newReplaceChild.setCreatedBy(SessionUtil.getUserCode()); - newReplaceChild.setRemark("【批量替代BOM】由" + baseBomVO.getMaterialNo() + "替代为" + baseBomVO.getNewMaterialNo()); - newReplaceChild.setSource(PbomSourceEnum.FROM_BATCH.getValue()); - } - bomNewPbomChildService.updateBatchById(replaceChildren); - } - } - } - } return addRowIds; } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/ForwardReportService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/ForwardReportService.java index 754b6c7a..8d0a68d0 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/ForwardReportService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/ForwardReportService.java @@ -4,6 +4,7 @@ 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.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.google.common.collect.Sets; @@ -532,6 +533,10 @@ public class ForwardReportService { if(!oldEnt.getMaterialNo().equals(newEnt.getMaterialNo()) || !oldEnt.getNum().equals(newEnt.getNum()) || !oldEnt.getProjectType().equals(newEnt.getProjectType())){ result.add(oldEnt); newEnt.setOpType(BomConstant.UP); + // 操作类型:批量替代 + if (ObjectUtil.isNotEmpty(newEnt.getSource()) && newEnt.getSource().equals(EBomSourceEnum.FROM_BATCH.getValue())) { + newEnt.setOpType(BomConstant.BATCH); + } result.add(newEnt); } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml index 2e52d286..56303bea 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewPbomParentMapper.xml @@ -346,9 +346,9 @@ - INSERT INTO `t_bom_new_pbom_child_formal` (`row_id`, `parent_row_id`, `identity_no`, `fac_code`, `order_number`, `drawing_no`, `material_no`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `material_category_code`, `unit_weight`, `num`, `total_weight`, `project_type`, `production_factory_code`, `production_factory_code_input_type`, `set_production_factory_time`, `super_material_status`, `virtual_part_is`, `created_by`, `created_time`, `modify_time`, `source_row_id`, `remark`, `source_parent_material_no`, `virtual_part_type`, `virtual_part_root_material_no`, `bom_version_row_id`, `sap_state`, `sap_time`) + INSERT INTO `t_bom_new_pbom_child_formal` (`row_id`, `parent_row_id`, `identity_no`, `fac_code`, `order_number`, `drawing_no`, `material_no`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `material_category_code`, `unit_weight`, `num`, `total_weight`, `project_type`, `production_factory_code`, `production_factory_code_input_type`, `set_production_factory_time`, `super_material_status`, `virtual_part_is`, `created_by`, `created_time`, `modify_time`, `source_row_id`, `remark`, `source_parent_material_no`, `virtual_part_type`, `virtual_part_root_material_no`, `bom_version_row_id`, `sap_state`, `sap_time`,`source`) - select `row_id`, `parent_row_id`, `identity_no`, `fac_code`, `order_number`, `drawing_no`, `material_no`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `material_category_code`, `unit_weight`, `num`, `total_weight`, `project_type`, `production_factory_code`, `production_factory_code_input_type`, `set_production_factory_time`, `super_material_status`, `virtual_part_is`, `created_by`, `created_time`, `modify_time`, `source_row_id`, `remark`, `source_parent_material_no`, `virtual_part_type`, `virtual_part_root_material_no`, `bom_version_row_id`, `sap_state`, `sap_time` + select `row_id`, `parent_row_id`, `identity_no`, `fac_code`, `order_number`, `drawing_no`, `material_no`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `material_category_code`, `unit_weight`, `num`, `total_weight`, `project_type`, `production_factory_code`, `production_factory_code_input_type`, `set_production_factory_time`, `super_material_status`, `virtual_part_is`, `created_by`, `created_time`, `modify_time`, `source_row_id`, `remark`, `source_parent_material_no`, `virtual_part_type`, `virtual_part_root_material_no`, `bom_version_row_id`, `sap_state`, `sap_time`,`source` from t_bom_new_pbom_child where parent_row_id in