Compare commits

..

No commits in common. "54a6056231e2f298349ea1de729d1a5d251c8c6c" and "514080a0f905399e68a10567c2ddabbcb606ba57" have entirely different histories.

4 changed files with 27 additions and 152 deletions

View File

@ -3,7 +3,12 @@ package com.nflg.qms.admin.controller;
import com.nflg.qms.admin.service.QmsInspectionStandardControllerService;
import com.nflg.wms.common.pojo.ApiResult;
import com.nflg.wms.common.pojo.PageData;
import com.nflg.wms.common.pojo.qo.*;
import com.nflg.wms.common.pojo.qo.EnableQO;
import com.nflg.wms.common.pojo.qo.IdsQO;
import com.nflg.wms.common.pojo.qo.QmsInspectionStandardAddQO;
import com.nflg.wms.common.pojo.qo.QmsInspectionStandardEditQO;
import com.nflg.wms.common.pojo.qo.QmsInspectionStandardSaveQO;
import com.nflg.wms.common.pojo.qo.QmsInspectionStandardSearchQO;
import com.nflg.wms.common.pojo.vo.QmsInspectionStandardDetailVO;
import com.nflg.wms.common.pojo.vo.QmsInspectionStandardVO;
import com.nflg.wms.starter.BaseController;
@ -11,7 +16,12 @@ import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 检验标准
@ -40,14 +50,14 @@ public class QmsInspectionStandardController extends BaseController {
return ApiResult.success(inspectionStandardControllerService.add(request));
}
// /**
// * 编辑检验标准
// */
// @PostMapping("edit")
// public ApiResult<Void> edit(@Valid @RequestBody QmsInspectionStandardEditQO request) {
// inspectionStandardControllerService.edit(request);
// return ApiResult.success();
// }
/**
* 编辑检验标准
*/
@PostMapping("edit")
public ApiResult<Void> edit(@Valid @RequestBody QmsInspectionStandardEditQO request) {
inspectionStandardControllerService.edit(request);
return ApiResult.success();
}
/**
* 批量发布检验标准
@ -68,7 +78,7 @@ public class QmsInspectionStandardController extends BaseController {
}
/**
* 暂存检验标准
* 暂存检验标准检测项和检测项内容
*/
@PostMapping("saveDraft")
public ApiResult<Void> saveDraft(@Valid @RequestBody QmsInspectionStandardSaveQO request) {

View File

@ -25,7 +25,9 @@ import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@ -179,20 +181,8 @@ public class QmsInspectionStandardControllerService {
// 4. 转换为VO并填充内容列表
List<QmsInspectionStandardItemVO> itemVOs = new ArrayList<>();
Set<Long> dictionaryItemIds = new HashSet<>();
items.forEach(item -> {
dictionaryItemIds.add(item.getTestingMethodDictItemId());
dictionaryItemIds.add(item.getSamplingMethodDictItemId());
dictionaryItemIds.add(item.getInspectionLevelDictItemId());
dictionaryItemIds.add(item.getAqlTypeDictItemId());
dictionaryItemIds.add(item.getAqlPriorityValueId());
dictionaryItemIds.add(item.getInspectionStandardId());
});
List<DictionaryItem> dictionaryItems = dictionaryItemService.lambdaQuery()
.in(DictionaryItem::getId, dictionaryItemIds)
.list();
for (QmsInspectionStandardItem item : items) {
QmsInspectionStandardItemVO itemVO = convertToItemVO(item, dictionaryItems);
QmsInspectionStandardItemVO itemVO = convertToItemVO(item);
// 查询检测项内容列表
List<QmsInspectionStandardItemContent> contents = inspectionStandardItemContentService.lambdaQuery()
@ -215,53 +205,17 @@ public class QmsInspectionStandardControllerService {
/**
* 转换检测项实体为VO
*/
private QmsInspectionStandardItemVO convertToItemVO(QmsInspectionStandardItem item, List<DictionaryItem> dictionaryItems) {
private QmsInspectionStandardItemVO convertToItemVO(QmsInspectionStandardItem item) {
QmsInspectionStandardItemVO vo = new QmsInspectionStandardItemVO();
vo.setId(item.getId());
vo.setName(item.getName());
vo.setSortNo(item.getSortNo());
vo.setTestingMethodDictItemId(item.getTestingMethodDictItemId());
vo.setTestingMethodDictItemName(dictionaryItems.stream()
.filter(it -> it.getId().equals(item.getTestingMethodDictItemId()))
.findFirst()
.map(DictionaryItem::getName)
.orElse(null)
);
vo.setSamplingMethodDictItemId(item.getSamplingMethodDictItemId());
vo.setSamplingMethodDictItemName(dictionaryItems.stream()
.filter(it -> it.getId().equals(item.getSamplingMethodDictItemId()))
.findFirst()
.map(DictionaryItem::getName)
.orElse(null)
);
vo.setSamplingPlanId(item.getSamplingPlanId());
vo.setSamplingPlanName(dictionaryItems.stream()
.filter(it -> it.getId().equals(item.getSamplingPlanId()))
.findFirst()
.map(DictionaryItem::getName)
.orElse(null)
);
vo.setInspectionLevelDictItemId(item.getInspectionLevelDictItemId());
vo.setInspectionLevelDictItemName(dictionaryItems.stream()
.filter(it -> it.getId().equals(item.getInspectionLevelDictItemId()))
.findFirst()
.map(DictionaryItem::getName)
.orElse(null)
);
vo.setAqlPriorityValueId(item.getAqlPriorityValueId());
vo.setAqlPriorityValueName(dictionaryItems.stream()
.filter(it -> it.getId().equals(item.getAqlPriorityValueId()))
.findFirst()
.map(DictionaryItem::getName)
.orElse(null)
);
vo.setAqlTypeDictItemId(item.getAqlTypeDictItemId());
vo.setAqlTypeDictItemName(dictionaryItems.stream()
.filter(it -> it.getId().equals(item.getAqlTypeDictItemId()))
.findFirst()
.map(DictionaryItem::getName)
.orElse(null)
);
vo.setItemType(item.getItemType());
vo.setPdfDrawing(item.getPdfDrawing());
vo.setCreateUserName(item.getCreateUserName());
@ -508,31 +462,7 @@ public class QmsInspectionStandardControllerService {
Long userId = UserUtil.getUserId();
String userName = UserUtil.getUserName();
LocalDateTime now = LocalDateTime.now();
// 2. 更新检验标准信息
VUtil.trueThrowBusinessError(
inspectionStandardService.lambdaQuery()
.ne(QmsInspectionStandard::getId, qo.getInspectionStandardId())
.eq(QmsInspectionStandard::getMaterialId, qo.getMaterialId())
.eq(QmsInspectionStandard::getVersion, qo.getVersion())
.exists()
).throwMessage("存在相同版本的检验标准");
// 3. 更新字段不修改版本号
standard.setMaterialId(qo.getMaterialId());
standard.setDrawingUrl(qo.getDrawingUrl());
standard.setPackagingMethodId(qo.getPackagingMethodId());
standard.setInspectionCycle(qo.getInspectionCycle());
standard.setVersion(qo.getVersion());
standard.setIsEnabled(qo.getIsEnabled());
// 审计字段
standard.setUpdateUserId(userId);
standard.setUpdateUserName(userName);
standard.setUpdateTime(now);
inspectionStandardService.updateById(standard);
// 3. 处理检测项列表
// 2. 处理检测项列表
processItems(dictionaryItemService.getListByDictionaryCode(Constant.DICTIONARY_INSPECTION_STANDARD_SAMPLING_METHOD),
qo.getInspectionStandardId(), qo.getItems(), userId, userName, now);
}

View File

@ -19,41 +19,6 @@ public class QmsInspectionStandardSaveQO {
@NotNull(message = "检验标准ID不能为空")
private Long inspectionStandardId;
/**
* 物料ID
*/
@NotNull(message = "物料ID不能为空")
private Long materialId;
/**
* 版本号
*/
@NotBlank
private String version;
/**
* 是否启用
*/
@NotNull
private Boolean isEnabled;
/**
* 图纸URL
*/
private String drawingUrl;
/**
* 包装方式ID
*/
@NotNull
private Long packagingMethodId;
/**
* 检验周期
*/
@NotNull
private Integer inspectionCycle;
/**
* 检测项列表
*/

View File

@ -31,61 +31,31 @@ public class QmsInspectionStandardItemVO {
*/
private Long testingMethodDictItemId;
/**
* 检测方式字典项名称
*/
private String testingMethodDictItemName;
/**
* 抽样方式字典项ID
*/
private Long samplingMethodDictItemId;
/**
* 抽样方式字典项名称
*/
private String samplingMethodDictItemName;
/**
* 抽样方案ID
*/
private Long samplingPlanId;
/**
* 抽样方案名称
*/
private String samplingPlanName;
/**
* 检验水平字典项ID
*/
private Long inspectionLevelDictItemId;
/**
* 检验水平字典项名称
*/
private String inspectionLevelDictItemName;
/**
* AQL值ID
*/
private Long aqlPriorityValueId;
/**
* AQL值名称
*/
private String aqlPriorityValueName;
/**
* AQL类型字典项ID
*/
private Long aqlTypeDictItemId;
/**
* AQL类型字典项名称
*/
private String aqlTypeDictItemName;
/**
* 检验标准项类型0-标准检测项1-尺寸检测项
*/