|
|
@@ -1200,6 +1200,16 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
if (StringUtils.isBlank(item.getNo())) {
|
|
|
throw new BusinessException("第" + lineNum + "行,备件编码不可为空");
|
|
|
}
|
|
|
+ // 必填校验:与新增表单、导入模板保持一致(备件名称、规格型号、计量单位、备件类别编码)
|
|
|
+ if (StringUtils.isBlank(item.getName())) {
|
|
|
+ throw new BusinessException("第" + lineNum + "行,备件名称不可为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(item.getGgxh())) {
|
|
|
+ throw new BusinessException("第" + lineNum + "行,规格型号不可为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(item.getUnit())) {
|
|
|
+ throw new BusinessException("第" + lineNum + "行,计量单位不可为空");
|
|
|
+ }
|
|
|
boolean itemExist = false;
|
|
|
for (SparePartInfo oldItem : oldList) {
|
|
|
if (item.getNo().trim().equals(oldItem.getNo())) {
|
|
|
@@ -1233,21 +1243,24 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
}
|
|
|
sparePartInfo.setLevel(level);
|
|
|
}
|
|
|
- // 判断类别
|
|
|
- if (StringUtils.isNotBlank(item.getTypeId())) {
|
|
|
- boolean isExist = false;
|
|
|
- for (SpareType spareType : spareTypeList) {
|
|
|
- if (spareType.getNo() != null && spareType.getNo().equals(item.getTypeId().trim())) {
|
|
|
- isExist = true;
|
|
|
- sparePartInfo.setTypeId(spareType.getId());
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isExist) {
|
|
|
- throw new BusinessException(
|
|
|
- "第" + lineNum + "行的备件类别编码【" + item.getTypeId() + "】,系统中不存在,请检查");
|
|
|
+ // 判断类别(必填)
|
|
|
+ if (StringUtils.isBlank(item.getTypeId())) {
|
|
|
+ throw new BusinessException("第" + lineNum + "行,备件类别编码不可为空");
|
|
|
+ }
|
|
|
+ boolean typeExist = false;
|
|
|
+ for (SpareType spareType : spareTypeList) {
|
|
|
+ if (spareType.getNo() != null && spareType.getNo().equals(item.getTypeId().trim())) {
|
|
|
+ typeExist = true;
|
|
|
+ sparePartInfo.setTypeId(spareType.getId());
|
|
|
+ // 与新增保持一致:同时写入 parent_type_id,避免编辑时类别显示为空
|
|
|
+ sparePartInfo.setParentTypeId(spareType.getId());
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ if (!typeExist) {
|
|
|
+ throw new BusinessException(
|
|
|
+ "第" + lineNum + "行的备件类别编码【" + item.getTypeId() + "】,系统中不存在,请检查");
|
|
|
+ }
|
|
|
// 生产厂商
|
|
|
if (StringUtils.isNotBlank(item.getProducerName())) {
|
|
|
boolean isExist = false;
|
|
|
@@ -1453,6 +1466,8 @@ public class SparePartInfoServiceImpl extends BaseServiceImpl<SparePartInfoMappe
|
|
|
if (spareType.getNo() != null && spareType.getNo().equals(item.getTypeId().trim())) {
|
|
|
isExist = true;
|
|
|
updInfo.setTypeId(spareType.getId());
|
|
|
+ // 与新增保持一致:同时写入 parent_type_id,避免编辑时类别显示为空
|
|
|
+ updInfo.setParentTypeId(spareType.getId());
|
|
|
break;
|
|
|
}
|
|
|
}
|