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("子物料数据不能为空!");