Merge remote-tracking branch 'origin/qms/develop' into qms/develop
This commit is contained in:
commit
4995607ae2
|
|
@ -78,9 +78,8 @@ public class QmsInspectionStandardController extends BaseController {
|
|||
* 暂存检验标准
|
||||
*/
|
||||
@PostMapping("saveDraft")
|
||||
public ApiResult<Void> saveDraft(@Valid @RequestBody QmsInspectionStandardSaveQO request) {
|
||||
inspectionStandardControllerService.saveDraft(request);
|
||||
return ApiResult.success();
|
||||
public ApiResult<Long> saveDraft(@Valid @RequestBody QmsInspectionStandardSaveQO request) {
|
||||
return ApiResult.success(inspectionStandardControllerService.saveDraft(request));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -26,10 +26,7 @@ import org.springframework.stereotype.Component;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -1103,7 +1100,7 @@ public class IncomingInspectionTaskControllerService {
|
|||
if (StrUtil.isNotBlank(data.getImageIds())) {
|
||||
dataVO.setImages(
|
||||
fileUploadRecordService.lambdaQuery()
|
||||
.in(FileUploadRecord::getId, StrUtil.split(data.getImageIds(), ","))
|
||||
.in(FileUploadRecord::getId, Arrays.stream(StrUtil.splitToLong(data.getImageIds(), ",")).boxed().toList())
|
||||
.list()
|
||||
.stream()
|
||||
.map(file -> new FileUploadVO()
|
||||
|
|
|
|||
|
|
@ -513,22 +513,23 @@ public class QmsInspectionStandardControllerService {
|
|||
* @param qo 暂存请求参数
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveDraft(QmsInspectionStandardSaveQO qo) {
|
||||
public Long saveDraft(QmsInspectionStandardSaveQO qo) {
|
||||
// 1. 校验检验标准是否存在
|
||||
QmsInspectionStandard standard = inspectionStandardService.getById(qo.getInspectionStandardId());
|
||||
if (standard == null) {
|
||||
throw new NflgException(com.nflg.wms.common.constant.STATE.BusinessError, "检验标准不存在");
|
||||
}
|
||||
|
||||
// 已发布的标准不允许暂存修改
|
||||
if (standard.getPublishStatus() != null && standard.getPublishStatus() == 1) {
|
||||
throw new NflgException(com.nflg.wms.common.constant.STATE.BusinessError, "已发布的检验标准不允许修改");
|
||||
}
|
||||
|
||||
Long userId = UserUtil.getUserId();
|
||||
String userName = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 已发布的标准不允许直接修改,改为创建新的草稿记录
|
||||
if (standard.getPublishStatus() != null && standard.getPublishStatus() == 1) {
|
||||
validateSamplingFields(qo);
|
||||
return createNewDraftFromPublished(qo, userId, userName, now);
|
||||
}
|
||||
|
||||
// 2. 更新检验标准信息
|
||||
VUtil.trueThrowBusinessError(
|
||||
inspectionStandardService.lambdaQuery()
|
||||
|
|
@ -539,22 +540,7 @@ public class QmsInspectionStandardControllerService {
|
|||
).throwMessage("存在相同版本的检验标准");
|
||||
|
||||
// 检测方式为抽样时校验相关字段
|
||||
if (qo.getTestingMethodDictItemId() != null) {
|
||||
List<DictionaryItem> testingMethodItems = dictionaryItemService.lambdaQuery()
|
||||
.eq(DictionaryItem::getId, qo.getTestingMethodDictItemId())
|
||||
.list();
|
||||
DictionaryItem testingMethod = testingMethodItems.isEmpty() ? null : testingMethodItems.get(0);
|
||||
if (testingMethod != null && StrUtil.equals(testingMethod.getCode(), "抽样")) {
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(qo.getSamplingPlanId()))
|
||||
.throwMessage("检测方式为【抽样】时,抽样方案不能为空");
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(qo.getInspectionLevelDictItemId()))
|
||||
.throwMessage("检测方式为【抽样】时,检验水平不能为空");
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(qo.getAqlPriorityValueId()))
|
||||
.throwMessage("检测方式为【抽样】时,AQL值不能为空");
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(qo.getAqlTypeDictItemId()))
|
||||
.throwMessage("检测方式为【抽样】时,AQL类型不能为空");
|
||||
}
|
||||
}
|
||||
validateSamplingFields(qo);
|
||||
|
||||
// 3. 更新字段(不修改版本号)
|
||||
standard.setMaterialId(qo.getMaterialId());
|
||||
|
|
@ -578,6 +564,96 @@ public class QmsInspectionStandardControllerService {
|
|||
// 3. 处理检测项列表
|
||||
processItems(dictionaryItemService.getListByDictionaryCode("InspectionStandardDetectionType"),
|
||||
qo.getInspectionStandardId(), qo.getItems(), userId, userName, now);
|
||||
|
||||
return standard.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验检测方式为抽样时的必填字段
|
||||
*/
|
||||
private void validateSamplingFields(QmsInspectionStandardSaveQO qo) {
|
||||
if (qo.getTestingMethodDictItemId() != null) {
|
||||
List<DictionaryItem> testingMethodItems = dictionaryItemService.lambdaQuery()
|
||||
.eq(DictionaryItem::getId, qo.getTestingMethodDictItemId())
|
||||
.list();
|
||||
DictionaryItem testingMethod = testingMethodItems.isEmpty() ? null : testingMethodItems.get(0);
|
||||
if (testingMethod != null && StrUtil.equals(testingMethod.getCode(), "抽样")) {
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(qo.getSamplingPlanId()))
|
||||
.throwMessage("检测方式为【抽样】时,抽样方案不能为空");
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(qo.getInspectionLevelDictItemId()))
|
||||
.throwMessage("检测方式为【抽样】时,检验水平不能为空");
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(qo.getAqlPriorityValueId()))
|
||||
.throwMessage("检测方式为【抽样】时,AQL值不能为空");
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(qo.getAqlTypeDictItemId()))
|
||||
.throwMessage("检测方式为【抽样】时,AQL类型不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于已发布的检验标准创建新的草稿记录(全量新增,不复用旧记录 ID)
|
||||
*/
|
||||
private Long createNewDraftFromPublished(QmsInspectionStandardSaveQO qo,
|
||||
Long userId, String userName, LocalDateTime now) {
|
||||
// 1. 版本唯一性校验(排除原发布记录本身)
|
||||
VUtil.trueThrowBusinessError(
|
||||
inspectionStandardService.lambdaQuery()
|
||||
.ne(QmsInspectionStandard::getId, qo.getInspectionStandardId())
|
||||
.eq(QmsInspectionStandard::getMaterialId, qo.getMaterialId())
|
||||
.eq(QmsInspectionStandard::getVersion, qo.getVersion())
|
||||
.exists()
|
||||
).throwMessage("存在相同版本的检验标准");
|
||||
|
||||
// 2. 创建新的检验标准(草稿状态)
|
||||
QmsInspectionStandard newStandard = new QmsInspectionStandard();
|
||||
newStandard.setMaterialId(qo.getMaterialId());
|
||||
newStandard.setDrawingUrl(qo.getDrawingUrl());
|
||||
newStandard.setPackagingMethodId(qo.getPackagingMethodId());
|
||||
newStandard.setInspectionCycle(qo.getInspectionCycle());
|
||||
newStandard.setVersion(qo.getVersion());
|
||||
newStandard.setIsEnabled(qo.getIsEnabled());
|
||||
newStandard.setTestingMethodDictItemId(qo.getTestingMethodDictItemId());
|
||||
newStandard.setSamplingPlanId(qo.getSamplingPlanId());
|
||||
newStandard.setInspectionLevelDictItemId(qo.getInspectionLevelDictItemId());
|
||||
newStandard.setAqlPriorityValueId(qo.getAqlPriorityValueId());
|
||||
newStandard.setAqlTypeDictItemId(qo.getAqlTypeDictItemId());
|
||||
newStandard.setPublishStatus((short) 0);
|
||||
newStandard.setCreateUserId(userId);
|
||||
newStandard.setCreateUserName(userName);
|
||||
newStandard.setCreateTime(now);
|
||||
newStandard.setUpdateUserId(userId);
|
||||
newStandard.setUpdateUserName(userName);
|
||||
newStandard.setUpdateTime(now);
|
||||
inspectionStandardService.save(newStandard);
|
||||
|
||||
// 3. 全量新增检测项及内容(不引用旧记录的 ID)
|
||||
if (qo.getItems() == null) {
|
||||
return newStandard.getId();
|
||||
}
|
||||
List<DictionaryItem> dictionaryItems = dictionaryItemService.getListByDictionaryCode("InspectionStandardDetectionType");
|
||||
for (QmsInspectionStandardSaveQO.InspectionStandardItemQO itemQO : qo.getItems()) {
|
||||
DictionaryItem dictionaryItem = dictionaryItems.stream()
|
||||
.filter(d -> d.getId().equals(itemQO.getDetectionTypeDictItemId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(dictionaryItem))
|
||||
.throwMessage("检测项【" + itemQO.getName() + "】设置的检测类型不存在");
|
||||
|
||||
QmsInspectionStandardItem newItem = new QmsInspectionStandardItem()
|
||||
.setInspectionStandardId(newStandard.getId());
|
||||
updateItemFields(newItem, itemQO, userId, userName, now);
|
||||
inspectionStandardItemService.save(newItem);
|
||||
|
||||
if (itemQO.getContents() != null) {
|
||||
for (QmsInspectionStandardSaveQO.InspectionStandardItemContentQO contentQO : itemQO.getContents()) {
|
||||
QmsInspectionStandardItemContent newContent = new QmsInspectionStandardItemContent()
|
||||
.setInspectionStandardItemId(newItem.getId());
|
||||
updateContentFields(newContent, contentQO, userId, userName, now);
|
||||
inspectionStandardItemContentService.save(newContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newStandard.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -524,22 +524,26 @@ public class QmsIssueTicketControllerService {
|
|||
return r1;
|
||||
});
|
||||
r.setUnqualifiedQty(r.getUnqualifiedQty() + record.getUnqualifiedQty());
|
||||
r.setImageIds(StrUtil.join(",", r.getImageIds(), record.getImageIds()));
|
||||
if (StrUtil.isNotBlank(r.getImageIds())) {
|
||||
r.setImageIds(StrUtil.join(",", r.getImageIds(), record.getImageIds()));
|
||||
}
|
||||
});
|
||||
records.stream()
|
||||
.filter(record -> StrUtil.isNotBlank(record.getImageIds()))
|
||||
.forEach(record -> {
|
||||
record.setImages(fileUploadRecordService.lambdaQuery()
|
||||
.in(FileUploadRecord::getId, StrUtil.split(record.getImageIds(), ","))
|
||||
.list()
|
||||
.stream()
|
||||
.map(file -> new FileUploadVO()
|
||||
.setId(file.getId())
|
||||
.setFileName(file.getFileName())
|
||||
.setUrl(file.getUrl())
|
||||
)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
if(StrUtil.isNotBlank(record.getImageIds())) {
|
||||
record.setImages(fileUploadRecordService.lambdaQuery()
|
||||
.in(FileUploadRecord::getId, Arrays.stream(StrUtil.splitToLong(record.getImageIds(), ",")).boxed().toList())
|
||||
.list()
|
||||
.stream()
|
||||
.map(file -> new FileUploadVO()
|
||||
.setId(file.getId())
|
||||
.setFileName(file.getFileName())
|
||||
.setUrl(file.getUrl())
|
||||
)
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
});
|
||||
vo.setRecords(records);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ public class QmsSamplingPlanControllerService {
|
|||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(@Valid QmsSamplingPlanAddQO request) {
|
||||
VUtil.trueThrowBusinessError(samplingPlanService.lambdaQuery()
|
||||
.eq(QmsSamplingPlan::getPlanName, request.getPlanName())
|
||||
.exists()
|
||||
).throwMessage("方案名称已存在");
|
||||
|
||||
String operator = UserUtil.getUserName();
|
||||
Long operatorId = UserUtil.getUserId();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
|
@ -147,7 +152,7 @@ public class QmsSamplingPlanControllerService {
|
|||
// 通过AQL优先值获取AQL优先值ID
|
||||
Long aqlPriorityValueId = aqlPriorityValueIdMap.get(qo.getAqlPriorityValue());
|
||||
VUtil.trueThrowBusinessError(aqlPriorityValueId == null).throwMessage("字码矩阵维护中的AQL优先值[" + qo.getAqlPriorityValue() + "]在AQL优先值列表中不存在");
|
||||
|
||||
|
||||
QmsCodeLetterMatrix entity = new QmsCodeLetterMatrix()
|
||||
.setSamplingPlanId(planId)
|
||||
.setInspectionType(qo.getInspectionType())
|
||||
|
|
@ -168,7 +173,7 @@ public class QmsSamplingPlanControllerService {
|
|||
// 通过字码内容获取字码ID
|
||||
Long codeLetterId = codeLetterIdMap.get(qo.getCodeLetter());
|
||||
VUtil.trueThrowBusinessError(codeLetterId == null).throwMessage("抽样方案检验中的字码[" + qo.getCodeLetter() + "]在字码列表中不存在");
|
||||
|
||||
|
||||
QmsSamplingPlanInspection entity = new QmsSamplingPlanInspection()
|
||||
.setSamplingPlanId(planId)
|
||||
.setRangeStart(qo.getRangeStart())
|
||||
|
|
@ -187,13 +192,19 @@ public class QmsSamplingPlanControllerService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void edit(@Valid QmsSamplingPlanEditQO request) {
|
||||
Long planId = request.getId();
|
||||
|
||||
|
||||
VUtil.trueThrowBusinessError(samplingPlanService.lambdaQuery()
|
||||
.eq(QmsSamplingPlan::getPlanName, request.getPlanName())
|
||||
.ne(QmsSamplingPlan::getId, planId)
|
||||
.exists()
|
||||
).throwMessage("方案名称已存在");
|
||||
|
||||
// 0. 验证抽样方案是否存在
|
||||
QmsSamplingPlan existPlan = samplingPlanService.getById(planId);
|
||||
VUtil.trueThrowBusinessError(ObjectUtil.isNull(existPlan)).throwMessage("抽样方案不存在");
|
||||
// 已发布状态不能编辑
|
||||
VUtil.trueThrowBusinessError(existPlan.getPublishStatus() == 1).throwMessage("已发布的抽样方案不能编辑");
|
||||
|
||||
|
||||
String operator = UserUtil.getUserName();
|
||||
Long operatorId = UserUtil.getUserId();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
|
@ -283,7 +294,7 @@ public class QmsSamplingPlanControllerService {
|
|||
// 通过AQL优先值获取AQL优先值ID
|
||||
Long aqlPriorityValueId = aqlPriorityValueIdMap.get(qo.getAqlPriorityValue());
|
||||
VUtil.trueThrowBusinessError(aqlPriorityValueId == null).throwMessage("字码矩阵维护中的AQL优先值[" + qo.getAqlPriorityValue() + "]在AQL优先值列表中不存在");
|
||||
|
||||
|
||||
QmsCodeLetterMatrix entity = new QmsCodeLetterMatrix()
|
||||
.setSamplingPlanId(planId)
|
||||
.setInspectionType(qo.getInspectionType())
|
||||
|
|
@ -307,7 +318,7 @@ public class QmsSamplingPlanControllerService {
|
|||
// 通过字码内容获取字码ID
|
||||
Long codeLetterId = codeLetterIdMap.get(qo.getCodeLetter());
|
||||
VUtil.trueThrowBusinessError(codeLetterId == null).throwMessage("抽样方案检验中的字码[" + qo.getCodeLetter() + "]在字码列表中不存在");
|
||||
|
||||
|
||||
QmsSamplingPlanInspection entity = new QmsSamplingPlanInspection()
|
||||
.setSamplingPlanId(planId)
|
||||
.setRangeStart(qo.getRangeStart())
|
||||
|
|
@ -363,7 +374,7 @@ public class QmsSamplingPlanControllerService {
|
|||
VUtil.trueThrowBusinessError(ObjectUtil.isNull(existPlan)).throwMessage("抽样方案不存在");
|
||||
// 已发布状态不能删除
|
||||
VUtil.trueThrowBusinessError(existPlan.getPublishStatus() == 1).throwMessage("已发布的抽样方案不能删除");
|
||||
|
||||
|
||||
// 1. 删除关联的子表数据
|
||||
aqlPriorityValueService.lambdaUpdate()
|
||||
.eq(QmsAqlPriorityValue::getSamplingPlanId, id)
|
||||
|
|
@ -380,7 +391,7 @@ public class QmsSamplingPlanControllerService {
|
|||
samplingPlanInspectionService.lambdaUpdate()
|
||||
.eq(QmsSamplingPlanInspection::getSamplingPlanId, id)
|
||||
.remove();
|
||||
|
||||
|
||||
// 2. 删除主表数据
|
||||
samplingPlanService.removeById(id);
|
||||
}
|
||||
|
|
@ -390,21 +401,22 @@ public class QmsSamplingPlanControllerService {
|
|||
*/
|
||||
public PageData<QmsSamplingPlanVO> search(QmsSamplingPlanSearchQO request) {
|
||||
Page<QmsSamplingPlan> page = new Page<>(request.getPage(), request.getPageSize());
|
||||
|
||||
|
||||
var query = samplingPlanService.lambdaQuery()
|
||||
.like(StrUtil.isNotBlank(request.getPlanCode()), QmsSamplingPlan::getPlanCode, request.getPlanCode())
|
||||
.like(StrUtil.isNotBlank(request.getPlanName()), QmsSamplingPlan::getPlanName, request.getPlanName())
|
||||
.eq(request.getPublishStatus() != null, QmsSamplingPlan::getPublishStatus, request.getPublishStatus())
|
||||
.ge(request.getStartDate() != null, QmsSamplingPlan::getCreateTime, request.getStartDate())
|
||||
.le(request.getEndDate() != null, QmsSamplingPlan::getCreateTime, request.getEndDate())
|
||||
.like(StrUtil.isNotBlank(request.getPlanCode()), QmsSamplingPlan::getPlanCode, request.getPlanCode())
|
||||
.like(StrUtil.isNotBlank(request.getPlanName()), QmsSamplingPlan::getPlanName, request.getPlanName())
|
||||
.orderByAsc(QmsSamplingPlan::getPublishStatus)
|
||||
.orderByDesc(QmsSamplingPlan::getId);
|
||||
|
||||
|
||||
IPage<QmsSamplingPlan> result = query.page(page);
|
||||
|
||||
|
||||
List<QmsSamplingPlanVO> voList = result.getRecords().stream()
|
||||
.map(plan -> BeanUtil.copyProperties(plan, QmsSamplingPlanVO.class))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
PageData<QmsSamplingPlanVO> pageData = new PageData<>();
|
||||
pageData.setPage((int) result.getCurrent());
|
||||
pageData.setPageSize((int) result.getSize());
|
||||
|
|
@ -435,9 +447,9 @@ public class QmsSamplingPlanControllerService {
|
|||
// 1. 查询主表
|
||||
QmsSamplingPlan plan = samplingPlanService.getById(id);
|
||||
VUtil.trueThrowBusinessError(ObjectUtil.isNull(plan)).throwMessage("抽样方案不存在");
|
||||
|
||||
|
||||
QmsSamplingPlanDetailVO detail = BeanUtil.copyProperties(plan, QmsSamplingPlanDetailVO.class);
|
||||
|
||||
|
||||
// 2. 查询AQL优先值预定义
|
||||
List<QmsAqlPriorityValue> aqlPriorityValues = aqlPriorityValueService.lambdaQuery()
|
||||
.eq(QmsAqlPriorityValue::getSamplingPlanId, id)
|
||||
|
|
@ -447,7 +459,7 @@ public class QmsSamplingPlanControllerService {
|
|||
.map(v -> BeanUtil.copyProperties(v, QmsSamplingPlanDetailVO.AqlPriorityValueVO.class))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
||||
// 3. 查询抽样严格性转移规则
|
||||
List<QmsSamplingStrictnessTransferRule> transferRules = strictnessTransferRuleService.lambdaQuery()
|
||||
.eq(QmsSamplingStrictnessTransferRule::getSamplingPlanId, id)
|
||||
|
|
@ -457,7 +469,7 @@ public class QmsSamplingPlanControllerService {
|
|||
.map(r -> BeanUtil.copyProperties(r, QmsSamplingPlanDetailVO.StrictnessTransferRuleVO.class))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
||||
// 4. 查询字码
|
||||
List<QmsCodeLetter> codeLetters = codeLetterService.lambdaQuery()
|
||||
.eq(QmsCodeLetter::getSamplingPlanId, id)
|
||||
|
|
@ -469,11 +481,11 @@ public class QmsSamplingPlanControllerService {
|
|||
.map(c -> BeanUtil.copyProperties(c, QmsSamplingPlanDetailVO.CodeLetterVO.class))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
||||
// 5. 查询AQL优先值Map
|
||||
Map<Long, java.math.BigDecimal> aqlPriorityValueMap = aqlPriorityValues.stream()
|
||||
.collect(Collectors.toMap(QmsAqlPriorityValue::getId, QmsAqlPriorityValue::getPriorityValue));
|
||||
|
||||
|
||||
// 6. 查询字码矩阵维护
|
||||
List<QmsCodeLetterMatrix> codeLetterMatrices = codeLetterMatrixService.lambdaQuery()
|
||||
.eq(QmsCodeLetterMatrix::getSamplingPlanId, id)
|
||||
|
|
@ -488,7 +500,7 @@ public class QmsSamplingPlanControllerService {
|
|||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
||||
// 7. 查询抽样方案检验
|
||||
List<QmsSamplingPlanInspection> inspections = samplingPlanInspectionService.lambdaQuery()
|
||||
.eq(QmsSamplingPlanInspection::getSamplingPlanId, id)
|
||||
|
|
@ -502,7 +514,7 @@ public class QmsSamplingPlanControllerService {
|
|||
})
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
||||
return detail;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import com.nflg.wms.common.pojo.vo.FileUploadVO;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -26,5 +27,6 @@ public class QmsIncomingInspectionTaskTodoCheckSubmitItemDataQO {
|
|||
/**
|
||||
* 图片列表
|
||||
*/
|
||||
@Valid
|
||||
private List<FileUploadVO> images;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,4 +19,9 @@ public class QmsSamplingPlanSearchQO extends SearchBaseQO {
|
|||
* 方案名称
|
||||
*/
|
||||
private String planName;
|
||||
|
||||
/**
|
||||
* 发布状态:0-未发布,1-已发布,2-已撤回
|
||||
*/
|
||||
private Short publishStatus;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ public class QmsIncomingInspectionTaskNonconformanceVO {
|
|||
*/
|
||||
private Long taskId;
|
||||
|
||||
/**
|
||||
* 工单ID
|
||||
*/
|
||||
private Long ticketId;
|
||||
|
||||
/**
|
||||
* 检测单号
|
||||
*/
|
||||
|
|
@ -50,6 +55,11 @@ public class QmsIncomingInspectionTaskNonconformanceVO {
|
|||
*/
|
||||
private String drawingNoVer;
|
||||
|
||||
/**
|
||||
* 检测标准版本号
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* 供应商编号
|
||||
*/
|
||||
|
|
@ -154,4 +164,9 @@ public class QmsIncomingInspectionTaskNonconformanceVO {
|
|||
* 流程状态:0=未发起,1=处理中,2=已完成
|
||||
*/
|
||||
private Short status;
|
||||
|
||||
/**
|
||||
* 关联检测任务单号
|
||||
*/
|
||||
private String associationTaskNo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class QmsInspectionStandard implements Serializable {
|
|||
private Long aqlTypeDictItemId;
|
||||
|
||||
/**
|
||||
* 发布状态:0-未发布,1-已发布
|
||||
* 发布状态:0-未发布,1-已发布,2=已废弃
|
||||
*/
|
||||
private Short publishStatus;
|
||||
|
||||
|
|
|
|||
|
|
@ -164,4 +164,9 @@ public class QmsIssueTicket implements Serializable {
|
|||
*/
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
/**
|
||||
* 关联检测任务单号
|
||||
*/
|
||||
private String associationTaskNo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,16 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.nflg.wms.common.pojo.qo.QmsIncomingInspectionTaskTodoCheckItemsQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsIncomingInspectionTaskCheckItemVO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import com.nflg.wms.repository.entity.QmsInspectionStandard;
|
||||
import com.nflg.wms.repository.mapper.QmsInspectionStandardMapper;
|
||||
import com.nflg.wms.repository.service.IQmsInspectionStandardService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 检验标准 服务实现类
|
||||
|
|
@ -19,15 +22,26 @@ import java.util.List;
|
|||
public class QmsInspectionStandardServiceImpl extends ServiceImpl<QmsInspectionStandardMapper, QmsInspectionStandard>
|
||||
implements IQmsInspectionStandardService {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void publish(List<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 查询待发布的记录
|
||||
List<QmsInspectionStandard> standards = listByIds(ids);
|
||||
|
||||
// 校验是否包含已发布的记录
|
||||
boolean hasPublished = standards.stream()
|
||||
.anyMatch(s -> s.getPublishStatus() == 1);
|
||||
VUtil.trueThrowBusinessError(hasPublished).throwMessage("包含已发布的检验标准,请重新选择");
|
||||
|
||||
Long userId = UserUtil.getUserId();
|
||||
String userName = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
|
||||
// 发布选中的记录
|
||||
lambdaUpdate()
|
||||
.eq(QmsInspectionStandard::getPublishStatus, (short) 0)
|
||||
.in(QmsInspectionStandard::getId, ids)
|
||||
|
|
@ -39,6 +53,24 @@ public class QmsInspectionStandardServiceImpl extends ServiceImpl<QmsInspectionS
|
|||
.set(QmsInspectionStandard::getUpdateUserName, userName)
|
||||
.set(QmsInspectionStandard::getUpdateTime, now)
|
||||
.update();
|
||||
|
||||
// 将相同物料ID的其他记录设置为已废弃
|
||||
List<Long> materialIds = standards.stream()
|
||||
.map(QmsInspectionStandard::getMaterialId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!materialIds.isEmpty()) {
|
||||
lambdaUpdate()
|
||||
.in(QmsInspectionStandard::getMaterialId, materialIds)
|
||||
.notIn(QmsInspectionStandard::getId, ids)
|
||||
.ne(QmsInspectionStandard::getPublishStatus, (short) 2)
|
||||
.set(QmsInspectionStandard::getPublishStatus, (short) 2)
|
||||
.set(QmsInspectionStandard::getUpdateUserId, userId)
|
||||
.set(QmsInspectionStandard::getUpdateUserName, userName)
|
||||
.set(QmsInspectionStandard::getUpdateTime, now)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<select id="search" resultType="com.nflg.wms.common.pojo.vo.QmsIncomingInspectionTaskNonconformanceVO">
|
||||
SELECT
|
||||
t.id as task_id,
|
||||
it.id as ticket_id,
|
||||
t.task_no,
|
||||
it.ticket_no,
|
||||
it.ticket_title,
|
||||
|
|
@ -12,6 +13,7 @@
|
|||
m.material_no,
|
||||
m.material_desc,
|
||||
m.drawing_no_ver,
|
||||
is.version,
|
||||
t.supplier_code,
|
||||
t.supplier_name,
|
||||
t.delivery_order_no,
|
||||
|
|
@ -32,10 +34,12 @@
|
|||
t.inspection_finish_time,
|
||||
t.required_finish_time,
|
||||
t.is_overdue,
|
||||
CASE WHEN it.status IS NULL THEN 0 ELSE it.status END AS status
|
||||
CASE WHEN it.status IS NULL THEN 0 ELSE it.status END AS status,
|
||||
it.association_task_no
|
||||
FROM qms_incoming_inspection_task t
|
||||
LEFT JOIN qms_issue_ticket it ON it.source_id = t.id
|
||||
INNER JOIN qms_qc_material m ON t.material_id = m.id
|
||||
LEFT JOIN qms_inspection_standard is ON t.inspection_standard_id = is.id
|
||||
WHERE t.inspection_status=2 and t.inspection_result=false
|
||||
AND ((t.inspection_type=0 and t.purchase_group=#{request.purchaseGroup}) or (t.inspection_type=1 and #{request.isWarehouseManager}=true))
|
||||
<if test="request.dataType != null">
|
||||
|
|
|
|||
Loading…
Reference in New Issue