Commit 6ddbb29422b14e4c4e838e936cfc23676b0cc9ed
1 parent
e48245ef
review(mes):pro-process 的初步实现 50%
Showing
14 changed files
with
746 additions
and
1 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/MesProProcessContentController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.process; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.content.MesProProcessContentRespVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.content.MesProProcessContentSaveReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.MesProProcessContentDO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.service.pro.MesProProcessContentService; | ||
| 9 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 10 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 11 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 12 | +import jakarta.annotation.Resource; | ||
| 13 | +import jakarta.validation.Valid; | ||
| 14 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 15 | +import org.springframework.validation.annotation.Validated; | ||
| 16 | +import org.springframework.web.bind.annotation.*; | ||
| 17 | + | ||
| 18 | +import java.util.List; | ||
| 19 | + | ||
| 20 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 21 | + | ||
| 22 | +@Tag(name = "管理后台 - MES 生产工序内容") | ||
| 23 | +@RestController | ||
| 24 | +@RequestMapping("/mes/pro/process-content") | ||
| 25 | +@Validated | ||
| 26 | +public class MesProProcessContentController { | ||
| 27 | + | ||
| 28 | + @Resource | ||
| 29 | + private MesProProcessContentService processContentService; | ||
| 30 | + | ||
| 31 | + @PostMapping("/create") | ||
| 32 | + @Operation(summary = "创建生产工序内容") | ||
| 33 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:update')") | ||
| 34 | + public CommonResult<Long> createProcessContent(@Valid @RequestBody MesProProcessContentSaveReqVO createReqVO) { | ||
| 35 | + return success(processContentService.createProcessContent(createReqVO)); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @PutMapping("/update") | ||
| 39 | + @Operation(summary = "更新生产工序内容") | ||
| 40 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:update')") | ||
| 41 | + public CommonResult<Boolean> updateProcessContent(@Valid @RequestBody MesProProcessContentSaveReqVO updateReqVO) { | ||
| 42 | + processContentService.updateProcessContent(updateReqVO); | ||
| 43 | + return success(true); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @DeleteMapping("/delete") | ||
| 47 | + @Operation(summary = "删除生产工序内容") | ||
| 48 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 49 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:update')") | ||
| 50 | + public CommonResult<Boolean> deleteProcessContent(@RequestParam("id") Long id) { | ||
| 51 | + processContentService.deleteProcessContent(id); | ||
| 52 | + return success(true); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @GetMapping("/get") | ||
| 56 | + @Operation(summary = "获得生产工序内容") | ||
| 57 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 58 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:query')") | ||
| 59 | + public CommonResult<MesProProcessContentRespVO> getProcessContent(@RequestParam("id") Long id) { | ||
| 60 | + MesProProcessContentDO content = processContentService.getProcessContent(id); | ||
| 61 | + return success(BeanUtils.toBean(content, MesProProcessContentRespVO.class)); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @GetMapping("/list-by-process") | ||
| 65 | + @Operation(summary = "获得生产工序内容列表(按工序编号)") | ||
| 66 | + @Parameter(name = "processId", description = "工序编号", required = true, example = "1024") | ||
| 67 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:query')") | ||
| 68 | + public CommonResult<List<MesProProcessContentRespVO>> getProcessContentListByProcessId(@RequestParam("processId") Long processId) { | ||
| 69 | + List<MesProProcessContentDO> list = processContentService.getProcessContentListByProcessId(processId); | ||
| 70 | + return success(BeanUtils.toBean(list, MesProProcessContentRespVO.class)); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/MesProProcessController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.process; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; | ||
| 4 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 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.pro.process.vo.MesProProcessPageReqVO; | ||
| 11 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessRespVO; | ||
| 12 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessSaveReqVO; | ||
| 13 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.MesProProcessDO; | ||
| 14 | +import cn.iocoder.yudao.module.mes.service.pro.MesProProcessService; | ||
| 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.servlet.http.HttpServletResponse; | ||
| 20 | +import jakarta.validation.Valid; | ||
| 21 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 22 | +import org.springframework.validation.annotation.Validated; | ||
| 23 | +import org.springframework.web.bind.annotation.*; | ||
| 24 | + | ||
| 25 | +import java.io.IOException; | ||
| 26 | +import java.util.List; | ||
| 27 | + | ||
| 28 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | ||
| 29 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 31 | + | ||
| 32 | +@Tag(name = "管理后台 - MES 生产工序") | ||
| 33 | +@RestController | ||
| 34 | +@RequestMapping("/mes/pro/process") | ||
| 35 | +@Validated | ||
| 36 | +public class MesProProcessController { | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private MesProProcessService processService; | ||
| 40 | + | ||
| 41 | + @PostMapping("/create") | ||
| 42 | + @Operation(summary = "创建生产工序") | ||
| 43 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:create')") | ||
| 44 | + public CommonResult<Long> createProcess(@Valid @RequestBody MesProProcessSaveReqVO createReqVO) { | ||
| 45 | + return success(processService.createProcess(createReqVO)); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @PutMapping("/update") | ||
| 49 | + @Operation(summary = "更新生产工序") | ||
| 50 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:update')") | ||
| 51 | + public CommonResult<Boolean> updateProcess(@Valid @RequestBody MesProProcessSaveReqVO updateReqVO) { | ||
| 52 | + processService.updateProcess(updateReqVO); | ||
| 53 | + return success(true); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @DeleteMapping("/delete") | ||
| 57 | + @Operation(summary = "删除生产工序") | ||
| 58 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 59 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:delete')") | ||
| 60 | + public CommonResult<Boolean> deleteProcess(@RequestParam("id") Long id) { | ||
| 61 | + processService.deleteProcess(id); | ||
| 62 | + return success(true); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @GetMapping("/get") | ||
| 66 | + @Operation(summary = "获得生产工序") | ||
| 67 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 68 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:query')") | ||
| 69 | + public CommonResult<MesProProcessRespVO> getProcess(@RequestParam("id") Long id) { | ||
| 70 | + MesProProcessDO process = processService.getProcess(id); | ||
| 71 | + return success(BeanUtils.toBean(process, MesProProcessRespVO.class)); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @GetMapping("/page") | ||
| 75 | + @Operation(summary = "获得生产工序分页") | ||
| 76 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:query')") | ||
| 77 | + public CommonResult<PageResult<MesProProcessRespVO>> getProcessPage(@Valid MesProProcessPageReqVO pageReqVO) { | ||
| 78 | + PageResult<MesProProcessDO> pageResult = processService.getProcessPage(pageReqVO); | ||
| 79 | + return success(BeanUtils.toBean(pageResult, MesProProcessRespVO.class)); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @GetMapping("/simple-list") | ||
| 83 | + @Operation(summary = "获得生产工序精简列表", description = "只包含被开启的工序,主要用于前端的下拉选项") | ||
| 84 | + public CommonResult<List<MesProProcessRespVO>> getProcessSimpleList() { | ||
| 85 | + List<MesProProcessDO> list = processService.getProcessListByStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 86 | + return success(convertList(list, process -> new MesProProcessRespVO() | ||
| 87 | + .setId(process.getId()).setName(process.getName()).setCode(process.getCode()))); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + @GetMapping("/export-excel") | ||
| 91 | + @Operation(summary = "导出生产工序 Excel") | ||
| 92 | + @PreAuthorize("@ss.hasPermission('mes:pro-process:export')") | ||
| 93 | + @ApiAccessLog(operateType = EXPORT) | ||
| 94 | + public void exportProcessExcel(@Valid MesProProcessPageReqVO pageReqVO, | ||
| 95 | + HttpServletResponse response) throws IOException { | ||
| 96 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 97 | + List<MesProProcessDO> list = processService.getProcessPage(pageReqVO).getList(); | ||
| 98 | + List<MesProProcessRespVO> data = BeanUtils.toBean(list, MesProProcessRespVO.class); | ||
| 99 | + ExcelUtils.write(response, "生产工序.xls", "数据", MesProProcessRespVO.class, data); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/vo/process/MesProProcessPageReqVO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/vo/MesProProcessPageReqVO.java
| 1 | -package cn.iocoder.yudao.module.mes.controller.admin.pro.vo.process; | 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/vo/MesProProcessRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - MES 生产工序 Response VO") | ||
| 9 | +@Data | ||
| 10 | +public class MesProProcessRespVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "工序编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "PROCESS001") | ||
| 16 | + private String code; | ||
| 17 | + | ||
| 18 | + @Schema(description = "工序名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "下料工序") | ||
| 19 | + private String name; | ||
| 20 | + | ||
| 21 | + @Schema(description = "工艺要求", example = "按照图纸尺寸进行切割") | ||
| 22 | + private String attention; | ||
| 23 | + | ||
| 24 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 25 | + private Integer status; | ||
| 26 | + | ||
| 27 | + @Schema(description = "备注", example = "金属板材下料") | ||
| 28 | + private String remark; | ||
| 29 | + | ||
| 30 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 31 | + private LocalDateTime createTime; | ||
| 32 | + | ||
| 33 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/vo/MesProProcessSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotBlank; | ||
| 5 | +import jakarta.validation.constraints.NotNull; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - MES 生产工序新增/修改 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class MesProProcessSaveReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "编号", example = "1") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "工序编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "PROCESS001") | ||
| 16 | + @NotBlank(message = "工序编码不能为空") | ||
| 17 | + private String code; | ||
| 18 | + | ||
| 19 | + @Schema(description = "工序名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "下料工序") | ||
| 20 | + @NotBlank(message = "工序名称不能为空") | ||
| 21 | + private String name; | ||
| 22 | + | ||
| 23 | + @Schema(description = "工艺要求", example = "按照图纸尺寸进行切割") | ||
| 24 | + private String attention; | ||
| 25 | + | ||
| 26 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | ||
| 27 | + @NotNull(message = "状态不能为空") | ||
| 28 | + private Integer status; | ||
| 29 | + | ||
| 30 | + @Schema(description = "备注", example = "金属板材下料") | ||
| 31 | + private String remark; | ||
| 32 | + | ||
| 33 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/vo/content/MesProProcessContentPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.content; | ||
| 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 MesProProcessContentPageReqVO extends PageParam { | ||
| 15 | + | ||
| 16 | + @Schema(description = "工序编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | ||
| 17 | + @NotNull(message = "工序编号不能为空") | ||
| 18 | + private Long processId; | ||
| 19 | + | ||
| 20 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/vo/content/MesProProcessContentRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.content; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - MES 生产工序内容 Response VO") | ||
| 9 | +@Data | ||
| 10 | +public class MesProProcessContentRespVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "工序编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 16 | + private Long processId; | ||
| 17 | + | ||
| 18 | + @Schema(description = "顺序编号", example = "1") | ||
| 19 | + private Integer sort; | ||
| 20 | + | ||
| 21 | + @Schema(description = "步骤说明", example = "检查焊接设备是否正常") | ||
| 22 | + private String content; | ||
| 23 | + | ||
| 24 | + @Schema(description = "辅助设备", example = "氩弧焊机") | ||
| 25 | + private String device; | ||
| 26 | + | ||
| 27 | + @Schema(description = "辅助材料", example = "焊丝 ER308") | ||
| 28 | + private String material; | ||
| 29 | + | ||
| 30 | + @Schema(description = "材料文档 URL", example = "https://example.com/doc.pdf") | ||
| 31 | + private String docUrl; | ||
| 32 | + | ||
| 33 | + @Schema(description = "备注", example = "注意安全") | ||
| 34 | + private String remark; | ||
| 35 | + | ||
| 36 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 37 | + private LocalDateTime createTime; | ||
| 38 | + | ||
| 39 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/process/vo/content/MesProProcessContentSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.content; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotNull; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - MES 生产工序内容新增/修改 Request VO") | ||
| 8 | +@Data | ||
| 9 | +public class MesProProcessContentSaveReqVO { | ||
| 10 | + | ||
| 11 | + @Schema(description = "编号", example = "1") | ||
| 12 | + private Long id; | ||
| 13 | + | ||
| 14 | + @Schema(description = "工序编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 15 | + @NotNull(message = "工序编号不能为空") | ||
| 16 | + private Long processId; | ||
| 17 | + | ||
| 18 | + @Schema(description = "顺序编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 19 | + @NotNull(message = "顺序编号不能为空") | ||
| 20 | + private Integer sort; | ||
| 21 | + | ||
| 22 | + @Schema(description = "步骤说明", example = "检查焊接设备是否正常") | ||
| 23 | + private String content; | ||
| 24 | + | ||
| 25 | + @Schema(description = "辅助设备", example = "氩弧焊机") | ||
| 26 | + private String device; | ||
| 27 | + | ||
| 28 | + @Schema(description = "辅助材料", example = "焊丝 ER308") | ||
| 29 | + private String material; | ||
| 30 | + | ||
| 31 | + @Schema(description = "材料文档 URL", example = "https://example.com/doc.pdf") | ||
| 32 | + private String docUrl; | ||
| 33 | + | ||
| 34 | + @Schema(description = "备注", example = "注意安全") | ||
| 35 | + private String remark; | ||
| 36 | + | ||
| 37 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/MesProProcessContentMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.pro; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.MesProProcessContentDO; | ||
| 6 | +import org.apache.ibatis.annotations.Mapper; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * MES 生产工序内容 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface MesProProcessContentMapper extends BaseMapperX<MesProProcessContentDO> { | ||
| 17 | + | ||
| 18 | + default List<MesProProcessContentDO> selectListByProcessId(Long processId) { | ||
| 19 | + return selectList(new LambdaQueryWrapperX<MesProProcessContentDO>() | ||
| 20 | + .eq(MesProProcessContentDO::getProcessId, processId) | ||
| 21 | + .orderByAsc(MesProProcessContentDO::getSort)); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + default void deleteByProcessId(Long processId) { | ||
| 25 | + delete(new LambdaQueryWrapperX<MesProProcessContentDO>() | ||
| 26 | + .eq(MesProProcessContentDO::getProcessId, processId)); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/MesProProcessMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.pro; | ||
| 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.pro.process.vo.MesProProcessPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.MesProProcessDO; | ||
| 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 MesProProcessMapper extends BaseMapperX<MesProProcessDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<MesProProcessDO> selectPage(MesProProcessPageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesProProcessDO>() | ||
| 22 | + .likeIfPresent(MesProProcessDO::getCode, reqVO.getCode()) | ||
| 23 | + .likeIfPresent(MesProProcessDO::getName, reqVO.getName()) | ||
| 24 | + .eqIfPresent(MesProProcessDO::getStatus, reqVO.getStatus()) | ||
| 25 | + .betweenIfPresent(MesProProcessDO::getCreateTime, reqVO.getCreateTime()) | ||
| 26 | + .orderByDesc(MesProProcessDO::getId)); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + default List<MesProProcessDO> selectList(MesProProcessPageReqVO reqVO) { | ||
| 30 | + return selectList(new LambdaQueryWrapperX<MesProProcessDO>() | ||
| 31 | + .likeIfPresent(MesProProcessDO::getCode, reqVO.getCode()) | ||
| 32 | + .likeIfPresent(MesProProcessDO::getName, reqVO.getName()) | ||
| 33 | + .eqIfPresent(MesProProcessDO::getStatus, reqVO.getStatus()) | ||
| 34 | + .betweenIfPresent(MesProProcessDO::getCreateTime, reqVO.getCreateTime()) | ||
| 35 | + .orderByDesc(MesProProcessDO::getId)); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + default MesProProcessDO selectByCode(String code) { | ||
| 39 | + return selectOne(MesProProcessDO::getCode, code); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + default MesProProcessDO selectByName(String name) { | ||
| 43 | + return selectOne(MesProProcessDO::getName, name); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + default List<MesProProcessDO> selectListByStatus(Integer status) { | ||
| 47 | + return selectList(MesProProcessDO::getStatus, status); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/MesProProcessContentService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.pro; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.content.MesProProcessContentSaveReqVO; | ||
| 4 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.MesProProcessContentDO; | ||
| 5 | + | ||
| 6 | +import jakarta.validation.Valid; | ||
| 7 | +import java.util.List; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * MES 生产工序内容 Service 接口 | ||
| 11 | + * | ||
| 12 | + * @author 芋道源码 | ||
| 13 | + */ | ||
| 14 | +public interface MesProProcessContentService { | ||
| 15 | + | ||
| 16 | + /** | ||
| 17 | + * 创建生产工序内容 | ||
| 18 | + * | ||
| 19 | + * @param createReqVO 创建信息 | ||
| 20 | + * @return 编号 | ||
| 21 | + */ | ||
| 22 | + Long createProcessContent(@Valid MesProProcessContentSaveReqVO createReqVO); | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 更新生产工序内容 | ||
| 26 | + * | ||
| 27 | + * @param updateReqVO 更新信息 | ||
| 28 | + */ | ||
| 29 | + void updateProcessContent(@Valid MesProProcessContentSaveReqVO updateReqVO); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 删除生产工序内容 | ||
| 33 | + * | ||
| 34 | + * @param id 编号 | ||
| 35 | + */ | ||
| 36 | + void deleteProcessContent(Long id); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 获得生产工序内容 | ||
| 40 | + * | ||
| 41 | + * @param id 编号 | ||
| 42 | + * @return 生产工序内容 | ||
| 43 | + */ | ||
| 44 | + MesProProcessContentDO getProcessContent(Long id); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 获得生产工序内容列表(按工序编号) | ||
| 48 | + * | ||
| 49 | + * @param processId 工序编号 | ||
| 50 | + * @return 生产工序内容列表 | ||
| 51 | + */ | ||
| 52 | + List<MesProProcessContentDO> getProcessContentListByProcessId(Long processId); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 删除生产工序内容(按工序编号) | ||
| 56 | + * | ||
| 57 | + * @param processId 工序编号 | ||
| 58 | + */ | ||
| 59 | + void deleteProcessContentByProcessId(Long processId); | ||
| 60 | + | ||
| 61 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/MesProProcessContentServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.pro; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.content.MesProProcessContentSaveReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.MesProProcessContentDO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.dal.mysql.pro.MesProProcessContentMapper; | ||
| 7 | +import jakarta.annotation.Resource; | ||
| 8 | +import org.springframework.stereotype.Service; | ||
| 9 | +import org.springframework.validation.annotation.Validated; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 14 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_PROCESS_CONTENT_NOT_EXISTS; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * MES 生产工序内容 Service 实现类 | ||
| 18 | + * | ||
| 19 | + * @author 芋道源码 | ||
| 20 | + */ | ||
| 21 | +@Service | ||
| 22 | +@Validated | ||
| 23 | +public class MesProProcessContentServiceImpl implements MesProProcessContentService { | ||
| 24 | + | ||
| 25 | + @Resource | ||
| 26 | + private MesProProcessContentMapper processContentMapper; | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public Long createProcessContent(MesProProcessContentSaveReqVO createReqVO) { | ||
| 30 | + MesProProcessContentDO content = BeanUtils.toBean(createReqVO, MesProProcessContentDO.class); | ||
| 31 | + processContentMapper.insert(content); | ||
| 32 | + return content.getId(); | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public void updateProcessContent(MesProProcessContentSaveReqVO updateReqVO) { | ||
| 37 | + // 校验存在 | ||
| 38 | + validateProcessContentExists(updateReqVO.getId()); | ||
| 39 | + // 更新 | ||
| 40 | + MesProProcessContentDO updateObj = BeanUtils.toBean(updateReqVO, MesProProcessContentDO.class); | ||
| 41 | + processContentMapper.updateById(updateObj); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + public void deleteProcessContent(Long id) { | ||
| 46 | + // 校验存在 | ||
| 47 | + validateProcessContentExists(id); | ||
| 48 | + // 删除 | ||
| 49 | + processContentMapper.deleteById(id); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + private void validateProcessContentExists(Long id) { | ||
| 53 | + if (processContentMapper.selectById(id) == null) { | ||
| 54 | + throw exception(PRO_PROCESS_CONTENT_NOT_EXISTS); | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public MesProProcessContentDO getProcessContent(Long id) { | ||
| 60 | + return processContentMapper.selectById(id); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public List<MesProProcessContentDO> getProcessContentListByProcessId(Long processId) { | ||
| 65 | + return processContentMapper.selectListByProcessId(processId); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public void deleteProcessContentByProcessId(Long processId) { | ||
| 70 | + processContentMapper.deleteByProcessId(processId); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/MesProProcessService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.pro; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessSaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.MesProProcessDO; | ||
| 7 | + | ||
| 8 | +import jakarta.validation.Valid; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * MES 生产工序 Service 接口 | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +public interface MesProProcessService { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 创建生产工序 | ||
| 20 | + * | ||
| 21 | + * @param createReqVO 创建信息 | ||
| 22 | + * @return 编号 | ||
| 23 | + */ | ||
| 24 | + Long createProcess(@Valid MesProProcessSaveReqVO createReqVO); | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 更新生产工序 | ||
| 28 | + * | ||
| 29 | + * @param updateReqVO 更新信息 | ||
| 30 | + */ | ||
| 31 | + void updateProcess(@Valid MesProProcessSaveReqVO updateReqVO); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 删除生产工序 | ||
| 35 | + * | ||
| 36 | + * @param id 编号 | ||
| 37 | + */ | ||
| 38 | + void deleteProcess(Long id); | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 获得生产工序 | ||
| 42 | + * | ||
| 43 | + * @param id 编号 | ||
| 44 | + * @return 生产工序 | ||
| 45 | + */ | ||
| 46 | + MesProProcessDO getProcess(Long id); | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 获得生产工序列表 | ||
| 50 | + * | ||
| 51 | + * @param ids 编号列表 | ||
| 52 | + * @return 生产工序列表 | ||
| 53 | + */ | ||
| 54 | + List<MesProProcessDO> getProcessList(List<Long> ids); | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 获得生产工序分页 | ||
| 58 | + * | ||
| 59 | + * @param pageReqVO 分页查询 | ||
| 60 | + * @return 生产工序分页 | ||
| 61 | + */ | ||
| 62 | + PageResult<MesProProcessDO> getProcessPage(MesProProcessPageReqVO pageReqVO); | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * 获得指定状态的生产工序列表 | ||
| 66 | + * | ||
| 67 | + * @param status 状态 | ||
| 68 | + * @return 生产工序列表 | ||
| 69 | + */ | ||
| 70 | + List<MesProProcessDO> getProcessListByStatus(Integer status); | ||
| 71 | + | ||
| 72 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/MesProProcessServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.pro; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessPageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessSaveReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.MesProProcessDO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.dal.mysql.pro.MesProProcessMapper; | ||
| 9 | +import jakarta.annotation.Resource; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | +import org.springframework.transaction.annotation.Transactional; | ||
| 12 | +import org.springframework.validation.annotation.Validated; | ||
| 13 | + | ||
| 14 | +import java.util.List; | ||
| 15 | + | ||
| 16 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 17 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * MES 生产工序 Service 实现类 | ||
| 21 | + * | ||
| 22 | + * @author 芋道源码 | ||
| 23 | + */ | ||
| 24 | +@Service | ||
| 25 | +@Validated | ||
| 26 | +public class MesProProcessServiceImpl implements MesProProcessService { | ||
| 27 | + | ||
| 28 | + @Resource | ||
| 29 | + private MesProProcessMapper processMapper; | ||
| 30 | + | ||
| 31 | + @Resource | ||
| 32 | + private MesProProcessContentService processContentService; | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public Long createProcess(MesProProcessSaveReqVO createReqVO) { | ||
| 36 | + // 1. 校验工序编码唯一性 | ||
| 37 | + validateProcessCodeUnique(null, createReqVO.getCode()); | ||
| 38 | + // 2. 校验工序名称唯一性 | ||
| 39 | + validateProcessNameUnique(null, createReqVO.getName()); | ||
| 40 | + // 3. 插入工序 | ||
| 41 | + MesProProcessDO process = BeanUtils.toBean(createReqVO, MesProProcessDO.class); | ||
| 42 | + processMapper.insert(process); | ||
| 43 | + return process.getId(); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @Override | ||
| 47 | + public void updateProcess(MesProProcessSaveReqVO updateReqVO) { | ||
| 48 | + // 1. 校验存在 | ||
| 49 | + validateProcessExists(updateReqVO.getId()); | ||
| 50 | + // 2. 校验工序编码唯一性 | ||
| 51 | + validateProcessCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | ||
| 52 | + // 3. 校验工序名称唯一性 | ||
| 53 | + validateProcessNameUnique(updateReqVO.getId(), updateReqVO.getName()); | ||
| 54 | + // 4. 更新工序 | ||
| 55 | + MesProProcessDO updateObj = BeanUtils.toBean(updateReqVO, MesProProcessDO.class); | ||
| 56 | + processMapper.updateById(updateObj); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + @Transactional(rollbackFor = Exception.class) | ||
| 61 | + public void deleteProcess(Long id) { | ||
| 62 | + // 1. 校验存在 | ||
| 63 | + validateProcessExists(id); | ||
| 64 | + // TODO @芋艿:校验是否被工艺路线引用(pro_route_process 表实现后) | ||
| 65 | + // 2. 删除工序 | ||
| 66 | + processMapper.deleteById(id); | ||
| 67 | + // 3. 级联删除工序内容 | ||
| 68 | + processContentService.deleteProcessContentByProcessId(id); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + private void validateProcessExists(Long id) { | ||
| 72 | + if (processMapper.selectById(id) == null) { | ||
| 73 | + throw exception(PRO_PROCESS_NOT_EXISTS); | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + private void validateProcessCodeUnique(Long id, String code) { | ||
| 78 | + MesProProcessDO process = processMapper.selectByCode(code); | ||
| 79 | + if (process == null) { | ||
| 80 | + return; | ||
| 81 | + } | ||
| 82 | + if (id == null) { | ||
| 83 | + throw exception(PRO_PROCESS_CODE_EXISTS); | ||
| 84 | + } | ||
| 85 | + if (!process.getId().equals(id)) { | ||
| 86 | + throw exception(PRO_PROCESS_CODE_EXISTS); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + private void validateProcessNameUnique(Long id, String name) { | ||
| 91 | + MesProProcessDO process = processMapper.selectByName(name); | ||
| 92 | + if (process == null) { | ||
| 93 | + return; | ||
| 94 | + } | ||
| 95 | + if (id == null) { | ||
| 96 | + throw exception(PRO_PROCESS_NAME_EXISTS); | ||
| 97 | + } | ||
| 98 | + if (!process.getId().equals(id)) { | ||
| 99 | + throw exception(PRO_PROCESS_NAME_EXISTS); | ||
| 100 | + } | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + @Override | ||
| 104 | + public MesProProcessDO getProcess(Long id) { | ||
| 105 | + return processMapper.selectById(id); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + @Override | ||
| 109 | + public List<MesProProcessDO> getProcessList(List<Long> ids) { | ||
| 110 | + return processMapper.selectBatchIds(ids); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + @Override | ||
| 114 | + public PageResult<MesProProcessDO> getProcessPage(MesProProcessPageReqVO pageReqVO) { | ||
| 115 | + return processMapper.selectPage(pageReqVO); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + @Override | ||
| 119 | + public List<MesProProcessDO> getProcessListByStatus(Integer status) { | ||
| 120 | + return processMapper.selectListByStatus(status); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | +} |