From de0202274ed147e89fdbba0a953936a3b9997ec7 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 22 九月 2026 17:37:50 +0800
Subject: [PATCH] feat(mes): 更新IPQC过程检验功能
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/template/MesQcTemplateItemServiceImpl.java | 42 ++++++++++++++++++++++++++----------------
1 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/template/MesQcTemplateItemServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/template/MesQcTemplateItemServiceImpl.java
index 5d6bb01..7a3d219 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/template/MesQcTemplateItemServiceImpl.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/template/MesQcTemplateItemServiceImpl.java
@@ -7,18 +7,19 @@
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemSaveReqVO;
-import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateItemDO;
import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateItemMapper;
-import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
import jakarta.annotation.Resource;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
+import java.util.Collections;
import java.util.List;
import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@@ -40,8 +41,6 @@
@Resource
@Lazy
private MesQcTemplateService templateService;
- @Resource
- private MesMdItemService mesMdItemService;
@Override
public Long createTemplateItem(MesQcTemplateItemSaveReqVO createReqVO) {
@@ -116,23 +115,34 @@
@Override
public MesQcTemplateItemDO getRequiredTemplateByItemIdAndType(Long itemId, Integer qcType) {
- // 1. 鏌ュ嚭 itemId 鍏宠仈鐨勬墍鏈� templateItem
- MesMdItemDO item1 = mesMdItemService.getItem(itemId);
- List<MesQcTemplateItemDO> templateItems = templateItemMapper.selectListByItemId(item1.getMdmItemId());
+ List<MesQcTemplateItemDO> templateItems = getTemplateItemList(itemId, qcType);
if (CollUtil.isEmpty(templateItems)) {
throw exception(QC_NO_TEMPLATE);
}
- // 2. 绛涢�� types 鍖呭惈 qcType 涓旂姸鎬佷负寮�鍚殑妯℃澘
+ return templateItems.get(0);
+ }
+
+ @Override
+ public List<MesQcTemplateItemDO> getTemplateItemList(Long itemId, Integer qcType) {
+ // 1. 浜у搧鍏宠仈琛� item_id 瀛樼殑鏄� MDM 鐗╂枡 ID锛坢dm_item.id锛夛紝璐ㄦ渚х粺涓�鎸� MDM 鐗╂枡鏌ヨ
+ if (itemId == null) {
+ return Collections.emptyList();
+ }
+ List<MesQcTemplateItemDO> templateItems = templateItemMapper.selectListByItemId(itemId);
+ if (CollUtil.isEmpty(templateItems)) {
+ return Collections.emptyList();
+ }
+ // 2. 杩囨护锛氭柟妗堝惎鐢ㄤ笖妫�娴嬬绫诲寘鍚� qcType锛岃繑鍥炲叏閮ㄥ尮閰嶉」
List<MesQcTemplateDO> templates = templateService.getTemplateList(
convertSet(templateItems, MesQcTemplateItemDO::getTemplateId));
- MesQcTemplateDO matchedTemplate = findFirst(templates,
- t -> CommonStatusEnum.isEnable(t.getStatus()) && CollUtil.contains(t.getTypes(), qcType));
- if (matchedTemplate == null) {
- throw exception(QC_NO_TEMPLATE);
- }
- // 3. 杩斿洖瀵瑰簲鐨� templateItem
- return findFirst(templateItems,
- item -> Objects.equals(item.getTemplateId(), matchedTemplate.getId()));
+ Set<Long> matchedTemplateIds = templates.stream()
+ .filter(t -> CommonStatusEnum.isEnable(t.getStatus())
+ && CollUtil.contains(t.getTypes(), qcType))
+ .map(MesQcTemplateDO::getId)
+ .collect(Collectors.toSet());
+ return templateItems.stream()
+ .filter(t -> matchedTemplateIds.contains(t.getTemplateId()))
+ .collect(Collectors.toList());
}
}
--
Gitblit v1.9.3