Commit 9b22a9cf4d17fd403f5c87e4b719ff9f9068b26f
1 parent
ff1d20f4
feat(mes): 新增 MES 点检保养项目相关功能,包括请求和响应 VO、Controller 及 API 接口
Showing
11 changed files
with
495 additions
and
0 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/subject/MesDvSubjectController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.subject; | |
| 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.dv.subject.vo.MesDvSubjectPageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.subject.vo.MesDvSubjectRespVO; | |
| 11 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.subject.vo.MesDvSubjectSaveReqVO; | |
| 12 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO; | |
| 13 | +import cn.iocoder.yudao.module.mes.service.dv.subject.MesDvSubjectService; | |
| 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/dv/subject") | |
| 33 | +@Validated | |
| 34 | +public class MesDvSubjectController { | |
| 35 | + | |
| 36 | + @Resource | |
| 37 | + private MesDvSubjectService subjectService; | |
| 38 | + | |
| 39 | + @PostMapping("/create") | |
| 40 | + @Operation(summary = "创建点检保养项目") | |
| 41 | + @PreAuthorize("@ss.hasPermission('mes:dv-subject:create')") | |
| 42 | + public CommonResult<Long> createSubject(@Valid @RequestBody MesDvSubjectSaveReqVO createReqVO) { | |
| 43 | + return success(subjectService.createSubject(createReqVO)); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @PutMapping("/update") | |
| 47 | + @Operation(summary = "更新点检保养项目") | |
| 48 | + @PreAuthorize("@ss.hasPermission('mes:dv-subject:update')") | |
| 49 | + public CommonResult<Boolean> updateSubject(@Valid @RequestBody MesDvSubjectSaveReqVO updateReqVO) { | |
| 50 | + subjectService.updateSubject(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:dv-subject:delete')") | |
| 58 | + public CommonResult<Boolean> deleteSubject(@RequestParam("id") Long id) { | |
| 59 | + subjectService.deleteSubject(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:dv-subject:query')") | |
| 67 | + public CommonResult<MesDvSubjectRespVO> getSubject(@RequestParam("id") Long id) { | |
| 68 | + MesDvSubjectDO subject = subjectService.getSubject(id); | |
| 69 | + return success(BeanUtils.toBean(subject, MesDvSubjectRespVO.class)); | |
| 70 | + } | |
| 71 | + | |
| 72 | + @GetMapping("/page") | |
| 73 | + @Operation(summary = "获得点检保养项目分页") | |
| 74 | + @PreAuthorize("@ss.hasPermission('mes:dv-subject:query')") | |
| 75 | + public CommonResult<PageResult<MesDvSubjectRespVO>> getSubjectPage(@Valid MesDvSubjectPageReqVO pageReqVO) { | |
| 76 | + PageResult<MesDvSubjectDO> pageResult = subjectService.getSubjectPage(pageReqVO); | |
| 77 | + return success(BeanUtils.toBean(pageResult, MesDvSubjectRespVO.class)); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @GetMapping("/export-excel") | |
| 81 | + @Operation(summary = "导出点检保养项目 Excel") | |
| 82 | + @PreAuthorize("@ss.hasPermission('mes:dv-subject:export')") | |
| 83 | + @ApiAccessLog(operateType = EXPORT) | |
| 84 | + public void exportSubjectExcel(@Valid MesDvSubjectPageReqVO pageReqVO, | |
| 85 | + HttpServletResponse response) throws IOException { | |
| 86 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 87 | + List<MesDvSubjectDO> list = subjectService.getSubjectPage(pageReqVO).getList(); | |
| 88 | + // 导出 Excel | |
| 89 | + ExcelUtils.write(response, "点检保养项目.xls", "数据", MesDvSubjectRespVO.class, | |
| 90 | + BeanUtils.toBean(list, MesDvSubjectRespVO.class)); | |
| 91 | + } | |
| 92 | + | |
| 93 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/subject/vo/MesDvSubjectPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.subject.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 MesDvSubjectPageReqVO extends PageParam { | |
| 14 | + | |
| 15 | + @Schema(description = "项目编码", example = "CHK001") | |
| 16 | + private String code; | |
| 17 | + | |
| 18 | + @Schema(description = "项目名称", example = "注塑机外观检查") | |
| 19 | + private String name; | |
| 20 | + | |
| 21 | + @Schema(description = "项目类型", example = "1") | |
| 22 | + private Integer type; | |
| 23 | + | |
| 24 | + @Schema(description = "状态", example = "0") | |
| 25 | + private Integer status; | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/subject/vo/MesDvSubjectRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.subject.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 MesDvSubjectRespVO { | |
| 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 = "CHK001") | |
| 23 | + @ExcelProperty("项目编码") | |
| 24 | + private String code; | |
| 25 | + | |
| 26 | + @Schema(description = "项目名称", example = "注塑机外观检查") | |
| 27 | + @ExcelProperty("项目名称") | |
| 28 | + private String name; | |
| 29 | + | |
| 30 | + @Schema(description = "项目类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 31 | + @ExcelProperty(value = "项目类型", converter = DictConvert.class) | |
| 32 | + @DictFormat(DictTypeConstants.MES_DV_SUBJECT_TYPE) | |
| 33 | + private Integer type; | |
| 34 | + | |
| 35 | + @Schema(description = "项目内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "检查注塑机外壳是否有裂纹") | |
| 36 | + @ExcelProperty("项目内容") | |
| 37 | + private String content; | |
| 38 | + | |
| 39 | + @Schema(description = "标准", example = "外观完好,无明显损伤") | |
| 40 | + @ExcelProperty("标准") | |
| 41 | + private String standard; | |
| 42 | + | |
| 43 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 44 | + @ExcelProperty(value = "状态", converter = DictConvert.class) | |
| 45 | + @DictFormat("common_status") | |
| 46 | + private Integer status; | |
| 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/dv/subject/vo/MesDvSubjectSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.subject.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 | +@Schema(description = "管理后台 - MES 点检保养项目新增/修改 Request VO") | |
| 9 | +@Data | |
| 10 | +public class MesDvSubjectSaveReqVO { | |
| 11 | + | |
| 12 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 13 | + private Long id; | |
| 14 | + | |
| 15 | + @Schema(description = "项目编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "CHK001") | |
| 16 | + @NotEmpty(message = "项目编码不能为空") | |
| 17 | + private String code; | |
| 18 | + | |
| 19 | + @Schema(description = "项目名称", example = "注塑机外观检查") | |
| 20 | + private String name; | |
| 21 | + | |
| 22 | + @Schema(description = "项目类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 23 | + @NotNull(message = "项目类型不能为空") | |
| 24 | + private Integer type; | |
| 25 | + | |
| 26 | + @Schema(description = "项目内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "检查注塑机外壳是否有裂纹") | |
| 27 | + @NotEmpty(message = "项目内容不能为空") | |
| 28 | + private String content; | |
| 29 | + | |
| 30 | + @Schema(description = "标准", example = "外观完好,无明显损伤") | |
| 31 | + private String standard; | |
| 32 | + | |
| 33 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 34 | + @NotNull(message = "状态不能为空") | |
| 35 | + private Integer status; | |
| 36 | + | |
| 37 | + @Schema(description = "备注", example = "备注") | |
| 38 | + private String remark; | |
| 39 | + | |
| 40 | + @Schema(description = "预留字段1") | |
| 41 | + private String attribute1; | |
| 42 | + | |
| 43 | + @Schema(description = "预留字段2") | |
| 44 | + private String attribute2; | |
| 45 | + | |
| 46 | + @Schema(description = "预留字段3") | |
| 47 | + private Integer attribute3; | |
| 48 | + | |
| 49 | + @Schema(description = "预留字段4") | |
| 50 | + private Integer attribute4; | |
| 51 | + | |
| 52 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/subject/MesDvSubjectDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject; | |
| 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_dv_subject") | |
| 15 | +@KeySequence("mes_dv_subject_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 MesDvSubjectDO 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 | + /** | |
| 38 | + * 项目类型 | |
| 39 | + * | |
| 40 | + * 字典类型 mes_dv_subject_type | |
| 41 | + */ | |
| 42 | + private Integer type; | |
| 43 | + /** | |
| 44 | + * 项目内容 | |
| 45 | + */ | |
| 46 | + private String content; | |
| 47 | + /** | |
| 48 | + * 标准 | |
| 49 | + */ | |
| 50 | + private String standard; | |
| 51 | + /** | |
| 52 | + * 状态 | |
| 53 | + * | |
| 54 | + * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} | |
| 55 | + */ | |
| 56 | + private Integer status; | |
| 57 | + /** | |
| 58 | + * 备注 | |
| 59 | + */ | |
| 60 | + private String remark; | |
| 61 | + /** | |
| 62 | + * 预留字段1 | |
| 63 | + */ | |
| 64 | + private String attribute1; | |
| 65 | + /** | |
| 66 | + * 预留字段2 | |
| 67 | + */ | |
| 68 | + private String attribute2; | |
| 69 | + /** | |
| 70 | + * 预留字段3 | |
| 71 | + */ | |
| 72 | + private Integer attribute3; | |
| 73 | + /** | |
| 74 | + * 预留字段4 | |
| 75 | + */ | |
| 76 | + private Integer attribute4; | |
| 77 | + | |
| 78 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/subject/MesDvSubjectMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.dv.subject; | |
| 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.dv.subject.vo.MesDvSubjectPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +@Mapper | |
| 11 | +public interface MesDvSubjectMapper extends BaseMapperX<MesDvSubjectDO> { | |
| 12 | + | |
| 13 | + default PageResult<MesDvSubjectDO> selectPage(MesDvSubjectPageReqVO reqVO) { | |
| 14 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesDvSubjectDO>() | |
| 15 | + .likeIfPresent(MesDvSubjectDO::getCode, reqVO.getCode()) | |
| 16 | + .likeIfPresent(MesDvSubjectDO::getName, reqVO.getName()) | |
| 17 | + .eqIfPresent(MesDvSubjectDO::getType, reqVO.getType()) | |
| 18 | + .eqIfPresent(MesDvSubjectDO::getStatus, reqVO.getStatus()) | |
| 19 | + .orderByDesc(MesDvSubjectDO::getId)); | |
| 20 | + } | |
| 21 | + | |
| 22 | + default MesDvSubjectDO selectByCode(String code) { | |
| 23 | + return selectOne(MesDvSubjectDO::getCode, code); | |
| 24 | + } | |
| 25 | + | |
| 26 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/subject/MesDvSubjectService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.dv.subject; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.subject.vo.MesDvSubjectPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.subject.vo.MesDvSubjectSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO; | |
| 7 | +import jakarta.validation.Valid; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * MES 点检保养项目 Service 接口 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +public interface MesDvSubjectService { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 创建点检保养项目 | |
| 18 | + * | |
| 19 | + * @param createReqVO 创建信息 | |
| 20 | + * @return 编号 | |
| 21 | + */ | |
| 22 | + Long createSubject(@Valid MesDvSubjectSaveReqVO createReqVO); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 更新点检保养项目 | |
| 26 | + * | |
| 27 | + * @param updateReqVO 更新信息 | |
| 28 | + */ | |
| 29 | + void updateSubject(@Valid MesDvSubjectSaveReqVO updateReqVO); | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * 删除点检保养项目 | |
| 33 | + * | |
| 34 | + * @param id 编号 | |
| 35 | + */ | |
| 36 | + void deleteSubject(Long id); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 获得点检保养项目 | |
| 40 | + * | |
| 41 | + * @param id 编号 | |
| 42 | + * @return 点检保养项目 | |
| 43 | + */ | |
| 44 | + MesDvSubjectDO getSubject(Long id); | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * 获得点检保养项目分页 | |
| 48 | + * | |
| 49 | + * @param pageReqVO 分页查询 | |
| 50 | + * @return 点检保养项目分页 | |
| 51 | + */ | |
| 52 | + PageResult<MesDvSubjectDO> getSubjectPage(MesDvSubjectPageReqVO pageReqVO); | |
| 53 | + | |
| 54 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/subject/MesDvSubjectServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.dv.subject; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.ObjUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.subject.vo.MesDvSubjectPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.subject.vo.MesDvSubjectSaveReqVO; | |
| 8 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO; | |
| 9 | +import cn.iocoder.yudao.module.mes.dal.mysql.dv.subject.MesDvSubjectMapper; | |
| 10 | +import jakarta.annotation.Resource; | |
| 11 | +import org.springframework.stereotype.Service; | |
| 12 | +import org.springframework.validation.annotation.Validated; | |
| 13 | + | |
| 14 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 15 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | |
| 16 | + | |
| 17 | +/** | |
| 18 | + * MES 点检保养项目 Service 实现类 | |
| 19 | + * | |
| 20 | + * @author 芋道源码 | |
| 21 | + */ | |
| 22 | +@Service | |
| 23 | +@Validated | |
| 24 | +public class MesDvSubjectServiceImpl implements MesDvSubjectService { | |
| 25 | + | |
| 26 | + @Resource | |
| 27 | + private MesDvSubjectMapper subjectMapper; | |
| 28 | + | |
| 29 | + @Override | |
| 30 | + public Long createSubject(MesDvSubjectSaveReqVO createReqVO) { | |
| 31 | + // 校验编码唯一 | |
| 32 | + validateSubjectCodeUnique(null, createReqVO.getCode()); | |
| 33 | + | |
| 34 | + // 插入 | |
| 35 | + MesDvSubjectDO subject = BeanUtils.toBean(createReqVO, MesDvSubjectDO.class); | |
| 36 | + subjectMapper.insert(subject); | |
| 37 | + return subject.getId(); | |
| 38 | + } | |
| 39 | + | |
| 40 | + @Override | |
| 41 | + public void updateSubject(MesDvSubjectSaveReqVO updateReqVO) { | |
| 42 | + // 校验存在 | |
| 43 | + validateSubjectExists(updateReqVO.getId()); | |
| 44 | + // 校验编码唯一 | |
| 45 | + validateSubjectCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | |
| 46 | + | |
| 47 | + // 更新 | |
| 48 | + MesDvSubjectDO updateObj = BeanUtils.toBean(updateReqVO, MesDvSubjectDO.class); | |
| 49 | + subjectMapper.updateById(updateObj); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public void deleteSubject(Long id) { | |
| 54 | + // 校验存在 | |
| 55 | + validateSubjectExists(id); | |
| 56 | + // 删除 | |
| 57 | + subjectMapper.deleteById(id); | |
| 58 | + } | |
| 59 | + | |
| 60 | + private void validateSubjectExists(Long id) { | |
| 61 | + if (subjectMapper.selectById(id) == null) { | |
| 62 | + throw exception(DV_SUBJECT_NOT_EXISTS); | |
| 63 | + } | |
| 64 | + } | |
| 65 | + | |
| 66 | + private void validateSubjectCodeUnique(Long id, String code) { | |
| 67 | + if (code == null) { | |
| 68 | + return; | |
| 69 | + } | |
| 70 | + MesDvSubjectDO subject = subjectMapper.selectByCode(code); | |
| 71 | + if (subject == null) { | |
| 72 | + return; | |
| 73 | + } | |
| 74 | + if (ObjUtil.notEqual(subject.getId(), id)) { | |
| 75 | + throw exception(DV_SUBJECT_CODE_DUPLICATE); | |
| 76 | + } | |
| 77 | + } | |
| 78 | + | |
| 79 | + @Override | |
| 80 | + public MesDvSubjectDO getSubject(Long id) { | |
| 81 | + return subjectMapper.selectById(id); | |
| 82 | + } | |
| 83 | + | |
| 84 | + @Override | |
| 85 | + public PageResult<MesDvSubjectDO> getSubjectPage(MesDvSubjectPageReqVO pageReqVO) { | |
| 86 | + return subjectMapper.selectPage(pageReqVO); | |
| 87 | + } | |
| 88 | + | |
| 89 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseAreaServiceImpl.java
| ... | ... | @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.mes.dal.mysql.wm.warehouse.MesWmWarehouseAreaMapp |
| 11 | 11 | import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; |
| 12 | 12 | import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService; |
| 13 | 13 | import jakarta.annotation.Resource; |
| 14 | +import org.springframework.context.annotation.Lazy; | |
| 14 | 15 | import org.springframework.stereotype.Service; |
| 15 | 16 | import org.springframework.validation.annotation.Validated; |
| 16 | 17 | |
| ... | ... | @@ -32,10 +33,12 @@ public class MesWmWarehouseAreaServiceImpl implements MesWmWarehouseAreaService |
| 32 | 33 | private MesWmWarehouseAreaMapper areaMapper; |
| 33 | 34 | |
| 34 | 35 | @Resource |
| 36 | + @Lazy | |
| 35 | 37 | private MesMdWorkstationService workstationService; |
| 36 | 38 | @Resource |
| 37 | 39 | private MesWmMaterialStockService materialStockService; |
| 38 | 40 | @Resource |
| 41 | + @Lazy | |
| 39 | 42 | private MesWmWarehouseLocationService locationService; |
| 40 | 43 | |
| 41 | 44 | @Override | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseLocationServiceImpl.java
| ... | ... | @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.mes.dal.mysql.wm.warehouse.MesWmWarehouseLocation |
| 11 | 11 | import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; |
| 12 | 12 | import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService; |
| 13 | 13 | import jakarta.annotation.Resource; |
| 14 | +import org.springframework.context.annotation.Lazy; | |
| 14 | 15 | import org.springframework.stereotype.Service; |
| 15 | 16 | import org.springframework.validation.annotation.Validated; |
| 16 | 17 | |
| ... | ... | @@ -34,10 +35,12 @@ public class MesWmWarehouseLocationServiceImpl implements MesWmWarehouseLocation |
| 34 | 35 | @Resource |
| 35 | 36 | private MesWmWarehouseAreaService areaService; |
| 36 | 37 | @Resource |
| 38 | + @Lazy | |
| 37 | 39 | private MesMdWorkstationService workstationService; |
| 38 | 40 | @Resource |
| 39 | 41 | private MesWmMaterialStockService materialStockService; |
| 40 | 42 | @Resource |
| 43 | + @Lazy | |
| 41 | 44 | private MesWmWarehouseService warehouseService; |
| 42 | 45 | |
| 43 | 46 | @Override | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/wm/warehouse/MesWmWarehouseServiceImpl.java
| ... | ... | @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.mes.dal.mysql.wm.warehouse.MesWmWarehouseMapper; |
| 11 | 11 | import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; |
| 12 | 12 | import cn.iocoder.yudao.module.mes.service.wm.materialstock.MesWmMaterialStockService; |
| 13 | 13 | import jakarta.annotation.Resource; |
| 14 | +import org.springframework.context.annotation.Lazy; | |
| 14 | 15 | import org.springframework.stereotype.Service; |
| 15 | 16 | import org.springframework.validation.annotation.Validated; |
| 16 | 17 | |
| ... | ... | @@ -34,6 +35,7 @@ public class MesWmWarehouseServiceImpl implements MesWmWarehouseService { |
| 34 | 35 | @Resource |
| 35 | 36 | private MesWmWarehouseLocationService locationService; |
| 36 | 37 | @Resource |
| 38 | + @Lazy | |
| 37 | 39 | private MesMdWorkstationService workstationService; |
| 38 | 40 | @Resource |
| 39 | 41 | private MesWmMaterialStockService materialStockService; | ... | ... |