From 2976e1e20ef35775630a11f9fc7563ab5b6216f0 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期五, 30 十月 2026 19:12:29 +0800
Subject: [PATCH] fix(api): 修复全量接口测试发现的 500 系统异常
---
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/template/MesQcTemplateItemController.java | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/template/MesQcTemplateItemController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/template/MesQcTemplateItemController.java
index 32562ac..e1a8ad1 100644
--- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/template/MesQcTemplateItemController.java
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/template/MesQcTemplateItemController.java
@@ -1,17 +1,21 @@
package cn.iocoder.yudao.module.mes.controller.admin.qc.template;
+import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemOptionRespVO;
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.MesQcTemplateItemRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.mdm.MesMdmItemDO;
import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO;
+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.service.mdm.MesMdmItemService;
import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService;
import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateItemService;
+import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -23,6 +27,8 @@
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@@ -37,6 +43,8 @@
@Resource
private MesQcTemplateItemService templateItemService;
+ @Resource
+ private MesQcTemplateService templateService;
@Resource
private MesMdmItemService mdmItemService;
@Resource
@@ -72,6 +80,9 @@
@PreAuthorize("@ss.hasPermission('mes:qc-template:query')")
public CommonResult<MesQcTemplateItemRespVO> getTemplateItem(@RequestParam("id") Long id) {
MesQcTemplateItemDO item = templateItemService.getTemplateItem(id);
+ if (item == null) {
+ return success(null);
+ }
return success(buildItemRespVOList(Collections.singletonList(item)).get(0));
}
@@ -84,10 +95,40 @@
return success(new PageResult<>(buildItemRespVOList(pageResult.getList()), pageResult.getTotal()));
}
+ @GetMapping("/list-by-item-and-type")
+ @Operation(summary = "鏍规嵁鐗╂枡鎴栧伐鍗�/浠诲姟鍜屾娴嬬绫昏幏鍙栧彲鐢ㄨ川妫�鏂规")
+ @PreAuthorize("@ss.hasPermission('mes:qc-template:query')")
+ public CommonResult<List<MesQcTemplateItemOptionRespVO>> getTemplateItemOptionList(
+ @RequestParam(value = "qcType", required = false) Integer qcType,
+ @RequestParam(value = "itemId", required = false) Long itemId,
+ @RequestParam(value = "workOrderId", required = false) Long workOrderId,
+ @RequestParam(value = "taskId", required = false) Long taskId) {
+ List<MesQcTemplateItemDO> list = templateItemService.getTemplateItemList(
+ itemId, qcType, workOrderId, taskId);
+ if (CollUtil.isEmpty(list)) {
+ return success(Collections.emptyList());
+ }
+ Map<Long, MesQcTemplateDO> templateMap = templateService.getTemplateMap(
+ convertSet(list, MesQcTemplateItemDO::getTemplateId));
+ List<MesQcTemplateItemOptionRespVO> result = BeanUtils.toBean(list,
+ MesQcTemplateItemOptionRespVO.class, vo -> {
+ MesQcTemplateDO template = templateMap.get(vo.getTemplateId());
+ if (template != null) {
+ vo.setTemplateCode(template.getCode()).setTemplateName(template.getName());
+ }
+ });
+ return success(result);
+ }
+
// ==================== 鎷兼帴 VO ====================
private List<MesQcTemplateItemRespVO> buildItemRespVOList(List<MesQcTemplateItemDO> list) {
- if (list.isEmpty()) {
+ // 杩囨护 null 鍏冪礌锛氬崟鏉� get 鏌ヤ笉鍒版椂浼犲叆鐨勬槸 [null]锛屽惁鍒� convertSet 浼� NPE
+ if (CollUtil.isEmpty(list)) {
+ return Collections.emptyList();
+ }
+ list = list.stream().filter(Objects::nonNull).collect(Collectors.toList());
+ if (CollUtil.isEmpty(list)) {
return Collections.emptyList();
}
// 鎵归噺鏌ヨ鐗╂枡锛坕temId 瀛樼殑鏄� mdm_item_id锛屽叧鑱� mdm_item 琛級
--
Gitblit v1.9.3