Commit 9f3538f4ccc6b3e4c714cb323412e697f0f8e2fe
1 parent
702d212f
✨ feat(mes): 重构过程检验行服务,优化方法命名与逻辑
- 重命名 selectListByIpqcId 为 getIpqcLineListByIpqcId,提升可读性 - 添加 validateIpqcLineExists 方法,增强行存在性校验 - 移除不再使用的字段和方法,简化代码结构
Showing
7 changed files
with
50 additions
and
53 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/indicatorresult/MesQcIndicatorResultController.java
| @@ -137,7 +137,7 @@ public class MesQcIndicatorResultController { | @@ -137,7 +137,7 @@ public class MesQcIndicatorResultController { | ||
| 137 | indicatorIds = CollUtil.isEmpty(lines) ? Collections.emptyList() | 137 | indicatorIds = CollUtil.isEmpty(lines) ? Collections.emptyList() |
| 138 | : new ArrayList<>(convertSet(lines, MesQcIqcLineDO::getIndicatorId)); | 138 | : new ArrayList<>(convertSet(lines, MesQcIqcLineDO::getIndicatorId)); |
| 139 | } else if (Objects.equals(qcType, MesQcTypeEnum.IPQC.getType())) { | 139 | } else if (Objects.equals(qcType, MesQcTypeEnum.IPQC.getType())) { |
| 140 | - List<MesQcIpqcLineDO> lines = ipqcLineService.selectListByIpqcId(qcId); | 140 | + List<MesQcIpqcLineDO> lines = ipqcLineService.getIpqcLineListByIpqcId(qcId); |
| 141 | indicatorIds = CollUtil.isEmpty(lines) ? Collections.emptyList() | 141 | indicatorIds = CollUtil.isEmpty(lines) ? Collections.emptyList() |
| 142 | : new ArrayList<>(convertSet(lines, MesQcIpqcLineDO::getIndicatorId)); | 142 | : new ArrayList<>(convertSet(lines, MesQcIpqcLineDO::getIndicatorId)); |
| 143 | } else if (Objects.equals(qcType, MesQcTypeEnum.OQC.getType())) { | 143 | } else if (Objects.equals(qcType, MesQcTypeEnum.OQC.getType())) { |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ipqc/MesQcIpqcController.java
| @@ -35,7 +35,6 @@ import org.springframework.validation.annotation.Validated; | @@ -35,7 +35,6 @@ import org.springframework.validation.annotation.Validated; | ||
| 35 | import org.springframework.web.bind.annotation.*; | 35 | import org.springframework.web.bind.annotation.*; |
| 36 | 36 | ||
| 37 | import java.io.IOException; | 37 | import java.io.IOException; |
| 38 | -import java.util.ArrayList; | ||
| 39 | import java.util.Collections; | 38 | import java.util.Collections; |
| 40 | import java.util.List; | 39 | import java.util.List; |
| 41 | import java.util.Map; | 40 | import java.util.Map; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ipqc/MesQcIpqcLineController.java
| @@ -9,11 +9,9 @@ import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.line.MesQcIpqcLin | @@ -9,11 +9,9 @@ import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.line.MesQcIpqcLin | ||
| 9 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | 9 | import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; |
| 10 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO; | 10 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO; |
| 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ipqc.MesQcIpqcLineDO; | 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ipqc.MesQcIpqcLineDO; |
| 12 | -import cn.iocoder.yudao.module.mes.dal.dataobject.tm.tool.MesTmToolDO; | ||
| 13 | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | 12 | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; |
| 14 | import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService; | 13 | import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService; |
| 15 | import cn.iocoder.yudao.module.mes.service.qc.ipqc.MesQcIpqcLineService; | 14 | import cn.iocoder.yudao.module.mes.service.qc.ipqc.MesQcIpqcLineService; |
| 16 | -import cn.iocoder.yudao.module.mes.service.tm.tool.MesTmToolService; | ||
| 17 | import io.swagger.v3.oas.annotations.Operation; | 15 | import io.swagger.v3.oas.annotations.Operation; |
| 18 | import io.swagger.v3.oas.annotations.Parameter; | 16 | import io.swagger.v3.oas.annotations.Parameter; |
| 19 | import io.swagger.v3.oas.annotations.tags.Tag; | 17 | import io.swagger.v3.oas.annotations.tags.Tag; |
| @@ -46,8 +44,6 @@ public class MesQcIpqcLineController { | @@ -46,8 +44,6 @@ public class MesQcIpqcLineController { | ||
| 46 | private MesQcIndicatorService indicatorService; | 44 | private MesQcIndicatorService indicatorService; |
| 47 | @Resource | 45 | @Resource |
| 48 | private MesMdUnitMeasureService unitMeasureService; | 46 | private MesMdUnitMeasureService unitMeasureService; |
| 49 | - @Resource | ||
| 50 | - private MesTmToolService toolService; | ||
| 51 | 47 | ||
| 52 | @GetMapping("/get") | 48 | @GetMapping("/get") |
| 53 | @Operation(summary = "获得过程检验单行") | 49 | @Operation(summary = "获得过程检验单行") |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/ipqc/vo/MesQcIpqcSaveReqVO.java
| @@ -31,9 +31,6 @@ public class MesQcIpqcSaveReqVO { | @@ -31,9 +31,6 @@ public class MesQcIpqcSaveReqVO { | ||
| 31 | @NotNull(message = "检验类型不能为空") | 31 | @NotNull(message = "检验类型不能为空") |
| 32 | private Integer type; | 32 | private Integer type; |
| 33 | 33 | ||
| 34 | - @Schema(description = "检验模板 ID", example = "100") | ||
| 35 | - private Long templateId; | ||
| 36 | - | ||
| 37 | // ========== 来源单据 ========== | 34 | // ========== 来源单据 ========== |
| 38 | 35 | ||
| 39 | @Schema(description = "来源单据类型", example = "FEEDBACK") | 36 | @Schema(description = "来源单据类型", example = "FEEDBACK") |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ipqc/MesQcIpqcLineService.java
| @@ -15,6 +15,14 @@ import java.util.List; | @@ -15,6 +15,14 @@ import java.util.List; | ||
| 15 | public interface MesQcIpqcLineService { | 15 | public interface MesQcIpqcLineService { |
| 16 | 16 | ||
| 17 | /** | 17 | /** |
| 18 | + * 校验过程检验行存在 | ||
| 19 | + * | ||
| 20 | + * @param id 编号 | ||
| 21 | + * @return 过程检验行 | ||
| 22 | + */ | ||
| 23 | + MesQcIpqcLineDO validateIpqcLineExists(Long id); | ||
| 24 | + | ||
| 25 | + /** | ||
| 18 | * 获得过程检验行 | 26 | * 获得过程检验行 |
| 19 | * | 27 | * |
| 20 | * @param id 编号 | 28 | * @param id 编号 |
| @@ -31,14 +39,6 @@ public interface MesQcIpqcLineService { | @@ -31,14 +39,6 @@ public interface MesQcIpqcLineService { | ||
| 31 | PageResult<MesQcIpqcLineDO> getIpqcLinePage(MesQcIpqcLinePageReqVO pageReqVO); | 39 | PageResult<MesQcIpqcLineDO> getIpqcLinePage(MesQcIpqcLinePageReqVO pageReqVO); |
| 32 | 40 | ||
| 33 | /** | 41 | /** |
| 34 | - * 根据过程检验单 ID 查询所有行 | ||
| 35 | - * | ||
| 36 | - * @param ipqcId 过程检验单 ID | ||
| 37 | - * @return 行列表 | ||
| 38 | - */ | ||
| 39 | - List<MesQcIpqcLineDO> selectListByIpqcId(Long ipqcId); | ||
| 40 | - | ||
| 41 | - /** | ||
| 42 | * 从模板指标自动生成检验行 | 42 | * 从模板指标自动生成检验行 |
| 43 | * | 43 | * |
| 44 | * @param ipqcId 过程检验单 ID | 44 | * @param ipqcId 过程检验单 ID |
| @@ -47,26 +47,26 @@ public interface MesQcIpqcLineService { | @@ -47,26 +47,26 @@ public interface MesQcIpqcLineService { | ||
| 47 | void createLinesFromTemplate(Long ipqcId, Long templateId); | 47 | void createLinesFromTemplate(Long ipqcId, Long templateId); |
| 48 | 48 | ||
| 49 | /** | 49 | /** |
| 50 | - * 根据过程检验单 ID 级联删除所有行 | 50 | + * 根据缺陷记录重新计算行级缺陷统计 |
| 51 | * | 51 | * |
| 52 | - * @param ipqcId 过程检验单 ID | 52 | + * @param ipqcId 过程检验单 ID |
| 53 | + * @param records 缺陷记录列表 | ||
| 53 | */ | 54 | */ |
| 54 | - void deleteByIpqcId(Long ipqcId); | 55 | + void recalculateLineDefectStats(Long ipqcId, List<MesQcDefectRecordDO> records); |
| 55 | 56 | ||
| 56 | /** | 57 | /** |
| 57 | - * 校验过程检验行存在 | 58 | + * 根据过程检验单 ID 获取所有行 |
| 58 | * | 59 | * |
| 59 | - * @param id 编号 | ||
| 60 | - * @return 过程检验行 | 60 | + * @param ipqcId 过程检验单 ID |
| 61 | + * @return 行列表 | ||
| 61 | */ | 62 | */ |
| 62 | - MesQcIpqcLineDO validateIpqcLineExists(Long id); | 63 | + List<MesQcIpqcLineDO> getIpqcLineListByIpqcId(Long ipqcId); |
| 63 | 64 | ||
| 64 | /** | 65 | /** |
| 65 | - * 根据缺陷记录重新计算行级缺陷统计 | 66 | + * 根据过程检验单 ID 级联删除所有行 |
| 66 | * | 67 | * |
| 67 | - * @param ipqcId 过程检验单 ID | ||
| 68 | - * @param records 缺陷记录列表 | 68 | + * @param ipqcId 过程检验单 ID |
| 69 | */ | 69 | */ |
| 70 | - void recalculateLineDefectStats(Long ipqcId, List<MesQcDefectRecordDO> records); | 70 | + void deleteListByIpqcId(Long ipqcId); |
| 71 | 71 | ||
| 72 | } | 72 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ipqc/MesQcIpqcLineServiceImpl.java
| @@ -44,6 +44,15 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService { | @@ -44,6 +44,15 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService { | ||
| 44 | private MesQcIndicatorService indicatorService; | 44 | private MesQcIndicatorService indicatorService; |
| 45 | 45 | ||
| 46 | @Override | 46 | @Override |
| 47 | + public MesQcIpqcLineDO validateIpqcLineExists(Long id) { | ||
| 48 | + MesQcIpqcLineDO line = ipqcLineMapper.selectById(id); | ||
| 49 | + if (line == null) { | ||
| 50 | + throw exception(QC_IPQC_LINE_NOT_EXISTS); | ||
| 51 | + } | ||
| 52 | + return line; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Override | ||
| 47 | public MesQcIpqcLineDO getIpqcLine(Long id) { | 56 | public MesQcIpqcLineDO getIpqcLine(Long id) { |
| 48 | return ipqcLineMapper.selectById(id); | 57 | return ipqcLineMapper.selectById(id); |
| 49 | } | 58 | } |
| @@ -54,11 +63,6 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService { | @@ -54,11 +63,6 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService { | ||
| 54 | } | 63 | } |
| 55 | 64 | ||
| 56 | @Override | 65 | @Override |
| 57 | - public List<MesQcIpqcLineDO> selectListByIpqcId(Long ipqcId) { | ||
| 58 | - return ipqcLineMapper.selectListByIpqcId(ipqcId); | ||
| 59 | - } | ||
| 60 | - | ||
| 61 | - @Override | ||
| 62 | public void createLinesFromTemplate(Long ipqcId, Long templateId) { | 66 | public void createLinesFromTemplate(Long ipqcId, Long templateId) { |
| 63 | List<MesQcTemplateIndicatorDO> templateIndicators = templateIndicatorMapper.selectListByTemplateId(templateId); | 67 | List<MesQcTemplateIndicatorDO> templateIndicators = templateIndicatorMapper.selectListByTemplateId(templateId); |
| 64 | if (CollUtil.isEmpty(templateIndicators)) { | 68 | if (CollUtil.isEmpty(templateIndicators)) { |
| @@ -80,20 +84,6 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService { | @@ -80,20 +84,6 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService { | ||
| 80 | } | 84 | } |
| 81 | 85 | ||
| 82 | @Override | 86 | @Override |
| 83 | - public void deleteByIpqcId(Long ipqcId) { | ||
| 84 | - ipqcLineMapper.deleteByIpqcId(ipqcId); | ||
| 85 | - } | ||
| 86 | - | ||
| 87 | - @Override | ||
| 88 | - public MesQcIpqcLineDO validateIpqcLineExists(Long id) { | ||
| 89 | - MesQcIpqcLineDO line = ipqcLineMapper.selectById(id); | ||
| 90 | - if (line == null) { | ||
| 91 | - throw exception(QC_IPQC_LINE_NOT_EXISTS); | ||
| 92 | - } | ||
| 93 | - return line; | ||
| 94 | - } | ||
| 95 | - | ||
| 96 | - @Override | ||
| 97 | public void recalculateLineDefectStats(Long ipqcId, List<MesQcDefectRecordDO> records) { | 87 | public void recalculateLineDefectStats(Long ipqcId, List<MesQcDefectRecordDO> records) { |
| 98 | List<MesQcIpqcLineDO> lines = ipqcLineMapper.selectListByIpqcId(ipqcId); | 88 | List<MesQcIpqcLineDO> lines = ipqcLineMapper.selectListByIpqcId(ipqcId); |
| 99 | if (CollUtil.isEmpty(lines)) { | 89 | if (CollUtil.isEmpty(lines)) { |
| @@ -101,7 +91,9 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService { | @@ -101,7 +91,9 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService { | ||
| 101 | } | 91 | } |
| 102 | List<MesQcIpqcLineDO> updateLines = new ArrayList<>(lines.size()); | 92 | List<MesQcIpqcLineDO> updateLines = new ArrayList<>(lines.size()); |
| 103 | for (MesQcIpqcLineDO line : lines) { | 93 | for (MesQcIpqcLineDO line : lines) { |
| 104 | - int critical = 0, major = 0, minor = 0; | 94 | + int critical = 0; |
| 95 | + int major = 0; | ||
| 96 | + int minor = 0; | ||
| 105 | for (MesQcDefectRecordDO record : records) { | 97 | for (MesQcDefectRecordDO record : records) { |
| 106 | if (ObjUtil.notEqual(record.getLineId(), line.getId())) { | 98 | if (ObjUtil.notEqual(record.getLineId(), line.getId())) { |
| 107 | continue; | 99 | continue; |
| @@ -125,4 +117,14 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService { | @@ -125,4 +117,14 @@ public class MesQcIpqcLineServiceImpl implements MesQcIpqcLineService { | ||
| 125 | } | 117 | } |
| 126 | } | 118 | } |
| 127 | 119 | ||
| 120 | + @Override | ||
| 121 | + public List<MesQcIpqcLineDO> getIpqcLineListByIpqcId(Long ipqcId) { | ||
| 122 | + return ipqcLineMapper.selectListByIpqcId(ipqcId); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + @Override | ||
| 126 | + public void deleteListByIpqcId(Long ipqcId) { | ||
| 127 | + ipqcLineMapper.deleteByIpqcId(ipqcId); | ||
| 128 | + } | ||
| 129 | + | ||
| 128 | } | 130 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ipqc/MesQcIpqcServiceImpl.java
| @@ -104,8 +104,12 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -104,8 +104,12 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 104 | adminUserApi.validateUser(updateReqVO.getInspectorUserId()); | 104 | adminUserApi.validateUser(updateReqVO.getInspectorUserId()); |
| 105 | itemService.validateItemExists(updateReqVO.getItemId()); | 105 | itemService.validateItemExists(updateReqVO.getItemId()); |
| 106 | 106 | ||
| 107 | - // 2. 更新 | 107 | + // 2. 更新主表 |
| 108 | MesQcIpqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcIpqcDO.class); | 108 | MesQcIpqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcIpqcDO.class); |
| 109 | + updateObj.setSourceDocType(null).setSourceDocId(null).setSourceLineId(null); // 不允许修改来源单据 | ||
| 110 | + updateObj.setTemplateId(null); // 不允许修改模板 | ||
| 111 | + updateObj.setItemId(null); // 不允许修改物料 | ||
| 112 | + updateObj.setWorkOrderId(null); // 不允许修改工单 | ||
| 109 | ipqcMapper.updateById(updateObj); | 113 | ipqcMapper.updateById(updateObj); |
| 110 | } | 114 | } |
| 111 | 115 | ||
| @@ -119,9 +123,8 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -119,9 +123,8 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 119 | } | 123 | } |
| 120 | 124 | ||
| 121 | // 2. 更新状态为已完成 | 125 | // 2. 更新状态为已完成 |
| 122 | - MesQcIpqcDO updateObj = new MesQcIpqcDO(); | ||
| 123 | - updateObj.setId(id); | ||
| 124 | - updateObj.setStatus(MesQcStatusEnum.FINISHED.getStatus()); | 126 | + MesQcIpqcDO updateObj = new MesQcIpqcDO() |
| 127 | + .setId(id).setStatus(MesQcStatusEnum.FINISHED.getStatus()); | ||
| 125 | ipqcMapper.updateById(updateObj); | 128 | ipqcMapper.updateById(updateObj); |
| 126 | 129 | ||
| 127 | // TODO @AI(from codex):如果检验来源是报工,需要对待检产出按检验结果拆分合格/不合格行、生成产出明细、完成产品产出入库、 | 130 | // TODO @AI(from codex):如果检验来源是报工,需要对待检产出按检验结果拆分合格/不合格行、生成产出明细、完成产品产出入库、 |
| @@ -137,7 +140,7 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -137,7 +140,7 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 137 | // 2.1 删除主表 | 140 | // 2.1 删除主表 |
| 138 | ipqcMapper.deleteById(id); | 141 | ipqcMapper.deleteById(id); |
| 139 | // 2.2 级联删除行 | 142 | // 2.2 级联删除行 |
| 140 | - ipqcLineService.deleteByIpqcId(id); | 143 | + ipqcLineService.deleteListByIpqcId(id); |
| 141 | // 2.3 级联删除缺陷记录 | 144 | // 2.3 级联删除缺陷记录 |
| 142 | defectRecordService.deleteListByQcTypeAndQcId(MesQcTypeEnum.IPQC.getType(), id); | 145 | defectRecordService.deleteListByQcTypeAndQcId(MesQcTypeEnum.IPQC.getType(), id); |
| 143 | } | 146 | } |