|
|
|
@ -660,13 +660,14 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Map<String, Object> saveBomComponent(BomComponentEntity data) { |
|
|
|
String normalizedComponentPart = normalizeAndValidateComponentPart(data); |
|
|
|
// // 校验查重 |
|
|
|
// List<BomComponentEntity> checkList = bomManagementMapper.checkBomComponentOnlyOne(data); |
|
|
|
// if (!checkList.isEmpty()) { |
|
|
|
// throw new RuntimeException("子物料已存在,请检查!"); |
|
|
|
// } |
|
|
|
// 校验不能选择自己为子件 |
|
|
|
if (data.getPartNo().equals(data.getComponentPart())) { |
|
|
|
if (StringUtils.equals(normalizePartNo(data.getPartNo()), normalizedComponentPart)) { |
|
|
|
throw new RuntimeException("不能将自己作为子物料!"); |
|
|
|
} |
|
|
|
// 校验子物料是否合规 |
|
|
|
@ -812,6 +813,7 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Map<String, Object> updateBomComponent(BomComponentEntity data) { |
|
|
|
normalizeAndValidateComponentPart(data); |
|
|
|
BomComponentEntity oldData = bomManagementMapper.queryBomComponentByLineItemNo(data); |
|
|
|
// 修改bom子明细物料 |
|
|
|
if ("byProduct".equals(data.getProductFlag())) { |
|
|
|
@ -886,6 +888,7 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
} |
|
|
|
|
|
|
|
for (BomComponentEntity data : items) { |
|
|
|
normalizeAndValidateComponentPart(data); |
|
|
|
if ("byProduct".equals(data.getProductFlag())) { |
|
|
|
data.setQtyPerAssembly(data.getQtyPerAssembly().negate()); |
|
|
|
} |
|
|
|
@ -1738,6 +1741,7 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
data.setBomType(inData.getBomType()); |
|
|
|
data.setAlternativeNo(inData.getAlternativeNo()); |
|
|
|
data.setCreateBy(inData.getUpdateBy()); |
|
|
|
normalizeAndValidateComponentPart(data); |
|
|
|
// 校验子物料是否合规 |
|
|
|
PartInformationEntity partInformationEntity = partInformationMapper.selectOne(new QueryWrapper<PartInformationEntity>().eq("site", data.getSite()).eq("part_no", data.getComponentPart())); |
|
|
|
if (partInformationEntity == null) { |
|
|
|
@ -1838,6 +1842,22 @@ public class BomManagementServiceImpl extends ServiceImpl<BomManagementMapper, B |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String normalizePartNo(String partNo) { |
|
|
|
return StringUtils.upperCase(StringUtils.trimToEmpty(partNo)); |
|
|
|
} |
|
|
|
|
|
|
|
private String normalizeAndValidateComponentPart(BomComponentEntity data) { |
|
|
|
if (data == null) { |
|
|
|
throw new RuntimeException("子物料数据不能为空!"); |
|
|
|
} |
|
|
|
String normalizedComponentPart = normalizePartNo(data.getComponentPart()); |
|
|
|
if (StringUtils.isBlank(normalizedComponentPart)) { |
|
|
|
throw new RuntimeException("子物料编码不能为空!"); |
|
|
|
} |
|
|
|
data.setComponentPart(normalizedComponentPart); |
|
|
|
return normalizedComponentPart; |
|
|
|
} |
|
|
|
|
|
|
|
private void autoFillWidthByComponentPart(BomComponentEntity data) { |
|
|
|
if (data == null || data.getWidth() != null || StringUtils.isBlank(data.getComponentPart())) { |
|
|
|
return; |
|
|
|
|