Commit 06d795610bd4a625895ccf029d9da16295278251
1 parent
3f2c13f3
feat:新增 qc indicator 质量管理 - 检测项
Showing
10 changed files
with
577 additions
and
1 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/MesQcIndicatorController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 7 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 8 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | |
| 9 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcIndicatorPageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcIndicatorRespVO; | |
| 11 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcIndicatorSaveReqVO; | |
| 12 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.MesQcIndicatorDO; | |
| 13 | +import cn.iocoder.yudao.module.mes.service.qc.MesQcIndicatorService; | |
| 14 | +import io.swagger.v3.oas.annotations.Operation; | |
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 17 | +import jakarta.annotation.Resource; | |
| 18 | +import jakarta.servlet.http.HttpServletResponse; | |
| 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.*; | |
| 23 | + | |
| 24 | +import java.io.IOException; | |
| 25 | +import java.util.List; | |
| 26 | + | |
| 27 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | |
| 28 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 29 | + | |
| 30 | +@Tag(name = "管理后台 - MES 质检指标") | |
| 31 | +@RestController | |
| 32 | +@RequestMapping("/mes/qc/indicator") | |
| 33 | +@Validated | |
| 34 | +public class MesQcIndicatorController { | |
| 35 | + | |
| 36 | + @Resource | |
| 37 | + private MesQcIndicatorService indicatorService; | |
| 38 | + | |
| 39 | + @PostMapping("/create") | |
| 40 | + @Operation(summary = "创建质检指标") | |
| 41 | + @PreAuthorize("@ss.hasPermission('mes:qc-indicator:create')") | |
| 42 | + public CommonResult<Long> createIndicator(@Valid @RequestBody MesQcIndicatorSaveReqVO createReqVO) { | |
| 43 | + return success(indicatorService.createIndicator(createReqVO)); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @PutMapping("/update") | |
| 47 | + @Operation(summary = "更新质检指标") | |
| 48 | + @PreAuthorize("@ss.hasPermission('mes:qc-indicator:update')") | |
| 49 | + public CommonResult<Boolean> updateIndicator(@Valid @RequestBody MesQcIndicatorSaveReqVO updateReqVO) { | |
| 50 | + indicatorService.updateIndicator(updateReqVO); | |
| 51 | + return success(true); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @DeleteMapping("/delete") | |
| 55 | + @Operation(summary = "删除质检指标") | |
| 56 | + @Parameter(name = "id", description = "编号", required = true) | |
| 57 | + @PreAuthorize("@ss.hasPermission('mes:qc-indicator:delete')") | |
| 58 | + public CommonResult<Boolean> deleteIndicator(@RequestParam("id") Long id) { | |
| 59 | + indicatorService.deleteIndicator(id); | |
| 60 | + return success(true); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @GetMapping("/get") | |
| 64 | + @Operation(summary = "获得质检指标") | |
| 65 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 66 | + @PreAuthorize("@ss.hasPermission('mes:qc-indicator:query')") | |
| 67 | + public CommonResult<MesQcIndicatorRespVO> getIndicator(@RequestParam("id") Long id) { | |
| 68 | + MesQcIndicatorDO indicator = indicatorService.getIndicator(id); | |
| 69 | + return success(BeanUtils.toBean(indicator, MesQcIndicatorRespVO.class)); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @GetMapping("/page") | |
| 73 | + @Operation(summary = "获得质检指标分页") | |
| 74 | + @PreAuthorize("@ss.hasPermission('mes:qc-indicator:query')") | |
| 75 | + public CommonResult<PageResult<MesQcIndicatorRespVO>> getIndicatorPage(@Valid MesQcIndicatorPageReqVO pageReqVO) { | |
| 76 | + PageResult<MesQcIndicatorDO> pageResult = indicatorService.getIndicatorPage(pageReqVO); | |
| 77 | + return success(BeanUtils.toBean(pageResult, MesQcIndicatorRespVO.class)); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @GetMapping("/simple-list") | |
| 81 | + @Operation(summary = "获得质检指标精简列表", description = "主要用于前端的下拉选项") | |
| 82 | + public CommonResult<List<MesQcIndicatorRespVO>> getIndicatorSimpleList() { | |
| 83 | + List<MesQcIndicatorDO> list = indicatorService.getIndicatorList(); | |
| 84 | + return success(BeanUtils.toBean(list, MesQcIndicatorRespVO.class)); | |
| 85 | + } | |
| 86 | + | |
| 87 | + @GetMapping("/export-excel") | |
| 88 | + @Operation(summary = "导出质检指标 Excel") | |
| 89 | + @PreAuthorize("@ss.hasPermission('mes:qc-indicator:export')") | |
| 90 | + @ApiAccessLog(operateType = EXPORT) | |
| 91 | + public void exportIndicatorExcel(@Valid MesQcIndicatorPageReqVO pageReqVO, | |
| 92 | + HttpServletResponse response) throws IOException { | |
| 93 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 94 | + List<MesQcIndicatorDO> list = indicatorService.getIndicatorPage(pageReqVO).getList(); | |
| 95 | + // 导出 Excel | |
| 96 | + ExcelUtils.write(response, "质检指标.xls", "数据", MesQcIndicatorRespVO.class, | |
| 97 | + BeanUtils.toBean(list, MesQcIndicatorRespVO.class)); | |
| 98 | + } | |
| 99 | + | |
| 100 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/vo/MesQcIndicatorPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc.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 | + | |
| 9 | +@Schema(description = "管理后台 - MES 质检指标分页 Request VO") | |
| 10 | +@Data | |
| 11 | +@EqualsAndHashCode(callSuper = true) | |
| 12 | +@ToString(callSuper = true) | |
| 13 | +public class MesQcIndicatorPageReqVO extends PageParam { | |
| 14 | + | |
| 15 | + @Schema(description = "检测项编码", example = "QI001") | |
| 16 | + private String code; | |
| 17 | + | |
| 18 | + @Schema(description = "检测项名称", example = "长度") | |
| 19 | + private String name; | |
| 20 | + | |
| 21 | + @Schema(description = "检测项类型", example = "SIZE") | |
| 22 | + private String type; | |
| 23 | + | |
| 24 | + @Schema(description = "结果值类型", example = "FLOAT") | |
| 25 | + private String resultType; | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/vo/MesQcIndicatorRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; | |
| 4 | +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; | |
| 5 | +import cn.iocoder.yudao.module.mes.enums.DictTypeConstants; | |
| 6 | +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; | |
| 7 | +import cn.idev.excel.annotation.ExcelProperty; | |
| 8 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 9 | +import lombok.Data; | |
| 10 | + | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | + | |
| 13 | +@Schema(description = "管理后台 - MES 质检指标 Response VO") | |
| 14 | +@Data | |
| 15 | +@ExcelIgnoreUnannotated | |
| 16 | +public class MesQcIndicatorRespVO { | |
| 17 | + | |
| 18 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 19 | + @ExcelProperty("编号") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | + @Schema(description = "检测项编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "QI001") | |
| 23 | + @ExcelProperty("检测项编码") | |
| 24 | + private String code; | |
| 25 | + | |
| 26 | + @Schema(description = "检测项名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "长度") | |
| 27 | + @ExcelProperty("检测项名称") | |
| 28 | + private String name; | |
| 29 | + | |
| 30 | + @Schema(description = "检测项类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "SIZE") | |
| 31 | + @ExcelProperty(value = "检测项类型", converter = DictConvert.class) | |
| 32 | + @DictFormat(DictTypeConstants.MES_INDEX_TYPE) | |
| 33 | + private String type; | |
| 34 | + | |
| 35 | + @Schema(description = "检测工具", example = "卡尺") | |
| 36 | + @ExcelProperty("检测工具") | |
| 37 | + private String tool; | |
| 38 | + | |
| 39 | + @Schema(description = "结果值类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "FLOAT") | |
| 40 | + @ExcelProperty(value = "结果值类型", converter = DictConvert.class) | |
| 41 | + @DictFormat(DictTypeConstants.MES_QC_RESULT_TYPE) | |
| 42 | + private String resultType; | |
| 43 | + | |
| 44 | + @Schema(description = "结果值属性", example = "IMG") | |
| 45 | + @ExcelProperty("结果值属性") | |
| 46 | + private String resultSpec; | |
| 47 | + | |
| 48 | + @Schema(description = "备注", example = "备注") | |
| 49 | + @ExcelProperty("备注") | |
| 50 | + private String remark; | |
| 51 | + | |
| 52 | + @Schema(description = "预留字段1") | |
| 53 | + private String attribute1; | |
| 54 | + | |
| 55 | + @Schema(description = "预留字段2") | |
| 56 | + private String attribute2; | |
| 57 | + | |
| 58 | + @Schema(description = "预留字段3") | |
| 59 | + private Integer attribute3; | |
| 60 | + | |
| 61 | + @Schema(description = "预留字段4") | |
| 62 | + private Integer attribute4; | |
| 63 | + | |
| 64 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 65 | + @ExcelProperty("创建时间") | |
| 66 | + private LocalDateTime createTime; | |
| 67 | + | |
| 68 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/vo/MesQcIndicatorSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.qc.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import jakarta.validation.constraints.NotEmpty; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +@Schema(description = "管理后台 - MES 质检指标新增/修改 Request VO") | |
| 8 | +@Data | |
| 9 | +public class MesQcIndicatorSaveReqVO { | |
| 10 | + | |
| 11 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 12 | + private Long id; | |
| 13 | + | |
| 14 | + @Schema(description = "检测项编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "QI001") | |
| 15 | + @NotEmpty(message = "检测项编码不能为空") | |
| 16 | + private String code; | |
| 17 | + | |
| 18 | + @Schema(description = "检测项名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "长度") | |
| 19 | + @NotEmpty(message = "检测项名称不能为空") | |
| 20 | + private String name; | |
| 21 | + | |
| 22 | + @Schema(description = "检测项类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "SIZE") | |
| 23 | + @NotEmpty(message = "检测项类型不能为空") | |
| 24 | + private String type; | |
| 25 | + | |
| 26 | + @Schema(description = "检测工具", example = "卡尺") | |
| 27 | + private String tool; | |
| 28 | + | |
| 29 | + @Schema(description = "结果值类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "FLOAT") | |
| 30 | + @NotEmpty(message = "结果值类型不能为空") | |
| 31 | + private String resultType; | |
| 32 | + | |
| 33 | + @Schema(description = "结果值属性", example = "IMG") | |
| 34 | + private String resultSpec; | |
| 35 | + | |
| 36 | + @Schema(description = "备注", example = "备注") | |
| 37 | + private String remark; | |
| 38 | + | |
| 39 | + @Schema(description = "预留字段1") | |
| 40 | + private String attribute1; | |
| 41 | + | |
| 42 | + @Schema(description = "预留字段2") | |
| 43 | + private String attribute2; | |
| 44 | + | |
| 45 | + @Schema(description = "预留字段3") | |
| 46 | + private Integer attribute3; | |
| 47 | + | |
| 48 | + @Schema(description = "预留字段4") | |
| 49 | + private Integer attribute4; | |
| 50 | + | |
| 51 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/MesQcIndicatorDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.qc; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 7 | +import lombok.*; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * MES 质检指标 DO | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@TableName("mes_qc_indicator") | |
| 15 | +@KeySequence("mes_qc_indicator_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 16 | +@Data | |
| 17 | +@EqualsAndHashCode(callSuper = true) | |
| 18 | +@ToString(callSuper = true) | |
| 19 | +@Builder | |
| 20 | +@NoArgsConstructor | |
| 21 | +@AllArgsConstructor | |
| 22 | +public class MesQcIndicatorDO extends BaseDO { | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 编号 | |
| 26 | + */ | |
| 27 | + @TableId | |
| 28 | + private Long id; | |
| 29 | + /** | |
| 30 | + * 检测项编码 | |
| 31 | + */ | |
| 32 | + private String code; | |
| 33 | + /** | |
| 34 | + * 检测项名称 | |
| 35 | + */ | |
| 36 | + private String name; | |
| 37 | + // TODO @AI:字典枚举,链接过去; | |
| 38 | + /** | |
| 39 | + * 检测项类型 | |
| 40 | + * | |
| 41 | + * 字典类型 mes_index_type | |
| 42 | + */ | |
| 43 | + private String type; | |
| 44 | + /** | |
| 45 | + * 检测工具 | |
| 46 | + */ | |
| 47 | + private String tool; | |
| 48 | + // TODO @AI:字典枚举,链接过去; | |
| 49 | + /** | |
| 50 | + * 结果值类型 | |
| 51 | + * | |
| 52 | + * 字典类型 mes_qc_result_type | |
| 53 | + */ | |
| 54 | + private String resultType; | |
| 55 | + /** | |
| 56 | + * 结果值属性 | |
| 57 | + * | |
| 58 | + * FILE 时存 IMG/FILE;DICT 时存字典类型名 | |
| 59 | + */ | |
| 60 | + private String resultSpec; | |
| 61 | + /** | |
| 62 | + * 备注 | |
| 63 | + */ | |
| 64 | + private String remark; | |
| 65 | + /** | |
| 66 | + * 预留字段1 | |
| 67 | + */ | |
| 68 | + private String attribute1; | |
| 69 | + /** | |
| 70 | + * 预留字段2 | |
| 71 | + */ | |
| 72 | + private String attribute2; | |
| 73 | + /** | |
| 74 | + * 预留字段3 | |
| 75 | + */ | |
| 76 | + private Integer attribute3; | |
| 77 | + /** | |
| 78 | + * 预留字段4 | |
| 79 | + */ | |
| 80 | + private Integer attribute4; | |
| 81 | + | |
| 82 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/MesQcIndicatorMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.qc; | |
| 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.vo.MesQcIndicatorPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.MesQcIndicatorDO; | |
| 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 MesQcIndicatorMapper extends BaseMapperX<MesQcIndicatorDO> { | |
| 19 | + | |
| 20 | + default PageResult<MesQcIndicatorDO> selectPage(MesQcIndicatorPageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesQcIndicatorDO>() | |
| 22 | + .likeIfPresent(MesQcIndicatorDO::getCode, reqVO.getCode()) | |
| 23 | + .likeIfPresent(MesQcIndicatorDO::getName, reqVO.getName()) | |
| 24 | + .eqIfPresent(MesQcIndicatorDO::getType, reqVO.getType()) | |
| 25 | + .eqIfPresent(MesQcIndicatorDO::getResultType, reqVO.getResultType()) | |
| 26 | + .orderByDesc(MesQcIndicatorDO::getId)); | |
| 27 | + } | |
| 28 | + | |
| 29 | + default MesQcIndicatorDO selectByCode(String code) { | |
| 30 | + return selectOne(MesQcIndicatorDO::getCode, code); | |
| 31 | + } | |
| 32 | + | |
| 33 | + default MesQcIndicatorDO selectByName(String name) { | |
| 34 | + return selectOne(MesQcIndicatorDO::getName, name); | |
| 35 | + } | |
| 36 | + | |
| 37 | + default List<MesQcIndicatorDO> selectList() { | |
| 38 | + return selectList(new LambdaQueryWrapperX<MesQcIndicatorDO>() | |
| 39 | + .orderByDesc(MesQcIndicatorDO::getId)); | |
| 40 | + } | |
| 41 | + | |
| 42 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java
| ... | ... | @@ -18,6 +18,7 @@ public interface DictTypeConstants { |
| 18 | 18 | String MES_CAL_PLAN_STATUS = "mes_cal_plan_status"; // MES 排班计划状态 |
| 19 | 19 | String MES_DV_MACHINERY_STATUS = "mes_dv_machinery_status"; // MES 设备状态 |
| 20 | 20 | String MES_INDEX_TYPE = "mes_index_type"; // MES 检测项类型 |
| 21 | + String MES_QC_RESULT_TYPE = "mes_qc_result_type"; // MES 质检结果值类型 | |
| 21 | 22 | String MES_DEFECT_LEVEL = "mes_defect_level"; // MES 缺陷等级 |
| 22 | 23 | String MES_PRO_WORKORDER_STATUS = "mes_pro_workorder_status"; // MES 生产工单状态 |
| 23 | 24 | String MES_PRO_WORKORDER_SOURCE_TYPE = "mes_pro_workorder_source_type"; // MES 工单来源类型 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
| ... | ... | @@ -149,7 +149,9 @@ public interface ErrorCodeConstants { |
| 149 | 149 | ErrorCode QC_TEMPLATE_NOT_EXISTS = new ErrorCode(1_040_600_000, "检验模板不存在"); |
| 150 | 150 | |
| 151 | 151 | // ========== MES 质量管理-质检指标(1-040-601-000) ========== |
| 152 | - ErrorCode QC_INDEX_NOT_EXISTS = new ErrorCode(1_040_601_000, "质检指标不存在"); | |
| 152 | + ErrorCode QC_INDICATOR_NOT_EXISTS = new ErrorCode(1_040_601_000, "质检指标不存在"); | |
| 153 | + ErrorCode QC_INDICATOR_CODE_DUPLICATE = new ErrorCode(1_040_601_001, "质检指标编码已存在"); | |
| 154 | + ErrorCode QC_INDICATOR_NAME_DUPLICATE = new ErrorCode(1_040_601_002, "质检指标名称已存在"); | |
| 153 | 155 | |
| 154 | 156 | // ========== MES 质量管理-缺陷类型(1-040-602-000) ========== |
| 155 | 157 | ErrorCode QC_DEFECT_NOT_EXISTS = new ErrorCode(1_040_602_000, "缺陷类型不存在"); | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/MesQcIndicatorService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.qc; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcIndicatorPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcIndicatorSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.MesQcIndicatorDO; | |
| 7 | +import jakarta.validation.Valid; | |
| 8 | + | |
| 9 | +import java.util.Collection; | |
| 10 | +import java.util.List; | |
| 11 | +import java.util.Map; | |
| 12 | + | |
| 13 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * MES 质检指标 Service 接口 | |
| 17 | + * | |
| 18 | + * @author 芋道源码 | |
| 19 | + */ | |
| 20 | +public interface MesQcIndicatorService { | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * 创建质检指标 | |
| 24 | + * | |
| 25 | + * @param createReqVO 创建信息 | |
| 26 | + * @return 编号 | |
| 27 | + */ | |
| 28 | + Long createIndicator(@Valid MesQcIndicatorSaveReqVO createReqVO); | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 更新质检指标 | |
| 32 | + * | |
| 33 | + * @param updateReqVO 更新信息 | |
| 34 | + */ | |
| 35 | + void updateIndicator(@Valid MesQcIndicatorSaveReqVO updateReqVO); | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * 删除质检指标 | |
| 39 | + * | |
| 40 | + * @param id 编号 | |
| 41 | + */ | |
| 42 | + void deleteIndicator(Long id); | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * 获得质检指标 | |
| 46 | + * | |
| 47 | + * @param id 编号 | |
| 48 | + * @return 质检指标 | |
| 49 | + */ | |
| 50 | + MesQcIndicatorDO getIndicator(Long id); | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * 获得质检指标分页 | |
| 54 | + * | |
| 55 | + * @param pageReqVO 分页查询 | |
| 56 | + * @return 质检指标分页 | |
| 57 | + */ | |
| 58 | + PageResult<MesQcIndicatorDO> getIndicatorPage(MesQcIndicatorPageReqVO pageReqVO); | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * 获得质检指标列表 | |
| 62 | + * | |
| 63 | + * @return 质检指标列表 | |
| 64 | + */ | |
| 65 | + List<MesQcIndicatorDO> getIndicatorList(); | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * 获得质检指标列表 | |
| 69 | + * | |
| 70 | + * @param ids 编号数组 | |
| 71 | + * @return 质检指标列表 | |
| 72 | + */ | |
| 73 | + List<MesQcIndicatorDO> getIndicatorList(Collection<Long> ids); | |
| 74 | + | |
| 75 | + /** | |
| 76 | + * 获得质检指标 Map | |
| 77 | + * | |
| 78 | + * @param ids 编号数组 | |
| 79 | + * @return 质检指标 Map | |
| 80 | + */ | |
| 81 | + default Map<Long, MesQcIndicatorDO> getIndicatorMap(Collection<Long> ids) { | |
| 82 | + return convertMap(getIndicatorList(ids), MesQcIndicatorDO::getId); | |
| 83 | + } | |
| 84 | + | |
| 85 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/MesQcIndicatorServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.qc; | |
| 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.vo.MesQcIndicatorPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.mes.controller.admin.qc.vo.MesQcIndicatorSaveReqVO; | |
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.qc.MesQcIndicatorDO; | |
| 10 | +import cn.iocoder.yudao.module.mes.dal.mysql.qc.MesQcIndicatorMapper; | |
| 11 | +import jakarta.annotation.Resource; | |
| 12 | +import org.springframework.stereotype.Service; | |
| 13 | +import org.springframework.validation.annotation.Validated; | |
| 14 | + | |
| 15 | +import java.util.Collection; | |
| 16 | +import java.util.Collections; | |
| 17 | +import java.util.List; | |
| 18 | + | |
| 19 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 20 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * MES 质检指标 Service 实现类 | |
| 24 | + * | |
| 25 | + * @author 芋道源码 | |
| 26 | + */ | |
| 27 | +@Service | |
| 28 | +@Validated | |
| 29 | +public class MesQcIndicatorServiceImpl implements MesQcIndicatorService { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private MesQcIndicatorMapper indicatorMapper; | |
| 33 | + | |
| 34 | + @Override | |
| 35 | + public Long createIndicator(MesQcIndicatorSaveReqVO createReqVO) { | |
| 36 | + // 校验编码唯一 | |
| 37 | + validateIndicatorCodeUnique(null, createReqVO.getCode()); | |
| 38 | + // 校验名称唯一 | |
| 39 | + validateIndicatorNameUnique(null, createReqVO.getName()); | |
| 40 | + | |
| 41 | + // 插入 | |
| 42 | + MesQcIndicatorDO indicator = BeanUtils.toBean(createReqVO, MesQcIndicatorDO.class); | |
| 43 | + indicatorMapper.insert(indicator); | |
| 44 | + return indicator.getId(); | |
| 45 | + } | |
| 46 | + | |
| 47 | + @Override | |
| 48 | + public void updateIndicator(MesQcIndicatorSaveReqVO updateReqVO) { | |
| 49 | + // 校验存在 | |
| 50 | + validateIndicatorExists(updateReqVO.getId()); | |
| 51 | + // 校验编码唯一 | |
| 52 | + validateIndicatorCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | |
| 53 | + // 校验名称唯一 | |
| 54 | + validateIndicatorNameUnique(updateReqVO.getId(), updateReqVO.getName()); | |
| 55 | + | |
| 56 | + // 更新 | |
| 57 | + MesQcIndicatorDO updateObj = BeanUtils.toBean(updateReqVO, MesQcIndicatorDO.class); | |
| 58 | + indicatorMapper.updateById(updateObj); | |
| 59 | + } | |
| 60 | + | |
| 61 | + @Override | |
| 62 | + public void deleteIndicator(Long id) { | |
| 63 | + // 校验存在 | |
| 64 | + validateIndicatorExists(id); | |
| 65 | + // 删除 | |
| 66 | + indicatorMapper.deleteById(id); | |
| 67 | + } | |
| 68 | + | |
| 69 | + private void validateIndicatorExists(Long id) { | |
| 70 | + if (indicatorMapper.selectById(id) == null) { | |
| 71 | + throw exception(QC_INDICATOR_NOT_EXISTS); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 75 | + private void validateIndicatorCodeUnique(Long id, String code) { | |
| 76 | + MesQcIndicatorDO indicator = indicatorMapper.selectByCode(code); | |
| 77 | + if (indicator == null) { | |
| 78 | + return; | |
| 79 | + } | |
| 80 | + if (ObjUtil.notEqual(indicator.getId(), id)) { | |
| 81 | + throw exception(QC_INDICATOR_CODE_DUPLICATE); | |
| 82 | + } | |
| 83 | + } | |
| 84 | + | |
| 85 | + private void validateIndicatorNameUnique(Long id, String name) { | |
| 86 | + MesQcIndicatorDO indicator = indicatorMapper.selectByName(name); | |
| 87 | + if (indicator == null) { | |
| 88 | + return; | |
| 89 | + } | |
| 90 | + if (ObjUtil.notEqual(indicator.getId(), id)) { | |
| 91 | + throw exception(QC_INDICATOR_NAME_DUPLICATE); | |
| 92 | + } | |
| 93 | + } | |
| 94 | + | |
| 95 | + @Override | |
| 96 | + public MesQcIndicatorDO getIndicator(Long id) { | |
| 97 | + return indicatorMapper.selectById(id); | |
| 98 | + } | |
| 99 | + | |
| 100 | + @Override | |
| 101 | + public PageResult<MesQcIndicatorDO> getIndicatorPage(MesQcIndicatorPageReqVO pageReqVO) { | |
| 102 | + return indicatorMapper.selectPage(pageReqVO); | |
| 103 | + } | |
| 104 | + | |
| 105 | + @Override | |
| 106 | + public List<MesQcIndicatorDO> getIndicatorList() { | |
| 107 | + return indicatorMapper.selectList(); | |
| 108 | + } | |
| 109 | + | |
| 110 | + @Override | |
| 111 | + public List<MesQcIndicatorDO> getIndicatorList(Collection<Long> ids) { | |
| 112 | + if (CollUtil.isEmpty(ids)) { | |
| 113 | + return Collections.emptyList(); | |
| 114 | + } | |
| 115 | + return indicatorMapper.selectByIds(ids); | |
| 116 | + } | |
| 117 | + | |
| 118 | +} | ... | ... |