pqc修改

This commit is contained in:
yf001217 2026-06-14 08:57:31 +08:00
parent 39534370ec
commit b53bac78a0
14 changed files with 1 additions and 233 deletions

View File

@ -18,11 +18,6 @@ public class PqcInspectionRuleAddQO {
@NotBlank(message = "机型编号不能为空") @NotBlank(message = "机型编号不能为空")
private String modelNo; private String modelNo;
/**
* 质检员id
*/
private Long inspectorId;
/** /**
* 规则编号可选后端自动生成 * 规则编号可选后端自动生成
*/ */

View File

@ -25,11 +25,6 @@ public class PqcInspectionRuleEditQO {
@NotBlank(message = "机型编号不能为空") @NotBlank(message = "机型编号不能为空")
private String modelNo; private String modelNo;
/**
* 质检员id
*/
private Long inspectorId;
/** /**
* 检查点列表 * 检查点列表
*/ */

View File

@ -23,11 +23,6 @@ public class PqcInspectionRuleSearchQO extends PageQO {
*/ */
private String pqcRuleCode; private String pqcRuleCode;
/**
* 质检员id
*/
private Long inspectorId;
/** /**
* 启用状态true=启用false=禁用 * 启用状态true=启用false=禁用
*/ */

View File

@ -23,11 +23,6 @@ public class PqcInspectionRuleDetailVO {
*/ */
private String modelNo; private String modelNo;
/**
* 质检员id
*/
private Long inspectorId;
/** /**
* 规则编号 * 规则编号
*/ */

View File

@ -22,11 +22,6 @@ public class PqcInspectionRuleVO {
*/ */
private String modelNo; private String modelNo;
/**
* 质检员id
*/
private Long inspectorId;
/** /**
* 规则编号 * 规则编号
*/ */

View File

@ -85,10 +85,6 @@ public class QmsPqcTaskRecordControllerService {
VUtil.trueThrowBusinessError(latestRule == null) VUtil.trueThrowBusinessError(latestRule == null)
.throwMessage("未找到机型[" + modelNo + "]的检验规则"); .throwMessage("未找到机型[" + modelNo + "]的检验规则");
User inspector = latestRule.getInspectorId() == null ? null : userService.getById(latestRule.getInspectorId());
String inspectorName = inspector == null ? null : inspector.getUserName();
// 2. 生成任务编号单号生成ID=42 // 2. 生成任务编号单号生成ID=42
String taskNo = basdeSerialNumberControllerService.generateSerialNumber(42); String taskNo = basdeSerialNumberControllerService.generateSerialNumber(42);
@ -99,8 +95,6 @@ public class QmsPqcTaskRecordControllerService {
.setModelNo(modelNo) .setModelNo(modelNo)
.setNo(no) .setNo(no)
.setInspectionPointId(inspectionPointId) .setInspectionPointId(inspectionPointId)
.setReviewerId(latestRule.getInspectorId())
.setReviewerName(inspectorName)
.setStatus((short) 0) // 0=自检中 .setStatus((short) 0) // 0=自检中
.setEnable(true) .setEnable(true)
.setCreateTime(LocalDateTime.now()); .setCreateTime(LocalDateTime.now());
@ -1037,13 +1031,6 @@ public class QmsPqcTaskRecordControllerService {
} }
pqcTaskRecordService.updateById(taskRecord); pqcTaskRecordService.updateById(taskRecord);
// 5. 自检提交后推送给所有QC人员
if (!hasReviewContent) {
// 推送给所有QC人员推送编码PQCReviewTask
sendTodoMessageToAllQC(taskRecord.getId(), currentUserId, currentUserName, now);
}
// 6. 同步生成工单仅当任务总体不合格时才额外生成重检任务 // 6. 同步生成工单仅当任务总体不合格时才额外生成重检任务
Map<Long, Long> detailIdMap = getTaskDetailIdMap(taskRecord.getId()); Map<Long, Long> detailIdMap = getTaskDetailIdMap(taskRecord.getId());
List<QmsPqcUnqualifiedItemVO> unqualifiedItems = buildUnqualifiedItems(request, detailIdMap); List<QmsPqcUnqualifiedItemVO> unqualifiedItems = buildUnqualifiedItems(request, detailIdMap);
@ -1647,29 +1634,6 @@ public class QmsPqcTaskRecordControllerService {
sendMessageServices.forEach(service -> service.sendSystemMessage(todoItem)); sendMessageServices.forEach(service -> service.sendSystemMessage(todoItem));
} }
/**
* 推送给所有QC人员
*/
private void sendTodoMessageToAllQC(Long taskId, Long createUserId, String createUserName, LocalDateTime now) {
// 查询消息类型ID
Long reviewTypeId = dictionaryItemService.getIdByCode("MessageType", "PQCReviewTask");
VUtil.trueThrowBusinessError(reviewTypeId == null).throwMessage("消息类型PQCReviewTask不存在");
// TODO: 根据实际业务获取所有QC人员列表
// 这里需要根据角色或用户组查询所有QC人员
// 示例List<User> qcUsers = userService.getUsersByRole("QC");
// 临时实现推送给任务的复核人如果有
QmsPqcTaskRecord taskRecord = pqcTaskRecordService.getById(taskId);
if (taskRecord != null && taskRecord.getReviewerId() != null) {
sendTodoMessage(taskRecord.getTaskNo(),taskRecord.getReviewerId(), taskRecord.getReviewerName(),
taskId, reviewTypeId, createUserId, createUserName, now);
}
}
/**
* 生成检查点合并键
*/
private String buildStepKey(QmsPqcInspectionPoint point) { private String buildStepKey(QmsPqcInspectionPoint point) {
String stepName = StrUtil.blankToDefault(point.getStepName(), ""); String stepName = StrUtil.blankToDefault(point.getStepName(), "");
String stepDicItemId = point.getStepDicItemId() == null ? "" : point.getStepDicItemId().toString(); String stepDicItemId = point.getStepDicItemId() == null ? "" : point.getStepDicItemId().toString();

View File

@ -192,7 +192,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
// 查询条件 // 查询条件
queryWrapper.like(StrUtil.isNotBlank(qo.getModelNo()), QmsPqcInspectionRule::getModelNo, qo.getModelNo()) queryWrapper.like(StrUtil.isNotBlank(qo.getModelNo()), QmsPqcInspectionRule::getModelNo, qo.getModelNo())
.like(StrUtil.isNotBlank(qo.getPqcRuleCode()), QmsPqcInspectionRule::getPqcRuleCode, qo.getPqcRuleCode()) .like(StrUtil.isNotBlank(qo.getPqcRuleCode()), QmsPqcInspectionRule::getPqcRuleCode, qo.getPqcRuleCode())
.eq(Objects.nonNull(qo.getInspectorId()), QmsPqcInspectionRule::getInspectorId, qo.getInspectorId())
.eq(Objects.nonNull(qo.getIsDisabled()), QmsPqcInspectionRule::getIsDisabled, qo.getIsDisabled()) .eq(Objects.nonNull(qo.getIsDisabled()), QmsPqcInspectionRule::getIsDisabled, qo.getIsDisabled())
.eq(Objects.nonNull(qo.getAuditStatus()), QmsPqcInspectionRule::getAuditStatus, qo.getAuditStatus()) .eq(Objects.nonNull(qo.getAuditStatus()), QmsPqcInspectionRule::getAuditStatus, qo.getAuditStatus())
.ge(Objects.nonNull(qo.getCreateTimeStart()), QmsPqcInspectionRule::getCreateTime, qo.getCreateTimeStart() == null ? null : qo.getCreateTimeStart().atStartOfDay()) .ge(Objects.nonNull(qo.getCreateTimeStart()), QmsPqcInspectionRule::getCreateTime, qo.getCreateTimeStart() == null ? null : qo.getCreateTimeStart().atStartOfDay())
@ -276,7 +275,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
// 创建规则主表 // 创建规则主表
QmsPqcInspectionRule rule = new QmsPqcInspectionRule(); QmsPqcInspectionRule rule = new QmsPqcInspectionRule();
rule.setModelNo(qo.getModelNo()); rule.setModelNo(qo.getModelNo());
rule.setInspectorId(qo.getInspectorId());
// 规则编号为空时自动生成 // 规则编号为空时自动生成
rule.setPqcRuleCode(StrUtil.isNotBlank(qo.getPqcRuleCode()) rule.setPqcRuleCode(StrUtil.isNotBlank(qo.getPqcRuleCode())
@ -319,7 +317,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
} }
existRule.setModelNo(qo.getModelNo()); existRule.setModelNo(qo.getModelNo());
existRule.setInspectorId(qo.getInspectorId());
existRule.setUpdateBy(operatorId); existRule.setUpdateBy(operatorId);
existRule.setUpdateName(operator); existRule.setUpdateName(operator);
existRule.setUpdateTime(now); existRule.setUpdateTime(now);
@ -376,7 +373,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
// 创建新规则 // 创建新规则
QmsPqcInspectionRule newRule = new QmsPqcInspectionRule(); QmsPqcInspectionRule newRule = new QmsPqcInspectionRule();
newRule.setModelNo(existRule.getModelNo()); newRule.setModelNo(existRule.getModelNo());
newRule.setInspectorId(existRule.getInspectorId());
newRule.setPqcRuleCode(serialNumberControllerService.generateSerialNumber(40)); newRule.setPqcRuleCode(serialNumberControllerService.generateSerialNumber(40));
newRule.setRuleVersion(getNextRuleVersion(existRule.getModelNo())); newRule.setRuleVersion(getNextRuleVersion(existRule.getModelNo()));
newRule.setIsDisabled(true); newRule.setIsDisabled(true);
@ -549,7 +545,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
QmsPqcInspectionRule newRule = new QmsPqcInspectionRule(); QmsPqcInspectionRule newRule = new QmsPqcInspectionRule();
newRule.setModelNo(existRule.getModelNo()); newRule.setModelNo(existRule.getModelNo());
newRule.setInspectorId(existRule.getInspectorId());
newRule.setPqcRuleCode(serialNumberControllerService.generateSerialNumber(40)); newRule.setPqcRuleCode(serialNumberControllerService.generateSerialNumber(40));
newRule.setRuleVersion(existRule.getRuleVersion() == null ? 1 : existRule.getRuleVersion() + 1); newRule.setRuleVersion(existRule.getRuleVersion() == null ? 1 : existRule.getRuleVersion() + 1);
newRule.setIsDisabled(existRule.getIsDisabled()); newRule.setIsDisabled(existRule.getIsDisabled());
@ -749,22 +744,8 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
StrUtil.isBlank(dto.getInspectionMethodsText()) && StrUtil.isBlank(dto.getInspectionMethodsText()) &&
StrUtil.isBlank(dto.getInspectionLevelText()) && StrUtil.isBlank(dto.getInspectionLevelText()) &&
StrUtil.isBlank(dto.getInspectionImage()) && StrUtil.isBlank(dto.getInspectionImage()) &&
Objects.isNull(dto.getInspectorId()) &&
Objects.isNull(dto.getSort())); Objects.isNull(dto.getSort()));
} }
private Long resolveImportInspectorId(List<PqcInspectionRuleImportDTO> rows) {
List<Long> inspectorIds = rows.stream()
.map(PqcInspectionRuleImportDTO::getInspectorId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (inspectorIds.size() > 1) {
throw new NflgException(STATE.BusinessError, "同一机型编号只能填写一个质检员ID");
}
return inspectorIds.isEmpty() ? null : inspectorIds.get(0);
}
@Override @Override
@Transactional @Transactional
public void importFromExcel(MultipartFile file, String importMode) throws Exception { public void importFromExcel(MultipartFile file, String importMode) throws Exception {
@ -846,7 +827,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
for (Map.Entry<String, List<PqcInspectionRuleImportDTO>> entry : modelNoGroups.entrySet()) { for (Map.Entry<String, List<PqcInspectionRuleImportDTO>> entry : modelNoGroups.entrySet()) {
String modelNo = entry.getKey(); String modelNo = entry.getKey();
List<PqcInspectionRuleImportDTO> modelRows = entry.getValue(); List<PqcInspectionRuleImportDTO> modelRows = entry.getValue();
Long importInspectorId = resolveImportInspectorId(modelRows);
// 查找该机型编号的最高版本规则 // 查找该机型编号的最高版本规则
QmsPqcInspectionRule highestRule = ruleService.lambdaQuery() QmsPqcInspectionRule highestRule = ruleService.lambdaQuery()
@ -861,7 +841,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
// 该机型无规则新建 // 该机型无规则新建
QmsPqcInspectionRule newRule = new QmsPqcInspectionRule(); QmsPqcInspectionRule newRule = new QmsPqcInspectionRule();
newRule.setModelNo(modelNo); newRule.setModelNo(modelNo);
newRule.setInspectorId(importInspectorId);
newRule.setPqcRuleCode(serialNumberControllerService.generateSerialNumber(40)); newRule.setPqcRuleCode(serialNumberControllerService.generateSerialNumber(40));
newRule.setRuleVersion(1); newRule.setRuleVersion(1);
newRule.setIsDisabled(true); newRule.setIsDisabled(true);
@ -882,16 +861,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
targetRuleId = highestRule.getId(); targetRuleId = highestRule.getId();
} }
if (importInspectorId != null) {
ruleService.lambdaUpdate()
.eq(QmsPqcInspectionRule::getId, targetRuleId)
.set(QmsPqcInspectionRule::getInspectorId, importInspectorId)
.set(QmsPqcInspectionRule::getUpdateBy, operatorId)
.set(QmsPqcInspectionRule::getUpdateName, operator)
.set(QmsPqcInspectionRule::getUpdateTime, now)
.update();
}
// (步装名称 + 检查点编号) 分组构建检查点和检查项的层级结构 // (步装名称 + 检查点编号) 分组构建检查点和检查项的层级结构
// 使用 "stepName|inspectionPointCode" 作为分组key // 使用 "stepName|inspectionPointCode" 作为分组key
Map<String, List<PqcInspectionRuleImportDTO>> pointGroups = modelRows.stream() Map<String, List<PqcInspectionRuleImportDTO>> pointGroups = modelRows.stream()
@ -1180,7 +1149,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
LambdaQueryWrapper<QmsPqcInspectionRule> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<QmsPqcInspectionRule> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.like(StrUtil.isNotBlank(qo.getModelNo()), QmsPqcInspectionRule::getModelNo, qo.getModelNo()) queryWrapper.like(StrUtil.isNotBlank(qo.getModelNo()), QmsPqcInspectionRule::getModelNo, qo.getModelNo())
.like(StrUtil.isNotBlank(qo.getPqcRuleCode()), QmsPqcInspectionRule::getPqcRuleCode, qo.getPqcRuleCode()) .like(StrUtil.isNotBlank(qo.getPqcRuleCode()), QmsPqcInspectionRule::getPqcRuleCode, qo.getPqcRuleCode())
.eq(Objects.nonNull(qo.getInspectorId()), QmsPqcInspectionRule::getInspectorId, qo.getInspectorId())
.eq(Objects.nonNull(qo.getIsDisabled()), QmsPqcInspectionRule::getIsDisabled, qo.getIsDisabled()) .eq(Objects.nonNull(qo.getIsDisabled()), QmsPqcInspectionRule::getIsDisabled, qo.getIsDisabled())
.eq(Objects.nonNull(qo.getAuditStatus()), QmsPqcInspectionRule::getAuditStatus, qo.getAuditStatus()) .eq(Objects.nonNull(qo.getAuditStatus()), QmsPqcInspectionRule::getAuditStatus, qo.getAuditStatus())
.ge(StrUtil.isNotBlank(qo.getCreateTimeStart()), QmsPqcInspectionRule::getCreateTime, qo.getCreateTimeStart()) .ge(StrUtil.isNotBlank(qo.getCreateTimeStart()), QmsPqcInspectionRule::getCreateTime, qo.getCreateTimeStart())
@ -1207,7 +1175,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
for (QmsPqcInspectionPointItems item : items) { for (QmsPqcInspectionPointItems item : items) {
PqcInspectionRuleExportDTO dto = new PqcInspectionRuleExportDTO(); PqcInspectionRuleExportDTO dto = new PqcInspectionRuleExportDTO();
dto.setModelNo(rule.getModelNo()); dto.setModelNo(rule.getModelNo());
dto.setInspectorId(rule.getInspectorId());
dto.setStepName(point.getStepName()); dto.setStepName(point.getStepName());
dto.setInspectionPointCode(point.getInspectionPointCode()); dto.setInspectionPointCode(point.getInspectionPointCode());
dto.setInspectionPointName(point.getInspectionPointName()); dto.setInspectionPointName(point.getInspectionPointName());
@ -1256,7 +1223,6 @@ public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspecti
public void downloadTemplate(HttpServletResponse response) throws IOException { public void downloadTemplate(HttpServletResponse response) throws IOException {
PqcInspectionRuleImportTemplateDTO example = new PqcInspectionRuleImportTemplateDTO() PqcInspectionRuleImportTemplateDTO example = new PqcInspectionRuleImportTemplateDTO()
.setModelNo("示例机型编号") .setModelNo("示例机型编号")
.setInspectorId(1L)
.setStepName("示例步装名称") .setStepName("示例步装名称")
.setInspectionPointCode("示例检查点编号") .setInspectionPointCode("示例检查点编号")
.setInspectionPointName("示例检查点名称") .setInspectionPointName("示例检查点名称")

View File

@ -23,7 +23,6 @@ public class PqcInspectionRuleExportDTO {
* 质检员ID * 质检员ID
*/ */
@ExcelColumn("质检员ID") @ExcelColumn("质检员ID")
private Long inspectorId;
/** /**
* 步装名称 * 步装名称

View File

@ -22,7 +22,6 @@ public class PqcInspectionRuleImportDTO {
* 质检员ID * 质检员ID
*/ */
@ExcelColumn("质检员ID") @ExcelColumn("质检员ID")
private Long inspectorId;
/** /**
* 步装名称必填 * 步装名称必填

View File

@ -15,7 +15,6 @@ public class PqcInspectionRuleImportTemplateDTO {
private String modelNo; private String modelNo;
@ExcelColumn("质检员ID") @ExcelColumn("质检员ID")
private Long inspectorId;
@ExcelColumn("步装名称*") @ExcelColumn("步装名称*")
private String stepName; private String stepName;

View File

@ -22,8 +22,6 @@ public class PqcInspectionRuleExportQO {
private String pqcRuleCode; private String pqcRuleCode;
private Long inspectorId;
private Boolean isDisabled; private Boolean isDisabled;
private Integer auditStatus; private Integer auditStatus;

View File

@ -35,12 +35,6 @@ public class QmsPqcInspectionRule implements Serializable {
* 机型编号 * 机型编号
*/ */
private String modelNo; private String modelNo;
/**
* 质检员id
*/
private Long inspectorId;
/** /**
* 规则编号 * 规则编号
*/ */

View File

@ -17,7 +17,6 @@ import com.nflg.wms.common.pojo.vo.*;
import com.nflg.wms.common.util.UserUtil; import com.nflg.wms.common.util.UserUtil;
import com.nflg.wms.repository.entity.QmsInspectorMaterialCategoryItem; import com.nflg.wms.repository.entity.QmsInspectorMaterialCategoryItem;
import com.nflg.wms.repository.entity.QmsInspectorMaterialItem; import com.nflg.wms.repository.entity.QmsInspectorMaterialItem;
import com.nflg.wms.repository.entity.QmsPqcInspectionRule;
import com.nflg.wms.repository.entity.QmsQcMaterialCategory; import com.nflg.wms.repository.entity.QmsQcMaterialCategory;
import com.nflg.wms.repository.entity.QmsQualityInspector; import com.nflg.wms.repository.entity.QmsQualityInspector;
import com.nflg.wms.repository.entity.User; import com.nflg.wms.repository.entity.User;
@ -32,7 +31,6 @@ import com.nflg.wms.repository.service.IPositionService;
import com.nflg.wms.repository.service.IUserInteriorService; import com.nflg.wms.repository.service.IUserInteriorService;
import com.nflg.wms.repository.service.IQmsQcMaterialCategoryService; import com.nflg.wms.repository.service.IQmsQcMaterialCategoryService;
import com.nflg.wms.repository.service.IQmsQualityInspectorService; import com.nflg.wms.repository.service.IQmsQualityInspectorService;
import com.nflg.wms.repository.service.IQmsPqcInspectionRuleService;
import com.nflg.wms.repository.service.IUserService; import com.nflg.wms.repository.service.IUserService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -75,10 +73,6 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
@Resource @Resource
private IPositionService positionService; private IPositionService positionService;
@Resource
private IQmsPqcInspectionRuleService pqcInspectionRuleService;
// ========================= 工具方法 ========================= // ========================= 工具方法 =========================
/** /**
@ -94,108 +88,6 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
return categories.stream() return categories.stream()
.collect(Collectors.toMap(QmsQcMaterialCategory::getCategoryCode, QmsQcMaterialCategory::getId)); .collect(Collectors.toMap(QmsQcMaterialCategory::getCategoryCode, QmsQcMaterialCategory::getId));
} }
private List<String> normalizeModelNos(List<String> modelNos) {
if (CollectionUtils.isEmpty(modelNos)) {
return Collections.emptyList();
}
return modelNos.stream()
.filter(Objects::nonNull)
.map(String::trim)
.filter(modelNo -> !modelNo.isEmpty())
.distinct()
.collect(Collectors.toList());
}
private void savePqcModelBindings(Long inspectorId, List<String> modelNos) {
List<String> normalizedModelNos = normalizeModelNos(modelNos);
if (!normalizedModelNos.isEmpty()) {
List<String> existingModelNos = pqcInspectionRuleService.lambdaQuery()
.in(QmsPqcInspectionRule::getModelNo, normalizedModelNos)
.list()
.stream()
.map(QmsPqcInspectionRule::getModelNo)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (existingModelNos.size() != normalizedModelNos.size()) {
List<String> missingModelNos = normalizedModelNos.stream()
.filter(modelNo -> !existingModelNos.contains(modelNo))
.collect(Collectors.toList());
throw new NflgException(STATE.BusinessError, "PQC机型规则不存在" + String.join(",", missingModelNos));
}
}
pqcInspectionRuleService.lambdaUpdate()
.eq(QmsPqcInspectionRule::getInspectorId, inspectorId)
.set(QmsPqcInspectionRule::getInspectorId, null)
.update();
if (normalizedModelNos.isEmpty()) {
return;
}
pqcInspectionRuleService.lambdaUpdate()
.in(QmsPqcInspectionRule::getModelNo, normalizedModelNos)
.set(QmsPqcInspectionRule::getInspectorId, inspectorId)
.set(QmsPqcInspectionRule::getUpdateBy, UserUtil.getUserId())
.set(QmsPqcInspectionRule::getUpdateName, UserUtil.getUserName())
.set(QmsPqcInspectionRule::getUpdateTime, LocalDateTime.now())
.update();
}
private List<QmsQualityInspectorPqcModelVO> getPqcModelsByInspectorId(Long inspectorId) {
if (inspectorId == null) {
return Collections.emptyList();
}
return pqcInspectionRuleService.lambdaQuery()
.eq(QmsPqcInspectionRule::getInspectorId, inspectorId)
.orderByAsc(QmsPqcInspectionRule::getModelNo)
.list()
.stream()
.map(rule -> {
QmsQualityInspectorPqcModelVO vo = new QmsQualityInspectorPqcModelVO();
vo.setPqcRuleId(rule.getId());
vo.setModelNo(rule.getModelNo());
vo.setPqcRuleCode(rule.getPqcRuleCode());
vo.setRuleVersion(rule.getRuleVersion());
return vo;
})
.collect(Collectors.toList());
}
private void fillPqcModelNos(List<QmsQualityInspectorVO> records) {
if (CollectionUtils.isEmpty(records)) {
return;
}
List<Long> inspectorIds = records.stream()
.filter(vo -> Objects.equals(vo.getInspectionType(), 2))
.map(QmsQualityInspectorVO::getId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (inspectorIds.isEmpty()) {
return;
}
Map<Long, List<String>> modelNoMap = pqcInspectionRuleService.lambdaQuery()
.in(QmsPqcInspectionRule::getInspectorId, inspectorIds)
.list()
.stream()
.collect(Collectors.groupingBy(
QmsPqcInspectionRule::getInspectorId,
Collectors.mapping(QmsPqcInspectionRule::getModelNo,
Collectors.collectingAndThen(Collectors.toList(), modelNos -> modelNos.stream()
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList())))
));
records.forEach(vo -> {
if (Objects.equals(vo.getInspectionType(), 2)) {
vo.setPqcModelNos(modelNoMap.getOrDefault(vo.getId(), Collections.emptyList()));
}
});
}
private QmsQualityInspector getPqcInspector(Long id) { private QmsQualityInspector getPqcInspector(Long id) {
QmsQualityInspector inspector = getById(id); QmsQualityInspector inspector = getById(id);
if (Objects.isNull(inspector)) { if (Objects.isNull(inspector)) {
@ -339,8 +231,6 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
.setUpdateBy(operator) .setUpdateBy(operator)
.setUpdateTime(now); .setUpdateTime(now);
save(inspector); save(inspector);
savePqcModelBindings(inspector.getId(), request.getModelNos());
} }
// ========================= 删除 ========================= // ========================= 删除 =========================
@ -364,12 +254,6 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
materialCategoryItemService.lambdaUpdate() materialCategoryItemService.lambdaUpdate()
.eq(QmsInspectorMaterialCategoryItem::getInspectorId, id) .eq(QmsInspectorMaterialCategoryItem::getInspectorId, id)
.remove(); .remove();
if (Objects.equals(inspector.getInspectionType(), 2)) {
pqcInspectionRuleService.lambdaUpdate()
.eq(QmsPqcInspectionRule::getInspectorId, inspector.getId())
.set(QmsPqcInspectionRule::getInspectorId, null)
.update();
}
// 删除主表 // 删除主表
removeById(id); removeById(id);
} }
@ -488,7 +372,6 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
@Override @Override
public void updatePqc(QmsQualityInspectorPqcUpdateQO request) { public void updatePqc(QmsQualityInspectorPqcUpdateQO request) {
QmsQualityInspector inspector = getPqcInspector(request.getId()); QmsQualityInspector inspector = getPqcInspector(request.getId());
savePqcModelBindings(inspector.getId(), request.getModelNos());
lambdaUpdate() lambdaUpdate()
.eq(QmsQualityInspector::getId, request.getId()) .eq(QmsQualityInspector::getId, request.getId())
.set(QmsQualityInspector::getUpdateBy, UserUtil.getUserName()) .set(QmsQualityInspector::getUpdateBy, UserUtil.getUserName())
@ -501,7 +384,6 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
@Override @Override
public IPage<QmsQualityInspectorVO> search(QmsQualityInspectorSearchQO request) { public IPage<QmsQualityInspectorVO> search(QmsQualityInspectorSearchQO request) {
IPage<QmsQualityInspectorVO> page = baseMapper.searchPage(request, new Page<>(request.getPage(), request.getPageSize())); IPage<QmsQualityInspectorVO> page = baseMapper.searchPage(request, new Page<>(request.getPage(), request.getPageSize()));
fillPqcModelNos(page.getRecords());
return page; return page;
} }
@ -571,7 +453,7 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
} }
detail.setMaterials(Collections.emptyList()); detail.setMaterials(Collections.emptyList());
detail.setCategories(Collections.emptyList()); detail.setCategories(Collections.emptyList());
detail.setPqcModels(getPqcModelsByInspectorId(inspector.getId())); detail.setPqcModels(Collections.emptyList());
return detail; return detail;
} }

View File

@ -48,14 +48,6 @@
AND m.material_no ilike concat('%', #{request.materialNo}, '%') AND m.material_no ilike concat('%', #{request.materialNo}, '%')
) )
</if> </if>
<if test="request.pqcModelNo != null and request.pqcModelNo != ''">
AND EXISTS (
SELECT 1
FROM qms_pqc_inspection_rule pir
WHERE pir.inspector_id = qi.id
AND pir.model_no ilike concat('%', #{request.pqcModelNo}, '%')
)
</if>
<if test="request.inspectionType != null"> <if test="request.inspectionType != null">
AND qi.inspection_type = #{request.inspectionType} AND qi.inspection_type = #{request.inspectionType}
</if> </if>