From b39c3db587976bfd1806c4dee06962d9c753fe74 Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Sat, 10 Oct 2026 15:51:31 +0800 Subject: [PATCH] =?UTF-8?q?2026-10-10=20=E4=BC=98=E5=8C=96=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E5=92=8C=E9=85=8D=E6=96=B9BOM=EF=BC=8C=E3=80=90Copy?= =?UTF-8?q?=E3=80=91=E5=92=8C=E3=80=90=E7=B2=98=E8=B4=B4=E3=80=91=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E2=80=9C=E4=B8=8D=E8=83=BD=E5=B0=86=E8=87=AA=E5=B7=B1?= =?UTF-8?q?=E4=BD=9C=E4=B8=BA=E5=AD=90=E7=89=A9=E6=96=99=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BomManagementServiceImpl.java | 38 ++++++++++++++++--- .../impl/RecipeManagementServiceImpl.java | 32 ++++++++++++++-- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/spring/modules/part/service/impl/BomManagementServiceImpl.java b/src/main/java/com/spring/modules/part/service/impl/BomManagementServiceImpl.java index 3292e7c5..0414ab04 100644 --- a/src/main/java/com/spring/modules/part/service/impl/BomManagementServiceImpl.java +++ b/src/main/java/com/spring/modules/part/service/impl/BomManagementServiceImpl.java @@ -667,9 +667,7 @@ public class BomManagementServiceImpl extends ServiceImpl().eq("site", data.getSite()).eq("part_no", data.getComponentPart())); if (partInformationEntity == null) { @@ -813,7 +811,8 @@ public class BomManagementServiceImpl extends ServiceImpl updateBomComponent(BomComponentEntity data) { - normalizeAndValidateComponentPart(data); + String normalizedComponentPart = normalizeAndValidateComponentPart(data); + assertNotSelfAsComponent(data.getPartNo(), normalizedComponentPart); BomComponentEntity oldData = bomManagementMapper.queryBomComponentByLineItemNo(data); // 修改bom子明细物料 if ("byProduct".equals(data.getProductFlag())) { @@ -888,7 +887,8 @@ public class BomManagementServiceImpl extends ServiceImpl componentDataList = bomManagementMapper.queryBomComponentAll(detailEntity); + assertNoSelfAsComponent(data.getPartNo(), componentDataList); // 查询原BOM副产品成本分配数据列表 List manufStructCostDistribList = bomManagementMapper.queryBomManufStructCostDistrib(detailEntity); detailEntity.setPartNo(data.getPartNo()); @@ -1228,6 +1229,7 @@ public class BomManagementServiceImpl extends ServiceImpl componentList = bomManagementMapper.queryBomComponentAll(data.getPreviousVersion()); + assertNoSelfAsComponent(data.getPartNo(), componentList); if (!componentList.isEmpty()) { List collect = componentList.stream().map(a -> { a.setPartNo(data.getPartNo()); @@ -1741,7 +1743,8 @@ public class BomManagementServiceImpl extends ServiceImpl().eq("site", data.getSite()).eq("part_no", data.getComponentPart())); if (partInformationEntity == null) { @@ -1846,6 +1849,29 @@ public class BomManagementServiceImpl extends ServiceImpl components) { + if (components == null || components.isEmpty()) { + return; + } + for (BomComponentEntity component : components) { + if (component == null) { + continue; + } + assertNotSelfAsComponent(partNo, component.getComponentPart()); + } + } + private String normalizeAndValidateComponentPart(BomComponentEntity data) { if (data == null) { throw new RuntimeException("子物料数据不能为空!"); diff --git a/src/main/java/com/spring/modules/part/service/impl/RecipeManagementServiceImpl.java b/src/main/java/com/spring/modules/part/service/impl/RecipeManagementServiceImpl.java index 4bbea59a..5a655a5f 100644 --- a/src/main/java/com/spring/modules/part/service/impl/RecipeManagementServiceImpl.java +++ b/src/main/java/com/spring/modules/part/service/impl/RecipeManagementServiceImpl.java @@ -727,9 +727,7 @@ public class RecipeManagementServiceImpl extends ServiceImpl saveRecipeComponent(RecipeComponentEntity data) { String normalizedComponentPart = normalizeAndValidateComponentPart(data); // 校验不能选择自己为子件 - if (StringUtils.equals(normalizePartNo(data.getPartNo()), normalizedComponentPart)) { - throw new RuntimeException("不能将自己作为子物料!"); - } + assertNotSelfAsComponent(data.getPartNo(), normalizedComponentPart); // 校验子物料是否合规 PartInformationEntity partInformationEntity = partInformationMapper.selectOne(new QueryWrapper().eq("site", data.getSite()).eq("part_no", data.getComponentPart())); if (partInformationEntity == null) { @@ -834,7 +832,8 @@ public class RecipeManagementServiceImpl extends ServiceImpl updateRecipeComponent(RecipeComponentEntity data) { - normalizeAndValidateComponentPart(data); + String normalizedComponentPart = normalizeAndValidateComponentPart(data); + assertNotSelfAsComponent(data.getPartNo(), normalizedComponentPart); // 修改recipe子明细物料 if ("byProduct".equals(data.getProductFlag())) { data.setQtyPerAssembly(data.getQtyPerAssembly().negate()); @@ -1056,6 +1055,7 @@ public class RecipeManagementServiceImpl extends ServiceImpl componentDataList = recipeManagementMapper.queryRecipeComponentAll(detailEntity); + assertNoSelfAsComponent(data.getPartNo(), componentDataList); // 查询原Recipe副产品成本分配数据列表 List manufStructCostDistribList = recipeManagementMapper.queryRecipeManufStructCostDistrib(detailEntity); detailEntity.setPartNo(data.getPartNo()); @@ -1151,6 +1151,7 @@ public class RecipeManagementServiceImpl extends ServiceImpl componentList = recipeManagementMapper.queryRecipeComponentAll(data.getPreviousVersion()); + assertNoSelfAsComponent(data.getPartNo(), componentList); if (!componentList.isEmpty()) { List collect = componentList.stream().map(a -> { a.setPartNo(data.getPartNo()); @@ -1504,6 +1505,29 @@ public class RecipeManagementServiceImpl extends ServiceImpl components) { + if (components == null || components.isEmpty()) { + return; + } + for (RecipeComponentEntity component : components) { + if (component == null) { + continue; + } + assertNotSelfAsComponent(partNo, component.getComponentPart()); + } + } + private String normalizeAndValidateComponentPart(RecipeComponentEntity data) { if (data == null) { throw new RuntimeException("子物料数据不能为空!");