【优化】暂存检验标准添加非空校验
This commit is contained in:
parent
50853294f0
commit
44576d5b2b
|
|
@ -1,7 +1,9 @@
|
||||||
package com.nflg.qms.admin.service;
|
package com.nflg.qms.admin.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nflg.wms.common.constant.Constant;
|
||||||
import com.nflg.wms.common.exception.NflgException;
|
import com.nflg.wms.common.exception.NflgException;
|
||||||
import com.nflg.wms.common.pojo.PageData;
|
import com.nflg.wms.common.pojo.PageData;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsInspectionStandardAddQO;
|
import com.nflg.wms.common.pojo.qo.QmsInspectionStandardAddQO;
|
||||||
|
|
@ -14,15 +16,9 @@ import com.nflg.wms.common.pojo.vo.QmsInspectionStandardItemVO;
|
||||||
import com.nflg.wms.common.pojo.vo.QmsInspectionStandardVO;
|
import com.nflg.wms.common.pojo.vo.QmsInspectionStandardVO;
|
||||||
import com.nflg.wms.common.util.UserUtil;
|
import com.nflg.wms.common.util.UserUtil;
|
||||||
import com.nflg.wms.common.util.VUtil;
|
import com.nflg.wms.common.util.VUtil;
|
||||||
import com.nflg.wms.repository.entity.QmsInspectionStandard;
|
import com.nflg.wms.repository.entity.*;
|
||||||
import com.nflg.wms.repository.entity.QmsInspectionStandardItem;
|
|
||||||
import com.nflg.wms.repository.entity.QmsInspectionStandardItemContent;
|
|
||||||
import com.nflg.wms.repository.entity.QmsQcMaterial;
|
|
||||||
import com.nflg.wms.repository.mapper.QmsInspectionStandardMapper;
|
import com.nflg.wms.repository.mapper.QmsInspectionStandardMapper;
|
||||||
import com.nflg.wms.repository.service.IQmsInspectionStandardItemContentService;
|
import com.nflg.wms.repository.service.*;
|
||||||
import com.nflg.wms.repository.service.IQmsInspectionStandardItemService;
|
|
||||||
import com.nflg.wms.repository.service.IQmsInspectionStandardService;
|
|
||||||
import com.nflg.wms.repository.service.IQmsQcMaterialService;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -31,6 +27,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -55,6 +52,9 @@ public class QmsInspectionStandardControllerService {
|
||||||
@Resource
|
@Resource
|
||||||
private IQmsQcMaterialService qmsQcMaterialService;
|
private IQmsQcMaterialService qmsQcMaterialService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IDictionaryItemService dictionaryItemService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询检验标准
|
* 分页查询检验标准
|
||||||
*/
|
*/
|
||||||
|
|
@ -366,7 +366,8 @@ public class QmsInspectionStandardControllerService {
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @param now 当前时间
|
* @param now 当前时间
|
||||||
*/
|
*/
|
||||||
private void processItems(Long inspectionStandardId,
|
private void processItems(List<DictionaryItem> dictionaryItems,
|
||||||
|
Long inspectionStandardId,
|
||||||
List<QmsInspectionStandardSaveQO.InspectionStandardItemQO> items,
|
List<QmsInspectionStandardSaveQO.InspectionStandardItemQO> items,
|
||||||
Long userId, String userName, LocalDateTime now) {
|
Long userId, String userName, LocalDateTime now) {
|
||||||
if (items == null) {
|
if (items == null) {
|
||||||
|
|
@ -384,6 +385,21 @@ public class QmsInspectionStandardControllerService {
|
||||||
// 处理传入的检测项
|
// 处理传入的检测项
|
||||||
List<Long> newItemIds = new ArrayList<>();
|
List<Long> newItemIds = new ArrayList<>();
|
||||||
for (QmsInspectionStandardSaveQO.InspectionStandardItemQO itemQO : items) {
|
for (QmsInspectionStandardSaveQO.InspectionStandardItemQO itemQO : items) {
|
||||||
|
DictionaryItem dictionaryItem = dictionaryItems.stream()
|
||||||
|
.filter(item -> item.getId().equals(itemQO.getSamplingMethodDictItemId()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
VUtil.trueThrowBusinessError(Objects.isNull(dictionaryItem)).throwMessage("检测项【" + itemQO.getName() + "】设置的抽样方式不存在");
|
||||||
|
if (StrUtil.equals(dictionaryItem.getCode(), "抽样")) {
|
||||||
|
VUtil.trueThrowBusinessError(Objects.isNull(itemQO.getSamplingPlanId()))
|
||||||
|
.throwMessage("检测项【" + itemQO.getName() + "】设置的抽样方式为【抽样】时,抽样方案不能为空");
|
||||||
|
VUtil.trueThrowBusinessError(Objects.isNull(itemQO.getInspectionLevelDictItemId()))
|
||||||
|
.throwMessage("检测项【" + itemQO.getName() + "】设置的抽样方式为【抽样】时,检验水平不能为空");
|
||||||
|
VUtil.trueThrowBusinessError(Objects.isNull(itemQO.getAqlPriorityValueId()))
|
||||||
|
.throwMessage("检测项【" + itemQO.getName() + "】设置的抽样方式为【抽样】时,AQL值不能为空");
|
||||||
|
VUtil.trueThrowBusinessError(Objects.isNull(itemQO.getAqlTypeDictItemId()))
|
||||||
|
.throwMessage("检测项【" + itemQO.getName() + "】设置的抽样方式为【抽样】时,AQL类型不能为空");
|
||||||
|
}
|
||||||
QmsInspectionStandardItem item;
|
QmsInspectionStandardItem item;
|
||||||
|
|
||||||
if (itemQO.getId() != null) {
|
if (itemQO.getId() != null) {
|
||||||
|
|
@ -448,7 +464,8 @@ public class QmsInspectionStandardControllerService {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
// 2. 处理检测项列表
|
// 2. 处理检测项列表
|
||||||
processItems(qo.getInspectionStandardId(), qo.getItems(), userId, userName, now);
|
processItems(dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_INSPECTION_STANDARD_SAMPLING_METHOD),
|
||||||
|
qo.getInspectionStandardId(), qo.getItems(), userId, userName, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -39,4 +39,6 @@ public class Constant {
|
||||||
public static final String DICTIONARY_AD_TYPE ="AdvertisementType";
|
public static final String DICTIONARY_AD_TYPE ="AdvertisementType";
|
||||||
|
|
||||||
public static final String DICTIONARY_AD_POSITION ="AdvertisementPosition";
|
public static final String DICTIONARY_AD_POSITION ="AdvertisementPosition";
|
||||||
|
|
||||||
|
public static final String DICTIONARY_INSPECTION_STANDARD_SAMPLING_METHOD ="InspectionStandardSamplingMethod";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.nflg.wms.common.pojo.qo;
|
package com.nflg.wms.common.pojo.qo;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
@ -38,21 +39,24 @@ public class QmsInspectionStandardSaveQO {
|
||||||
/**
|
/**
|
||||||
* 检测项名称
|
* 检测项名称
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "检测项名称不能为空")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序号
|
* 排序号
|
||||||
*/
|
*/
|
||||||
private Integer sortNo;
|
private Integer sortNo = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测方式,关联字典项id
|
* 检测方式,关联字典项id
|
||||||
*/
|
*/
|
||||||
|
@NotNull(message = "检测方式不能为空")
|
||||||
private Long testingMethodDictItemId;
|
private Long testingMethodDictItemId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 抽样方式,关联字典项id
|
* 抽样方式,关联字典项id
|
||||||
*/
|
*/
|
||||||
|
@NotNull(message = "抽样方式不能为空")
|
||||||
private Long samplingMethodDictItemId;
|
private Long samplingMethodDictItemId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -78,6 +82,7 @@ public class QmsInspectionStandardSaveQO {
|
||||||
/**
|
/**
|
||||||
* 检验标准项类型:0-标准检测项,1-尺寸检测项
|
* 检验标准项类型:0-标准检测项,1-尺寸检测项
|
||||||
*/
|
*/
|
||||||
|
@NotNull(message = "检验标准项类型不能为空")
|
||||||
private Short itemType;
|
private Short itemType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -106,16 +111,18 @@ public class QmsInspectionStandardSaveQO {
|
||||||
/**
|
/**
|
||||||
* 排序号
|
* 排序号
|
||||||
*/
|
*/
|
||||||
private Integer sortNo;
|
private Integer sortNo=0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测项名称
|
* 检测项名称
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "检测项内容不能为空")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测标准
|
* 检测标准
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "检测标准不能为空")
|
||||||
private String testStandard;
|
private String testStandard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -131,6 +138,7 @@ public class QmsInspectionStandardSaveQO {
|
||||||
/**
|
/**
|
||||||
* 判定类型,关联字典项id
|
* 判定类型,关联字典项id
|
||||||
*/
|
*/
|
||||||
|
@NotNull(message = "判定类型不能为空")
|
||||||
private Long judgmentTypeDictItemId;
|
private Long judgmentTypeDictItemId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue