云
2026-10-25 d54fbc9d4f8981fa0f7f613b33a28a8cd4f764ea
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/template/MesQcTemplateItemServiceImpl.java
@@ -28,7 +28,7 @@
/**
 * MES 质检方案-产品关联 Service 实现类
 *
 * @author 芋道源码
 * @author 超级管理员
 */
@Service
@Validated
@@ -116,9 +116,17 @@
    @Override
    public MesQcTemplateItemDO getRequiredTemplateByItemIdAndType(Long itemId, Integer qcType) {
        if (itemId == null) {
            throw exception(QC_NO_TEMPLATE);
        }
        // 1. 查出 itemId 关联的所有 templateItem
        MesMdItemDO item1 = mesMdItemService.getItem(itemId);
        List<MesQcTemplateItemDO> templateItems = templateItemMapper.selectListByItemId(item1.getMdmItemId());
        // 兼容两套物料 ID:质检/仓储单据传入 mdm_item.id,PRO 工单/任务传入 mes_md_item.id
        Long templateItemId = itemId;
        MesMdItemDO mesItem = mesMdItemService.getItem(itemId);
        if (mesItem != null && mesItem.getMdmItemId() != null) {
            templateItemId = mesItem.getMdmItemId();
        }
        List<MesQcTemplateItemDO> templateItems = templateItemMapper.selectListByItemId(templateItemId);
        if (CollUtil.isEmpty(templateItems)) {
            throw exception(QC_NO_TEMPLATE);
        }