Commit d0bd43942fbeaa8ff8dba42682252f9cb5542ced
1 parent
dd34cfdc
feat(mes): add RQC (退货检验单) related classes and API for handling inspection lines
Showing
15 changed files
with
1392 additions
and
0 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/oqc/MesQcOqcController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc.oqc; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 7 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 8 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 9 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 10 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcPageReqVO; | ||
| 11 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcRespVO; | ||
| 12 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.MesQcOqcSaveReqVO; | ||
| 13 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.client.MesMdClientDO; | ||
| 14 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | ||
| 15 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | ||
| 16 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcDO; | ||
| 17 | +import cn.iocoder.yudao.module.mes.service.md.client.MesMdClientService; | ||
| 18 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | ||
| 19 | +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | ||
| 20 | +import cn.iocoder.yudao.module.mes.service.qc.oqc.MesQcOqcService; | ||
| 21 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||
| 22 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||
| 23 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 24 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 25 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 26 | +import jakarta.annotation.Resource; | ||
| 27 | +import jakarta.servlet.http.HttpServletResponse; | ||
| 28 | +import jakarta.validation.Valid; | ||
| 29 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 30 | +import org.springframework.validation.annotation.Validated; | ||
| 31 | +import org.springframework.web.bind.annotation.*; | ||
| 32 | + | ||
| 33 | +import java.io.IOException; | ||
| 34 | +import java.util.Collections; | ||
| 35 | +import java.util.List; | ||
| 36 | +import java.util.Map; | ||
| 37 | + | ||
| 38 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | ||
| 39 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 40 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 41 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | ||
| 42 | + | ||
| 43 | +@Tag(name = "管理后台 - MES 出货检验单(OQC)") | ||
| 44 | +@RestController | ||
| 45 | +@RequestMapping("/mes/qc/oqc") | ||
| 46 | +@Validated | ||
| 47 | +public class MesQcOqcController { | ||
| 48 | + | ||
| 49 | + @Resource | ||
| 50 | + private MesQcOqcService oqcService; | ||
| 51 | + @Resource | ||
| 52 | + private MesMdClientService clientService; | ||
| 53 | + @Resource | ||
| 54 | + private MesMdItemService itemService; | ||
| 55 | + @Resource | ||
| 56 | + private MesMdUnitMeasureService unitMeasureService; | ||
| 57 | + | ||
| 58 | + @Resource | ||
| 59 | + private AdminUserApi adminUserApi; | ||
| 60 | + | ||
| 61 | + @PostMapping("/create") | ||
| 62 | + @Operation(summary = "创建出货检验单") | ||
| 63 | + @PreAuthorize("@ss.hasPermission('mes:qc-oqc:create')") | ||
| 64 | + public CommonResult<Long> createOqc(@Valid @RequestBody MesQcOqcSaveReqVO createReqVO) { | ||
| 65 | + return success(oqcService.createOqc(createReqVO)); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @PutMapping("/update") | ||
| 69 | + @Operation(summary = "更新出货检验单") | ||
| 70 | + @PreAuthorize("@ss.hasPermission('mes:qc-oqc:update')") | ||
| 71 | + public CommonResult<Boolean> updateOqc(@Valid @RequestBody MesQcOqcSaveReqVO updateReqVO) { | ||
| 72 | + oqcService.updateOqc(updateReqVO); | ||
| 73 | + return success(true); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + @PutMapping("/complete") | ||
| 77 | + @Operation(summary = "完成出货检验单") | ||
| 78 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 79 | + @PreAuthorize("@ss.hasPermission('mes:qc-oqc:update')") | ||
| 80 | + public CommonResult<Boolean> completeOqc(@RequestParam("id") Long id) { | ||
| 81 | + oqcService.completeOqc(id); | ||
| 82 | + return success(true); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @DeleteMapping("/delete") | ||
| 86 | + @Operation(summary = "删除出货检验单") | ||
| 87 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 88 | + @PreAuthorize("@ss.hasPermission('mes:qc-oqc:delete')") | ||
| 89 | + public CommonResult<Boolean> deleteOqc(@RequestParam("id") Long id) { | ||
| 90 | + oqcService.deleteOqc(id); | ||
| 91 | + return success(true); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + @GetMapping("/get") | ||
| 95 | + @Operation(summary = "获得出货检验单") | ||
| 96 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 97 | + @PreAuthorize("@ss.hasPermission('mes:qc-oqc:query')") | ||
| 98 | + public CommonResult<MesQcOqcRespVO> getOqc(@RequestParam("id") Long id) { | ||
| 99 | + MesQcOqcDO oqc = oqcService.getOqc(id); | ||
| 100 | + return success(buildOqcRespVOList(Collections.singletonList(oqc)).get(0)); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + @GetMapping("/page") | ||
| 104 | + @Operation(summary = "获得出货检验单分页") | ||
| 105 | + @PreAuthorize("@ss.hasPermission('mes:qc-oqc:query')") | ||
| 106 | + public CommonResult<PageResult<MesQcOqcRespVO>> getOqcPage(@Valid MesQcOqcPageReqVO pageReqVO) { | ||
| 107 | + PageResult<MesQcOqcDO> pageResult = oqcService.getOqcPage(pageReqVO); | ||
| 108 | + return success(new PageResult<>(buildOqcRespVOList(pageResult.getList()), pageResult.getTotal())); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + @GetMapping("/export-excel") | ||
| 112 | + @Operation(summary = "导出出货检验单 Excel") | ||
| 113 | + @PreAuthorize("@ss.hasPermission('mes:qc-oqc:export')") | ||
| 114 | + @ApiAccessLog(operateType = EXPORT) | ||
| 115 | + public void exportOqcExcel(@Valid MesQcOqcPageReqVO pageReqVO, | ||
| 116 | + HttpServletResponse response) throws IOException { | ||
| 117 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 118 | + List<MesQcOqcDO> list = oqcService.getOqcPage(pageReqVO).getList(); | ||
| 119 | + List<MesQcOqcRespVO> voList = buildOqcRespVOList(list); | ||
| 120 | + ExcelUtils.write(response, "出货检验单.xls", "数据", MesQcOqcRespVO.class, voList); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + // ==================== 拼接 VO ==================== | ||
| 124 | + | ||
| 125 | + private List<MesQcOqcRespVO> buildOqcRespVOList(List<MesQcOqcDO> list) { | ||
| 126 | + if (CollUtil.isEmpty(list)) { | ||
| 127 | + return Collections.emptyList(); | ||
| 128 | + } | ||
| 129 | + // 批量查询客户 | ||
| 130 | + Map<Long, MesMdClientDO> clientMap = clientService.getClientMap( | ||
| 131 | + convertSet(list, MesQcOqcDO::getClientId)); | ||
| 132 | + // 批量查询物料 | ||
| 133 | + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | ||
| 134 | + convertSet(list, MesQcOqcDO::getItemId)); | ||
| 135 | + // 批量查询计量单位 | ||
| 136 | + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | ||
| 137 | + convertSet(itemMap.values(), MesMdItemDO::getUnitMeasureId)); | ||
| 138 | + // 批量查询检测人员 | ||
| 139 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | ||
| 140 | + convertSet(list, MesQcOqcDO::getInspectorUserId)); | ||
| 141 | + // 拼装 VO | ||
| 142 | + return BeanUtils.toBean(list, MesQcOqcRespVO.class, vo -> { | ||
| 143 | + findAndThen(clientMap, vo.getClientId(), | ||
| 144 | + client -> vo.setClientNickname(client.getNickname())); | ||
| 145 | + findAndThen(itemMap, vo.getItemId(), item -> { | ||
| 146 | + vo.setItemCode(item.getCode()).setItemName(item.getName()).setItemSpecification(item.getSpecification()); | ||
| 147 | + findAndThen(unitMeasureMap, item.getUnitMeasureId(), | ||
| 148 | + unit -> vo.setUnitName(unit.getName())); | ||
| 149 | + }); | ||
| 150 | + findAndThen(userMap, vo.getInspectorUserId(), | ||
| 151 | + user -> vo.setInspectorNickname(user.getNickname())); | ||
| 152 | + }); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/oqc/MesQcOqcLineController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc.oqc; | ||
| 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.oqc.vo.line.MesQcOqcLinePageReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.line.MesQcOqcLineRespVO; | ||
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | ||
| 10 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.oqc.MesQcOqcLineDO; | ||
| 11 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.indicator.MesQcIndicatorDO; | ||
| 12 | +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | ||
| 13 | +import cn.iocoder.yudao.module.mes.service.qc.oqc.MesQcOqcLineService; | ||
| 14 | +import cn.iocoder.yudao.module.mes.service.qc.indicator.MesQcIndicatorService; | ||
| 15 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 16 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 17 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 18 | +import jakarta.annotation.Resource; | ||
| 19 | +import jakarta.validation.Valid; | ||
| 20 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 21 | +import org.springframework.validation.annotation.Validated; | ||
| 22 | +import org.springframework.web.bind.annotation.GetMapping; | ||
| 23 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 24 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 25 | +import org.springframework.web.bind.annotation.RestController; | ||
| 26 | + | ||
| 27 | +import java.util.Collections; | ||
| 28 | +import java.util.List; | ||
| 29 | +import java.util.Map; | ||
| 30 | + | ||
| 31 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 32 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 33 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | ||
| 34 | + | ||
| 35 | +@Tag(name = "管理后台 - MES 出货检验单行") | ||
| 36 | +@RestController | ||
| 37 | +@RequestMapping("/mes/qc/oqc/line") | ||
| 38 | +@Validated | ||
| 39 | +public class MesQcOqcLineController { | ||
| 40 | + | ||
| 41 | + @Resource | ||
| 42 | + private MesQcOqcLineService oqcLineService; | ||
| 43 | + @Resource | ||
| 44 | + private MesQcIndicatorService indicatorService; | ||
| 45 | + @Resource | ||
| 46 | + private MesMdUnitMeasureService unitMeasureService; | ||
| 47 | + | ||
| 48 | + @GetMapping("/get") | ||
| 49 | + @Operation(summary = "获得出货检验单行") | ||
| 50 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 51 | + @PreAuthorize("@ss.hasPermission('mes:qc-oqc:query')") | ||
| 52 | + public CommonResult<MesQcOqcLineRespVO> getOqcLine(@RequestParam("id") Long id) { | ||
| 53 | + MesQcOqcLineDO line = oqcLineService.getOqcLine(id); | ||
| 54 | + return success(buildLineRespVOList(Collections.singletonList(line)).get(0)); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @GetMapping("/page") | ||
| 58 | + @Operation(summary = "获得出货检验单行分页") | ||
| 59 | + @PreAuthorize("@ss.hasPermission('mes:qc-oqc:query')") | ||
| 60 | + public CommonResult<PageResult<MesQcOqcLineRespVO>> getOqcLinePage(@Valid MesQcOqcLinePageReqVO pageReqVO) { | ||
| 61 | + PageResult<MesQcOqcLineDO> pageResult = oqcLineService.getOqcLinePage(pageReqVO); | ||
| 62 | + return success(new PageResult<>(buildLineRespVOList(pageResult.getList()), pageResult.getTotal())); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + // ==================== 拼接 VO ==================== | ||
| 66 | + | ||
| 67 | + private List<MesQcOqcLineRespVO> buildLineRespVOList(List<MesQcOqcLineDO> list) { | ||
| 68 | + if (CollUtil.isEmpty(list)) { | ||
| 69 | + return Collections.emptyList(); | ||
| 70 | + } | ||
| 71 | + // 批量查询检测指标 | ||
| 72 | + Map<Long, MesQcIndicatorDO> indicatorMap = indicatorService.getIndicatorMap( | ||
| 73 | + convertSet(list, MesQcOqcLineDO::getIndicatorId)); | ||
| 74 | + // 批量查询计量单位 | ||
| 75 | + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | ||
| 76 | + convertSet(list, MesQcOqcLineDO::getUnitMeasureId)); | ||
| 77 | + // 拼装 VO | ||
| 78 | + return BeanUtils.toBean(list, MesQcOqcLineRespVO.class, vo -> { | ||
| 79 | + findAndThen(indicatorMap, vo.getIndicatorId(), indicator -> | ||
| 80 | + vo.setIndicatorCode(indicator.getCode()).setIndicatorName(indicator.getName()) | ||
| 81 | + .setIndicatorType(indicator.getType())); | ||
| 82 | + findAndThen(unitMeasureMap, vo.getUnitMeasureId(), | ||
| 83 | + unit -> vo.setUnitMeasureName(unit.getName())); | ||
| 84 | + }); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/oqc/vo/MesQcOqcPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | +import lombok.EqualsAndHashCode; | ||
| 7 | +import lombok.ToString; | ||
| 8 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | + | ||
| 10 | +import java.time.LocalDateTime; | ||
| 11 | + | ||
| 12 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | + | ||
| 14 | +@Schema(description = "管理后台 - MES 出货检验单分页 Request VO") | ||
| 15 | +@Data | ||
| 16 | +@EqualsAndHashCode(callSuper = true) | ||
| 17 | +@ToString(callSuper = true) | ||
| 18 | +public class MesQcOqcPageReqVO extends PageParam { | ||
| 19 | + | ||
| 20 | + @Schema(description = "检验单编号", example = "OQC2025") | ||
| 21 | + private String code; | ||
| 22 | + | ||
| 23 | + @Schema(description = "客户 ID", example = "10") | ||
| 24 | + private Long clientId; | ||
| 25 | + | ||
| 26 | + @Schema(description = "批次号", example = "BC2025") | ||
| 27 | + private String batchCode; | ||
| 28 | + | ||
| 29 | + @Schema(description = "产品物料 ID", example = "20") | ||
| 30 | + private Long itemId; | ||
| 31 | + | ||
| 32 | + @Schema(description = "检测结果", example = "1") | ||
| 33 | + private Integer checkResult; | ||
| 34 | + | ||
| 35 | + @Schema(description = "状态", example = "0") | ||
| 36 | + private Integer status; | ||
| 37 | + | ||
| 38 | + @Schema(description = "检测人员用户 ID", example = "1") | ||
| 39 | + private Long inspectorUserId; | ||
| 40 | + | ||
| 41 | + @Schema(description = "出货日期") | ||
| 42 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 43 | + private LocalDateTime[] outDate; | ||
| 44 | + | ||
| 45 | + @Schema(description = "检测日期") | ||
| 46 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 47 | + private LocalDateTime[] inspectDate; | ||
| 48 | + | ||
| 49 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/oqc/vo/MesQcOqcRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo; | ||
| 2 | + | ||
| 3 | +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | ||
| 4 | +import cn.idev.excel.annotation.ExcelProperty; | ||
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import java.math.BigDecimal; | ||
| 9 | +import java.time.LocalDateTime; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - MES 出货检验单 Response VO") | ||
| 12 | +@Data | ||
| 13 | +@ExcelIgnoreUnannotated | ||
| 14 | +public class MesQcOqcRespVO { | ||
| 15 | + | ||
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 17 | + @ExcelProperty("编号") | ||
| 18 | + private Long id; | ||
| 19 | + | ||
| 20 | + @Schema(description = "检验单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "OQC20250101001") | ||
| 21 | + @ExcelProperty("检验单编号") | ||
| 22 | + private String code; | ||
| 23 | + | ||
| 24 | + @Schema(description = "检验单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "物料A出货检验") | ||
| 25 | + @ExcelProperty("检验单名称") | ||
| 26 | + private String name; | ||
| 27 | + | ||
| 28 | + @Schema(description = "检验模板 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | ||
| 29 | + private Long templateId; | ||
| 30 | + | ||
| 31 | + // ========== 来源单据 ========== | ||
| 32 | + | ||
| 33 | + @Schema(description = "来源单据 ID", example = "200") | ||
| 34 | + private Long sourceDocId; | ||
| 35 | + | ||
| 36 | + @Schema(description = "来源单据类型", example = "SALES") | ||
| 37 | + private String sourceDocType; | ||
| 38 | + | ||
| 39 | + @Schema(description = "来源单据编号", example = "SO20250101001") | ||
| 40 | + private String sourceDocCode; | ||
| 41 | + | ||
| 42 | + @Schema(description = "来源单据行 ID", example = "300") | ||
| 43 | + private Long sourceLineId; | ||
| 44 | + | ||
| 45 | + // ========== 客户 ========== | ||
| 46 | + | ||
| 47 | + @Schema(description = "客户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | ||
| 48 | + private Long clientId; | ||
| 49 | + | ||
| 50 | + @Schema(description = "客户简称", example = "客户A") | ||
| 51 | + @ExcelProperty("客户简称") | ||
| 52 | + private String clientNickname; | ||
| 53 | + | ||
| 54 | + @Schema(description = "批次号", example = "BC20250101") | ||
| 55 | + @ExcelProperty("批次号") | ||
| 56 | + private String batchCode; | ||
| 57 | + | ||
| 58 | + // ========== 物料 ========== | ||
| 59 | + | ||
| 60 | + @Schema(description = "产品物料 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") | ||
| 61 | + private Long itemId; | ||
| 62 | + | ||
| 63 | + @Schema(description = "产品物料编码", example = "ITEM001") | ||
| 64 | + @ExcelProperty("产品物料编码") | ||
| 65 | + private String itemCode; | ||
| 66 | + | ||
| 67 | + @Schema(description = "产品物料名称", example = "物料A") | ||
| 68 | + @ExcelProperty("产品物料名称") | ||
| 69 | + private String itemName; | ||
| 70 | + | ||
| 71 | + @Schema(description = "规格型号", example = "100mm*50mm") | ||
| 72 | + private String itemSpecification; | ||
| 73 | + | ||
| 74 | + @Schema(description = "单位名称", example = "个") | ||
| 75 | + private String unitName; | ||
| 76 | + | ||
| 77 | + // ========== 数量 ========== | ||
| 78 | + | ||
| 79 | + @Schema(description = "最低检测数", example = "5") | ||
| 80 | + private Integer minCheckQuantity; | ||
| 81 | + | ||
| 82 | + @Schema(description = "最大不合格数", example = "0") | ||
| 83 | + private Integer maxUnqualifiedQuantity; | ||
| 84 | + | ||
| 85 | + @Schema(description = "本次出货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | ||
| 86 | + @ExcelProperty("出货数量") | ||
| 87 | + private BigDecimal outQuantity; | ||
| 88 | + | ||
| 89 | + @Schema(description = "本次检测数量", example = "10") | ||
| 90 | + @ExcelProperty("检测数量") | ||
| 91 | + private Integer checkQuantity; | ||
| 92 | + | ||
| 93 | + @Schema(description = "合格品数量", example = "9") | ||
| 94 | + @ExcelProperty("合格品数量") | ||
| 95 | + private Integer qualifiedQuantity; | ||
| 96 | + | ||
| 97 | + @Schema(description = "不合格品数量", example = "1") | ||
| 98 | + @ExcelProperty("不合格品数量") | ||
| 99 | + private Integer unqualifiedQuantity; | ||
| 100 | + | ||
| 101 | + // ========== 缺陷统计 ========== | ||
| 102 | + | ||
| 103 | + @Schema(description = "致命缺陷率(%)", example = "0.00") | ||
| 104 | + private BigDecimal criticalRate; | ||
| 105 | + | ||
| 106 | + @Schema(description = "严重缺陷率(%)", example = "0.00") | ||
| 107 | + private BigDecimal majorRate; | ||
| 108 | + | ||
| 109 | + @Schema(description = "轻微缺陷率(%)", example = "10.00") | ||
| 110 | + private BigDecimal minorRate; | ||
| 111 | + | ||
| 112 | + @Schema(description = "致命缺陷数量", example = "0") | ||
| 113 | + private Integer criticalQuantity; | ||
| 114 | + | ||
| 115 | + @Schema(description = "严重缺陷数量", example = "0") | ||
| 116 | + private Integer majorQuantity; | ||
| 117 | + | ||
| 118 | + @Schema(description = "轻微缺陷数量", example = "1") | ||
| 119 | + private Integer minorQuantity; | ||
| 120 | + | ||
| 121 | + // ========== 检验 ========== | ||
| 122 | + | ||
| 123 | + @Schema(description = "检测结果", example = "1") | ||
| 124 | + @ExcelProperty("检测结果") | ||
| 125 | + private Integer checkResult; | ||
| 126 | + | ||
| 127 | + @Schema(description = "出货日期") | ||
| 128 | + @ExcelProperty("出货日期") | ||
| 129 | + private LocalDateTime outDate; | ||
| 130 | + | ||
| 131 | + @Schema(description = "检测日期") | ||
| 132 | + @ExcelProperty("检测日期") | ||
| 133 | + private LocalDateTime inspectDate; | ||
| 134 | + | ||
| 135 | + @Schema(description = "检测人员用户 ID", example = "1") | ||
| 136 | + private Long inspectorUserId; | ||
| 137 | + | ||
| 138 | + @Schema(description = "检测人员昵称", example = "张三") | ||
| 139 | + @ExcelProperty("检测人员") | ||
| 140 | + private String inspectorNickname; | ||
| 141 | + | ||
| 142 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 143 | + @ExcelProperty("状态") | ||
| 144 | + private Integer status; | ||
| 145 | + | ||
| 146 | + @Schema(description = "备注", example = "备注") | ||
| 147 | + @ExcelProperty("备注") | ||
| 148 | + private String remark; | ||
| 149 | + | ||
| 150 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 151 | + @ExcelProperty("创建时间") | ||
| 152 | + private LocalDateTime createTime; | ||
| 153 | + | ||
| 154 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/oqc/vo/MesQcOqcSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotEmpty; | ||
| 5 | +import jakarta.validation.constraints.NotNull; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import java.math.BigDecimal; | ||
| 9 | +import java.time.LocalDateTime; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - MES 出货检验单新增/修改 Request VO") | ||
| 12 | +@Data | ||
| 13 | +public class MesQcOqcSaveReqVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "编号", example = "1024") | ||
| 16 | + private Long id; | ||
| 17 | + | ||
| 18 | + @Schema(description = "检验单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "OQC20250101001") | ||
| 19 | + @NotEmpty(message = "检验单编号不能为空") | ||
| 20 | + private String code; | ||
| 21 | + | ||
| 22 | + @Schema(description = "检验单名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "物料A出货检验") | ||
| 23 | + @NotEmpty(message = "检验单名称不能为空") | ||
| 24 | + private String name; | ||
| 25 | + | ||
| 26 | + @Schema(description = "检验模板 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | ||
| 27 | + @NotNull(message = "检验模板不能为空") | ||
| 28 | + private Long templateId; | ||
| 29 | + | ||
| 30 | + // ========== 来源单据 ========== | ||
| 31 | + | ||
| 32 | + @Schema(description = "来源单据 ID", example = "200") | ||
| 33 | + private Long sourceDocId; | ||
| 34 | + | ||
| 35 | + @Schema(description = "来源单据类型", example = "SALES") | ||
| 36 | + private String sourceDocType; | ||
| 37 | + | ||
| 38 | + @Schema(description = "来源单据编号", example = "SO20250101001") | ||
| 39 | + private String sourceDocCode; | ||
| 40 | + | ||
| 41 | + @Schema(description = "来源单据行 ID", example = "300") | ||
| 42 | + private Long sourceLineId; | ||
| 43 | + | ||
| 44 | + // ========== 客户 ========== | ||
| 45 | + | ||
| 46 | + @Schema(description = "客户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | ||
| 47 | + @NotNull(message = "客户不能为空") | ||
| 48 | + private Long clientId; | ||
| 49 | + | ||
| 50 | + @Schema(description = "批次号", example = "BC20250101") | ||
| 51 | + private String batchCode; | ||
| 52 | + | ||
| 53 | + // ========== 物料 ========== | ||
| 54 | + | ||
| 55 | + @Schema(description = "产品物料 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") | ||
| 56 | + @NotNull(message = "产品物料不能为空") | ||
| 57 | + private Long itemId; | ||
| 58 | + | ||
| 59 | + // ========== 数量 ========== | ||
| 60 | + | ||
| 61 | + @Schema(description = "最低检测数", example = "5") | ||
| 62 | + private Integer minCheckQuantity; | ||
| 63 | + | ||
| 64 | + @Schema(description = "最大不合格数", example = "0") | ||
| 65 | + private Integer maxUnqualifiedQuantity; | ||
| 66 | + | ||
| 67 | + @Schema(description = "本次出货数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | ||
| 68 | + @NotNull(message = "本次出货数量不能为空") | ||
| 69 | + private BigDecimal outQuantity; | ||
| 70 | + | ||
| 71 | + @Schema(description = "本次检测数量", example = "10") | ||
| 72 | + private Integer checkQuantity; | ||
| 73 | + | ||
| 74 | + @Schema(description = "合格品数量", example = "9") | ||
| 75 | + private Integer qualifiedQuantity; | ||
| 76 | + | ||
| 77 | + @Schema(description = "不合格品数量", example = "1") | ||
| 78 | + private Integer unqualifiedQuantity; | ||
| 79 | + | ||
| 80 | + // ========== 检验 ========== | ||
| 81 | + | ||
| 82 | + @Schema(description = "检测结果", example = "1") | ||
| 83 | + private Integer checkResult; | ||
| 84 | + | ||
| 85 | + @Schema(description = "出货日期") | ||
| 86 | + private LocalDateTime outDate; | ||
| 87 | + | ||
| 88 | + @Schema(description = "检测日期") | ||
| 89 | + private LocalDateTime inspectDate; | ||
| 90 | + | ||
| 91 | + @Schema(description = "检测人员用户 ID", example = "1") | ||
| 92 | + private Long inspectorUserId; | ||
| 93 | + | ||
| 94 | + @Schema(description = "备注", example = "备注") | ||
| 95 | + private String remark; | ||
| 96 | + | ||
| 97 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/oqc/vo/line/MesQcOqcLinePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.line; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import jakarta.validation.constraints.NotNull; | ||
| 6 | +import lombok.Data; | ||
| 7 | +import lombok.EqualsAndHashCode; | ||
| 8 | +import lombok.ToString; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - MES 出货检验单行分页 Request VO") | ||
| 11 | +@Data | ||
| 12 | +@EqualsAndHashCode(callSuper = true) | ||
| 13 | +@ToString(callSuper = true) | ||
| 14 | +public class MesQcOqcLinePageReqVO extends PageParam { | ||
| 15 | + | ||
| 16 | + @Schema(description = "出货检验单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | ||
| 17 | + @NotNull(message = "出货检验单 ID 不能为空") | ||
| 18 | + private Long oqcId; | ||
| 19 | + | ||
| 20 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/oqc/vo/line/MesQcOqcLineRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc.oqc.vo.line; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | +import lombok.experimental.Accessors; | ||
| 6 | + | ||
| 7 | +import java.math.BigDecimal; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - MES 出货检验单行 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@Accessors(chain = true) | ||
| 13 | +public class MesQcOqcLineRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 16 | + private Long id; | ||
| 17 | + | ||
| 18 | + @Schema(description = "出货检验单 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | ||
| 19 | + private Long oqcId; | ||
| 20 | + | ||
| 21 | + @Schema(description = "检测指标 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | ||
| 22 | + private Long indicatorId; | ||
| 23 | + | ||
| 24 | + @Schema(description = "检测指标编码", example = "IND001") | ||
| 25 | + private String indicatorCode; | ||
| 26 | + | ||
| 27 | + @Schema(description = "检测指标名称", example = "外观") | ||
| 28 | + private String indicatorName; | ||
| 29 | + | ||
| 30 | + @Schema(description = "检测指标类型", example = "QUANTITATIVE") | ||
| 31 | + private String indicatorType; | ||
| 32 | + | ||
| 33 | + @Schema(description = "检测方法", example = "目测") | ||
| 34 | + private String checkMethod; | ||
| 35 | + | ||
| 36 | + @Schema(description = "标准值", example = "10.5000") | ||
| 37 | + private BigDecimal standardValue; | ||
| 38 | + | ||
| 39 | + @Schema(description = "计量单位 ID", example = "3") | ||
| 40 | + private Long unitMeasureId; | ||
| 41 | + | ||
| 42 | + @Schema(description = "计量单位名称", example = "毫米") | ||
| 43 | + private String unitMeasureName; | ||
| 44 | + | ||
| 45 | + @Schema(description = "误差上限", example = "11.0000") | ||
| 46 | + private BigDecimal maxThreshold; | ||
| 47 | + | ||
| 48 | + @Schema(description = "误差下限", example = "10.0000") | ||
| 49 | + private BigDecimal minThreshold; | ||
| 50 | + | ||
| 51 | + @Schema(description = "致命缺陷数量", example = "0") | ||
| 52 | + private Integer criticalQuantity; | ||
| 53 | + | ||
| 54 | + @Schema(description = "严重缺陷数量", example = "0") | ||
| 55 | + private Integer majorQuantity; | ||
| 56 | + | ||
| 57 | + @Schema(description = "轻微缺陷数量", example = "1") | ||
| 58 | + private Integer minorQuantity; | ||
| 59 | + | ||
| 60 | + @Schema(description = "备注", example = "备注") | ||
| 61 | + private String remark; | ||
| 62 | + | ||
| 63 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 64 | + private LocalDateTime createTime; | ||
| 65 | + | ||
| 66 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/rqc/MesQcRqcDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.item.MesMdItemDO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateDO; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 8 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 9 | +import lombok.*; | ||
| 10 | + | ||
| 11 | +import java.math.BigDecimal; | ||
| 12 | +import java.time.LocalDateTime; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * MES 退货检验单(RQC, Return Quality Control) DO | ||
| 16 | + * | ||
| 17 | + * @author 芋道源码 | ||
| 18 | + */ | ||
| 19 | +@TableName("mes_qc_rqc") | ||
| 20 | +@KeySequence("mes_qc_rqc_seq") | ||
| 21 | +@Data | ||
| 22 | +@EqualsAndHashCode(callSuper = true) | ||
| 23 | +@ToString(callSuper = true) | ||
| 24 | +@Builder | ||
| 25 | +@NoArgsConstructor | ||
| 26 | +@AllArgsConstructor | ||
| 27 | +public class MesQcRqcDO extends BaseDO { | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 编号 | ||
| 31 | + */ | ||
| 32 | + @TableId | ||
| 33 | + private Long id; | ||
| 34 | + /** | ||
| 35 | + * 检验单编号 | ||
| 36 | + */ | ||
| 37 | + private String code; | ||
| 38 | + /** | ||
| 39 | + * 检验单名称 | ||
| 40 | + */ | ||
| 41 | + private String name; | ||
| 42 | + /** | ||
| 43 | + * 检验模板 ID | ||
| 44 | + * | ||
| 45 | + * 关联 {@link MesQcTemplateDO#getId()} | ||
| 46 | + */ | ||
| 47 | + private Long templateId; | ||
| 48 | + | ||
| 49 | + // ========== 来源单据(TODO @芋艿:WM 模块迁移后接入) ========== | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 来源单据 ID | ||
| 53 | + */ | ||
| 54 | + private Long sourceDocId; | ||
| 55 | + /** | ||
| 56 | + * 来源单据类型 | ||
| 57 | + */ | ||
| 58 | + private String sourceDocType; | ||
| 59 | + /** | ||
| 60 | + * 来源单据编号 | ||
| 61 | + */ | ||
| 62 | + private String sourceDocCode; | ||
| 63 | + /** | ||
| 64 | + * 来源单据行 ID | ||
| 65 | + */ | ||
| 66 | + private Long sourceLineId; | ||
| 67 | + | ||
| 68 | + // ========== 退货类型 ========== | ||
| 69 | + | ||
| 70 | + // TODO @AI:改成 int;然后枚举类在 dict constants 也添加下; | ||
| 71 | + /** | ||
| 72 | + * 退货检验类型 | ||
| 73 | + * | ||
| 74 | + * 字典 mes_rqc_type | ||
| 75 | + */ | ||
| 76 | + private String rqcType; | ||
| 77 | + | ||
| 78 | + // ========== 物料 ========== | ||
| 79 | + | ||
| 80 | + /** | ||
| 81 | + * 产品物料 ID | ||
| 82 | + * | ||
| 83 | + * 关联 {@link MesMdItemDO#getId()} | ||
| 84 | + */ | ||
| 85 | + private Long itemId; | ||
| 86 | + /** | ||
| 87 | + * 批次号 | ||
| 88 | + */ | ||
| 89 | + private String batchCode; | ||
| 90 | + | ||
| 91 | + // ========== 数量 ========== | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * 检测数量 | ||
| 95 | + */ | ||
| 96 | + private BigDecimal checkQuantity; | ||
| 97 | + /** | ||
| 98 | + * 合格品数量 | ||
| 99 | + */ | ||
| 100 | + private BigDecimal qualifiedQuantity; | ||
| 101 | + /** | ||
| 102 | + * 不合格数量 | ||
| 103 | + */ | ||
| 104 | + private BigDecimal unqualifiedQuantity; | ||
| 105 | + | ||
| 106 | + // ========== 检验 ========== | ||
| 107 | + | ||
| 108 | + /** | ||
| 109 | + * 检测结果 | ||
| 110 | + * | ||
| 111 | + * 枚举 {@link cn.iocoder.yudao.module.mes.enums.qc.MesQcCheckResultEnum} | ||
| 112 | + */ | ||
| 113 | + private Integer checkResult; | ||
| 114 | + /** | ||
| 115 | + * 检测日期 | ||
| 116 | + */ | ||
| 117 | + private LocalDateTime inspectDate; | ||
| 118 | + /** | ||
| 119 | + * 检测人员用户 ID | ||
| 120 | + * | ||
| 121 | + * 关联 AdminUserDO 的 id | ||
| 122 | + */ | ||
| 123 | + private Long inspectorUserId; | ||
| 124 | + /** | ||
| 125 | + * 状态 | ||
| 126 | + * | ||
| 127 | + * 枚举 {@link cn.iocoder.yudao.module.mes.enums.qc.MesQcIqcStatusEnum} | ||
| 128 | + */ | ||
| 129 | + private Integer status; | ||
| 130 | + /** | ||
| 131 | + * 备注 | ||
| 132 | + */ | ||
| 133 | + private String remark; | ||
| 134 | + | ||
| 135 | + // ========== 预留字段 ========== | ||
| 136 | + | ||
| 137 | + /** | ||
| 138 | + * 预留字段 1 | ||
| 139 | + */ | ||
| 140 | + private String attribute1; | ||
| 141 | + /** | ||
| 142 | + * 预留字段 2 | ||
| 143 | + */ | ||
| 144 | + private String attribute2; | ||
| 145 | + /** | ||
| 146 | + * 预留字段 3 | ||
| 147 | + */ | ||
| 148 | + private Integer attribute3; | ||
| 149 | + /** | ||
| 150 | + * 预留字段 4 | ||
| 151 | + */ | ||
| 152 | + private Integer attribute4; | ||
| 153 | + | ||
| 154 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/rqc/MesQcRqcLineDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.unitmeasure.MesMdUnitMeasureDO; | ||
| 5 | +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 com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 8 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 9 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 10 | +import lombok.*; | ||
| 11 | + | ||
| 12 | +import java.math.BigDecimal; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * MES 退货检验行 DO | ||
| 16 | + * | ||
| 17 | + * @author 芋道源码 | ||
| 18 | + */ | ||
| 19 | +@TableName("mes_qc_rqc_line") | ||
| 20 | +@KeySequence("mes_qc_rqc_line_seq") | ||
| 21 | +@Data | ||
| 22 | +@EqualsAndHashCode(callSuper = true) | ||
| 23 | +@ToString(callSuper = true) | ||
| 24 | +@Builder | ||
| 25 | +@NoArgsConstructor | ||
| 26 | +@AllArgsConstructor | ||
| 27 | +public class MesQcRqcLineDO extends BaseDO { | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 编号 | ||
| 31 | + */ | ||
| 32 | + @TableId | ||
| 33 | + private Long id; | ||
| 34 | + /** | ||
| 35 | + * 退货检验单 ID | ||
| 36 | + * | ||
| 37 | + * 关联 {@link MesQcRqcDO#getId()} | ||
| 38 | + */ | ||
| 39 | + private Long rqcId; | ||
| 40 | + /** | ||
| 41 | + * 检测指标 ID | ||
| 42 | + * | ||
| 43 | + * 关联 {@link MesQcIndicatorDO#getId()} | ||
| 44 | + */ | ||
| 45 | + private Long indicatorId; | ||
| 46 | + /** | ||
| 47 | + * 检测工具 ID | ||
| 48 | + * | ||
| 49 | + * 关联 {@link MesTmToolDO#getId()} | ||
| 50 | + */ | ||
| 51 | + private Long toolId; | ||
| 52 | + /** | ||
| 53 | + * 检测方法 | ||
| 54 | + */ | ||
| 55 | + private String checkMethod; | ||
| 56 | + /** | ||
| 57 | + * 标准值 | ||
| 58 | + */ | ||
| 59 | + private BigDecimal standardValue; | ||
| 60 | + /** | ||
| 61 | + * 计量单位 ID | ||
| 62 | + * | ||
| 63 | + * 关联 {@link MesMdUnitMeasureDO#getId()} | ||
| 64 | + */ | ||
| 65 | + private Long unitMeasureId; | ||
| 66 | + /** | ||
| 67 | + * 误差上限 | ||
| 68 | + */ | ||
| 69 | + private BigDecimal maxThreshold; | ||
| 70 | + /** | ||
| 71 | + * 误差下限 | ||
| 72 | + */ | ||
| 73 | + private BigDecimal minThreshold; | ||
| 74 | + /** | ||
| 75 | + * 致命缺陷数量 | ||
| 76 | + */ | ||
| 77 | + private Integer criticalQuantity; | ||
| 78 | + /** | ||
| 79 | + * 严重缺陷数量 | ||
| 80 | + */ | ||
| 81 | + private Integer majorQuantity; | ||
| 82 | + /** | ||
| 83 | + * 轻微缺陷数量 | ||
| 84 | + */ | ||
| 85 | + private Integer minorQuantity; | ||
| 86 | + /** | ||
| 87 | + * 备注 | ||
| 88 | + */ | ||
| 89 | + private String remark; | ||
| 90 | + | ||
| 91 | + // ========== 预留字段 ========== | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * 预留字段 1 | ||
| 95 | + */ | ||
| 96 | + private String attribute1; | ||
| 97 | + /** | ||
| 98 | + * 预留字段 2 | ||
| 99 | + */ | ||
| 100 | + private String attribute2; | ||
| 101 | + /** | ||
| 102 | + * 预留字段 3 | ||
| 103 | + */ | ||
| 104 | + private Integer attribute3; | ||
| 105 | + /** | ||
| 106 | + * 预留字段 4 | ||
| 107 | + */ | ||
| 108 | + private Integer attribute4; | ||
| 109 | + | ||
| 110 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/rqc/MesQcRqcLineMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.qc.rqc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.rqc.vo.line.MesQcRqcLinePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcLineDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * MES 退货检验行 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface MesQcRqcLineMapper extends BaseMapperX<MesQcRqcLineDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<MesQcRqcLineDO> selectPage(MesQcRqcLinePageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesQcRqcLineDO>() | ||
| 22 | + .eqIfPresent(MesQcRqcLineDO::getRqcId, reqVO.getRqcId()) | ||
| 23 | + .orderByAsc(MesQcRqcLineDO::getId)); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + default List<MesQcRqcLineDO> selectListByRqcId(Long rqcId) { | ||
| 27 | + return selectList(MesQcRqcLineDO::getRqcId, rqcId); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + default void deleteByRqcId(Long rqcId) { | ||
| 31 | + delete(new LambdaQueryWrapperX<MesQcRqcLineDO>() | ||
| 32 | + .eq(MesQcRqcLineDO::getRqcId, rqcId)); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/rqc/MesQcRqcMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.qc.rqc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.rqc.vo.MesQcRqcPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * MES 退货检验单(RQC) Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface MesQcRqcMapper extends BaseMapperX<MesQcRqcDO> { | ||
| 17 | + | ||
| 18 | + default PageResult<MesQcRqcDO> selectPage(MesQcRqcPageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesQcRqcDO>() | ||
| 20 | + .likeIfPresent(MesQcRqcDO::getCode, reqVO.getCode()) | ||
| 21 | + .eqIfPresent(MesQcRqcDO::getItemId, reqVO.getItemId()) | ||
| 22 | + .eqIfPresent(MesQcRqcDO::getRqcType, reqVO.getRqcType()) | ||
| 23 | + .eqIfPresent(MesQcRqcDO::getCheckResult, reqVO.getCheckResult()) | ||
| 24 | + .eqIfPresent(MesQcRqcDO::getStatus, reqVO.getStatus()) | ||
| 25 | + .betweenIfPresent(MesQcRqcDO::getInspectDate, reqVO.getInspectDate()) | ||
| 26 | + .eqIfPresent(MesQcRqcDO::getInspectorUserId, reqVO.getInspectorUserId()) | ||
| 27 | + .orderByDesc(MesQcRqcDO::getId)); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + default MesQcRqcDO selectByCode(String code) { | ||
| 31 | + return selectOne(MesQcRqcDO::getCode, code); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcLineService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.qc.rqc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.rqc.vo.line.MesQcRqcLinePageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.defectrecord.MesQcDefectRecordDO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcLineDO; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * MES 退货检验行 Service 接口 | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +public interface MesQcRqcLineService { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 校验退货检验行存在 | ||
| 19 | + * | ||
| 20 | + * @param id 编号 | ||
| 21 | + * @return 退货检验行 | ||
| 22 | + */ | ||
| 23 | + MesQcRqcLineDO validateRqcLineExists(Long id); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 获得退货检验行 | ||
| 27 | + * | ||
| 28 | + * @param id 编号 | ||
| 29 | + * @return 退货检验行 | ||
| 30 | + */ | ||
| 31 | + MesQcRqcLineDO getRqcLine(Long id); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 获得退货检验行分页 | ||
| 35 | + * | ||
| 36 | + * @param pageReqVO 分页查询 | ||
| 37 | + * @return 退货检验行分页 | ||
| 38 | + */ | ||
| 39 | + PageResult<MesQcRqcLineDO> getRqcLinePage(MesQcRqcLinePageReqVO pageReqVO); | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 从模板指标自动生成检验行 | ||
| 43 | + * | ||
| 44 | + * @param rqcId 退货检验单 ID | ||
| 45 | + * @param templateId 模板 ID | ||
| 46 | + */ | ||
| 47 | + void createLinesFromTemplate(Long rqcId, Long templateId); | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * 根据缺陷记录重新计算各行的缺陷统计数量 | ||
| 51 | + * | ||
| 52 | + * @param rqcId 退货检验单 ID | ||
| 53 | + * @param records 缺陷记录列表 | ||
| 54 | + */ | ||
| 55 | + void recalculateLineDefectStats(Long rqcId, List<MesQcDefectRecordDO> records); | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * 根据退货检验单 ID 获取所有行 | ||
| 59 | + * | ||
| 60 | + * @param rqcId 退货检验单 ID | ||
| 61 | + * @return 行列表 | ||
| 62 | + */ | ||
| 63 | + List<MesQcRqcLineDO> getRqcLineListByRqcId(Long rqcId); | ||
| 64 | + | ||
| 65 | + /** | ||
| 66 | + * 根据退货检验单 ID 级联删除所有行 | ||
| 67 | + * | ||
| 68 | + * @param rqcId 退货检验单 ID | ||
| 69 | + */ | ||
| 70 | + void deleteByRqcId(Long rqcId); | ||
| 71 | + | ||
| 72 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcLineServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.qc.rqc; | ||
| 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.module.mes.controller.admin.qc.rqc.vo.line.MesQcRqcLinePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.defectrecord.MesQcDefectRecordDO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcLineDO; | ||
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateIndicatorDO; | ||
| 10 | +import cn.iocoder.yudao.module.mes.dal.mysql.qc.rqc.MesQcRqcLineMapper; | ||
| 11 | +import cn.iocoder.yudao.module.mes.dal.mysql.qc.template.MesQcTemplateIndicatorMapper; | ||
| 12 | +import cn.iocoder.yudao.module.mes.enums.qc.MesQcDefectLevelEnum; | ||
| 13 | +import jakarta.annotation.Resource; | ||
| 14 | +import org.springframework.stereotype.Service; | ||
| 15 | +import org.springframework.validation.annotation.Validated; | ||
| 16 | + | ||
| 17 | +import java.util.ArrayList; | ||
| 18 | +import java.util.List; | ||
| 19 | +import java.util.Objects; | ||
| 20 | + | ||
| 21 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 22 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 23 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * MES 退货检验行 Service 实现类 | ||
| 27 | + * | ||
| 28 | + * @author 芋道源码 | ||
| 29 | + */ | ||
| 30 | +@Service | ||
| 31 | +@Validated | ||
| 32 | +public class MesQcRqcLineServiceImpl implements MesQcRqcLineService { | ||
| 33 | + | ||
| 34 | + @Resource | ||
| 35 | + private MesQcRqcLineMapper rqcLineMapper; | ||
| 36 | + @Resource | ||
| 37 | + private MesQcTemplateIndicatorMapper templateIndicatorMapper; | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public MesQcRqcLineDO validateRqcLineExists(Long id) { | ||
| 41 | + MesQcRqcLineDO line = rqcLineMapper.selectById(id); | ||
| 42 | + if (line == null) { | ||
| 43 | + throw exception(QC_RQC_LINE_NOT_EXISTS); | ||
| 44 | + } | ||
| 45 | + return line; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + public MesQcRqcLineDO getRqcLine(Long id) { | ||
| 50 | + return rqcLineMapper.selectById(id); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @Override | ||
| 54 | + public PageResult<MesQcRqcLineDO> getRqcLinePage(MesQcRqcLinePageReqVO pageReqVO) { | ||
| 55 | + return rqcLineMapper.selectPage(pageReqVO); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public void createLinesFromTemplate(Long rqcId, Long templateId) { | ||
| 60 | + List<MesQcTemplateIndicatorDO> indicators = templateIndicatorMapper.selectListByTemplateId(templateId); | ||
| 61 | + List<MesQcRqcLineDO> lines = convertList(indicators, indicator -> new MesQcRqcLineDO() | ||
| 62 | + .setRqcId(rqcId).setIndicatorId(indicator.getIndicatorId()) | ||
| 63 | + .setToolId(null) // TODO @芋艿:模板指标暂无 toolId,后续可扩展 | ||
| 64 | + .setCheckMethod(indicator.getCheckMethod()) | ||
| 65 | + .setStandardValue(indicator.getStandardValue()).setUnitMeasureId(indicator.getUnitMeasureId()) | ||
| 66 | + .setMaxThreshold(indicator.getThresholdMax()).setMinThreshold(indicator.getThresholdMin()) | ||
| 67 | + .setCriticalQuantity(0).setMajorQuantity(0).setMinorQuantity(0)); | ||
| 68 | + rqcLineMapper.insertBatch(lines); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @Override | ||
| 72 | + public void recalculateLineDefectStats(Long rqcId, List<MesQcDefectRecordDO> records) { | ||
| 73 | + List<MesQcRqcLineDO> lines = rqcLineMapper.selectListByRqcId(rqcId); | ||
| 74 | + if (CollUtil.isEmpty(lines)) { | ||
| 75 | + return; | ||
| 76 | + } | ||
| 77 | + List<MesQcRqcLineDO> updateLines = new ArrayList<>(lines.size()); | ||
| 78 | + for (MesQcRqcLineDO line : lines) { | ||
| 79 | + int critical = 0, major = 0, minor = 0; | ||
| 80 | + for (MesQcDefectRecordDO record : records) { | ||
| 81 | + if (ObjUtil.notEqual(record.getLineId(), line.getId())) { | ||
| 82 | + continue; | ||
| 83 | + } | ||
| 84 | + int quantity = ObjUtil.defaultIfNull(record.getQuantity(), 1); | ||
| 85 | + if (Objects.equals(record.getLevel(), MesQcDefectLevelEnum.CRITICAL.getType())) { | ||
| 86 | + critical += quantity; | ||
| 87 | + } else if (Objects.equals(record.getLevel(), MesQcDefectLevelEnum.MAJOR.getType())) { | ||
| 88 | + major += quantity; | ||
| 89 | + } else if (Objects.equals(record.getLevel(), MesQcDefectLevelEnum.MINOR.getType())) { | ||
| 90 | + minor += quantity; | ||
| 91 | + } else { | ||
| 92 | + throw exception(QC_DEFECT_RECORD_LEVEL_UNKNOWN); | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + updateLines.add(new MesQcRqcLineDO().setId(line.getId()) | ||
| 96 | + .setCriticalQuantity(critical).setMajorQuantity(major).setMinorQuantity(minor)); | ||
| 97 | + } | ||
| 98 | + for (MesQcRqcLineDO updateLine : updateLines) { | ||
| 99 | + rqcLineMapper.updateById(updateLine); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + @Override | ||
| 104 | + public List<MesQcRqcLineDO> getRqcLineListByRqcId(Long rqcId) { | ||
| 105 | + return rqcLineMapper.selectListByRqcId(rqcId); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @Override | ||
| 109 | + public void deleteByRqcId(Long rqcId) { | ||
| 110 | + rqcLineMapper.deleteByRqcId(rqcId); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.qc.rqc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.rqc.vo.MesQcRqcPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.rqc.vo.MesQcRqcSaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.defectrecord.MesQcDefectRecordDO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcDO; | ||
| 8 | +import jakarta.validation.Valid; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * MES 退货检验单(RQC) Service 接口 | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +public interface MesQcRqcService { | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 创建退货检验单 | ||
| 21 | + * | ||
| 22 | + * @param createReqVO 创建信息 | ||
| 23 | + * @return 编号 | ||
| 24 | + */ | ||
| 25 | + Long createRqc(@Valid MesQcRqcSaveReqVO createReqVO); | ||
| 26 | + | ||
| 27 | + /** | ||
| 28 | + * 更新退货检验单 | ||
| 29 | + * | ||
| 30 | + * @param updateReqVO 更新信息 | ||
| 31 | + */ | ||
| 32 | + void updateRqc(@Valid MesQcRqcSaveReqVO updateReqVO); | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 完成退货检验单 | ||
| 36 | + * | ||
| 37 | + * @param id 编号 | ||
| 38 | + */ | ||
| 39 | + void completeRqc(Long id); | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 删除退货检验单 | ||
| 43 | + * | ||
| 44 | + * @param id 编号 | ||
| 45 | + */ | ||
| 46 | + void deleteRqc(Long id); | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 校验退货检验单存在 | ||
| 50 | + * | ||
| 51 | + * @param id 编号 | ||
| 52 | + * @return 退货检验单 | ||
| 53 | + */ | ||
| 54 | + MesQcRqcDO validateRqcExists(Long id); | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 获得退货检验单 | ||
| 58 | + * | ||
| 59 | + * @param id 编号 | ||
| 60 | + * @return 退货检验单 | ||
| 61 | + */ | ||
| 62 | + MesQcRqcDO getRqc(Long id); | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 获得退货检验单分页 | ||
| 66 | + * | ||
| 67 | + * @param pageReqVO 分页查询 | ||
| 68 | + * @return 退货检验单分页 | ||
| 69 | + */ | ||
| 70 | + PageResult<MesQcRqcDO> getRqcPage(MesQcRqcPageReqVO pageReqVO); | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * 根据缺陷记录重新计算行级缺陷统计 | ||
| 74 | + * | ||
| 75 | + * @param rqcId 退货检验单 ID | ||
| 76 | + * @param records 缺陷记录列表 | ||
| 77 | + */ | ||
| 78 | + void recalculateDefectStats(Long rqcId, List<MesQcDefectRecordDO> records); | ||
| 79 | + | ||
| 80 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/rqc/MesQcRqcServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.qc.rqc; | ||
| 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.rqc.vo.MesQcRqcPageReqVO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.rqc.vo.MesQcRqcSaveReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.defectrecord.MesQcDefectRecordDO; | ||
| 10 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.rqc.MesQcRqcDO; | ||
| 11 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.template.MesQcTemplateDO; | ||
| 12 | +import cn.iocoder.yudao.module.mes.dal.mysql.qc.rqc.MesQcRqcMapper; | ||
| 13 | +import cn.iocoder.yudao.module.mes.enums.qc.MesQcIqcStatusEnum; | ||
| 14 | +import cn.iocoder.yudao.module.mes.enums.qc.MesQcTypeEnum; | ||
| 15 | +import cn.iocoder.yudao.module.mes.service.qc.defectrecord.MesQcDefectRecordService; | ||
| 16 | +import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateService; | ||
| 17 | +import jakarta.annotation.Resource; | ||
| 18 | +import org.springframework.context.annotation.Lazy; | ||
| 19 | +import org.springframework.stereotype.Service; | ||
| 20 | +import org.springframework.transaction.annotation.Transactional; | ||
| 21 | +import org.springframework.validation.annotation.Validated; | ||
| 22 | + | ||
| 23 | +import java.math.BigDecimal; | ||
| 24 | +import java.util.List; | ||
| 25 | + | ||
| 26 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 27 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | ||
| 28 | + | ||
| 29 | +/** | ||
| 30 | + * MES 退货检验单(RQC) Service 实现类 | ||
| 31 | + * | ||
| 32 | + * @author 芋道源码 | ||
| 33 | + */ | ||
| 34 | +@Service | ||
| 35 | +@Validated | ||
| 36 | +public class MesQcRqcServiceImpl implements MesQcRqcService { | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private MesQcRqcMapper rqcMapper; | ||
| 40 | + @Resource | ||
| 41 | + private MesQcTemplateService templateService; | ||
| 42 | + @Resource | ||
| 43 | + private MesQcRqcLineService rqcLineService; | ||
| 44 | + @Resource | ||
| 45 | + @Lazy | ||
| 46 | + private MesQcDefectRecordService defectRecordService; | ||
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + @Transactional(rollbackFor = Exception.class) | ||
| 50 | + public Long createRqc(MesQcRqcSaveReqVO createReqVO) { | ||
| 51 | + // 1.1 校验编号唯一 | ||
| 52 | + validateRqcCodeUnique(null, createReqVO.getCode()); | ||
| 53 | + // TODO @AI:关联的物资等存在的校验; | ||
| 54 | + // 1.2 校验检验模板存在且支持 RQC 类型 | ||
| 55 | + Long templateId = createReqVO.getTemplateId(); | ||
| 56 | + MesQcTemplateDO template = templateService.validateTemplateExists(templateId); | ||
| 57 | + if (!CollUtil.contains(template.getTypes(), MesQcTypeEnum.RQC.getType())) { | ||
| 58 | + throw exception(QC_RQC_NO_TEMPLATE); | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + // 2. 插入主表 | ||
| 62 | + MesQcRqcDO rqc = BeanUtils.toBean(createReqVO, MesQcRqcDO.class) | ||
| 63 | + .setStatus(MesQcIqcStatusEnum.PREPARE.getType()); | ||
| 64 | + rqcMapper.insert(rqc); | ||
| 65 | + | ||
| 66 | + // 3. 从模板指标自动生成检验行 | ||
| 67 | + rqcLineService.createLinesFromTemplate(rqc.getId(), templateId); | ||
| 68 | + return rqc.getId(); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + @Override | ||
| 72 | + public void updateRqc(MesQcRqcSaveReqVO updateReqVO) { | ||
| 73 | + // 1.1 校验存在 + 草稿状态 | ||
| 74 | + validateRqcStatusPrepare(updateReqVO.getId()); | ||
| 75 | + // 1.2 校验编号唯一 | ||
| 76 | + validateRqcCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | ||
| 77 | + | ||
| 78 | + // 2. 更新 | ||
| 79 | + MesQcRqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcRqcDO.class); | ||
| 80 | + rqcMapper.updateById(updateObj); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @Override | ||
| 84 | + public void completeRqc(Long id) { | ||
| 85 | + // 1.1 校验存在 + 草稿状态 | ||
| 86 | + MesQcRqcDO rqc = validateRqcStatusPrepare(id); | ||
| 87 | + // 1.2 校验合格品 + 不合格品 = 检测数量 | ||
| 88 | + if (rqc.getCheckQuantity() != null && rqc.getCheckQuantity().compareTo(BigDecimal.ZERO) > 0) { | ||
| 89 | + BigDecimal qualified = rqc.getQualifiedQuantity() != null ? rqc.getQualifiedQuantity() : BigDecimal.ZERO; | ||
| 90 | + BigDecimal unqualified = rqc.getUnqualifiedQuantity() != null ? rqc.getUnqualifiedQuantity() : BigDecimal.ZERO; | ||
| 91 | + if (qualified.add(unqualified).compareTo(rqc.getCheckQuantity()) != 0) { | ||
| 92 | + throw exception(QC_RQC_QUANTITY_MISMATCH); | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + // 2. 更新状态为已完成 | ||
| 97 | + MesQcRqcDO updateObj = new MesQcRqcDO().setId(id).setStatus(MesQcIqcStatusEnum.FINISHED.getType()); | ||
| 98 | + rqcMapper.updateById(updateObj); | ||
| 99 | + | ||
| 100 | + // TODO @芋艿:WM 模块迁移后,更新来源退料/退货单行的质量状态 | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + @Override | ||
| 104 | + @Transactional(rollbackFor = Exception.class) | ||
| 105 | + public void deleteRqc(Long id) { | ||
| 106 | + // 1. 校验存在 + 草稿状态 | ||
| 107 | + validateRqcStatusPrepare(id); | ||
| 108 | + | ||
| 109 | + // 2.1 删除主表 | ||
| 110 | + rqcMapper.deleteById(id); | ||
| 111 | + // 2.2 级联删除行 | ||
| 112 | + rqcLineService.deleteByRqcId(id); | ||
| 113 | + // 2.3 级联删除缺陷记录 | ||
| 114 | + defectRecordService.deleteByQcTypeAndQcId(MesQcTypeEnum.RQC.getType(), id); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + @Override | ||
| 118 | + public MesQcRqcDO validateRqcExists(Long id) { | ||
| 119 | + MesQcRqcDO rqc = rqcMapper.selectById(id); | ||
| 120 | + if (rqc == null) { | ||
| 121 | + throw exception(QC_RQC_NOT_EXISTS); | ||
| 122 | + } | ||
| 123 | + return rqc; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + /** | ||
| 127 | + * 校验退货检验单存在且为草稿状态 | ||
| 128 | + * | ||
| 129 | + * @param id 退货检验单 ID | ||
| 130 | + * @return 退货检验单 | ||
| 131 | + */ | ||
| 132 | + private MesQcRqcDO validateRqcStatusPrepare(Long id) { | ||
| 133 | + MesQcRqcDO rqc = validateRqcExists(id); | ||
| 134 | + if (ObjUtil.notEqual(rqc.getStatus(), MesQcIqcStatusEnum.PREPARE.getType())) { | ||
| 135 | + throw exception(QC_RQC_NOT_PREPARE); | ||
| 136 | + } | ||
| 137 | + return rqc; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + private void validateRqcCodeUnique(Long id, String code) { | ||
| 141 | + MesQcRqcDO rqc = rqcMapper.selectByCode(code); | ||
| 142 | + if (rqc == null) { | ||
| 143 | + return; | ||
| 144 | + } | ||
| 145 | + if (ObjUtil.notEqual(rqc.getId(), id)) { | ||
| 146 | + throw exception(QC_RQC_CODE_DUPLICATE); | ||
| 147 | + } | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + @Override | ||
| 151 | + public MesQcRqcDO getRqc(Long id) { | ||
| 152 | + return rqcMapper.selectById(id); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + @Override | ||
| 156 | + public PageResult<MesQcRqcDO> getRqcPage(MesQcRqcPageReqVO pageReqVO) { | ||
| 157 | + return rqcMapper.selectPage(pageReqVO); | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + @Override | ||
| 161 | + public void recalculateDefectStats(Long rqcId, List<MesQcDefectRecordDO> records) { | ||
| 162 | + // RQC 只更新行级缺陷统计,主表不存储缺陷统计字段 | ||
| 163 | + rqcLineService.recalculateLineDefectStats(rqcId, records); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | +} |