diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java index f68e393..b151269 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/MaTypeServiceImpl.java @@ -12,10 +12,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -94,24 +91,32 @@ public class MaTypeServiceImpl implements ITypeService { typeFileMapper.insertMaTypeFile(typeFile1); } // 库管员配置 - MaTypeKeeper typeKeeper = new MaTypeKeeper(); - typeKeeper.setUserId(maType.getKeeperUserId()); - typeKeeper.setTypeId(typeId); - typeKeeper.setCreateTime(DateUtils.getNowDate()); - maTypeMapper.insertKeeper(typeKeeper); + if (Objects.nonNull(maType.getKeeperUserId())) { + MaTypeKeeper typeKeeper = new MaTypeKeeper(); + typeKeeper.setUserId(maType.getKeeperUserId()); + typeKeeper.setTypeId(typeId); + typeKeeper.setCreateTime(DateUtils.getNowDate()); + maTypeMapper.insertKeeper(typeKeeper); + } // 维修员配置 - MaTypeRepair typeRepair = new MaTypeRepair(); - typeRepair.setUserId(maType.getRepairUserId()); - typeRepair.setTypeId(typeId); - typeRepair.setCreateTime(DateUtils.getNowDate()); - maTypeMapper.insertRepair(typeRepair); + if (Objects.nonNull(maType.getRepairUserId())) { + MaTypeRepair typeRepair = new MaTypeRepair(); + typeRepair.setUserId(maType.getRepairUserId()); + typeRepair.setTypeId(typeId); + typeRepair.setCreateTime(DateUtils.getNowDate()); + maTypeMapper.insertRepair(typeRepair); + } + // 资产属性配置 - MaPropSet propSet = new MaPropSet(); - propSet.setTypeId(typeId); - propSet.setPropId(maType.getPropId()); - propSet.setCreateTime(DateUtils.getNowDate()); - maTypeMapper.insertMaPropSet(propSet); + if (maType.getPropId() > 0) { + MaPropSet propSet = new MaPropSet(); + propSet.setTypeId(typeId); + propSet.setPropId(maType.getPropId()); + propSet.setCreateTime(DateUtils.getNowDate()); + maTypeMapper.insertMaPropSet(propSet); + } + return i; }