diff --git a/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java b/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java index cf016eae..1049764c 100644 --- a/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java +++ b/src/main/java/com/spring/modules/part/service/impl/PartInformationServiceImpl.java @@ -384,6 +384,28 @@ public class PartInformationServiceImpl extends ServiceImpl().eq("um_id", data.getUmId())); + if (data.getDensity() != null && !("Weight".equals(um.getUmType()) || "Volume".equals(um.getUmType()))) { + throw new RuntimeException("单位类型为 Weight 或者 Volume 时才可设置密度!"); + } + + // 查询是否已存在 master part,没有就创建 + MasterPartInformationEntity masterPart = masterPartInformationMapper.selectOne(new QueryWrapper().eq("part_no", data.getPartNo())); + if (masterPart == null) { + // 创建 masterPart + MasterPartInformationEntity masterPartEntity = new MasterPartInformationEntity(); + masterPartEntity.setPartNo(data.getPartNo()); + masterPartEntity.setPartDesc(data.getPartDesc()); + masterPartEntity.setUmId(data.getUmId()); + masterPartEntity.setOfficialFlag("N"); + masterPartEntity.setCodeNo(data.getCodeNo()); + masterPartEntity.setLotTrackingCode("Not Lot Tracking"); + masterPartEntity.setLotQuantityRule("One Lot Per Production Order"); + masterPartEntity.setSubLotRule("No Sub Lots Allowed"); + masterPartEntity.setComponentLotRule("Many Lots Allowed"); + masterPartInformationMapper.insert(masterPartEntity); + } partInformationMapper.insert(data); // 创建物料的默认revision PartRevisionEntity partRevision = new PartRevisionEntity();