|
|
|
@ -667,9 +667,7 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
// throw new RuntimeException("子物料已存在,请检查!"); |
|
|
|
// } |
|
|
|
// 校验不能选择自己为子件 |
|
|
|
if (StringUtils.equals(normalizePartNo(data.getPartNo()), normalizedComponentPart)) { |
|
|
|
throw new RuntimeException("不能将自己作为子物料!"); |
|
|
|
} |
|
|
|
assertNotSelfAsComponent(data.getPartNo(), normalizedComponentPart); |
|
|
|
// 校验子物料是否合规 |
|
|
|
PartInformationEntity partInformationEntity = partInformationMapper.selectOne(new QueryWrapper<PartInformationEntity>().eq("site", data.getSite()).eq("part_no", data.getComponentPart())); |
|
|
|
if (partInformationEntity == null) { |
|
|
|
@ -813,7 +811,8 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Map<String, Object> 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<BomManagementMapper, B |
|
|
|
} |
|
|
|
|
|
|
|
for (BomComponentEntity data : items) { |
|
|
|
normalizeAndValidateComponentPart(data); |
|
|
|
String normalizedComponentPart = normalizeAndValidateComponentPart(data); |
|
|
|
assertNotSelfAsComponent(data.getPartNo(), normalizedComponentPart); |
|
|
|
if ("byProduct".equals(data.getProductFlag())) { |
|
|
|
data.setQtyPerAssembly(data.getQtyPerAssembly().negate()); |
|
|
|
} |
|
|
|
@ -1125,6 +1125,7 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
for (BomDetailEntity detailEntity : detailDataList) { |
|
|
|
// 查询原BOM替代列表 |
|
|
|
List<BomComponentVo> componentDataList = bomManagementMapper.queryBomComponentAll(detailEntity); |
|
|
|
assertNoSelfAsComponent(data.getPartNo(), componentDataList); |
|
|
|
// 查询原BOM副产品成本分配数据列表 |
|
|
|
List<BomManufStructCostDistribVo> manufStructCostDistribList = bomManagementMapper.queryBomManufStructCostDistrib(detailEntity); |
|
|
|
detailEntity.setPartNo(data.getPartNo()); |
|
|
|
@ -1228,6 +1229,7 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
|
|
|
|
// 创建替代中的子件 |
|
|
|
List<BomComponentVo> componentList = bomManagementMapper.queryBomComponentAll(data.getPreviousVersion()); |
|
|
|
assertNoSelfAsComponent(data.getPartNo(), componentList); |
|
|
|
if (!componentList.isEmpty()) { |
|
|
|
List<BomComponentVo> collect = componentList.stream().map(a -> { |
|
|
|
a.setPartNo(data.getPartNo()); |
|
|
|
@ -1741,7 +1743,8 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
data.setBomType(inData.getBomType()); |
|
|
|
data.setAlternativeNo(inData.getAlternativeNo()); |
|
|
|
data.setCreateBy(inData.getUpdateBy()); |
|
|
|
normalizeAndValidateComponentPart(data); |
|
|
|
String normalizedComponentPart = normalizeAndValidateComponentPart(data); |
|
|
|
assertNotSelfAsComponent(data.getPartNo(), normalizedComponentPart); |
|
|
|
// 校验子物料是否合规 |
|
|
|
PartInformationEntity partInformationEntity = partInformationMapper.selectOne(new QueryWrapper<PartInformationEntity>().eq("site", data.getSite()).eq("part_no", data.getComponentPart())); |
|
|
|
if (partInformationEntity == null) { |
|
|
|
@ -1846,6 +1849,29 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
return StringUtils.upperCase(StringUtils.trimToEmpty(partNo)); |
|
|
|
} |
|
|
|
|
|
|
|
private void assertNotSelfAsComponent(String partNo, String componentPart) { |
|
|
|
String parentPartNo = normalizePartNo(partNo); |
|
|
|
String childPartNo = normalizePartNo(componentPart); |
|
|
|
if (StringUtils.isBlank(parentPartNo) || StringUtils.isBlank(childPartNo)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (StringUtils.equals(parentPartNo, childPartNo)) { |
|
|
|
throw new RuntimeException("不能将自己作为子物料!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void assertNoSelfAsComponent(String partNo, List<? extends BomComponentEntity> 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("子物料数据不能为空!"); |
|
|
|
|