Commit 34061f903c192ee82b55c3b524ce8c7e756e754f

Authored by YunaiV
1 parent 6ef9907c

feat(mes): refactor inspection result types and add new result detail structure

Showing 22 changed files with 580 additions and 642 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/defect/vo/MesQcDefectRespVO.java
... ... @@ -29,7 +29,7 @@ public class MesQcDefectRespVO {
29 29  
30 30 @Schema(description = "检测项类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "APPEARANCE")
31 31 @ExcelProperty(value = "检测项类型", converter = DictConvert.class)
32   - @DictFormat(DictTypeConstants.MES_INDEX_TYPE)
  32 + @DictFormat(DictTypeConstants.MES_INDICATOR_TYPE)
33 33 private String type;
34 34  
35 35 @Schema(description = "缺陷等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicator/vo/MesQcIndicatorRespVO.java
... ... @@ -29,7 +29,7 @@ public class MesQcIndicatorRespVO {
29 29  
30 30 @Schema(description = "检测项类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "SIZE")
31 31 @ExcelProperty(value = "检测项类型", converter = DictConvert.class)
32   - @DictFormat(DictTypeConstants.MES_INDEX_TYPE)
  32 + @DictFormat(DictTypeConstants.MES_INDICATOR_TYPE)
33 33 private String type;
34 34  
35 35 @Schema(description = "检测工具", example = "卡尺")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/MesQcIndicatorResultController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  7 +import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.*;
  8 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
  9 +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO;
  10 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO;
  11 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDO;
  12 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDetailDO;
  13 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.lqc.MesQcIqcDO;
  14 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.lqc.MesQcIqcLineDO;
  15 +import cn.iocoder.yudao.module.mes.dal.dataobject.tm.tool.MesTmToolDO;
  16 +import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
  17 +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
  18 +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService;
  19 +import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService;
  20 +import cn.iocoder.yudao.module.mes.service.qc.indicatorresult.MesQcIndicatorResultService;
  21 +import cn.iocoder.yudao.module.mes.service.qc.lqc.MesQcIqcLineService;
  22 +import cn.iocoder.yudao.module.mes.service.qc.lqc.MesQcIqcService;
  23 +import cn.iocoder.yudao.module.mes.service.tm.tool.MesTmToolService;
  24 +import io.swagger.v3.oas.annotations.Operation;
  25 +import io.swagger.v3.oas.annotations.Parameter;
  26 +import io.swagger.v3.oas.annotations.Parameters;
  27 +import io.swagger.v3.oas.annotations.tags.Tag;
  28 +import jakarta.annotation.Resource;
  29 +import jakarta.validation.Valid;
  30 +import org.springframework.security.access.prepost.PreAuthorize;
  31 +import org.springframework.validation.annotation.Validated;
  32 +import org.springframework.web.bind.annotation.*;
  33 +
  34 +import java.util.*;
  35 +
  36 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  37 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
  38 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  39 +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
  40 +
  41 +@Tag(name = "管理后台 - MES 检验结果")
  42 +@RestController
  43 +@RequestMapping("/mes/qc/indicator-result")
  44 +@Validated
  45 +public class MesQcIndicatorResultController {
  46 +
  47 + @Resource
  48 + private MesQcIndicatorResultService resultService;
  49 + @Resource
  50 + private MesQcIqcService iqcService;
  51 + @Resource
  52 + private MesQcIqcLineService iqcLineService;
  53 + @Resource
  54 + private MesMdItemService itemService;
  55 + @Resource
  56 + private MesMdUnitMeasureService unitMeasureService;
  57 + @Resource
  58 + private MesQcIndicatorService indicatorService;
  59 + @Resource
  60 + private MesTmToolService toolService;
  61 +
  62 + @PostMapping("/create")
  63 + @Operation(summary = "创建检验结果")
  64 + @PreAuthorize("@ss.hasPermission('mes:qc-iqc:create')")
  65 + public CommonResult<Long> createIndicatorResult(@Valid @RequestBody MesQcIndicatorResultSaveReqVO createReqVO) {
  66 + return success(resultService.createIndicatorResult(createReqVO));
  67 + }
  68 +
  69 + @PutMapping("/update")
  70 + @Operation(summary = "更新检验结果")
  71 + @PreAuthorize("@ss.hasPermission('mes:qc-iqc:update')")
  72 + public CommonResult<Boolean> updateIndicatorResult(@Valid @RequestBody MesQcIndicatorResultSaveReqVO updateReqVO) {
  73 + resultService.updateIndicatorResult(updateReqVO);
  74 + return success(true);
  75 + }
  76 +
  77 + @DeleteMapping("/delete")
  78 + @Operation(summary = "删除检验结果")
  79 + @Parameter(name = "id", description = "编号", required = true)
  80 + @PreAuthorize("@ss.hasPermission('mes:qc-iqc:delete')")
  81 + public CommonResult<Boolean> deleteIndicatorResult(@RequestParam("id") Long id) {
  82 + resultService.deleteIndicatorResult(id);
  83 + return success(true);
  84 + }
  85 +
  86 + // TODO @AI:是不是把 get 和 getIndicatorResultDetailTemplate 合并为一个接口?参数是 qcId + qcType;新的接口是 get-detail;
  87 + @GetMapping("/get")
  88 + @Operation(summary = "获得检验结果(含明细)")
  89 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  90 + @PreAuthorize("@ss.hasPermission('mes:qc-iqc:query')")
  91 + public CommonResult<MesQcIndicatorResultRespVO> getIndicatorResult(@RequestParam("id") Long id) {
  92 + MesQcIndicatorResultDO result = resultService.getIndicatorResult(id);
  93 + if (result == null) {
  94 + return success(null);
  95 + }
  96 + // 构建 RespVO(含关联字段)
  97 + MesQcIndicatorResultRespVO respVO = buildIndicatorResultRespVOList(Collections.singletonList(result)).get(0);
  98 + // 查询明细并组装
  99 + List<MesQcIndicatorResultDetailDO> details = resultService.getIndicatorResultDetailListByResultId(result.getId());
  100 + respVO.setItems(buildDetailItemList(details, result.getQcId(), result.getQcType()));
  101 + return success(respVO);
  102 + }
  103 +
  104 + @GetMapping("/page")
  105 + @Operation(summary = "获得检验结果分页")
  106 + @PreAuthorize("@ss.hasPermission('mes:qc-iqc:query')")
  107 + public CommonResult<PageResult<MesQcIndicatorResultRespVO>> getIndicatorResultPage(@Valid MesQcIndicatorResultPageReqVO pageReqVO) {
  108 + PageResult<MesQcIndicatorResultDO> pageResult = resultService.getIndicatorResultPage(pageReqVO);
  109 + return success(new PageResult<>(buildIndicatorResultRespVOList(pageResult.getList()), pageResult.getTotal()));
  110 + }
  111 +
  112 + @GetMapping("/detail-template")
  113 + @Operation(summary = "获取空值检测项模板")
  114 + @Parameters({
  115 + @Parameter(name = "qcId", description = "质检单ID", required = true, example = "1"),
  116 + @Parameter(name = "qcType", description = "质检类型", required = true, example = "1")
  117 + })
  118 + @PreAuthorize("@ss.hasPermission('mes:qc-iqc:query')")
  119 + public CommonResult<List<MesQcIndicatorResultRespVO.Item>> getIndicatorResultDetailTemplate(
  120 + @RequestParam("qcId") Long qcId,
  121 + @RequestParam("qcType") Integer qcType) {
  122 + return success(buildDetailItemList(Collections.emptyList(), qcId, qcType));
  123 + }
  124 +
  125 + // ==================== 拼接 VO ====================
  126 +
  127 + /**
  128 + * 构建主表 RespVO 列表(拼接物料、质检单等关联信息)
  129 + */
  130 + private List<MesQcIndicatorResultRespVO> buildIndicatorResultRespVOList(List<MesQcIndicatorResultDO> list) {
  131 + if (CollUtil.isEmpty(list)) {
  132 + return Collections.emptyList();
  133 + }
  134 + // 批量查询物料
  135 + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(
  136 + convertSet(list, MesQcIndicatorResultDO::getItemId));
  137 + // 批量查询计量单位
  138 + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap(
  139 + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId));
  140 + // 批量查询 IQC 质检单
  141 + Set<Long> iqcIds = convertSet(list, r ->
  142 + Objects.equals(r.getQcType(), MesQcTypeEnum.IQC.getType()) ? r.getQcId() : null);
  143 + iqcIds.remove(null);
  144 + Map<Long, MesQcIqcDO> iqcMap = iqcService.getIqcMap(iqcIds);
  145 +
  146 + // 拼装 VO
  147 + return BeanUtils.toBean(list, MesQcIndicatorResultRespVO.class, vo -> {
  148 + // 拼接物料信息
  149 + findAndThen(itemMap, vo.getItemId(), item -> {
  150 + vo.setItemCode(item.getCode()).setItemName(item.getName()).setItemSpecification(item.getSpecification());
  151 + findAndThen(unitMeasureMap, item.getUnitMeasureId(),
  152 + unit -> vo.setUnitName(unit.getName()));
  153 + });
  154 + // 拼接质检单编号/名称
  155 + if (Objects.equals(vo.getQcType(), MesQcTypeEnum.IQC.getType())) {
  156 + findAndThen(iqcMap, vo.getQcId(), iqc ->
  157 + vo.setQcCode(iqc.getCode()).setQcName(iqc.getName()));
  158 + }
  159 + // TODO @芋艿:IPQC/OQC/RQC 模块迁移后实现
  160 + });
  161 + }
  162 +
  163 + /**
  164 + * 构建明细 Item 列表:从 IQC line + indicator + tool + unitMeasure + 已有结果明细组装
  165 + *
  166 + * @param details 已有结果明细(空列表表示获取空值模板)
  167 + * @param qcId 质检单 ID
  168 + * @param qcType 质检类型
  169 + */
  170 + private List<MesQcIndicatorResultRespVO.Item> buildDetailItemList(
  171 + List<MesQcIndicatorResultDetailDO> details, Long qcId, Integer qcType) {
  172 + // 1. 获取检验单行列表
  173 + List<MesQcIqcLineDO> lines;
  174 + if (Objects.equals(qcType, MesQcTypeEnum.IQC.getType())) {
  175 + lines = iqcLineService.getIqcLineListByIqcId(qcId);
  176 + } else {
  177 + // TODO @芋艿:IPQC/OQC/RQC 模块迁移后实现
  178 + return Collections.emptyList();
  179 + }
  180 + if (CollUtil.isEmpty(lines)) {
  181 + return Collections.emptyList();
  182 + }
  183 +
  184 + // 2. 批量查询关联信息
  185 + Map<Long, MesQcIndicatorDO> indicatorMap = indicatorService.getIndicatorMap(
  186 + convertSet(lines, MesQcIqcLineDO::getIndicatorId));
  187 + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap(
  188 + convertSet(lines, MesQcIqcLineDO::getUnitMeasureId));
  189 +
  190 + // 3. 构建已有明细 Map(按 indicatorId 索引)
  191 + Map<Long, MesQcIndicatorResultDetailDO> detailMap = CollUtil.isEmpty(details)
  192 + ? Collections.emptyMap()
  193 + : convertMap(details, MesQcIndicatorResultDetailDO::getIndicatorId);
  194 +
  195 + // 4. 遍历行,组装 VO
  196 + List<MesQcIndicatorResultRespVO.Item> voList = new ArrayList<>(lines.size());
  197 + for (MesQcIqcLineDO line : lines) {
  198 + MesQcIndicatorResultRespVO.Item vo = new MesQcIndicatorResultRespVO.Item();
  199 + // 来自 IQC line
  200 + vo.setIndicatorId(line.getIndicatorId());
  201 + vo.setCheckMethod(line.getCheckMethod());
  202 + vo.setStandardValue(line.getStandardValue());
  203 + vo.setMaxThreshold(line.getMaxThreshold());
  204 + vo.setMinThreshold(line.getMinThreshold());
  205 +
  206 + // 来自 indicator
  207 + findAndThen(indicatorMap, line.getIndicatorId(), indicator -> {
  208 + vo.setIndicatorCode(indicator.getCode());
  209 + vo.setIndicatorName(indicator.getName());
  210 + vo.setIndicatorType(indicator.getType());
  211 + vo.setValueType(indicator.getResultType());
  212 + vo.setValueSpecification(indicator.getResultSpecification());
  213 + });
  214 +
  215 + // 来自 unitMeasure
  216 + findAndThen(unitMeasureMap, line.getUnitMeasureId(),
  217 + unit -> vo.setUnitMeasureName(unit.getName()));
  218 +
  219 + // 来自 tool(逐个查询,数量通常较少)
  220 + if (line.getToolId() != null) {
  221 + MesTmToolDO tool = toolService.getTool(line.getToolId());
  222 + if (tool != null) {
  223 + vo.setToolName(tool.getName());
  224 + }
  225 + }
  226 +
  227 + // 来自已有结果明细(如有)
  228 + MesQcIndicatorResultDetailDO detail = detailMap.get(line.getIndicatorId());
  229 + if (detail != null) {
  230 + vo.setId(detail.getId());
  231 + vo.setResultId(detail.getResultId());
  232 + vo.setValue(detail.getValue());
  233 + vo.setRemark(detail.getRemark());
  234 + }
  235 +
  236 + voList.add(vo);
  237 + }
  238 + return voList;
  239 + }
  240 +
  241 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/MesQcResultController.java deleted
1   -package cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult;
2   -
3   -import cn.hutool.core.collection.CollUtil;
4   -import cn.iocoder.yudao.framework.common.pojo.CommonResult;
5   -import cn.iocoder.yudao.framework.common.pojo.PageResult;
6   -import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
7   -import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.*;
8   -import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
9   -import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO;
10   -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.lqc.MesQcIqcDO;
11   -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcResultDO;
12   -import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
13   -import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService;
14   -import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService;
15   -import cn.iocoder.yudao.module.mes.service.qc.lqc.MesQcIqcService;
16   -import cn.iocoder.yudao.module.mes.service.qc.indicatorresult.MesQcResultService;
17   -import io.swagger.v3.oas.annotations.Operation;
18   -import io.swagger.v3.oas.annotations.Parameter;
19   -import io.swagger.v3.oas.annotations.Parameters;
20   -import io.swagger.v3.oas.annotations.tags.Tag;
21   -import jakarta.annotation.Resource;
22   -import jakarta.validation.Valid;
23   -import org.springframework.security.access.prepost.PreAuthorize;
24   -import org.springframework.validation.annotation.Validated;
25   -import org.springframework.web.bind.annotation.*;
26   -
27   -import java.util.Collections;
28   -import java.util.List;
29   -import java.util.Map;
30   -import java.util.Objects;
31   -
32   -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
33   -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
34   -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
35   -
36   -@Tag(name = "管理后台 - MES 检验结果")
37   -@RestController
38   -@RequestMapping("/mes/qc/result")
39   -@Validated
40   -public class MesQcResultController {
41   -
42   - @Resource
43   - private MesQcResultService resultService;
44   - @Resource
45   - private MesQcIqcService iqcService;
46   - @Resource
47   - private MesMdItemService itemService;
48   - @Resource
49   - private MesMdUnitMeasureService unitMeasureService;
50   -
51   - @PostMapping("/create")
52   - @Operation(summary = "创建检验结果")
53   - @PreAuthorize("@ss.hasPermission('mes:qc-iqc:create')")
54   - public CommonResult<Long> createResult(@Valid @RequestBody MesQcResultSaveReqVO createReqVO) {
55   - return success(resultService.createResult(createReqVO));
56   - }
57   -
58   - @PutMapping("/update")
59   - @Operation(summary = "更新检验结果")
60   - @PreAuthorize("@ss.hasPermission('mes:qc-iqc:update')")
61   - public CommonResult<Boolean> updateResult(@Valid @RequestBody MesQcResultSaveReqVO updateReqVO) {
62   - resultService.updateResult(updateReqVO);
63   - return success(true);
64   - }
65   -
66   - @DeleteMapping("/delete")
67   - @Operation(summary = "删除检验结果")
68   - @Parameter(name = "id", description = "编号", required = true)
69   - @PreAuthorize("@ss.hasPermission('mes:qc-iqc:delete')")
70   - public CommonResult<Boolean> deleteResult(@RequestParam("id") Long id) {
71   - resultService.deleteResult(id);
72   - return success(true);
73   - }
74   -
75   - @GetMapping("/get")
76   - @Operation(summary = "获得检验结果(含明细)")
77   - @Parameter(name = "id", description = "编号", required = true, example = "1024")
78   - @PreAuthorize("@ss.hasPermission('mes:qc-iqc:query')")
79   - public CommonResult<MesQcResultRespVO> getResult(@RequestParam("id") Long id) {
80   - MesQcResultDO result = resultService.getResult(id);
81   - if (result == null) {
82   - return success(null);
83   - }
84   - // 构建 RespVO(含关联字段 + 明细列表)
85   - MesQcResultRespVO respVO = buildResultRespVOList(Collections.singletonList(result)).get(0);
86   - // 组装明细
87   - // TODO @AI:先查询下;然后在 buildResultRespVOList 统一 build;
88   - respVO.setItems(resultService.getResultDetailList(result.getId(), result.getQcId(), result.getQcType()));
89   - return success(respVO);
90   - }
91   -
92   - @GetMapping("/page")
93   - @Operation(summary = "获得检验结果分页")
94   - @PreAuthorize("@ss.hasPermission('mes:qc-iqc:query')")
95   - public CommonResult<PageResult<MesQcResultRespVO>> getResultPage(@Valid MesQcResultPageReqVO pageReqVO) {
96   - PageResult<MesQcResultDO> pageResult = resultService.getResultPage(pageReqVO);
97   - return success(new PageResult<>(buildResultRespVOList(pageResult.getList()), pageResult.getTotal()));
98   - }
99   -
100   - // TODO @AI:resultService.getDetailTemplate(qcId, qcType) 放在 controller 里弄啊;
101   - @GetMapping("/detail-template")
102   - @Operation(summary = "获取空值检测项模板")
103   - @Parameters({
104   - @Parameter(name = "qcId", description = "质检单ID", required = true, example = "1"),
105   - @Parameter(name = "qcType", description = "质检类型", required = true, example = "1")
106   - })
107   - @PreAuthorize("@ss.hasPermission('mes:qc-iqc:query')")
108   - public CommonResult<List<MesQcResultDetailRespVO>> getDetailTemplate(
109   - @RequestParam("qcId") Long qcId,
110   - @RequestParam("qcType") Integer qcType) {
111   - return success(resultService.getDetailTemplate(qcId, qcType));
112   - }
113   -
114   - // ==================== 拼接 VO ====================
115   -
116   - private List<MesQcResultRespVO> buildResultRespVOList(List<MesQcResultDO> list) {
117   - if (CollUtil.isEmpty(list)) {
118   - return Collections.emptyList();
119   - }
120   - // 批量查询物料
121   - Map<Long, MesMdItemDO> itemMap = itemService.getItemMap(
122   - convertSet(list, MesQcResultDO::getItemId));
123   - // 批量查询计量单位
124   - Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap(
125   - convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId));
126   - // 拼装 VO
127   - return BeanUtils.toBean(list, MesQcResultRespVO.class, vo -> {
128   - // 拼接物料信息
129   - findAndThen(itemMap, vo.getItemId(), item -> {
130   - vo.setItemCode(item.getCode()).setItemName(item.getName()).setItemSpecification(item.getSpecification());
131   - findAndThen(unitMeasureMap, item.getUnitMeasureId(),
132   - unit -> vo.setUnitName(unit.getName()));
133   - });
134   - // 拼接质检单编号/名称(根据 qcType 从对应服务获取)
135   - if (Objects.equals(vo.getQcType(), MesQcTypeEnum.IQC.getType())) {
136   - // TODO @AI:findAndThen 方式优化;
137   - MesQcIqcDO iqc = iqcService.getIqc(vo.getQcId());
138   - if (iqc != null) {
139   - vo.setQcCode(iqc.getCode()).setQcName(iqc.getName());
140   - }
141   - }
142   - // TODO @芋艿:IPQC/OQC/RQC 模块迁移后实现
143   - });
144   - }
145   -
146   -}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/vo/MesQcResultPageReqVO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/vo/MesQcIndicatorResultPageReqVO.java
... ... @@ -12,7 +12,7 @@ import lombok.ToString;
12 12 @Data
13 13 @EqualsAndHashCode(callSuper = true)
14 14 @ToString(callSuper = true)
15   -public class MesQcResultPageReqVO extends PageParam {
  15 +public class MesQcIndicatorResultPageReqVO extends PageParam {
16 16  
17 17 @Schema(description = "关联质检单ID", example = "1")
18 18 private Long qcId;
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/vo/MesQcResultRespVO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/vo/MesQcIndicatorResultRespVO.java
... ... @@ -3,12 +3,13 @@ package cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo;
3 3 import io.swagger.v3.oas.annotations.media.Schema;
4 4 import lombok.Data;
5 5  
  6 +import java.math.BigDecimal;
6 7 import java.time.LocalDateTime;
7 8 import java.util.List;
8 9  
9 10 @Schema(description = "管理后台 - MES 检验结果 Response VO")
10 11 @Data
11   -public class MesQcResultRespVO {
  12 +public class MesQcIndicatorResultRespVO {
12 13  
13 14 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
14 15 private Long id;
... ... @@ -36,28 +37,83 @@ public class MesQcResultRespVO {
36 37  
37 38 // ========== 关联查询字段 ==========
38 39  
39   - @Schema(description = "质检单编号(关联查询)", example = "IQC-001")
  40 + @Schema(description = "质检单编号", example = "IQC-001")
40 41 private String qcCode;
41 42  
42   - @Schema(description = "质检单名称(关联查询)", example = "xxx来料检验")
  43 + @Schema(description = "质检单名称", example = "xxx来料检验")
43 44 private String qcName;
44 45  
45   - @Schema(description = "产品物料编码(关联查询)", example = "ITEM-001")
  46 + @Schema(description = "产品物料编码", example = "ITEM-001")
46 47 private String itemCode;
47 48  
48   - @Schema(description = "产品物料名称(关联查询)", example = "电阻")
  49 + @Schema(description = "产品物料名称", example = "电阻")
49 50 private String itemName;
50 51  
51   - @Schema(description = "规格型号(关联查询)", example = "100Ω")
  52 + @Schema(description = "规格型号", example = "100Ω")
52 53 private String itemSpecification;
53 54  
54   - @Schema(description = "单位名称(关联查询)", example = "个")
  55 + @Schema(description = "单位名称", example = "个")
55 56 private String unitName;
56 57  
57 58 // ========== 子表:检验结果明细 ==========
58 59  
59   - // TODO @AI:内嵌进来,不用队里类文件;
60 60 @Schema(description = "检验结果明细列表")
61   - private List<MesQcResultDetailRespVO> items;
  61 + private List<Item> items;
  62 +
  63 + @Schema(description = "检验结果明细项")
  64 + @Data
  65 + public static class Item {
  66 +
  67 + @Schema(description = "编号", example = "1024")
  68 + private Long id;
  69 +
  70 + @Schema(description = "关联检验结果ID", example = "1")
  71 + private Long resultId;
  72 +
  73 + @Schema(description = "检测指标ID", example = "1")
  74 + private Long indicatorId;
  75 +
  76 + @Schema(description = "检测值(统一存为字符串)", example = "3.14")
  77 + private String value;
  78 +
  79 + @Schema(description = "备注", example = "无")
  80 + private String remark;
  81 +
  82 + // ========== 关联查询字段(来自 IQC line + indicator) ==========
  83 +
  84 + @Schema(description = "检测指标编码", example = "IDX-001")
  85 + private String indicatorCode;
  86 +
  87 + @Schema(description = "检测指标名称", example = "外观检查")
  88 + private String indicatorName;
  89 +
  90 + @Schema(description = "检测指标类型", example = "QUANTITATIVE")
  91 + private String indicatorType;
  92 +
  93 + @Schema(description = "质检值类型", example = "1")
  94 + private Integer valueType;
  95 +
  96 + @Schema(description = "值属性", example = "IMG")
  97 + private String valueSpecification;
  98 +
  99 + @Schema(description = "检测工具名称", example = "卡尺")
  100 + private String toolName;
  101 +
  102 + @Schema(description = "检测方法", example = "目视检查")
  103 + private String checkMethod;
  104 +
  105 + @Schema(description = "标准值", example = "10.0000")
  106 + private BigDecimal standardValue;
  107 +
  108 + @Schema(description = "计量单位名称", example = "mm")
  109 + private String unitMeasureName;
  110 +
  111 + @Schema(description = "误差上限", example = "10.5000")
  112 + private BigDecimal maxThreshold;
  113 +
  114 + @Schema(description = "误差下限", example = "9.5000")
  115 + private BigDecimal minThreshold;
  116 +
  117 + }
62 118  
63 119 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/vo/MesQcResultSaveReqVO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/vo/MesQcIndicatorResultSaveReqVO.java
1 1 package cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo;
2 2  
  3 +import cn.iocoder.yudao.framework.common.validation.InEnum;
  4 +import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
3 5 import io.swagger.v3.oas.annotations.media.Schema;
4 6 import jakarta.validation.constraints.NotNull;
5 7 import lombok.Data;
... ... @@ -8,7 +10,7 @@ import java.util.List;
8 10  
9 11 @Schema(description = "管理后台 - MES 检验结果创建/更新 Request VO")
10 12 @Data
11   -public class MesQcResultSaveReqVO {
  13 +public class MesQcIndicatorResultSaveReqVO {
12 14  
13 15 @Schema(description = "编号", example = "1024")
14 16 private Long id;
... ... @@ -20,8 +22,9 @@ public class MesQcResultSaveReqVO {
20 22 @NotNull(message = "关联质检单ID不能为空")
21 23 private Long qcId;
22 24  
23   - @Schema(description = "质检类型(1=IQC 2=IPQC 3=OQC 4=RQC)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  25 + @Schema(description = "质检类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
24 26 @NotNull(message = "质检类型不能为空")
  27 + @InEnum(MesQcTypeEnum.class)
25 28 private Integer qcType;
26 29  
27 30 @Schema(description = "物资SN", example = "SN-001")
... ... @@ -30,8 +33,25 @@ public class MesQcResultSaveReqVO {
30 33 @Schema(description = "备注", example = "无")
31 34 private String remark;
32 35  
33   - // TODO @AI:MesQcResultDetailSaveReqVO 内嵌进来;不用独立类;
34 36 @Schema(description = "检验结果明细列表")
35   - private List<MesQcResultDetailSaveReqVO> items;
  37 + private List<Item> items;
  38 +
  39 + @Schema(description = "检验结果明细项")
  40 + @Data
  41 + public static class Item {
  42 +
  43 + @Schema(description = "编号(更新时传入已有明细的 ID)", example = "1024")
  44 + private Long id;
  45 +
  46 + @Schema(description = "检测指标ID", example = "1")
  47 + private Long indicatorId;
  48 +
  49 + @Schema(description = "检测值(统一存为字符串)", example = "3.14")
  50 + private String value;
  51 +
  52 + @Schema(description = "备注", example = "无")
  53 + private String remark;
  54 +
  55 + }
36 56  
37 57 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/vo/MesQcResultDetailRespVO.java deleted
1   -package cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo;
2   -
3   -import io.swagger.v3.oas.annotations.media.Schema;
4   -import lombok.Data;
5   -
6   -import java.math.BigDecimal;
7   -
8   -@Schema(description = "管理后台 - MES 检验结果明细 Response VO")
9   -@Data
10   -public class MesQcResultDetailRespVO {
11   -
12   - @Schema(description = "编号", example = "1024")
13   - private Long id;
14   -
15   - @Schema(description = "关联检验结果ID", example = "1")
16   - private Long resultId;
17   -
18   - @Schema(description = "检测指标ID", example = "1")
19   - private Long indicatorId;
20   -
21   - @Schema(description = "检测工具ID", example = "1")
22   - private Long toolId;
23   -
24   - @Schema(description = "计量单位ID", example = "1")
25   - private Long unitMeasureId;
26   -
27   - @Schema(description = "质检值类型(1=浮点 2=整数 3=文本 4=字典 5=文件)", example = "1")
28   - private Integer valueType;
29   -
30   - @Schema(description = "值属性", example = "IMG")
31   - private String valueSpecification;
32   -
33   - @Schema(description = "浮点值", example = "3.14")
34   - private BigDecimal valueFloat;
35   -
36   - @Schema(description = "整数值", example = "100")
37   - private Integer valueInteger;
38   -
39   - @Schema(description = "文字值", example = "合格")
40   - private String valueText;
41   -
42   - @Schema(description = "字典项值", example = "PASS")
43   - private String valueDict;
44   -
45   - @Schema(description = "文件值", example = "https://xxx.com/file.jpg")
46   - private String valueFile;
47   -
48   - @Schema(description = "备注", example = "无")
49   - private String remark;
50   -
51   - // ========== 关联查询字段(来自 IQC line + indicator) ==========
52   -
53   - @Schema(description = "检测指标编码(关联查询)", example = "IDX-001")
54   - private String indicatorCode;
55   -
56   - @Schema(description = "检测指标名称(关联查询)", example = "外观检查")
57   - private String indicatorName;
58   -
59   - @Schema(description = "检测指标类型(关联查询)", example = "QUANTITATIVE")
60   - private String indicatorType;
61   -
62   - @Schema(description = "检测工具名称(关联查询)", example = "卡尺")
63   - private String toolName;
64   -
65   - @Schema(description = "检测方法(关联查询)", example = "目视检查")
66   - private String checkMethod;
67   -
68   - @Schema(description = "标准值(关联查询)", example = "10.0000")
69   - private BigDecimal standardValue;
70   -
71   - @Schema(description = "计量单位名称(关联查询)", example = "mm")
72   - private String unitMeasureName;
73   -
74   - @Schema(description = "误差上限(关联查询)", example = "10.5000")
75   - private BigDecimal maxThreshold;
76   -
77   - @Schema(description = "误差下限(关联查询)", example = "9.5000")
78   - private BigDecimal minThreshold;
79   -
80   -}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/vo/MesQcResultDetailSaveReqVO.java deleted
1   -package cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo;
2   -
3   -import io.swagger.v3.oas.annotations.media.Schema;
4   -import lombok.Data;
5   -
6   -import java.math.BigDecimal;
7   -
8   -@Schema(description = "管理后台 - MES 检验结果明细创建/更新 Request VO")
9   -@Data
10   -public class MesQcResultDetailSaveReqVO {
11   -
12   - @Schema(description = "编号", example = "1024")
13   - private Long id;
14   -
15   - @Schema(description = "检测指标ID", example = "1")
16   - private Long indicatorId;
17   -
18   - @Schema(description = "检测工具ID", example = "1")
19   - private Long toolId;
20   -
21   - @Schema(description = "计量单位ID", example = "1")
22   - private Long unitMeasureId;
23   -
24   - @Schema(description = "质检值类型(1=浮点 2=整数 3=文本 4=字典 5=文件)", example = "1")
25   - private Integer valueType;
26   -
27   - @Schema(description = "值属性", example = "IMG")
28   - private String valueSpecification;
29   -
30   - @Schema(description = "浮点值", example = "3.14")
31   - private BigDecimal valueFloat;
32   -
33   - @Schema(description = "整数值", example = "100")
34   - private Integer valueInteger;
35   -
36   - @Schema(description = "文字值", example = "合格")
37   - private String valueText;
38   -
39   - @Schema(description = "字典项值", example = "PASS")
40   - private String valueDict;
41   -
42   - @Schema(description = "文件值", example = "https://xxx.com/file.jpg")
43   - private String valueFile;
44   -
45   - @Schema(description = "备注", example = "无")
46   - private String remark;
47   -
48   -}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/indicator/MesQcIndicatorDO.java
... ... @@ -37,7 +37,7 @@ public class MesQcIndicatorDO extends BaseDO {
37 37 /**
38 38 * 检测项类型
39 39 *
40   - * 枚举 {@link cn.iocoder.yudao.module.mes.enums.DictTypeConstants#MES_INDEX_TYPE}
  40 + * 枚举 {@link cn.iocoder.yudao.module.mes.enums.DictTypeConstants#MES_INDICATOR_TYPE}
41 41 */
42 42 private String type;
43 43 /**
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/indicatorresult/MesQcResultDO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/indicatorresult/MesQcIndicatorResultDO.java
... ... @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult;
2 2  
3 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4 4 import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO;
  5 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.lqc.MesQcIqcDO;
5 6 import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
6 7 import com.baomidou.mybatisplus.annotation.KeySequence;
7 8 import com.baomidou.mybatisplus.annotation.TableId;
... ... @@ -13,15 +14,15 @@ import lombok.*;
13 14 *
14 15 * @author 芋道源码
15 16 */
16   -@TableName("mes_qc_result")
17   -@KeySequence("mes_qc_result_seq")
  17 +@TableName("mes_qc_indicator_result")
  18 +@KeySequence("mes_qc_indicator_result_seq")
18 19 @Data
19 20 @EqualsAndHashCode(callSuper = true)
20 21 @ToString(callSuper = true)
21 22 @Builder
22 23 @NoArgsConstructor
23 24 @AllArgsConstructor
24   -public class MesQcResultDO extends BaseDO {
  25 +public class MesQcIndicatorResultDO extends BaseDO {
25 26  
26 27 /**
27 28 * 编号
... ... @@ -32,9 +33,11 @@ public class MesQcResultDO extends BaseDO {
32 33 * 样品编号
33 34 */
34 35 private String code;
35   - // TODO @AI:关联下 linkter;
36 36 /**
37 37 * 关联质检单 ID(IQC/IPQC/OQC/RQC 的 id)
  38 + *
  39 + * 关联 IQC {@link MesQcIqcDO#getId()}
  40 + * TODO @芋艿:IPQC/OQC/RQC 关联补充
38 41 */
39 42 private Long qcId;
40 43 /**
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/indicatorresult/MesQcResultDetailDO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/indicatorresult/MesQcIndicatorResultDetailDO.java
1 1 package cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult;
2 2  
3 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4   -import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO;
5 4 import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO;
6   -import cn.iocoder.yudao.module.mes.dal.dataobject.tm.tool.MesTmToolDO;
7   -import cn.iocoder.yudao.module.mes.enums.qc.MesQcResultValueTypeEnum;
8 5 import com.baomidou.mybatisplus.annotation.KeySequence;
9 6 import com.baomidou.mybatisplus.annotation.TableId;
10 7 import com.baomidou.mybatisplus.annotation.TableName;
11 8 import lombok.*;
12 9  
13   -import java.math.BigDecimal;
14   -
15 10 /**
16 11 * MES 检验结果明细记录 DO
17 12 *
18 13 * @author 芋道源码
19 14 */
20   -@TableName("mes_qc_result_detail")
21   -@KeySequence("mes_qc_result_detail_seq")
  15 +@TableName("mes_qc_indicator_result_detail")
  16 +@KeySequence("mes_qc_indicator_result_detail_seq")
22 17 @Data
23 18 @EqualsAndHashCode(callSuper = true)
24 19 @ToString(callSuper = true)
25 20 @Builder
26 21 @NoArgsConstructor
27 22 @AllArgsConstructor
28   -public class MesQcResultDetailDO extends BaseDO {
  23 +public class MesQcIndicatorResultDetailDO extends BaseDO {
29 24  
30 25 /**
31 26 * 编号
... ... @@ -35,7 +30,7 @@ public class MesQcResultDetailDO extends BaseDO {
35 30 /**
36 31 * 关联检验结果 ID
37 32 *
38   - * 关联 {@link MesQcResultDO#getId()}
  33 + * 关联 {@link MesQcIndicatorResultDO#getId()}
39 34 */
40 35 private Long resultId;
41 36 /**
... ... @@ -44,52 +39,10 @@ public class MesQcResultDetailDO extends BaseDO {
44 39 * 关联 {@link MesQcIndicatorDO#getId()}
45 40 */
46 41 private Long indicatorId;
47   - // TODO @AI:toolId、unitMeasureId、valueType、valueSpecification 都不存储;
48   - /**
49   - * 检测工具 ID
50   - *
51   - * 关联 {@link MesTmToolDO#getId()}
52   - */
53   - private Long toolId;
54   - /**
55   - * 计量单位 ID
56   - *
57   - * 关联 {@link MesMdUnitMeasureDO#getId()}
58   - */
59   - private Long unitMeasureId;
60   - /**
61   - * 质检值类型
62   - *
63   - * 枚举 {@link MesQcResultValueTypeEnum}
64   - */
65   - private Integer valueType;
66   - /**
67   - * 值属性
68   - *
69   - * FILE 时存 IMG/FILE;DICT 时存字典类型名
70   - */
71   - private String valueSpecification;
72   - // TODO @AI:是不是可以调整成 String value?
73   - /**
74   - * 浮点值
75   - */
76   - private BigDecimal valueFloat;
77   - /**
78   - * 整数值
79   - */
80   - private Integer valueInteger;
81   - /**
82   - * 文字值
83   - */
84   - private String valueText;
85   - /**
86   - * 字典项值
87   - */
88   - private String valueDict;
89 42 /**
90   - * 文件值
  43 + * 检测值(统一存为字符串)
91 44 */
92   - private String valueFile;
  45 + private String value;
93 46 /**
94 47 * 备注
95 48 */
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/indicatorresult/MesQcResultDetailMapper.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/indicatorresult/MesQcIndicatorResultDetailMapper.java
... ... @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.mes.dal.mysql.qc.indicatorresult;
2 2  
3 3 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
4 4 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
5   -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcResultDetailDO;
  5 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDetailDO;
6 6 import org.apache.ibatis.annotations.Mapper;
7 7  
8 8 import java.util.List;
... ... @@ -13,15 +13,15 @@ import java.util.List;
13 13 * @author 芋道源码
14 14 */
15 15 @Mapper
16   -public interface MesQcResultDetailMapper extends BaseMapperX<MesQcResultDetailDO> {
  16 +public interface MesQcIndicatorResultDetailMapper extends BaseMapperX<MesQcIndicatorResultDetailDO> {
17 17  
18   - default List<MesQcResultDetailDO> selectListByResultId(Long resultId) {
19   - return selectList(MesQcResultDetailDO::getResultId, resultId);
  18 + default List<MesQcIndicatorResultDetailDO> selectListByResultId(Long resultId) {
  19 + return selectList(MesQcIndicatorResultDetailDO::getResultId, resultId);
20 20 }
21 21  
22 22 default void deleteByResultId(Long resultId) {
23   - delete(new LambdaQueryWrapperX<MesQcResultDetailDO>()
24   - .eq(MesQcResultDetailDO::getResultId, resultId));
  23 + delete(new LambdaQueryWrapperX<MesQcIndicatorResultDetailDO>()
  24 + .eq(MesQcIndicatorResultDetailDO::getResultId, resultId));
25 25 }
26 26  
27 27 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/indicatorresult/MesQcResultMapper.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/indicatorresult/MesQcIndicatorResultMapper.java
... ... @@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.mes.dal.mysql.qc.indicatorresult;
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6   -import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcResultPageReqVO;
7   -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcResultDO;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcIndicatorResultPageReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDO;
8 8 import org.apache.ibatis.annotations.Mapper;
9 9  
10 10 /**
... ... @@ -13,15 +13,15 @@ import org.apache.ibatis.annotations.Mapper;
13 13 * @author 芋道源码
14 14 */
15 15 @Mapper
16   -public interface MesQcResultMapper extends BaseMapperX<MesQcResultDO> {
  16 +public interface MesQcIndicatorResultMapper extends BaseMapperX<MesQcIndicatorResultDO> {
17 17  
18   - default PageResult<MesQcResultDO> selectPage(MesQcResultPageReqVO reqVO) {
19   - return selectPage(reqVO, new LambdaQueryWrapperX<MesQcResultDO>()
20   - .eqIfPresent(MesQcResultDO::getQcId, reqVO.getQcId())
21   - .eqIfPresent(MesQcResultDO::getQcType, reqVO.getQcType())
22   - .likeIfPresent(MesQcResultDO::getCode, reqVO.getCode())
23   - .eqIfPresent(MesQcResultDO::getItemId, reqVO.getItemId())
24   - .orderByDesc(MesQcResultDO::getId));
  18 + default PageResult<MesQcIndicatorResultDO> selectPage(MesQcIndicatorResultPageReqVO reqVO) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<MesQcIndicatorResultDO>()
  20 + .eqIfPresent(MesQcIndicatorResultDO::getQcId, reqVO.getQcId())
  21 + .eqIfPresent(MesQcIndicatorResultDO::getQcType, reqVO.getQcType())
  22 + .likeIfPresent(MesQcIndicatorResultDO::getCode, reqVO.getCode())
  23 + .eqIfPresent(MesQcIndicatorResultDO::getItemId, reqVO.getItemId())
  24 + .orderByDesc(MesQcIndicatorResultDO::getId));
25 25 }
26 26  
27 27 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java
... ... @@ -18,7 +18,7 @@ public interface DictTypeConstants {
18 18 String MES_CAL_PLAN_STATUS = "mes_cal_plan_status"; // MES 排班计划状态
19 19 String MES_DV_MACHINERY_STATUS = "mes_dv_machinery_status"; // MES 设备状态
20 20 String MES_DV_SUBJECT_TYPE = "mes_dv_subject_type"; // MES 点检保养项目类型
21   - String MES_INDEX_TYPE = "mes_index_type"; // MES 检测项类型
  21 + String MES_INDICATOR_TYPE = "mes_indicator_type"; // MES 检测项类型
22 22 String MES_QC_RESULT_TYPE = "mes_qc_result_type"; // MES 质检结果值类型
23 23 String MES_DEFECT_LEVEL = "mes_defect_level"; // MES 缺陷等级
24 24 String MES_PRO_WORK_ORDER_STATUS = "mes_pro_work_order_status"; // MES 生产工单状态
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/indicatorresult/MesQcResultService.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/indicatorresult/MesQcIndicatorResultService.java
1 1 package cn.iocoder.yudao.module.mes.service.qc.indicatorresult;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcResultDetailRespVO;
5   -import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcResultPageReqVO;
6   -import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcResultSaveReqVO;
7   -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcResultDO;
  4 +import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcIndicatorResultPageReqVO;
  5 +import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcIndicatorResultSaveReqVO;
  6 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDetailDO;
8 8 import jakarta.validation.Valid;
9 9  
10 10 import java.util.List;
... ... @@ -14,7 +14,7 @@ import java.util.List;
14 14 *
15 15 * @author 芋道源码
16 16 */
17   -public interface MesQcResultService {
  17 +public interface MesQcIndicatorResultService {
18 18  
19 19 /**
20 20 * 创建检验结果(含明细)
... ... @@ -22,21 +22,21 @@ public interface MesQcResultService {
22 22 * @param createReqVO 创建信息
23 23 * @return 编号
24 24 */
25   - Long createResult(@Valid MesQcResultSaveReqVO createReqVO);
  25 + Long createIndicatorResult(@Valid MesQcIndicatorResultSaveReqVO createReqVO);
26 26  
27 27 /**
28 28 * 更新检验结果(含明细)
29 29 *
30 30 * @param updateReqVO 更新信息
31 31 */
32   - void updateResult(@Valid MesQcResultSaveReqVO updateReqVO);
  32 + void updateIndicatorResult(@Valid MesQcIndicatorResultSaveReqVO updateReqVO);
33 33  
34 34 /**
35 35 * 删除检验结果(级联删除明细)
36 36 *
37 37 * @param id 编号
38 38 */
39   - void deleteResult(Long id);
  39 + void deleteIndicatorResult(Long id);
40 40  
41 41 /**
42 42 * 获得检验结果
... ... @@ -44,7 +44,7 @@ public interface MesQcResultService {
44 44 * @param id 编号
45 45 * @return 检验结果
46 46 */
47   - MesQcResultDO getResult(Long id);
  47 + MesQcIndicatorResultDO getIndicatorResult(Long id);
48 48  
49 49 /**
50 50 * 获得检验结果分页
... ... @@ -52,25 +52,14 @@ public interface MesQcResultService {
52 52 * @param pageReqVO 分页查询
53 53 * @return 检验结果分页
54 54 */
55   - PageResult<MesQcResultDO> getResultPage(MesQcResultPageReqVO pageReqVO);
  55 + PageResult<MesQcIndicatorResultDO> getIndicatorResultPage(MesQcIndicatorResultPageReqVO pageReqVO);
56 56  
57 57 /**
58   - * 获取检验结果明细列表(含已填值,组装 IQC line + indicator 信息)
  58 + * 获取检验结果明细列表
59 59 *
60 60 * @param resultId 检验结果 ID
61   - * @param qcId 质检单 ID
62   - * @param qcType 质检类型
63 61 * @return 明细列表
64 62 */
65   - List<MesQcResultDetailRespVO> getResultDetailList(Long resultId, Long qcId, Integer qcType);
66   -
67   - /**
68   - * 获取空值检测项模板(新建结果时用)
69   - *
70   - * @param qcId 质检单 ID
71   - * @param qcType 质检类型
72   - * @return 空值明细列表
73   - */
74   - List<MesQcResultDetailRespVO> getDetailTemplate(Long qcId, Integer qcType);
  63 + List<MesQcIndicatorResultDetailDO> getIndicatorResultDetailListByResultId(Long resultId);
75 64  
76 65 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/indicatorresult/MesQcIndicatorResultServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.qc.indicatorresult;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcIndicatorResultPageReqVO;
  7 +import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcIndicatorResultSaveReqVO;
  8 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.lqc.MesQcIqcDO;
  9 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDO;
  10 +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcIndicatorResultDetailDO;
  11 +import cn.iocoder.yudao.module.mes.dal.mysql.qc.indicatorresult.MesQcIndicatorResultDetailMapper;
  12 +import cn.iocoder.yudao.module.mes.dal.mysql.qc.indicatorresult.MesQcIndicatorResultMapper;
  13 +import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
  14 +import cn.iocoder.yudao.module.mes.service.qc.lqc.MesQcIqcService;
  15 +import jakarta.annotation.Resource;
  16 +import org.springframework.stereotype.Service;
  17 +import org.springframework.transaction.annotation.Transactional;
  18 +import org.springframework.validation.annotation.Validated;
  19 +
  20 +import java.util.*;
  21 +
  22 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  23 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
  24 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  25 +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
  26 +
  27 +/**
  28 + * MES 检验结果 Service 实现类
  29 + *
  30 + * @author 芋道源码
  31 + */
  32 +@Service
  33 +@Validated
  34 +public class MesQcIndicatorResultServiceImpl implements MesQcIndicatorResultService {
  35 +
  36 + @Resource
  37 + private MesQcIndicatorResultMapper resultMapper;
  38 + @Resource
  39 + private MesQcIndicatorResultDetailMapper resultDetailMapper;
  40 +
  41 + @Resource
  42 + private MesQcIqcService iqcService;
  43 +
  44 + @Override
  45 + @Transactional(rollbackFor = Exception.class)
  46 + public Long createIndicatorResult(MesQcIndicatorResultSaveReqVO createReqVO) {
  47 + // 1. 校验明细不为空
  48 + // TODO @AI:是不是 MesQcIndicatorResultSaveReqVO validator 参数校验;
  49 + List<MesQcIndicatorResultSaveReqVO.Item> items = createReqVO.getItems();
  50 + if (CollUtil.isEmpty(items)) {
  51 + throw exception(QC_RESULT_ITEMS_EMPTY);
  52 + }
  53 +
  54 + // 2. 根据 qcType 查询源质检单,获取 itemId
  55 + Long itemId = getItemIdFromQcDoc(createReqVO.getQcId(), createReqVO.getQcType());
  56 +
  57 + // 3.1 插入主表
  58 + MesQcIndicatorResultDO result = BeanUtils.toBean(createReqVO, MesQcIndicatorResultDO.class);
  59 + result.setItemId(itemId);
  60 + resultMapper.insert(result);
  61 + // 3.2 批量插入明细
  62 + List<MesQcIndicatorResultDetailDO> details = BeanUtils.toBean(items, MesQcIndicatorResultDetailDO.class);
  63 + details.forEach(detail -> detail.setResultId(result.getId()));
  64 + resultDetailMapper.insertBatch(details);
  65 + return result.getId();
  66 + }
  67 +
  68 + @Override
  69 + @Transactional(rollbackFor = Exception.class)
  70 + public void updateIndicatorResult(MesQcIndicatorResultSaveReqVO updateReqVO) {
  71 + // 1. 校验存在
  72 + validateIndicatorResultExists(updateReqVO.getId());
  73 +
  74 + // 2. 校验明细不为空
  75 + // TODO @AI:是不是 MesQcIndicatorResultSaveReqVO validator 参数校验;
  76 + List<MesQcIndicatorResultSaveReqVO.Item> items = updateReqVO.getItems();
  77 + if (CollUtil.isEmpty(items)) {
  78 + throw exception(QC_RESULT_ITEMS_EMPTY);
  79 + }
  80 +
  81 + // 2.1 更新主表
  82 + MesQcIndicatorResultDO updateObj = BeanUtils.toBean(updateReqVO, MesQcIndicatorResultDO.class);
  83 + resultMapper.updateById(updateObj);
  84 +
  85 + // TODO @AI:直接 for 循环,resultMapper.insertOrUpdate() 简单粗暴点!
  86 + // 4. 更新明细:diff 方式(有 id → 更新,无 id → 新增,不在列表中 → 删除)
  87 + List<MesQcIndicatorResultDetailDO> existingDetails = resultDetailMapper.selectListByResultId(updateReqVO.getId());
  88 + Map<Long, MesQcIndicatorResultDetailDO> existingMap = convertMap(existingDetails, MesQcIndicatorResultDetailDO::getId);
  89 +
  90 + // 4.1 收集前端传入的、已有 id 的集合
  91 + Set<Long> newItemIds = convertSet(items, MesQcIndicatorResultSaveReqVO.Item::getId);
  92 + newItemIds.remove(null);
  93 +
  94 + // 4.2 遍历传入的明细:有 id 则更新,无 id 则新增
  95 + for (MesQcIndicatorResultSaveReqVO.Item item : items) {
  96 + MesQcIndicatorResultDetailDO detail = BeanUtils.toBean(item, MesQcIndicatorResultDetailDO.class);
  97 + detail.setResultId(updateReqVO.getId());
  98 + if (item.getId() != null && existingMap.containsKey(item.getId())) {
  99 + // 更新已有记录
  100 + resultDetailMapper.updateById(detail);
  101 + } else {
  102 + // 新增记录
  103 + detail.setId(null);
  104 + resultDetailMapper.insert(detail);
  105 + }
  106 + }
  107 +
  108 + // 4.3 删除不在新列表中的旧记录
  109 + for (MesQcIndicatorResultDetailDO existing : existingDetails) {
  110 + if (!newItemIds.contains(existing.getId())) {
  111 + resultDetailMapper.deleteById(existing.getId());
  112 + }
  113 + }
  114 + }
  115 +
  116 + @Override
  117 + @Transactional(rollbackFor = Exception.class)
  118 + public void deleteIndicatorResult(Long id) {
  119 + // 1. 校验存在
  120 + validateIndicatorResultExists(id);
  121 +
  122 + // 2.1 级联删除明细
  123 + resultDetailMapper.deleteByResultId(id);
  124 + // 2.2 删除主表
  125 + resultMapper.deleteById(id);
  126 + }
  127 +
  128 + @Override
  129 + public MesQcIndicatorResultDO getIndicatorResult(Long id) {
  130 + return resultMapper.selectById(id);
  131 + }
  132 +
  133 + @Override
  134 + public PageResult<MesQcIndicatorResultDO> getIndicatorResultPage(MesQcIndicatorResultPageReqVO pageReqVO) {
  135 + return resultMapper.selectPage(pageReqVO);
  136 + }
  137 +
  138 + @Override
  139 + public List<MesQcIndicatorResultDetailDO> getIndicatorResultDetailListByResultId(Long resultId) {
  140 + return resultDetailMapper.selectListByResultId(resultId);
  141 + }
  142 +
  143 + // ==================== 私有方法 ====================
  144 +
  145 + private MesQcIndicatorResultDO validateIndicatorResultExists(Long id) {
  146 + MesQcIndicatorResultDO result = resultMapper.selectById(id);
  147 + if (result == null) {
  148 + throw exception(QC_RESULT_NOT_EXISTS);
  149 + }
  150 + return result;
  151 + }
  152 +
  153 + /**
  154 + * 根据 qcType 查询源质检单,获取 itemId
  155 + */
  156 + private Long getItemIdFromQcDoc(Long qcId, Integer qcType) {
  157 + if (Objects.equals(qcType, MesQcTypeEnum.IQC.getType())) {
  158 + // TODO @AI:使用 iqcService 的 validateIqcExists 方法,这样更聚焦!
  159 + MesQcIqcDO iqc = iqcService.getIqc(qcId);
  160 + if (iqc == null) {
  161 + throw exception(QC_RESULT_SOURCE_DOC_NOT_EXISTS);
  162 + }
  163 + return iqc.getItemId();
  164 + }
  165 + // TODO @芋艿:IPQC/OQC/RQC 模块迁移后实现
  166 + throw exception(QC_RESULT_SOURCE_DOC_TYPE_INVALID);
  167 + }
  168 +
  169 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/indicatorresult/MesQcResultServiceImpl.java deleted
1   -package cn.iocoder.yudao.module.mes.service.qc.indicatorresult;
2   -
3   -import cn.hutool.core.collection.CollUtil;
4   -import cn.iocoder.yudao.framework.common.pojo.PageResult;
5   -import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
6   -import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcResultDetailRespVO;
7   -import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcResultDetailSaveReqVO;
8   -import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcResultPageReqVO;
9   -import cn.iocoder.yudao.module.mes.controller.admin.qc.indicatorresult.vo.MesQcResultSaveReqVO;
10   -import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO;
11   -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO;
12   -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.lqc.MesQcIqcDO;
13   -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.lqc.MesQcIqcLineDO;
14   -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcResultDO;
15   -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicatorresult.MesQcResultDetailDO;
16   -import cn.iocoder.yudao.module.mes.dal.dataobject.tm.tool.MesTmToolDO;
17   -import cn.iocoder.yudao.module.mes.dal.mysql.qc.lqc.MesQcIqcLineMapper;
18   -import cn.iocoder.yudao.module.mes.dal.mysql.qc.indicatorresult.MesQcResultDetailMapper;
19   -import cn.iocoder.yudao.module.mes.dal.mysql.qc.indicatorresult.MesQcResultMapper;
20   -import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum;
21   -import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService;
22   -import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService;
23   -import cn.iocoder.yudao.module.mes.service.qc.lqc.MesQcIqcService;
24   -import cn.iocoder.yudao.module.mes.service.tm.tool.MesTmToolService;
25   -import jakarta.annotation.Resource;
26   -import org.springframework.stereotype.Service;
27   -import org.springframework.transaction.annotation.Transactional;
28   -import org.springframework.validation.annotation.Validated;
29   -
30   -import java.util.*;
31   -
32   -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
33   -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
34   -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
35   -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
36   -import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
37   -
38   -/**
39   - * MES 检验结果 Service 实现类
40   - *
41   - * @author 芋道源码
42   - */
43   -@Service
44   -@Validated
45   -public class MesQcResultServiceImpl implements MesQcResultService {
46   -
47   - @Resource
48   - private MesQcResultMapper resultMapper;
49   - @Resource
50   - private MesQcResultDetailMapper resultDetailMapper;
51   -
52   - @Resource
53   - private MesQcIqcService iqcService;
54   - @Resource
55   - private MesQcIqcLineMapper iqcLineMapper;
56   - @Resource
57   - private MesQcIndicatorService indicatorService;
58   - @Resource
59   - private MesMdUnitMeasureService unitMeasureService;
60   - @Resource
61   - private MesTmToolService toolService;
62   -
63   - @Override
64   - @Transactional(rollbackFor = Exception.class)
65   - public Long createResult(MesQcResultSaveReqVO createReqVO) {
66   - // 1. 校验明细不为空
67   - List<MesQcResultDetailSaveReqVO> items = createReqVO.getItems();
68   - if (CollUtil.isEmpty(items)) {
69   - throw exception(QC_RESULT_ITEMS_EMPTY);
70   - }
71   -
72   - // 2. 根据 qcType 查询源质检单,获取 itemId
73   - Long itemId = getItemIdFromQcDoc(createReqVO.getQcId(), createReqVO.getQcType());
74   -
75   - // 3. 插入主表
76   - MesQcResultDO result = BeanUtils.toBean(createReqVO, MesQcResultDO.class);
77   - result.setItemId(itemId);
78   - resultMapper.insert(result);
79   -
80   - // 4. 批量插入明细
81   - List<MesQcResultDetailDO> details = BeanUtils.toBean(items, MesQcResultDetailDO.class);
82   - details.forEach(detail -> detail.setResultId(result.getId()));
83   - resultDetailMapper.insertBatch(details);
84   - return result.getId();
85   - }
86   -
87   - @Override
88   - @Transactional(rollbackFor = Exception.class)
89   - public void updateResult(MesQcResultSaveReqVO updateReqVO) {
90   - // 1. 校验存在
91   - validateResultExists(updateReqVO.getId());
92   -
93   - // 2. 校验明细不为空
94   - List<MesQcResultDetailSaveReqVO> items = updateReqVO.getItems();
95   - if (CollUtil.isEmpty(items)) {
96   - throw exception(QC_RESULT_ITEMS_EMPTY);
97   - }
98   -
99   - // 3. 更新主表
100   - MesQcResultDO updateObj = BeanUtils.toBean(updateReqVO, MesQcResultDO.class);
101   - resultMapper.updateById(updateObj);
102   -
103   - // 4. 更新明细:先删后插
104   - resultDetailMapper.deleteByResultId(updateReqVO.getId());
105   - List<MesQcResultDetailDO> details = BeanUtils.toBean(items, MesQcResultDetailDO.class);
106   - details.forEach(detail -> detail.setResultId(updateReqVO.getId()));
107   - resultDetailMapper.insertBatch(details);
108   - }
109   -
110   - @Override
111   - @Transactional(rollbackFor = Exception.class)
112   - public void deleteResult(Long id) {
113   - // 1. 校验存在
114   - validateResultExists(id);
115   - // 2. 级联删除明细
116   - resultDetailMapper.deleteByResultId(id);
117   - // 3. 删除主表
118   - resultMapper.deleteById(id);
119   - }
120   -
121   - @Override
122   - public MesQcResultDO getResult(Long id) {
123   - return resultMapper.selectById(id);
124   - }
125   -
126   - @Override
127   - public PageResult<MesQcResultDO> getResultPage(MesQcResultPageReqVO pageReqVO) {
128   - return resultMapper.selectPage(pageReqVO);
129   - }
130   -
131   - @Override
132   - public List<MesQcResultDetailRespVO> getResultDetailList(Long resultId, Long qcId, Integer qcType) {
133   - return buildDetailRespVOList(resultId, qcId, qcType);
134   - }
135   -
136   - @Override
137   - public List<MesQcResultDetailRespVO> getDetailTemplate(Long qcId, Integer qcType) {
138   - return buildDetailRespVOList(null, qcId, qcType);
139   - }
140   -
141   - // ==================== 私有方法 ====================
142   -
143   - private MesQcResultDO validateResultExists(Long id) {
144   - MesQcResultDO result = resultMapper.selectById(id);
145   - if (result == null) {
146   - throw exception(QC_RESULT_NOT_EXISTS);
147   - }
148   - return result;
149   - }
150   -
151   - /**
152   - * 根据 qcType 查询源质检单,获取 itemId
153   - */
154   - private Long getItemIdFromQcDoc(Long qcId, Integer qcType) {
155   - if (Objects.equals(qcType, MesQcTypeEnum.IQC.getType())) {
156   - MesQcIqcDO iqc = iqcService.getIqc(qcId);
157   - if (iqc == null) {
158   - throw exception(QC_RESULT_SOURCE_DOC_NOT_EXISTS);
159   - }
160   - return iqc.getItemId();
161   - }
162   - // TODO @芋艿:IPQC/OQC/RQC 模块迁移后实现
163   - throw exception(QC_RESULT_SOURCE_DOC_TYPE_INVALID);
164   - }
165   -
166   - /**
167   - * 组装明细 VO 列表:从 IQC line + indicator + tool + unitMeasure + 已有结果明细 三方组装
168   - *
169   - * @param resultId 检验结果 ID,为 null 时表示获取空值模板
170   - * @param qcId 质检单 ID
171   - * @param qcType 质检类型
172   - */
173   - private List<MesQcResultDetailRespVO> buildDetailRespVOList(Long resultId, Long qcId, Integer qcType) {
174   - // 1. 获取检验单行列表
175   - List<MesQcIqcLineDO> lines;
176   - if (Objects.equals(qcType, MesQcTypeEnum.IQC.getType())) {
177   - lines = iqcLineMapper.selectListByIqcId(qcId);
178   - } else {
179   - // TODO @芋艿:IPQC/OQC/RQC 模块迁移后实现
180   - return Collections.emptyList();
181   - }
182   - if (CollUtil.isEmpty(lines)) {
183   - return Collections.emptyList();
184   - }
185   -
186   - // 2. 批量查询关联信息
187   - Map<Long, MesQcIndicatorDO> indicatorMap = indicatorService.getIndicatorMap(
188   - convertSet(lines, MesQcIqcLineDO::getIndicatorId));
189   - Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap(
190   - convertSet(lines, MesQcIqcLineDO::getUnitMeasureId));
191   -
192   - // 3. 查询已有结果明细(如有 resultId)
193   - Map<Long, MesQcResultDetailDO> detailMap;
194   - if (resultId != null) {
195   - List<MesQcResultDetailDO> details = resultDetailMapper.selectListByResultId(resultId);
196   - detailMap = convertMap(details, MesQcResultDetailDO::getIndicatorId);
197   - } else {
198   - detailMap = Collections.emptyMap();
199   - }
200   -
201   - // 4. 遍历行,组装 VO
202   - List<MesQcResultDetailRespVO> voList = new ArrayList<>(lines.size());
203   - for (MesQcIqcLineDO line : lines) {
204   - MesQcResultDetailRespVO vo = new MesQcResultDetailRespVO();
205   - // 来自 IQC line
206   - vo.setIndicatorId(line.getIndicatorId());
207   - vo.setToolId(line.getToolId());
208   - vo.setUnitMeasureId(line.getUnitMeasureId());
209   - vo.setCheckMethod(line.getCheckMethod());
210   - vo.setStandardValue(line.getStandardValue());
211   - vo.setMaxThreshold(line.getMaxThreshold());
212   - vo.setMinThreshold(line.getMinThreshold());
213   -
214   - // 来自 indicator
215   - findAndThen(indicatorMap, line.getIndicatorId(), indicator -> {
216   - vo.setIndicatorCode(indicator.getCode());
217   - vo.setIndicatorName(indicator.getName());
218   - vo.setIndicatorType(indicator.getType());
219   - vo.setValueType(indicator.getResultType());
220   - vo.setValueSpecification(indicator.getResultSpecification());
221   - });
222   -
223   - // 来自 unitMeasure
224   - findAndThen(unitMeasureMap, line.getUnitMeasureId(),
225   - unit -> vo.setUnitMeasureName(unit.getName()));
226   -
227   - // 来自 tool(逐个查询,数量通常较少)
228   - if (line.getToolId() != null) {
229   - MesTmToolDO tool = toolService.getTool(line.getToolId());
230   - if (tool != null) {
231   - vo.setToolName(tool.getName());
232   - }
233   - }
234   -
235   - // 来自已有结果明细(如有)
236   - MesQcResultDetailDO detail = detailMap.get(line.getIndicatorId());
237   - if (detail != null) {
238   - vo.setId(detail.getId());
239   - vo.setResultId(detail.getResultId());
240   - vo.setValueFloat(detail.getValueFloat());
241   - vo.setValueInteger(detail.getValueInteger());
242   - vo.setValueText(detail.getValueText());
243   - vo.setValueDict(detail.getValueDict());
244   - vo.setValueFile(detail.getValueFile());
245   - }
246   -
247   - voList.add(vo);
248   - }
249   - return voList;
250   - }
251   -
252   -}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/lqc/MesQcIqcLineService.java
... ... @@ -56,6 +56,14 @@ public interface MesQcIqcLineService {
56 56 void recalculateLineDefectStats(Long iqcId, List<MesQcDefectRecordDO> records);
57 57  
58 58 /**
  59 + * 根据来料检验单 ID 获取所有行
  60 + *
  61 + * @param iqcId 来料检验单 ID
  62 + * @return 行列表
  63 + */
  64 + List<MesQcIqcLineDO> getIqcLineListByIqcId(Long iqcId);
  65 +
  66 + /**
59 67 * 根据来料检验单 ID 级联删除所有行
60 68 *
61 69 * @param iqcId 来料检验单 ID
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/lqc/MesQcIqcLineServiceImpl.java
... ... @@ -101,6 +101,11 @@ public class MesQcIqcLineServiceImpl implements MesQcIqcLineService {
101 101 }
102 102  
103 103 @Override
  104 + public List<MesQcIqcLineDO> getIqcLineListByIqcId(Long iqcId) {
  105 + return iqcLineMapper.selectListByIqcId(iqcId);
  106 + }
  107 +
  108 + @Override
104 109 public void deleteByIqcId(Long iqcId) {
105 110 iqcLineMapper.deleteByIqcId(iqcId);
106 111 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/lqc/MesQcIqcService.java
... ... @@ -7,7 +7,9 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.qc.defectrecord.MesQcDefectRec
7 7 import cn.iocoder.yudao.module.mes.dal.dataobject.qc.lqc.MesQcIqcDO;
8 8 import jakarta.validation.Valid;
9 9  
  10 +import java.util.Collection;
10 11 import java.util.List;
  12 +import java.util.Map;
11 13  
12 14 /**
13 15 * MES 来料检验单(IQC) Service 接口
... ... @@ -77,4 +79,12 @@ public interface MesQcIqcService {
77 79 */
78 80 void recalculateDefectStats(Long iqcId, List<MesQcDefectRecordDO> records);
79 81  
  82 + /**
  83 + * 批量获取来料检验单 Map
  84 + *
  85 + * @param ids 编号集合
  86 + * @return 来料检验单 Map
  87 + */
  88 + Map<Long, MesQcIqcDO> getIqcMap(Collection<Long> ids);
  89 +
80 90 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/lqc/MesQcIqcServiceImpl.java
... ... @@ -23,8 +23,9 @@ import org.springframework.validation.annotation.Validated;
23 23  
24 24 import java.math.BigDecimal;
25 25 import java.math.RoundingMode;
26   -import java.util.List;
27   -import java.util.Objects;
  26 +import java.util.*;
  27 +
  28 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
28 29  
29 30 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
30 31 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
... ... @@ -212,4 +213,13 @@ public class MesQcIqcServiceImpl implements MesQcIqcService {
212 213 iqcMapper.updateById(updateIqc);
213 214 }
214 215  
  216 + @Override
  217 + public Map<Long, MesQcIqcDO> getIqcMap(Collection<Long> ids) {
  218 + if (CollUtil.isEmpty(ids)) {
  219 + return Collections.emptyMap();
  220 + }
  221 + List<MesQcIqcDO> list = iqcMapper.selectBatchIds(ids);
  222 + return convertMap(list, MesQcIqcDO::getId);
  223 + }
  224 +
215 225 }
... ...