Commit 0d27932d439e2f157a749b7cb5090ce72979156d
1 parent
ab748c03
refactor(mes): IQC 模块重构 - Service 拆分 + 字段清理 + 业务逻辑优化
1. 拆分 MesQcTemplateService → MesQcTemplateDetailService - 检测指标项、产品关联 CRUD 迁移至 DetailService - 新增 getRequiredTemplateByItemIdAndType 方法 2. MesQcIqcSaveReqVO 字段清理 - 删除 templateId/minCheckQuantity/maxUnqualifiedQuantity/checkQuantity/inspectorUserId - 增加 qualifiedQuantity/unqualifiedQuantity @NotNull + @DecimalMin 校验 - 增加 receiveDate/inspectDate @NotNull 校验 3. MesQcIqcServiceImpl 业务逻辑调整 - createIqc/updateIqc 增加 inspectorUserId 参数,由 Controller 传入 getLoginUserId() - templateId 不再由前端传递,后端根据 itemId + IQC 类型自动查找模板 - checkQuantity 由后端计算(= qualifiedQuantity + unqualifiedQuantity) - updateIqc 禁止修改 sourceDocType/sourceDocId/sourceLineId/templateId 4. MesQcIqcDO/RespVO 删除 minCheckQuantity、maxUnqualifiedQuantity 字段 5. 更新调用方:IndicatorController、ItemController、IQC/OQC/IPQC ServiceImpl
Showing
17 changed files
with
383 additions
and
308 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/iqc/MesQcIqcController.java
| @@ -39,6 +39,7 @@ import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPOR | @@ -39,6 +39,7 @@ import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPOR | ||
| 39 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 39 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 40 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 40 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 41 | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | 41 | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; |
| 42 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
| 42 | 43 | ||
| 43 | @Tag(name = "管理后台 - MES 来料检验单(IQC)") | 44 | @Tag(name = "管理后台 - MES 来料检验单(IQC)") |
| 44 | @RestController | 45 | @RestController |
| @@ -62,14 +63,14 @@ public class MesQcIqcController { | @@ -62,14 +63,14 @@ public class MesQcIqcController { | ||
| 62 | @Operation(summary = "创建来料检验单") | 63 | @Operation(summary = "创建来料检验单") |
| 63 | @PreAuthorize("@ss.hasPermission('mes:qc-iqc:create')") | 64 | @PreAuthorize("@ss.hasPermission('mes:qc-iqc:create')") |
| 64 | public CommonResult<Long> createIqc(@Valid @RequestBody MesQcIqcSaveReqVO createReqVO) { | 65 | public CommonResult<Long> createIqc(@Valid @RequestBody MesQcIqcSaveReqVO createReqVO) { |
| 65 | - return success(iqcService.createIqc(createReqVO)); | 66 | + return success(iqcService.createIqc(createReqVO, getLoginUserId())); |
| 66 | } | 67 | } |
| 67 | 68 | ||
| 68 | @PutMapping("/update") | 69 | @PutMapping("/update") |
| 69 | @Operation(summary = "更新来料检验单") | 70 | @Operation(summary = "更新来料检验单") |
| 70 | @PreAuthorize("@ss.hasPermission('mes:qc-iqc:update')") | 71 | @PreAuthorize("@ss.hasPermission('mes:qc-iqc:update')") |
| 71 | public CommonResult<Boolean> updateIqc(@Valid @RequestBody MesQcIqcSaveReqVO updateReqVO) { | 72 | public CommonResult<Boolean> updateIqc(@Valid @RequestBody MesQcIqcSaveReqVO updateReqVO) { |
| 72 | - iqcService.updateIqc(updateReqVO); | 73 | + iqcService.updateIqc(updateReqVO, getLoginUserId()); |
| 73 | return success(true); | 74 | return success(true); |
| 74 | } | 75 | } |
| 75 | 76 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/iqc/vo/MesQcIqcRespVO.java
| @@ -72,12 +72,6 @@ public class MesQcIqcRespVO { | @@ -72,12 +72,6 @@ public class MesQcIqcRespVO { | ||
| 72 | 72 | ||
| 73 | // ========== 数量 ========== | 73 | // ========== 数量 ========== |
| 74 | 74 | ||
| 75 | - @Schema(description = "最低检测数", example = "5") | ||
| 76 | - private Integer minCheckQuantity; | ||
| 77 | - | ||
| 78 | - @Schema(description = "最大不合格数", example = "0") | ||
| 79 | - private Integer maxUnqualifiedQuantity; | ||
| 80 | - | ||
| 81 | @Schema(description = "本次接收数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | 75 | @Schema(description = "本次接收数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| 82 | @ExcelProperty("接收数量") | 76 | @ExcelProperty("接收数量") |
| 83 | private BigDecimal receivedQuantity; | 77 | private BigDecimal receivedQuantity; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/iqc/vo/MesQcIqcSaveReqVO.java
| 1 | package cn.iocoder.yudao.module.mes.controller.admin.qc.iqc.vo; | 1 | package cn.iocoder.yudao.module.mes.controller.admin.qc.iqc.vo; |
| 2 | 2 | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | +import jakarta.validation.constraints.DecimalMin; | ||
| 4 | import jakarta.validation.constraints.NotEmpty; | 5 | import jakarta.validation.constraints.NotEmpty; |
| 5 | import jakarta.validation.constraints.NotNull; | 6 | import jakarta.validation.constraints.NotNull; |
| 6 | import lombok.Data; | 7 | import lombok.Data; |
| @@ -23,18 +24,14 @@ public class MesQcIqcSaveReqVO { | @@ -23,18 +24,14 @@ public class MesQcIqcSaveReqVO { | ||
| 23 | @NotEmpty(message = "检验单名称不能为空") | 24 | @NotEmpty(message = "检验单名称不能为空") |
| 24 | private String name; | 25 | private String name; |
| 25 | 26 | ||
| 26 | - @Schema(description = "检验模板 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | ||
| 27 | - @NotNull(message = "检验模板不能为空") | ||
| 28 | - private Long templateId; | ||
| 29 | - | ||
| 30 | // ========== 来源单据 ========== | 27 | // ========== 来源单据 ========== |
| 31 | 28 | ||
| 32 | - @Schema(description = "来源单据 ID", example = "200") | ||
| 33 | - private Long sourceDocId; | ||
| 34 | - | ||
| 35 | @Schema(description = "来源单据类型", example = "100") | 29 | @Schema(description = "来源单据类型", example = "100") |
| 36 | private Integer sourceDocType; | 30 | private Integer sourceDocType; |
| 37 | 31 | ||
| 32 | + @Schema(description = "来源单据 ID", example = "200") | ||
| 33 | + private Long sourceDocId; | ||
| 34 | + | ||
| 38 | @Schema(description = "来源单据行 ID", example = "300") | 35 | @Schema(description = "来源单据行 ID", example = "300") |
| 39 | private Long sourceLineId; | 36 | private Long sourceLineId; |
| 40 | 37 | ||
| @@ -55,23 +52,18 @@ public class MesQcIqcSaveReqVO { | @@ -55,23 +52,18 @@ public class MesQcIqcSaveReqVO { | ||
| 55 | 52 | ||
| 56 | // ========== 数量 ========== | 53 | // ========== 数量 ========== |
| 57 | 54 | ||
| 58 | - @Schema(description = "最低检测数", example = "5") | ||
| 59 | - private Integer minCheckQuantity; | ||
| 60 | - | ||
| 61 | - @Schema(description = "最大不合格数", example = "0") | ||
| 62 | - private Integer maxUnqualifiedQuantity; | ||
| 63 | - | ||
| 64 | @Schema(description = "本次接收数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | 55 | @Schema(description = "本次接收数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| 65 | @NotNull(message = "本次接收数量不能为空") | 56 | @NotNull(message = "本次接收数量不能为空") |
| 66 | private BigDecimal receivedQuantity; | 57 | private BigDecimal receivedQuantity; |
| 67 | 58 | ||
| 68 | - @Schema(description = "本次检测数量", example = "10") | ||
| 69 | - private BigDecimal checkQuantity; | ||
| 70 | - | ||
| 71 | - @Schema(description = "合格品数量", example = "9") | 59 | + @Schema(description = "合格品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "9") |
| 60 | + @NotNull(message = "合格品数量不能为空") | ||
| 61 | + @DecimalMin(value = "0", message = "合格品数量不能小于 0") | ||
| 72 | private BigDecimal qualifiedQuantity; | 62 | private BigDecimal qualifiedQuantity; |
| 73 | 63 | ||
| 74 | - @Schema(description = "不合格品数量", example = "1") | 64 | + @Schema(description = "不合格品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 65 | + @NotNull(message = "不合格品数量不能为空") | ||
| 66 | + @DecimalMin(value = "0", message = "不合格品数量不能小于 0") | ||
| 75 | private BigDecimal unqualifiedQuantity; | 67 | private BigDecimal unqualifiedQuantity; |
| 76 | 68 | ||
| 77 | // ========== 检验 ========== | 69 | // ========== 检验 ========== |
| @@ -79,15 +71,14 @@ public class MesQcIqcSaveReqVO { | @@ -79,15 +71,14 @@ public class MesQcIqcSaveReqVO { | ||
| 79 | @Schema(description = "检测结果", example = "1") | 71 | @Schema(description = "检测结果", example = "1") |
| 80 | private Integer checkResult; | 72 | private Integer checkResult; |
| 81 | 73 | ||
| 82 | - @Schema(description = "来料日期") | 74 | + @Schema(description = "来料日期", requiredMode = Schema.RequiredMode.REQUIRED) |
| 75 | + @NotNull(message = "来料日期不能为空") | ||
| 83 | private LocalDateTime receiveDate; | 76 | private LocalDateTime receiveDate; |
| 84 | 77 | ||
| 85 | - @Schema(description = "检测日期") | 78 | + @Schema(description = "检测日期", requiredMode = Schema.RequiredMode.REQUIRED) |
| 79 | + @NotNull(message = "检测日期不能为空") | ||
| 86 | private LocalDateTime inspectDate; | 80 | private LocalDateTime inspectDate; |
| 87 | 81 | ||
| 88 | - @Schema(description = "检测人员用户 ID", example = "1") | ||
| 89 | - private Long inspectorUserId; | ||
| 90 | - | ||
| 91 | @Schema(description = "备注", example = "备注") | 82 | @Schema(description = "备注", example = "备注") |
| 92 | private String remark; | 83 | private String remark; |
| 93 | 84 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/template/MesQcTemplateIndicatorController.java
| @@ -12,7 +12,7 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO; | @@ -12,7 +12,7 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO; | ||
| 12 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateIndicatorDO; | 12 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateIndicatorDO; |
| 13 | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | 13 | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; |
| 14 | import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService; | 14 | import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService; |
| 15 | -import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateService; | 15 | +import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateDetailService; |
| 16 | import io.swagger.v3.oas.annotations.Operation; | 16 | import io.swagger.v3.oas.annotations.Operation; |
| 17 | import io.swagger.v3.oas.annotations.Parameter; | 17 | import io.swagger.v3.oas.annotations.Parameter; |
| 18 | import io.swagger.v3.oas.annotations.tags.Tag; | 18 | import io.swagger.v3.oas.annotations.tags.Tag; |
| @@ -37,7 +37,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | @@ -37,7 +37,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 37 | public class MesQcTemplateIndicatorController { | 37 | public class MesQcTemplateIndicatorController { |
| 38 | 38 | ||
| 39 | @Resource | 39 | @Resource |
| 40 | - private MesQcTemplateService templateService; | 40 | + private MesQcTemplateDetailService templateDetailService; |
| 41 | @Resource | 41 | @Resource |
| 42 | private MesQcIndicatorService indicatorService; | 42 | private MesQcIndicatorService indicatorService; |
| 43 | @Resource | 43 | @Resource |
| @@ -47,14 +47,14 @@ public class MesQcTemplateIndicatorController { | @@ -47,14 +47,14 @@ public class MesQcTemplateIndicatorController { | ||
| 47 | @Operation(summary = "创建质检方案-检测指标项") | 47 | @Operation(summary = "创建质检方案-检测指标项") |
| 48 | @PreAuthorize("@ss.hasPermission('mes:qc-template:create')") | 48 | @PreAuthorize("@ss.hasPermission('mes:qc-template:create')") |
| 49 | public CommonResult<Long> createTemplateIndicator(@Valid @RequestBody MesQcTemplateIndicatorSaveReqVO createReqVO) { | 49 | public CommonResult<Long> createTemplateIndicator(@Valid @RequestBody MesQcTemplateIndicatorSaveReqVO createReqVO) { |
| 50 | - return success(templateService.createTemplateIndicator(createReqVO)); | 50 | + return success(templateDetailService.createTemplateIndicator(createReqVO)); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | @PutMapping("/update") | 53 | @PutMapping("/update") |
| 54 | @Operation(summary = "更新质检方案-检测指标项") | 54 | @Operation(summary = "更新质检方案-检测指标项") |
| 55 | @PreAuthorize("@ss.hasPermission('mes:qc-template:update')") | 55 | @PreAuthorize("@ss.hasPermission('mes:qc-template:update')") |
| 56 | public CommonResult<Boolean> updateTemplateIndicator(@Valid @RequestBody MesQcTemplateIndicatorSaveReqVO updateReqVO) { | 56 | public CommonResult<Boolean> updateTemplateIndicator(@Valid @RequestBody MesQcTemplateIndicatorSaveReqVO updateReqVO) { |
| 57 | - templateService.updateTemplateIndicator(updateReqVO); | 57 | + templateDetailService.updateTemplateIndicator(updateReqVO); |
| 58 | return success(true); | 58 | return success(true); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| @@ -63,7 +63,7 @@ public class MesQcTemplateIndicatorController { | @@ -63,7 +63,7 @@ public class MesQcTemplateIndicatorController { | ||
| 63 | @Parameter(name = "id", description = "编号", required = true) | 63 | @Parameter(name = "id", description = "编号", required = true) |
| 64 | @PreAuthorize("@ss.hasPermission('mes:qc-template:update')") | 64 | @PreAuthorize("@ss.hasPermission('mes:qc-template:update')") |
| 65 | public CommonResult<Boolean> deleteTemplateIndicator(@RequestParam("id") Long id) { | 65 | public CommonResult<Boolean> deleteTemplateIndicator(@RequestParam("id") Long id) { |
| 66 | - templateService.deleteTemplateIndicator(id); | 66 | + templateDetailService.deleteTemplateIndicator(id); |
| 67 | return success(true); | 67 | return success(true); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| @@ -72,7 +72,7 @@ public class MesQcTemplateIndicatorController { | @@ -72,7 +72,7 @@ public class MesQcTemplateIndicatorController { | ||
| 72 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 72 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 73 | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") | 73 | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") |
| 74 | public CommonResult<MesQcTemplateIndicatorRespVO> getTemplateIndicator(@RequestParam("id") Long id) { | 74 | public CommonResult<MesQcTemplateIndicatorRespVO> getTemplateIndicator(@RequestParam("id") Long id) { |
| 75 | - MesQcTemplateIndicatorDO indicator = templateService.getTemplateIndicator(id); | 75 | + MesQcTemplateIndicatorDO indicator = templateDetailService.getTemplateIndicator(id); |
| 76 | return success(buildIndicatorRespVOList(Collections.singletonList(indicator)).get(0)); | 76 | return success(buildIndicatorRespVOList(Collections.singletonList(indicator)).get(0)); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| @@ -81,7 +81,7 @@ public class MesQcTemplateIndicatorController { | @@ -81,7 +81,7 @@ public class MesQcTemplateIndicatorController { | ||
| 81 | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") | 81 | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") |
| 82 | public CommonResult<PageResult<MesQcTemplateIndicatorRespVO>> getTemplateIndicatorPage( | 82 | public CommonResult<PageResult<MesQcTemplateIndicatorRespVO>> getTemplateIndicatorPage( |
| 83 | @Valid MesQcTemplateIndicatorPageReqVO pageReqVO) { | 83 | @Valid MesQcTemplateIndicatorPageReqVO pageReqVO) { |
| 84 | - PageResult<MesQcTemplateIndicatorDO> pageResult = templateService.getTemplateIndicatorPage(pageReqVO); | 84 | + PageResult<MesQcTemplateIndicatorDO> pageResult = templateDetailService.getTemplateIndicatorPage(pageReqVO); |
| 85 | return success(new PageResult<>(buildIndicatorRespVOList(pageResult.getList()), pageResult.getTotal())); | 85 | return success(new PageResult<>(buildIndicatorRespVOList(pageResult.getList()), pageResult.getTotal())); |
| 86 | } | 86 | } |
| 87 | 87 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/template/MesQcTemplateItemController.java
| @@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasur | @@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasur | ||
| 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateItemDO; | 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateItemDO; |
| 12 | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | 12 | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| 13 | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | 13 | import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; |
| 14 | -import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateService; | 14 | +import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateDetailService; |
| 15 | import io.swagger.v3.oas.annotations.Operation; | 15 | import io.swagger.v3.oas.annotations.Operation; |
| 16 | import io.swagger.v3.oas.annotations.Parameter; | 16 | import io.swagger.v3.oas.annotations.Parameter; |
| 17 | import io.swagger.v3.oas.annotations.tags.Tag; | 17 | import io.swagger.v3.oas.annotations.tags.Tag; |
| @@ -36,7 +36,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | @@ -36,7 +36,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 36 | public class MesQcTemplateItemController { | 36 | public class MesQcTemplateItemController { |
| 37 | 37 | ||
| 38 | @Resource | 38 | @Resource |
| 39 | - private MesQcTemplateService templateService; | 39 | + private MesQcTemplateDetailService templateDetailService; |
| 40 | @Resource | 40 | @Resource |
| 41 | private MesMdItemService mdItemService; | 41 | private MesMdItemService mdItemService; |
| 42 | @Resource | 42 | @Resource |
| @@ -46,14 +46,14 @@ public class MesQcTemplateItemController { | @@ -46,14 +46,14 @@ public class MesQcTemplateItemController { | ||
| 46 | @Operation(summary = "创建质检方案-产品关联") | 46 | @Operation(summary = "创建质检方案-产品关联") |
| 47 | @PreAuthorize("@ss.hasPermission('mes:qc-template:create')") | 47 | @PreAuthorize("@ss.hasPermission('mes:qc-template:create')") |
| 48 | public CommonResult<Long> createTemplateItem(@Valid @RequestBody MesQcTemplateItemSaveReqVO createReqVO) { | 48 | public CommonResult<Long> createTemplateItem(@Valid @RequestBody MesQcTemplateItemSaveReqVO createReqVO) { |
| 49 | - return success(templateService.createTemplateItem(createReqVO)); | 49 | + return success(templateDetailService.createTemplateItem(createReqVO)); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | @PutMapping("/update") | 52 | @PutMapping("/update") |
| 53 | @Operation(summary = "更新质检方案-产品关联") | 53 | @Operation(summary = "更新质检方案-产品关联") |
| 54 | @PreAuthorize("@ss.hasPermission('mes:qc-template:update')") | 54 | @PreAuthorize("@ss.hasPermission('mes:qc-template:update')") |
| 55 | public CommonResult<Boolean> updateTemplateItem(@Valid @RequestBody MesQcTemplateItemSaveReqVO updateReqVO) { | 55 | public CommonResult<Boolean> updateTemplateItem(@Valid @RequestBody MesQcTemplateItemSaveReqVO updateReqVO) { |
| 56 | - templateService.updateTemplateItem(updateReqVO); | 56 | + templateDetailService.updateTemplateItem(updateReqVO); |
| 57 | return success(true); | 57 | return success(true); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -62,7 +62,7 @@ public class MesQcTemplateItemController { | @@ -62,7 +62,7 @@ public class MesQcTemplateItemController { | ||
| 62 | @Parameter(name = "id", description = "编号", required = true) | 62 | @Parameter(name = "id", description = "编号", required = true) |
| 63 | @PreAuthorize("@ss.hasPermission('mes:qc-template:update')") | 63 | @PreAuthorize("@ss.hasPermission('mes:qc-template:update')") |
| 64 | public CommonResult<Boolean> deleteTemplateItem(@RequestParam("id") Long id) { | 64 | public CommonResult<Boolean> deleteTemplateItem(@RequestParam("id") Long id) { |
| 65 | - templateService.deleteTemplateItem(id); | 65 | + templateDetailService.deleteTemplateItem(id); |
| 66 | return success(true); | 66 | return success(true); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| @@ -71,7 +71,7 @@ public class MesQcTemplateItemController { | @@ -71,7 +71,7 @@ public class MesQcTemplateItemController { | ||
| 71 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 71 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 72 | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") | 72 | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") |
| 73 | public CommonResult<MesQcTemplateItemRespVO> getTemplateItem(@RequestParam("id") Long id) { | 73 | public CommonResult<MesQcTemplateItemRespVO> getTemplateItem(@RequestParam("id") Long id) { |
| 74 | - MesQcTemplateItemDO item = templateService.getTemplateItem(id); | 74 | + MesQcTemplateItemDO item = templateDetailService.getTemplateItem(id); |
| 75 | return success(buildItemRespVOList(Collections.singletonList(item)).get(0)); | 75 | return success(buildItemRespVOList(Collections.singletonList(item)).get(0)); |
| 76 | } | 76 | } |
| 77 | 77 | ||
| @@ -80,7 +80,7 @@ public class MesQcTemplateItemController { | @@ -80,7 +80,7 @@ public class MesQcTemplateItemController { | ||
| 80 | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") | 80 | @PreAuthorize("@ss.hasPermission('mes:qc-template:query')") |
| 81 | public CommonResult<PageResult<MesQcTemplateItemRespVO>> getTemplateItemPage( | 81 | public CommonResult<PageResult<MesQcTemplateItemRespVO>> getTemplateItemPage( |
| 82 | @Valid MesQcTemplateItemPageReqVO pageReqVO) { | 82 | @Valid MesQcTemplateItemPageReqVO pageReqVO) { |
| 83 | - PageResult<MesQcTemplateItemDO> pageResult = templateService.getTemplateItemPage(pageReqVO); | 83 | + PageResult<MesQcTemplateItemDO> pageResult = templateDetailService.getTemplateItemPage(pageReqVO); |
| 84 | return success(new PageResult<>(buildItemRespVOList(pageResult.getList()), pageResult.getTotal())); | 84 | return success(new PageResult<>(buildItemRespVOList(pageResult.getList()), pageResult.getTotal())); |
| 85 | } | 85 | } |
| 86 | 86 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/iqc/MesQcIqcDO.java
| @@ -98,14 +98,6 @@ public class MesQcIqcDO extends BaseDO { | @@ -98,14 +98,6 @@ public class MesQcIqcDO extends BaseDO { | ||
| 98 | // ========== 数量 ========== | 98 | // ========== 数量 ========== |
| 99 | 99 | ||
| 100 | /** | 100 | /** |
| 101 | - * 最低检测数 | ||
| 102 | - */ | ||
| 103 | - private Integer minCheckQuantity; | ||
| 104 | - /** | ||
| 105 | - * 最大不合格数 | ||
| 106 | - */ | ||
| 107 | - private Integer maxUnqualifiedQuantity; | ||
| 108 | - /** | ||
| 109 | * 本次接收数量 | 101 | * 本次接收数量 |
| 110 | */ | 102 | */ |
| 111 | private BigDecimal receivedQuantity; | 103 | private BigDecimal receivedQuantity; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/defectrecord/MesQcDefectRecordService.java
| @@ -49,6 +49,6 @@ public interface MesQcDefectRecordService { | @@ -49,6 +49,6 @@ public interface MesQcDefectRecordService { | ||
| 49 | * @param qcType 检验类型 | 49 | * @param qcType 检验类型 |
| 50 | * @param qcId 检验单 ID | 50 | * @param qcId 检验单 ID |
| 51 | */ | 51 | */ |
| 52 | - void deleteByQcTypeAndQcId(Integer qcType, Long qcId); | 52 | + void deleteListByQcTypeAndQcId(Integer qcType, Long qcId); |
| 53 | 53 | ||
| 54 | } | 54 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/defectrecord/MesQcDefectRecordServiceImpl.java
| @@ -115,7 +115,7 @@ public class MesQcDefectRecordServiceImpl implements MesQcDefectRecordService { | @@ -115,7 +115,7 @@ public class MesQcDefectRecordServiceImpl implements MesQcDefectRecordService { | ||
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | @Override | 117 | @Override |
| 118 | - public void deleteByQcTypeAndQcId(Integer qcType, Long qcId) { | 118 | + public void deleteListByQcTypeAndQcId(Integer qcType, Long qcId) { |
| 119 | defectRecordMapper.deleteByQcTypeAndQcId(qcType, qcId); | 119 | defectRecordMapper.deleteByQcTypeAndQcId(qcType, qcId); |
| 120 | } | 120 | } |
| 121 | 121 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ipqc/MesQcIpqcServiceImpl.java
| @@ -16,7 +16,7 @@ import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum; | @@ -16,7 +16,7 @@ import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum; | ||
| 16 | import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; | 16 | import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; |
| 17 | import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService; | 17 | import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService; |
| 18 | import cn.iocoder.yudao.module.mes.service.qc.defectrecord.MesQcDefectRecordService; | 18 | import cn.iocoder.yudao.module.mes.service.qc.defectrecord.MesQcDefectRecordService; |
| 19 | -import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateService; | 19 | +import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateDetailService; |
| 20 | import jakarta.annotation.Resource; | 20 | import jakarta.annotation.Resource; |
| 21 | import org.springframework.context.annotation.Lazy; | 21 | import org.springframework.context.annotation.Lazy; |
| 22 | import org.springframework.stereotype.Service; | 22 | import org.springframework.stereotype.Service; |
| @@ -44,7 +44,7 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -44,7 +44,7 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 44 | private MesQcIpqcMapper ipqcMapper; | 44 | private MesQcIpqcMapper ipqcMapper; |
| 45 | 45 | ||
| 46 | @Resource | 46 | @Resource |
| 47 | - private MesQcTemplateService templateService; | 47 | + private MesQcTemplateDetailService templateDetailService; |
| 48 | @Resource | 48 | @Resource |
| 49 | private MesQcIpqcLineService ipqcLineService; | 49 | private MesQcIpqcLineService ipqcLineService; |
| 50 | @Resource | 50 | @Resource |
| @@ -67,7 +67,7 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -67,7 +67,7 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 67 | // 1.3 校验工位存在 | 67 | // 1.3 校验工位存在 |
| 68 | workstationService.validateWorkstationExists(createReqVO.getWorkstationId()); | 68 | workstationService.validateWorkstationExists(createReqVO.getWorkstationId()); |
| 69 | // 1.4 根据产品 + 检验类型自动匹配模板 | 69 | // 1.4 根据产品 + 检验类型自动匹配模板 |
| 70 | - MesQcTemplateDO template = templateService.getTemplateByItemIdAndType( | 70 | + MesQcTemplateDO template = templateDetailService.getTemplateByItemIdAndType( |
| 71 | workOrder.getProductId(), MesQcTypeEnum.IPQC.getType()); | 71 | workOrder.getProductId(), MesQcTypeEnum.IPQC.getType()); |
| 72 | if (template == null) { | 72 | if (template == null) { |
| 73 | throw exception(QC_IPQC_NO_TEMPLATE); | 73 | throw exception(QC_IPQC_NO_TEMPLATE); |
| @@ -129,7 +129,7 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -129,7 +129,7 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 129 | // 2.2 级联删除行 | 129 | // 2.2 级联删除行 |
| 130 | ipqcLineService.deleteByIpqcId(id); | 130 | ipqcLineService.deleteByIpqcId(id); |
| 131 | // 2.3 级联删除缺陷记录 | 131 | // 2.3 级联删除缺陷记录 |
| 132 | - defectRecordService.deleteByQcTypeAndQcId(MesQcTypeEnum.IPQC.getType(), id); | 132 | + defectRecordService.deleteListByQcTypeAndQcId(MesQcTypeEnum.IPQC.getType(), id); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | @Override | 135 | @Override |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcLineService.java
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/iqc/MesQcIqcLineServiceImpl.java
| @@ -106,7 +106,7 @@ public class MesQcIqcLineServiceImpl implements MesQcIqcLineService { | @@ -106,7 +106,7 @@ public class MesQcIqcLineServiceImpl implements MesQcIqcLineService { | ||
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | @Override | 108 | @Override |
| 109 | - public void deleteByIqcId(Long iqcId) { | 109 | + public void deleteListByIqcId(Long iqcId) { |
| 110 | iqcLineMapper.deleteByIqcId(iqcId); | 110 | iqcLineMapper.deleteByIqcId(iqcId); |
| 111 | } | 111 | } |
| 112 | 112 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/oqc/MesQcOqcServiceImpl.java
| @@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.mes.enums.qc.MesQcDefectLevelEnum; | @@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.mes.enums.qc.MesQcDefectLevelEnum; | ||
| 15 | import cn.iocoder.yudao.module.mes.enums.qc.MesQcOqcStatusEnum; | 15 | import cn.iocoder.yudao.module.mes.enums.qc.MesQcOqcStatusEnum; |
| 16 | import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum; | 16 | import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum; |
| 17 | import cn.iocoder.yudao.module.mes.service.qc.defectrecord.MesQcDefectRecordService; | 17 | import cn.iocoder.yudao.module.mes.service.qc.defectrecord.MesQcDefectRecordService; |
| 18 | +import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateDetailService; | ||
| 18 | import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateService; | 19 | import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateService; |
| 19 | import jakarta.annotation.Resource; | 20 | import jakarta.annotation.Resource; |
| 20 | import org.springframework.context.annotation.Lazy; | 21 | import org.springframework.context.annotation.Lazy; |
| @@ -44,6 +45,8 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | @@ -44,6 +45,8 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | ||
| 44 | @Resource | 45 | @Resource |
| 45 | private MesQcTemplateService templateService; | 46 | private MesQcTemplateService templateService; |
| 46 | @Resource | 47 | @Resource |
| 48 | + private MesQcTemplateDetailService templateDetailService; | ||
| 49 | + @Resource | ||
| 47 | private MesQcOqcLineService oqcLineService; | 50 | private MesQcOqcLineService oqcLineService; |
| 48 | @Resource | 51 | @Resource |
| 49 | @Lazy | 52 | @Lazy |
| @@ -63,7 +66,7 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | @@ -63,7 +66,7 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | ||
| 63 | 66 | ||
| 64 | // 1.3 从模板的产品关联中获取检测参数 | 67 | // 1.3 从模板的产品关联中获取检测参数 |
| 65 | // TODO @芋艿:【暂时不用删除】到底 miniCheckQuantity 和 maxUnqualifiedQuantity 是否有必要存储? | 68 | // TODO @芋艿:【暂时不用删除】到底 miniCheckQuantity 和 maxUnqualifiedQuantity 是否有必要存储? |
| 66 | - MesQcTemplateItemDO templateItem = templateService.getTemplateItemByTemplateIdAndItemId( | 69 | + MesQcTemplateItemDO templateItem = templateDetailService.getTemplateItemByTemplateIdAndItemId( |
| 67 | templateId, createReqVO.getItemId()); | 70 | templateId, createReqVO.getItemId()); |
| 68 | if (templateItem != null) { | 71 | if (templateItem != null) { |
| 69 | if (createReqVO.getMinCheckQuantity() == null) { | 72 | if (createReqVO.getMinCheckQuantity() == null) { |
| @@ -128,7 +131,7 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | @@ -128,7 +131,7 @@ public class MesQcOqcServiceImpl implements MesQcOqcService { | ||
| 128 | // 2.2 级联删除行 | 131 | // 2.2 级联删除行 |
| 129 | oqcLineService.deleteByOqcId(id); | 132 | oqcLineService.deleteByOqcId(id); |
| 130 | // 2.3 级联删除缺陷记录 | 133 | // 2.3 级联删除缺陷记录 |
| 131 | - defectRecordService.deleteByQcTypeAndQcId(MesQcTypeEnum.OQC.getType(), id); | 134 | + defectRecordService.deleteListByQcTypeAndQcId(MesQcTypeEnum.OQC.getType(), id); |
| 132 | } | 135 | } |
| 133 | 136 | ||
| 134 | @Override | 137 | @Override |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcServiceImpl.java
| @@ -111,7 +111,7 @@ public class MesQcRqcServiceImpl implements MesQcRqcService { | @@ -111,7 +111,7 @@ public class MesQcRqcServiceImpl implements MesQcRqcService { | ||
| 111 | // 2.2 级联删除行 | 111 | // 2.2 级联删除行 |
| 112 | rqcLineService.deleteByRqcId(id); | 112 | rqcLineService.deleteByRqcId(id); |
| 113 | // 2.3 级联删除缺陷记录 | 113 | // 2.3 级联删除缺陷记录 |
| 114 | - defectRecordService.deleteByQcTypeAndQcId(MesQcTypeEnum.RQC.getType(), id); | 114 | + defectRecordService.deleteListByQcTypeAndQcId(MesQcTypeEnum.RQC.getType(), id); |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | @Override | 117 | @Override |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/template/MesQcTemplateDetailService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.qc.template; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.indicator.MesQcTemplateIndicatorPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.indicator.MesQcTemplateIndicatorSaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemSaveReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateDO; | ||
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateIndicatorDO; | ||
| 10 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateItemDO; | ||
| 11 | +import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum; | ||
| 12 | +import jakarta.validation.Valid; | ||
| 13 | + | ||
| 14 | +// TODO @AI:还是按照表,拆分。而不是 detail; | ||
| 15 | +/** | ||
| 16 | + * MES 质检方案明细 Service 接口 | ||
| 17 | + * | ||
| 18 | + * 专注于质检方案的检测指标项和产品关联的 CRUD,以及复杂查询逻辑 | ||
| 19 | + * | ||
| 20 | + * @author 芋道源码 | ||
| 21 | + */ | ||
| 22 | +public interface MesQcTemplateDetailService { | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 创建检测指标项 | ||
| 26 | + * | ||
| 27 | + * @param createReqVO 创建信息 | ||
| 28 | + * @return 编号 | ||
| 29 | + */ | ||
| 30 | + Long createTemplateIndicator(@Valid MesQcTemplateIndicatorSaveReqVO createReqVO); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 更新检测指标项 | ||
| 34 | + * | ||
| 35 | + * @param updateReqVO 更新信息 | ||
| 36 | + */ | ||
| 37 | + void updateTemplateIndicator(@Valid MesQcTemplateIndicatorSaveReqVO updateReqVO); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 删除检测指标项 | ||
| 41 | + * | ||
| 42 | + * @param id 编号 | ||
| 43 | + */ | ||
| 44 | + void deleteTemplateIndicator(Long id); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得检测指标项 | ||
| 48 | + * | ||
| 49 | + * @param id 编号 | ||
| 50 | + * @return 检测指标项 | ||
| 51 | + */ | ||
| 52 | + MesQcTemplateIndicatorDO getTemplateIndicator(Long id); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 获得检测指标项分页 | ||
| 56 | + * | ||
| 57 | + * @param pageReqVO 分页查询 | ||
| 58 | + * @return 检测指标项分页 | ||
| 59 | + */ | ||
| 60 | + PageResult<MesQcTemplateIndicatorDO> getTemplateIndicatorPage(MesQcTemplateIndicatorPageReqVO pageReqVO); | ||
| 61 | + | ||
| 62 | + // ========== 质检方案-产品关联 ========== | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 创建产品关联 | ||
| 66 | + * | ||
| 67 | + * @param createReqVO 创建信息 | ||
| 68 | + * @return 编号 | ||
| 69 | + */ | ||
| 70 | + Long createTemplateItem(@Valid MesQcTemplateItemSaveReqVO createReqVO); | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 更新产品关联 | ||
| 74 | + * | ||
| 75 | + * @param updateReqVO 更新信息 | ||
| 76 | + */ | ||
| 77 | + void updateTemplateItem(@Valid MesQcTemplateItemSaveReqVO updateReqVO); | ||
| 78 | + | ||
| 79 | + /** | ||
| 80 | + * 删除产品关联 | ||
| 81 | + * | ||
| 82 | + * @param id 编号 | ||
| 83 | + */ | ||
| 84 | + void deleteTemplateItem(Long id); | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * 获得产品关联 | ||
| 88 | + * | ||
| 89 | + * @param id 编号 | ||
| 90 | + * @return 产品关联 | ||
| 91 | + */ | ||
| 92 | + MesQcTemplateItemDO getTemplateItem(Long id); | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * 获得产品关联分页 | ||
| 96 | + * | ||
| 97 | + * @param pageReqVO 分页查询 | ||
| 98 | + * @return 产品关联分页 | ||
| 99 | + */ | ||
| 100 | + PageResult<MesQcTemplateItemDO> getTemplateItemPage(MesQcTemplateItemPageReqVO pageReqVO); | ||
| 101 | + | ||
| 102 | + // ========== 复杂查询 ========== | ||
| 103 | + | ||
| 104 | + /** | ||
| 105 | + * 根据方案 ID + 产品 ID 获取产品关联 | ||
| 106 | + * | ||
| 107 | + * @param templateId 方案 ID | ||
| 108 | + * @param itemId 产品 ID | ||
| 109 | + * @return 产品关联 | ||
| 110 | + */ | ||
| 111 | + MesQcTemplateItemDO getTemplateItemByTemplateIdAndItemId(Long templateId, Long itemId); | ||
| 112 | + | ||
| 113 | + // TODO @芋艿:【不要删除】后续这个方法,会慢慢被替代掉; | ||
| 114 | + /** | ||
| 115 | + * 根据产品物料 ID 和 QC 类型查找检验模板 | ||
| 116 | + * | ||
| 117 | + * 查找逻辑:在 template_item 中找到匹配 itemId 的模板,再校验该模板的 types 包含给定的 qcType | ||
| 118 | + * | ||
| 119 | + * @param itemId 产品物料 ID | ||
| 120 | + * @param qcType 检测种类(枚举 {@link MesQcTypeEnum}) | ||
| 121 | + * @return 匹配的检验模板(可能为 null) | ||
| 122 | + */ | ||
| 123 | + MesQcTemplateDO getTemplateByItemIdAndType(Long itemId, Integer qcType); | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * 根据产品物料 ID 和 QC 类型查找检验模板的产品关联(必须存在,否则抛异常) | ||
| 127 | + * | ||
| 128 | + * @param itemId 产品物料 ID | ||
| 129 | + * @param qcType 检测种类(枚举 {@link MesQcTypeEnum}) | ||
| 130 | + * @return 匹配的产品关联 | ||
| 131 | + */ | ||
| 132 | + MesQcTemplateItemDO getRequiredTemplateByItemIdAndType(Long itemId, Integer qcType); | ||
| 133 | + | ||
| 134 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/template/MesQcTemplateDetailServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.qc.template; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.hutool.core.util.ObjUtil; | ||
| 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.template.vo.indicator.MesQcTemplateIndicatorPageReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.indicator.MesQcTemplateIndicatorSaveReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemPageReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemSaveReqVO; | ||
| 11 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateDO; | ||
| 12 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateIndicatorDO; | ||
| 13 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateItemDO; | ||
| 14 | +import cn.iocoder.yudao.module.mes.dal.mysql.qc.indicator.MesQcIndicatorMapper; | ||
| 15 | +import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateIndicatorMapper; | ||
| 16 | +import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateItemMapper; | ||
| 17 | +import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateMapper; | ||
| 18 | +import jakarta.annotation.Resource; | ||
| 19 | +import org.springframework.context.annotation.Lazy; | ||
| 20 | +import org.springframework.stereotype.Service; | ||
| 21 | +import org.springframework.validation.annotation.Validated; | ||
| 22 | + | ||
| 23 | +import java.util.List; | ||
| 24 | +import java.util.Objects; | ||
| 25 | + | ||
| 26 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 27 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 28 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; | ||
| 29 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | ||
| 30 | + | ||
| 31 | +/** | ||
| 32 | + * MES 质检方案明细 Service 实现类 | ||
| 33 | + * | ||
| 34 | + * 专注于质检方案的检测指标项和产品关联的 CRUD,以及复杂查询逻辑 | ||
| 35 | + * | ||
| 36 | + * @author 芋道源码 | ||
| 37 | + */ | ||
| 38 | +@Service | ||
| 39 | +@Validated | ||
| 40 | +public class MesQcTemplateDetailServiceImpl implements MesQcTemplateDetailService { | ||
| 41 | + | ||
| 42 | + @Resource | ||
| 43 | + private MesQcTemplateMapper templateMapper; | ||
| 44 | + @Resource | ||
| 45 | + private MesQcTemplateIndicatorMapper templateIndicatorMapper; | ||
| 46 | + @Resource | ||
| 47 | + private MesQcTemplateItemMapper templateItemMapper; | ||
| 48 | + @Resource | ||
| 49 | + private MesQcIndicatorMapper indicatorMapper; | ||
| 50 | + | ||
| 51 | + @Resource | ||
| 52 | + @Lazy | ||
| 53 | + private MesQcTemplateService templateService; | ||
| 54 | + | ||
| 55 | + // ========== 质检方案-检测指标项 ========== | ||
| 56 | + | ||
| 57 | + @Override | ||
| 58 | + public Long createTemplateIndicator(MesQcTemplateIndicatorSaveReqVO createReqVO) { | ||
| 59 | + // 校验方案存在 | ||
| 60 | + templateService.validateTemplateExists(createReqVO.getTemplateId()); | ||
| 61 | + // 插入 | ||
| 62 | + MesQcTemplateIndicatorDO indicator = BeanUtils.toBean(createReqVO, MesQcTemplateIndicatorDO.class); | ||
| 63 | + templateIndicatorMapper.insert(indicator); | ||
| 64 | + return indicator.getId(); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Override | ||
| 68 | + public void updateTemplateIndicator(MesQcTemplateIndicatorSaveReqVO updateReqVO) { | ||
| 69 | + // 校验存在 | ||
| 70 | + validateTemplateIndicatorExists(updateReqVO.getId()); | ||
| 71 | + // 更新 | ||
| 72 | + MesQcTemplateIndicatorDO updateObj = BeanUtils.toBean(updateReqVO, MesQcTemplateIndicatorDO.class); | ||
| 73 | + templateIndicatorMapper.updateById(updateObj); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @Override | ||
| 77 | + public void deleteTemplateIndicator(Long id) { | ||
| 78 | + // 校验存在 | ||
| 79 | + validateTemplateIndicatorExists(id); | ||
| 80 | + // 删除 | ||
| 81 | + templateIndicatorMapper.deleteById(id); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + private void validateTemplateIndicatorExists(Long id) { | ||
| 85 | + if (templateIndicatorMapper.selectById(id) == null) { | ||
| 86 | + throw exception(QC_TEMPLATE_INDICATOR_NOT_EXISTS); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + @Override | ||
| 91 | + public MesQcTemplateIndicatorDO getTemplateIndicator(Long id) { | ||
| 92 | + return templateIndicatorMapper.selectById(id); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @Override | ||
| 96 | + public PageResult<MesQcTemplateIndicatorDO> getTemplateIndicatorPage(MesQcTemplateIndicatorPageReqVO pageReqVO) { | ||
| 97 | + return templateIndicatorMapper.selectPage(pageReqVO); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + // ========== 质检方案-产品关联 ========== | ||
| 101 | + | ||
| 102 | + @Override | ||
| 103 | + public Long createTemplateItem(MesQcTemplateItemSaveReqVO createReqVO) { | ||
| 104 | + // 校验方案存在 | ||
| 105 | + templateService.validateTemplateExists(createReqVO.getTemplateId()); | ||
| 106 | + // 校验产品在此方案中唯一 | ||
| 107 | + validateTemplateItemNotDuplicate(null, createReqVO.getTemplateId(), createReqVO.getItemId()); | ||
| 108 | + // 插入 | ||
| 109 | + MesQcTemplateItemDO item = BeanUtils.toBean(createReqVO, MesQcTemplateItemDO.class); | ||
| 110 | + templateItemMapper.insert(item); | ||
| 111 | + return item.getId(); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + @Override | ||
| 115 | + public void updateTemplateItem(MesQcTemplateItemSaveReqVO updateReqVO) { | ||
| 116 | + // 校验存在 | ||
| 117 | + validateTemplateItemExists(updateReqVO.getId()); | ||
| 118 | + // 校验产品在此方案中唯一 | ||
| 119 | + validateTemplateItemNotDuplicate(updateReqVO.getId(), updateReqVO.getTemplateId(), updateReqVO.getItemId()); | ||
| 120 | + // 更新 | ||
| 121 | + MesQcTemplateItemDO updateObj = BeanUtils.toBean(updateReqVO, MesQcTemplateItemDO.class); | ||
| 122 | + templateItemMapper.updateById(updateObj); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + @Override | ||
| 126 | + public void deleteTemplateItem(Long id) { | ||
| 127 | + // 校验存在 | ||
| 128 | + validateTemplateItemExists(id); | ||
| 129 | + // 删除 | ||
| 130 | + templateItemMapper.deleteById(id); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + private void validateTemplateItemExists(Long id) { | ||
| 134 | + if (templateItemMapper.selectById(id) == null) { | ||
| 135 | + throw exception(QC_TEMPLATE_ITEM_NOT_EXISTS); | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + private void validateTemplateItemNotDuplicate(Long id, Long templateId, Long itemId) { | ||
| 140 | + MesQcTemplateItemDO existing = templateItemMapper.selectByTemplateIdAndItemId(templateId, itemId); | ||
| 141 | + if (existing == null) { | ||
| 142 | + return; | ||
| 143 | + } | ||
| 144 | + if (ObjUtil.notEqual(existing.getId(), id)) { | ||
| 145 | + throw exception(QC_TEMPLATE_ITEM_DUPLICATE); | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + @Override | ||
| 150 | + public MesQcTemplateItemDO getTemplateItem(Long id) { | ||
| 151 | + return templateItemMapper.selectById(id); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + @Override | ||
| 155 | + public PageResult<MesQcTemplateItemDO> getTemplateItemPage(MesQcTemplateItemPageReqVO pageReqVO) { | ||
| 156 | + return templateItemMapper.selectPage(pageReqVO); | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + // ========== 复杂查询 ========== | ||
| 160 | + | ||
| 161 | + @Override | ||
| 162 | + public MesQcTemplateItemDO getTemplateItemByTemplateIdAndItemId(Long templateId, Long itemId) { | ||
| 163 | + return templateItemMapper.selectByTemplateIdAndItemId(templateId, itemId); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + @Override | ||
| 167 | + public MesQcTemplateDO getTemplateByItemIdAndType(Long itemId, Integer qcType) { | ||
| 168 | + // 1.1 查出 itemId 关联的所有 templateId | ||
| 169 | + List<MesQcTemplateItemDO> templateItems = templateItemMapper.selectListByItemId(itemId); | ||
| 170 | + if (CollUtil.isEmpty(templateItems)) { | ||
| 171 | + return null; | ||
| 172 | + } | ||
| 173 | + // 1.2 批量查模板,筛选 types 包含给定 qcType 的第一个 | ||
| 174 | + List<MesQcTemplateDO> templates = templateMapper.selectByIds( | ||
| 175 | + convertSet(templateItems, MesQcTemplateItemDO::getTemplateId)); | ||
| 176 | + // 2. 筛选 types 包含给定 qcType 的第一个 | ||
| 177 | + return findFirst(templates, template -> CollUtil.contains(template.getTypes(), qcType)); | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + @Override | ||
| 181 | + public MesQcTemplateItemDO getRequiredTemplateByItemIdAndType(Long itemId, Integer qcType) { | ||
| 182 | + // 1. 查出 itemId 关联的所有 templateId | ||
| 183 | + List<MesQcTemplateItemDO> templateItems = templateItemMapper.selectListByItemId(itemId); | ||
| 184 | + if (CollUtil.isEmpty(templateItems)) { | ||
| 185 | + throw exception(QC_IQC_NO_TEMPLATE); | ||
| 186 | + } | ||
| 187 | + // 2. 筛选 types 包含 qcType 的模板 | ||
| 188 | + List<MesQcTemplateDO> templates = templateMapper.selectByIds( | ||
| 189 | + convertSet(templateItems, MesQcTemplateItemDO::getTemplateId)); | ||
| 190 | + MesQcTemplateDO matchedTemplate = findFirst(templates, | ||
| 191 | + t -> CollUtil.contains(t.getTypes(), qcType)); | ||
| 192 | + if (matchedTemplate == null) { | ||
| 193 | + throw exception(QC_IQC_NO_TEMPLATE); | ||
| 194 | + } | ||
| 195 | + // 3. 返回对应的 templateItem | ||
| 196 | + return findFirst(templateItems, | ||
| 197 | + item -> Objects.equals(item.getTemplateId(), matchedTemplate.getId())); | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/template/MesQcTemplateService.java
| @@ -3,13 +3,7 @@ package cn.iocoder.yudao.module.mes.service.qc.template; | @@ -3,13 +3,7 @@ package cn.iocoder.yudao.module.mes.service.qc.template; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.MesQcTemplatePageReqVO; | 4 | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.MesQcTemplatePageReqVO; |
| 5 | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.MesQcTemplateSaveReqVO; | 5 | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.MesQcTemplateSaveReqVO; |
| 6 | -import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.indicator.MesQcTemplateIndicatorPageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.indicator.MesQcTemplateIndicatorSaveReqVO; | ||
| 8 | -import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemPageReqVO; | ||
| 9 | -import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemSaveReqVO; | ||
| 10 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateDO; | 6 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateDO; |
| 11 | -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateIndicatorDO; | ||
| 12 | -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateItemDO; | ||
| 13 | import jakarta.validation.Valid; | 7 | import jakarta.validation.Valid; |
| 14 | 8 | ||
| 15 | import java.util.Collection; | 9 | import java.util.Collection; |
| @@ -18,6 +12,7 @@ import java.util.Map; | @@ -18,6 +12,7 @@ import java.util.Map; | ||
| 18 | 12 | ||
| 19 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | 13 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| 20 | 14 | ||
| 15 | +// DONE @AI:已拆分成 2 个 service;MesQcTemplateService 专注于质检方案主表的 CRUD;MesQcTemplateDetailService 专注于质检方案的检测指标项和产品关联的 CRUD,以及复杂查询逻辑。 | ||
| 21 | /** | 16 | /** |
| 22 | * MES 质检方案 Service 接口 | 17 | * MES 质检方案 Service 接口 |
| 23 | * | 18 | * |
| @@ -98,104 +93,4 @@ public interface MesQcTemplateService { | @@ -98,104 +93,4 @@ public interface MesQcTemplateService { | ||
| 98 | */ | 93 | */ |
| 99 | MesQcTemplateDO validateTemplateExists(Long id); | 94 | MesQcTemplateDO validateTemplateExists(Long id); |
| 100 | 95 | ||
| 101 | - /** | ||
| 102 | - * 根据方案 ID + 产品 ID 获取产品关联 | ||
| 103 | - * | ||
| 104 | - * @param templateId 方案 ID | ||
| 105 | - * @param itemId 产品 ID | ||
| 106 | - * @return 产品关联(可能为 null) | ||
| 107 | - */ | ||
| 108 | - MesQcTemplateItemDO getTemplateItemByTemplateIdAndItemId(Long templateId, Long itemId); | ||
| 109 | - | ||
| 110 | - /** | ||
| 111 | - * 根据产品物料 ID 和 QC 类型查找检验模板 | ||
| 112 | - * | ||
| 113 | - * 查找逻辑:在 template_item 中找到匹配 itemId 的模板,再校验该模板的 types 包含给定的 qcType | ||
| 114 | - * | ||
| 115 | - * @param itemId 产品物料 ID | ||
| 116 | - * @param qcType 检测种类(枚举 {@link cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum}) | ||
| 117 | - * @return 匹配的检验模板(可能为 null) | ||
| 118 | - */ | ||
| 119 | - MesQcTemplateDO getTemplateByItemIdAndType(Long itemId, Integer qcType); | ||
| 120 | - | ||
| 121 | - // ========== 质检方案-检测指标项 ========== | ||
| 122 | - | ||
| 123 | - /** | ||
| 124 | - * 创建检测指标项 | ||
| 125 | - * | ||
| 126 | - * @param createReqVO 创建信息 | ||
| 127 | - * @return 编号 | ||
| 128 | - */ | ||
| 129 | - Long createTemplateIndicator(@Valid MesQcTemplateIndicatorSaveReqVO createReqVO); | ||
| 130 | - | ||
| 131 | - /** | ||
| 132 | - * 更新检测指标项 | ||
| 133 | - * | ||
| 134 | - * @param updateReqVO 更新信息 | ||
| 135 | - */ | ||
| 136 | - void updateTemplateIndicator(@Valid MesQcTemplateIndicatorSaveReqVO updateReqVO); | ||
| 137 | - | ||
| 138 | - /** | ||
| 139 | - * 删除检测指标项 | ||
| 140 | - * | ||
| 141 | - * @param id 编号 | ||
| 142 | - */ | ||
| 143 | - void deleteTemplateIndicator(Long id); | ||
| 144 | - | ||
| 145 | - /** | ||
| 146 | - * 获得检测指标项 | ||
| 147 | - * | ||
| 148 | - * @param id 编号 | ||
| 149 | - * @return 检测指标项 | ||
| 150 | - */ | ||
| 151 | - MesQcTemplateIndicatorDO getTemplateIndicator(Long id); | ||
| 152 | - | ||
| 153 | - /** | ||
| 154 | - * 获得检测指标项分页 | ||
| 155 | - * | ||
| 156 | - * @param pageReqVO 分页查询 | ||
| 157 | - * @return 检测指标项分页 | ||
| 158 | - */ | ||
| 159 | - PageResult<MesQcTemplateIndicatorDO> getTemplateIndicatorPage(MesQcTemplateIndicatorPageReqVO pageReqVO); | ||
| 160 | - | ||
| 161 | - // ========== 质检方案-产品关联 ========== | ||
| 162 | - | ||
| 163 | - /** | ||
| 164 | - * 创建产品关联 | ||
| 165 | - * | ||
| 166 | - * @param createReqVO 创建信息 | ||
| 167 | - * @return 编号 | ||
| 168 | - */ | ||
| 169 | - Long createTemplateItem(@Valid MesQcTemplateItemSaveReqVO createReqVO); | ||
| 170 | - | ||
| 171 | - /** | ||
| 172 | - * 更新产品关联 | ||
| 173 | - * | ||
| 174 | - * @param updateReqVO 更新信息 | ||
| 175 | - */ | ||
| 176 | - void updateTemplateItem(@Valid MesQcTemplateItemSaveReqVO updateReqVO); | ||
| 177 | - | ||
| 178 | - /** | ||
| 179 | - * 删除产品关联 | ||
| 180 | - * | ||
| 181 | - * @param id 编号 | ||
| 182 | - */ | ||
| 183 | - void deleteTemplateItem(Long id); | ||
| 184 | - | ||
| 185 | - /** | ||
| 186 | - * 获得产品关联 | ||
| 187 | - * | ||
| 188 | - * @param id 编号 | ||
| 189 | - * @return 产品关联 | ||
| 190 | - */ | ||
| 191 | - MesQcTemplateItemDO getTemplateItem(Long id); | ||
| 192 | - | ||
| 193 | - /** | ||
| 194 | - * 获得产品关联分页 | ||
| 195 | - * | ||
| 196 | - * @param pageReqVO 分页查询 | ||
| 197 | - * @return 产品关联分页 | ||
| 198 | - */ | ||
| 199 | - PageResult<MesQcTemplateItemDO> getTemplateItemPage(MesQcTemplateItemPageReqVO pageReqVO); | ||
| 200 | - | ||
| 201 | } | 96 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/template/MesQcTemplateServiceImpl.java
| @@ -6,14 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -6,14 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.MesQcTemplatePageReqVO; | 7 | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.MesQcTemplatePageReqVO; |
| 8 | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.MesQcTemplateSaveReqVO; | 8 | import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.MesQcTemplateSaveReqVO; |
| 9 | -import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.indicator.MesQcTemplateIndicatorPageReqVO; | ||
| 10 | -import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.indicator.MesQcTemplateIndicatorSaveReqVO; | ||
| 11 | -import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemPageReqVO; | ||
| 12 | -import cn.iocoder.yudao.module.mes.controller.admin.qc.template.vo.item.MesQcTemplateItemSaveReqVO; | ||
| 13 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateDO; | 9 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateDO; |
| 14 | -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateIndicatorDO; | ||
| 15 | -import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateItemDO; | ||
| 16 | -import cn.iocoder.yudao.module.mes.dal.mysql.qc.indicator.MesQcIndicatorMapper; | ||
| 17 | import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateIndicatorMapper; | 10 | import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateIndicatorMapper; |
| 18 | import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateItemMapper; | 11 | import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateItemMapper; |
| 19 | import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateMapper; | 12 | import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateMapper; |
| @@ -25,11 +18,8 @@ import org.springframework.validation.annotation.Validated; | @@ -25,11 +18,8 @@ import org.springframework.validation.annotation.Validated; | ||
| 25 | import java.util.Collection; | 18 | import java.util.Collection; |
| 26 | import java.util.Collections; | 19 | import java.util.Collections; |
| 27 | import java.util.List; | 20 | import java.util.List; |
| 28 | -import java.util.Set; | ||
| 29 | 21 | ||
| 30 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 31 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 32 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; | ||
| 33 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | 23 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| 34 | 24 | ||
| 35 | /** | 25 | /** |
| @@ -47,10 +37,6 @@ public class MesQcTemplateServiceImpl implements MesQcTemplateService { | @@ -47,10 +37,6 @@ public class MesQcTemplateServiceImpl implements MesQcTemplateService { | ||
| 47 | private MesQcTemplateIndicatorMapper templateIndicatorMapper; | 37 | private MesQcTemplateIndicatorMapper templateIndicatorMapper; |
| 48 | @Resource | 38 | @Resource |
| 49 | private MesQcTemplateItemMapper templateItemMapper; | 39 | private MesQcTemplateItemMapper templateItemMapper; |
| 50 | - @Resource | ||
| 51 | - private MesQcIndicatorMapper indicatorMapper; | ||
| 52 | - | ||
| 53 | - // ========== 质检方案主表 ========== | ||
| 54 | 40 | ||
| 55 | @Override | 41 | @Override |
| 56 | public Long createTemplate(MesQcTemplateSaveReqVO createReqVO) { | 42 | public Long createTemplate(MesQcTemplateSaveReqVO createReqVO) { |
| @@ -69,6 +55,7 @@ public class MesQcTemplateServiceImpl implements MesQcTemplateService { | @@ -69,6 +55,7 @@ public class MesQcTemplateServiceImpl implements MesQcTemplateService { | ||
| 69 | validateTemplateExists(updateReqVO.getId()); | 55 | validateTemplateExists(updateReqVO.getId()); |
| 70 | // 校验编码唯一 | 56 | // 校验编码唯一 |
| 71 | validateTemplateCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | 57 | validateTemplateCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); |
| 58 | + | ||
| 72 | // 更新 | 59 | // 更新 |
| 73 | MesQcTemplateDO updateObj = BeanUtils.toBean(updateReqVO, MesQcTemplateDO.class); | 60 | MesQcTemplateDO updateObj = BeanUtils.toBean(updateReqVO, MesQcTemplateDO.class); |
| 74 | templateMapper.updateById(updateObj); | 61 | templateMapper.updateById(updateObj); |
| @@ -79,6 +66,7 @@ public class MesQcTemplateServiceImpl implements MesQcTemplateService { | @@ -79,6 +66,7 @@ public class MesQcTemplateServiceImpl implements MesQcTemplateService { | ||
| 79 | public void deleteTemplate(Long id) { | 66 | public void deleteTemplate(Long id) { |
| 80 | // 校验存在 | 67 | // 校验存在 |
| 81 | validateTemplateExists(id); | 68 | validateTemplateExists(id); |
| 69 | + | ||
| 82 | // 删除主表 | 70 | // 删除主表 |
| 83 | templateMapper.deleteById(id); | 71 | templateMapper.deleteById(id); |
| 84 | // 级联删除检测指标项 | 72 | // 级联删除检测指标项 |
| @@ -107,26 +95,6 @@ public class MesQcTemplateServiceImpl implements MesQcTemplateService { | @@ -107,26 +95,6 @@ public class MesQcTemplateServiceImpl implements MesQcTemplateService { | ||
| 107 | } | 95 | } |
| 108 | 96 | ||
| 109 | @Override | 97 | @Override |
| 110 | - public MesQcTemplateItemDO getTemplateItemByTemplateIdAndItemId(Long templateId, Long itemId) { | ||
| 111 | - return templateItemMapper.selectByTemplateIdAndItemId(templateId, itemId); | ||
| 112 | - } | ||
| 113 | - | ||
| 114 | - @Override | ||
| 115 | - public MesQcTemplateDO getTemplateByItemIdAndType(Long itemId, Integer qcType) { | ||
| 116 | - // 1.1 查出 itemId 关联的所有 templateId | ||
| 117 | - List<MesQcTemplateItemDO> templateItems = templateItemMapper.selectListByItemId(itemId); | ||
| 118 | - if (CollUtil.isEmpty(templateItems)) { | ||
| 119 | - return null; | ||
| 120 | - } | ||
| 121 | - // 1.2 批量查模板,筛选 types 包含给定 qcType 的第一个 | ||
| 122 | - List<MesQcTemplateDO> templates = templateMapper.selectByIds( | ||
| 123 | - convertSet(templateItems, MesQcTemplateItemDO::getTemplateId)); | ||
| 124 | - | ||
| 125 | - // 2. 筛选 types 包含给定 qcType 的第一个 | ||
| 126 | - return findFirst(templates, template -> CollUtil.contains(template.getTypes(), qcType)); | ||
| 127 | - } | ||
| 128 | - | ||
| 129 | - @Override | ||
| 130 | public MesQcTemplateDO getTemplate(Long id) { | 98 | public MesQcTemplateDO getTemplate(Long id) { |
| 131 | return templateMapper.selectById(id); | 99 | return templateMapper.selectById(id); |
| 132 | } | 100 | } |
| @@ -149,108 +117,5 @@ public class MesQcTemplateServiceImpl implements MesQcTemplateService { | @@ -149,108 +117,5 @@ public class MesQcTemplateServiceImpl implements MesQcTemplateService { | ||
| 149 | return templateMapper.selectByIds(ids); | 117 | return templateMapper.selectByIds(ids); |
| 150 | } | 118 | } |
| 151 | 119 | ||
| 152 | - // ========== 质检方案-检测指标项 ========== | ||
| 153 | - | ||
| 154 | - @Override | ||
| 155 | - public Long createTemplateIndicator(MesQcTemplateIndicatorSaveReqVO createReqVO) { | ||
| 156 | - // 校验方案存在 | ||
| 157 | - validateTemplateExists(createReqVO.getTemplateId()); | ||
| 158 | - // 插入 | ||
| 159 | - MesQcTemplateIndicatorDO indicator = BeanUtils.toBean(createReqVO, MesQcTemplateIndicatorDO.class); | ||
| 160 | - templateIndicatorMapper.insert(indicator); | ||
| 161 | - return indicator.getId(); | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | - @Override | ||
| 165 | - public void updateTemplateIndicator(MesQcTemplateIndicatorSaveReqVO updateReqVO) { | ||
| 166 | - // 校验存在 | ||
| 167 | - validateTemplateIndicatorExists(updateReqVO.getId()); | ||
| 168 | - // 更新 | ||
| 169 | - MesQcTemplateIndicatorDO updateObj = BeanUtils.toBean(updateReqVO, MesQcTemplateIndicatorDO.class); | ||
| 170 | - templateIndicatorMapper.updateById(updateObj); | ||
| 171 | - } | ||
| 172 | - | ||
| 173 | - @Override | ||
| 174 | - public void deleteTemplateIndicator(Long id) { | ||
| 175 | - // 校验存在 | ||
| 176 | - validateTemplateIndicatorExists(id); | ||
| 177 | - // 删除 | ||
| 178 | - templateIndicatorMapper.deleteById(id); | ||
| 179 | - } | ||
| 180 | - | ||
| 181 | - private void validateTemplateIndicatorExists(Long id) { | ||
| 182 | - if (templateIndicatorMapper.selectById(id) == null) { | ||
| 183 | - throw exception(QC_TEMPLATE_INDICATOR_NOT_EXISTS); | ||
| 184 | - } | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | - @Override | ||
| 188 | - public MesQcTemplateIndicatorDO getTemplateIndicator(Long id) { | ||
| 189 | - return templateIndicatorMapper.selectById(id); | ||
| 190 | - } | ||
| 191 | - | ||
| 192 | - @Override | ||
| 193 | - public PageResult<MesQcTemplateIndicatorDO> getTemplateIndicatorPage(MesQcTemplateIndicatorPageReqVO pageReqVO) { | ||
| 194 | - return templateIndicatorMapper.selectPage(pageReqVO); | ||
| 195 | - } | ||
| 196 | - | ||
| 197 | - // ========== 质检方案-产品关联 ========== | ||
| 198 | - | ||
| 199 | - @Override | ||
| 200 | - public Long createTemplateItem(MesQcTemplateItemSaveReqVO createReqVO) { | ||
| 201 | - // 校验方案存在 | ||
| 202 | - validateTemplateExists(createReqVO.getTemplateId()); | ||
| 203 | - // 校验产品在此方案中唯一 | ||
| 204 | - validateTemplateItemNotDuplicate(null, createReqVO.getTemplateId(), createReqVO.getItemId()); | ||
| 205 | - // 插入 | ||
| 206 | - MesQcTemplateItemDO item = BeanUtils.toBean(createReqVO, MesQcTemplateItemDO.class); | ||
| 207 | - templateItemMapper.insert(item); | ||
| 208 | - return item.getId(); | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - @Override | ||
| 212 | - public void updateTemplateItem(MesQcTemplateItemSaveReqVO updateReqVO) { | ||
| 213 | - // 校验存在 | ||
| 214 | - validateTemplateItemExists(updateReqVO.getId()); | ||
| 215 | - // 校验产品在此方案中唯一 | ||
| 216 | - validateTemplateItemNotDuplicate(updateReqVO.getId(), updateReqVO.getTemplateId(), updateReqVO.getItemId()); | ||
| 217 | - // 更新 | ||
| 218 | - MesQcTemplateItemDO updateObj = BeanUtils.toBean(updateReqVO, MesQcTemplateItemDO.class); | ||
| 219 | - templateItemMapper.updateById(updateObj); | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | - @Override | ||
| 223 | - public void deleteTemplateItem(Long id) { | ||
| 224 | - // 校验存在 | ||
| 225 | - validateTemplateItemExists(id); | ||
| 226 | - // 删除 | ||
| 227 | - templateItemMapper.deleteById(id); | ||
| 228 | - } | ||
| 229 | - | ||
| 230 | - private void validateTemplateItemExists(Long id) { | ||
| 231 | - if (templateItemMapper.selectById(id) == null) { | ||
| 232 | - throw exception(QC_TEMPLATE_ITEM_NOT_EXISTS); | ||
| 233 | - } | ||
| 234 | - } | ||
| 235 | - | ||
| 236 | - private void validateTemplateItemNotDuplicate(Long id, Long templateId, Long itemId) { | ||
| 237 | - MesQcTemplateItemDO existing = templateItemMapper.selectByTemplateIdAndItemId(templateId, itemId); | ||
| 238 | - if (existing == null) { | ||
| 239 | - return; | ||
| 240 | - } | ||
| 241 | - if (ObjUtil.notEqual(existing.getId(), id)) { | ||
| 242 | - throw exception(QC_TEMPLATE_ITEM_DUPLICATE); | ||
| 243 | - } | ||
| 244 | - } | ||
| 245 | - | ||
| 246 | - @Override | ||
| 247 | - public MesQcTemplateItemDO getTemplateItem(Long id) { | ||
| 248 | - return templateItemMapper.selectById(id); | ||
| 249 | - } | ||
| 250 | - | ||
| 251 | - @Override | ||
| 252 | - public PageResult<MesQcTemplateItemDO> getTemplateItemPage(MesQcTemplateItemPageReqVO pageReqVO) { | ||
| 253 | - return templateItemMapper.selectPage(pageReqVO); | ||
| 254 | - } | ||
| 255 | - | ||
| 256 | } | 120 | } |
| 121 | + |