Commit c093da8cad9a4fe47518e63a7a7880a10753ceb3
1 parent
bcad0a89
feat(mes): 添加生产任务相关的请求和响应 VO,重构生产任务控制器及服务接口
Showing
8 changed files
with
779 additions
and
0 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/MesProTaskController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.task; | |
| 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.pro.task.vo.MesProTaskPageReqVO; | |
| 11 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskRespVO; | |
| 12 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskSaveReqVO; | |
| 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.md.workstation.MesMdWorkstationDO; | |
| 17 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO; | |
| 18 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; | |
| 19 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; | |
| 20 | +import cn.iocoder.yudao.module.mes.service.md.client.MesMdClientService; | |
| 21 | +import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | |
| 22 | +import cn.iocoder.yudao.module.mes.service.md.unitmeasure.MesMdUnitMeasureService; | |
| 23 | +import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; | |
| 24 | +import cn.iocoder.yudao.module.mes.service.pro.process.MesProProcessService; | |
| 25 | +import cn.iocoder.yudao.module.mes.service.pro.task.MesProTaskService; | |
| 26 | +import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService; | |
| 27 | +import io.swagger.v3.oas.annotations.Operation; | |
| 28 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 29 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 30 | +import jakarta.annotation.Resource; | |
| 31 | +import jakarta.servlet.http.HttpServletResponse; | |
| 32 | +import jakarta.validation.Valid; | |
| 33 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 34 | +import org.springframework.validation.annotation.Validated; | |
| 35 | +import org.springframework.web.bind.annotation.*; | |
| 36 | + | |
| 37 | +import java.io.IOException; | |
| 38 | +import java.util.Collections; | |
| 39 | +import java.util.List; | |
| 40 | +import java.util.Map; | |
| 41 | + | |
| 42 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | |
| 43 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 44 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 45 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 46 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | |
| 47 | + | |
| 48 | +@Tag(name = "管理后台 - MES 生产任务") | |
| 49 | +@RestController | |
| 50 | +@RequestMapping("/mes/pro/task") | |
| 51 | +@Validated | |
| 52 | +public class MesProTaskController { | |
| 53 | + | |
| 54 | + @Resource | |
| 55 | + private MesProTaskService taskService; | |
| 56 | + | |
| 57 | + @Resource | |
| 58 | + private MesProWorkOrderService workOrderService; | |
| 59 | + | |
| 60 | + @Resource | |
| 61 | + private MesMdWorkstationService workstationService; | |
| 62 | + | |
| 63 | + @Resource | |
| 64 | + private MesProProcessService processService; | |
| 65 | + | |
| 66 | + @Resource | |
| 67 | + private MesMdItemService itemService; | |
| 68 | + | |
| 69 | + @Resource | |
| 70 | + private MesMdUnitMeasureService unitMeasureService; | |
| 71 | + | |
| 72 | + @Resource | |
| 73 | + private MesMdClientService clientService; | |
| 74 | + | |
| 75 | + @PostMapping("/create") | |
| 76 | + @Operation(summary = "创建生产任务") | |
| 77 | + @PreAuthorize("@ss.hasPermission('mes:pro-task:create')") | |
| 78 | + public CommonResult<Long> createTask(@Valid @RequestBody MesProTaskSaveReqVO createReqVO) { | |
| 79 | + return success(taskService.createTask(createReqVO)); | |
| 80 | + } | |
| 81 | + | |
| 82 | + @PutMapping("/update") | |
| 83 | + @Operation(summary = "更新生产任务") | |
| 84 | + @PreAuthorize("@ss.hasPermission('mes:pro-task:update')") | |
| 85 | + public CommonResult<Boolean> updateTask(@Valid @RequestBody MesProTaskSaveReqVO updateReqVO) { | |
| 86 | + taskService.updateTask(updateReqVO); | |
| 87 | + return success(true); | |
| 88 | + } | |
| 89 | + | |
| 90 | + @DeleteMapping("/delete") | |
| 91 | + @Operation(summary = "删除生产任务") | |
| 92 | + @Parameter(name = "id", description = "编号", required = true) | |
| 93 | + @PreAuthorize("@ss.hasPermission('mes:pro-task:delete')") | |
| 94 | + public CommonResult<Boolean> deleteTask(@RequestParam("id") Long id) { | |
| 95 | + taskService.deleteTask(id); | |
| 96 | + return success(true); | |
| 97 | + } | |
| 98 | + | |
| 99 | + @GetMapping("/get") | |
| 100 | + @Operation(summary = "获得生产任务") | |
| 101 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 102 | + @PreAuthorize("@ss.hasPermission('mes:pro-task:query')") | |
| 103 | + public CommonResult<MesProTaskRespVO> getTask(@RequestParam("id") Long id) { | |
| 104 | + MesProTaskDO task = taskService.getTask(id); | |
| 105 | + if (task == null) { | |
| 106 | + return success(null); | |
| 107 | + } | |
| 108 | + return success(buildTaskRespVOList(List.of(task)).get(0)); | |
| 109 | + } | |
| 110 | + | |
| 111 | + @GetMapping("/page") | |
| 112 | + @Operation(summary = "获得生产任务分页") | |
| 113 | + @PreAuthorize("@ss.hasPermission('mes:pro-task:query')") | |
| 114 | + public CommonResult<PageResult<MesProTaskRespVO>> getTaskPage(@Valid MesProTaskPageReqVO pageReqVO) { | |
| 115 | + PageResult<MesProTaskDO> pageResult = taskService.getTaskPage(pageReqVO); | |
| 116 | + return success(new PageResult<>(buildTaskRespVOList(pageResult.getList()), pageResult.getTotal())); | |
| 117 | + } | |
| 118 | + | |
| 119 | + @GetMapping("/simple-list") | |
| 120 | + @Operation(summary = "获得生产任务精简列表", description = "主要用于前端的下拉选项") | |
| 121 | + public CommonResult<List<MesProTaskRespVO>> getTaskSimpleList( | |
| 122 | + @RequestParam(value = "workOrderId", required = false) Long workOrderId) { | |
| 123 | + List<MesProTaskDO> list = taskService.getTaskSimpleList(workOrderId); | |
| 124 | + return success(convertList(list, task -> new MesProTaskRespVO() | |
| 125 | + .setId(task.getId()).setCode(task.getCode()).setName(task.getName()) | |
| 126 | + .setWorkOrderId(task.getWorkOrderId()).setProcessId(task.getProcessId()) | |
| 127 | + .setStatus(task.getStatus()))); | |
| 128 | + } | |
| 129 | + | |
| 130 | + @GetMapping("/export-excel") | |
| 131 | + @Operation(summary = "导出生产任务 Excel") | |
| 132 | + @PreAuthorize("@ss.hasPermission('mes:pro-task:export')") | |
| 133 | + @ApiAccessLog(operateType = EXPORT) | |
| 134 | + public void exportTaskExcel(@Valid MesProTaskPageReqVO pageReqVO, | |
| 135 | + HttpServletResponse response) throws IOException { | |
| 136 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | |
| 137 | + List<MesProTaskDO> list = taskService.getTaskPage(pageReqVO).getList(); | |
| 138 | + List<MesProTaskRespVO> voList = buildTaskRespVOList(list); | |
| 139 | + ExcelUtils.write(response, "生产任务.xls", "数据", MesProTaskRespVO.class, voList); | |
| 140 | + } | |
| 141 | + | |
| 142 | + // ==================== 拼接 VO ==================== | |
| 143 | + | |
| 144 | + private List<MesProTaskRespVO> buildTaskRespVOList(List<MesProTaskDO> list) { | |
| 145 | + if (CollUtil.isEmpty(list)) { | |
| 146 | + return Collections.emptyList(); | |
| 147 | + } | |
| 148 | + // 批量查询关联数据 | |
| 149 | + Map<Long, MesProWorkOrderDO> workOrderMap = workOrderService.getWorkOrderMap( | |
| 150 | + convertSet(list, MesProTaskDO::getWorkOrderId)); | |
| 151 | + Map<Long, MesMdWorkstationDO> workstationMap = workstationService.getWorkstationMap( | |
| 152 | + convertSet(list, MesProTaskDO::getWorkstationId)); | |
| 153 | + Map<Long, MesProProcessDO> processMap = processService.getProcessMap( | |
| 154 | + new java.util.ArrayList<>(convertSet(list, MesProTaskDO::getProcessId))); | |
| 155 | + Map<Long, MesMdItemDO> itemMap = itemService.getItemMap( | |
| 156 | + convertSet(list, MesProTaskDO::getItemId)); | |
| 157 | + Map<Long, MesMdUnitMeasureDO> unitMeasureMap = unitMeasureService.getUnitMeasureMap( | |
| 158 | + convertSet(list, MesProTaskDO::getUnitMeasureId)); | |
| 159 | + Map<Long, MesMdClientDO> clientMap = clientService.getClientMap( | |
| 160 | + convertSet(list, MesProTaskDO::getClientId)); | |
| 161 | + | |
| 162 | + // 拼接 VO | |
| 163 | + return convertList(list, task -> { | |
| 164 | + MesProTaskRespVO vo = BeanUtils.toBean(task, MesProTaskRespVO.class); | |
| 165 | + findAndThen(workOrderMap, task.getWorkOrderId(), wo -> { | |
| 166 | + vo.setWorkOrderCode(wo.getCode()); | |
| 167 | + vo.setWorkOrderName(wo.getName()); | |
| 168 | + vo.setRequestDate(wo.getRequestDate()); | |
| 169 | + }); | |
| 170 | + findAndThen(workstationMap, task.getWorkstationId(), ws -> | |
| 171 | + vo.setWorkstationName(ws.getName())); | |
| 172 | + findAndThen(processMap, task.getProcessId(), p -> | |
| 173 | + vo.setProcessName(p.getName())); | |
| 174 | + findAndThen(itemMap, task.getItemId(), item -> { | |
| 175 | + vo.setItemCode(item.getCode()); | |
| 176 | + vo.setItemName(item.getName()); | |
| 177 | + vo.setItemSpec(item.getSpecification()); | |
| 178 | + }); | |
| 179 | + findAndThen(unitMeasureMap, task.getUnitMeasureId(), um -> | |
| 180 | + vo.setUnitMeasureName(um.getName())); | |
| 181 | + findAndThen(clientMap, task.getClientId(), c -> | |
| 182 | + vo.setClientName(c.getName())); | |
| 183 | + return vo; | |
| 184 | + }); | |
| 185 | + } | |
| 186 | + | |
| 187 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/vo/MesProTaskPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.task.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 MesProTaskPageReqVO extends PageParam { | |
| 19 | + | |
| 20 | + @Schema(description = "任务编码", example = "PT202503150001") | |
| 21 | + private String code; | |
| 22 | + | |
| 23 | + @Schema(description = "任务名称", example = "注塑任务") | |
| 24 | + private String name; | |
| 25 | + | |
| 26 | + @Schema(description = "生产工单编号", example = "1") | |
| 27 | + private Long workOrderId; | |
| 28 | + | |
| 29 | + @Schema(description = "工序编号", example = "1") | |
| 30 | + private Long processId; | |
| 31 | + | |
| 32 | + @Schema(description = "工作站编号", example = "1") | |
| 33 | + private Long workstationId; | |
| 34 | + | |
| 35 | + @Schema(description = "任务状态", example = "0") | |
| 36 | + private Integer status; | |
| 37 | + | |
| 38 | + @Schema(description = "创建时间") | |
| 39 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 40 | + private LocalDateTime[] createTime; | |
| 41 | + | |
| 42 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/vo/MesProTaskRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.math.BigDecimal; | |
| 7 | +import java.time.LocalDateTime; | |
| 8 | + | |
| 9 | +@Schema(description = "管理后台 - MES 生产任务 Response VO") | |
| 10 | +@Data | |
| 11 | +public class MesProTaskRespVO { | |
| 12 | + | |
| 13 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 14 | + private Long id; | |
| 15 | + | |
| 16 | + @Schema(description = "任务编码", example = "PT202503150001") | |
| 17 | + private String code; | |
| 18 | + | |
| 19 | + @Schema(description = "任务名称", example = "注塑任务") | |
| 20 | + private String name; | |
| 21 | + | |
| 22 | + @Schema(description = "生产工单编号", example = "1") | |
| 23 | + private Long workOrderId; | |
| 24 | + | |
| 25 | + @Schema(description = "工单编码", example = "WO-001") | |
| 26 | + private String workOrderCode; | |
| 27 | + | |
| 28 | + @Schema(description = "工单名称", example = "生产工单-A") | |
| 29 | + private String workOrderName; | |
| 30 | + | |
| 31 | + @Schema(description = "工作站编号", example = "1") | |
| 32 | + private Long workstationId; | |
| 33 | + | |
| 34 | + @Schema(description = "工作站名称", example = "注塑工作站") | |
| 35 | + private String workstationName; | |
| 36 | + | |
| 37 | + @Schema(description = "工艺路线编号", example = "1") | |
| 38 | + private Long routeId; | |
| 39 | + | |
| 40 | + @Schema(description = "工序编号", example = "1") | |
| 41 | + private Long processId; | |
| 42 | + | |
| 43 | + @Schema(description = "工序名称", example = "注塑") | |
| 44 | + private String processName; | |
| 45 | + | |
| 46 | + @Schema(description = "产品物料编号", example = "100") | |
| 47 | + private Long itemId; | |
| 48 | + | |
| 49 | + @Schema(description = "产品编码", example = "P-001") | |
| 50 | + private String itemCode; | |
| 51 | + | |
| 52 | + @Schema(description = "产品名称", example = "电路板") | |
| 53 | + private String itemName; | |
| 54 | + | |
| 55 | + @Schema(description = "规格型号", example = "100x200mm") | |
| 56 | + private String itemSpec; | |
| 57 | + | |
| 58 | + @Schema(description = "单位编号", example = "200") | |
| 59 | + private Long unitMeasureId; | |
| 60 | + | |
| 61 | + @Schema(description = "单位名称", example = "个") | |
| 62 | + private String unitMeasureName; | |
| 63 | + | |
| 64 | + @Schema(description = "排产数量", example = "100.00") | |
| 65 | + private BigDecimal quantity; | |
| 66 | + | |
| 67 | + @Schema(description = "已生产数量", example = "50.00") | |
| 68 | + private BigDecimal producedQuantity; | |
| 69 | + | |
| 70 | + @Schema(description = "合格品数量", example = "48.00") | |
| 71 | + private BigDecimal qualifyQuantity; | |
| 72 | + | |
| 73 | + @Schema(description = "不良品数量", example = "2.00") | |
| 74 | + private BigDecimal unqualifyQuantity; | |
| 75 | + | |
| 76 | + @Schema(description = "调整数量", example = "0") | |
| 77 | + private BigDecimal changedQuantity; | |
| 78 | + | |
| 79 | + @Schema(description = "客户编号", example = "300") | |
| 80 | + private Long clientId; | |
| 81 | + | |
| 82 | + @Schema(description = "客户名称", example = "客户A") | |
| 83 | + private String clientName; | |
| 84 | + | |
| 85 | + @Schema(description = "开始生产时间") | |
| 86 | + private LocalDateTime startTime; | |
| 87 | + | |
| 88 | + @Schema(description = "生产时长(工作日)", example = "3") | |
| 89 | + private Integer duration; | |
| 90 | + | |
| 91 | + @Schema(description = "结束生产时间") | |
| 92 | + private LocalDateTime endTime; | |
| 93 | + | |
| 94 | + @Schema(description = "甘特图显示颜色", example = "#00AEF3") | |
| 95 | + private String colorCode; | |
| 96 | + | |
| 97 | + @Schema(description = "需求日期") | |
| 98 | + private LocalDateTime requestDate; | |
| 99 | + | |
| 100 | + @Schema(description = "完成日期") | |
| 101 | + private LocalDateTime finishDate; | |
| 102 | + | |
| 103 | + @Schema(description = "取消日期") | |
| 104 | + private LocalDateTime cancelDate; | |
| 105 | + | |
| 106 | + @Schema(description = "任务状态", example = "0") | |
| 107 | + private Integer status; | |
| 108 | + | |
| 109 | + @Schema(description = "备注", example = "备注") | |
| 110 | + private String remark; | |
| 111 | + | |
| 112 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 113 | + private LocalDateTime createTime; | |
| 114 | + | |
| 115 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/vo/MesProTaskSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.pro.task.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 MesProTaskSaveReqVO { | |
| 14 | + | |
| 15 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 16 | + private Long id; | |
| 17 | + | |
| 18 | + @Schema(description = "任务编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "PT202503150001") | |
| 19 | + @NotEmpty(message = "任务编码不能为空") | |
| 20 | + private String code; | |
| 21 | + | |
| 22 | + @Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "注塑任务") | |
| 23 | + @NotEmpty(message = "任务名称不能为空") | |
| 24 | + private String name; | |
| 25 | + | |
| 26 | + @Schema(description = "生产工单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 27 | + @NotNull(message = "生产工单不能为空") | |
| 28 | + private Long workOrderId; | |
| 29 | + | |
| 30 | + @Schema(description = "工作站编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 31 | + @NotNull(message = "工作站不能为空") | |
| 32 | + private Long workstationId; | |
| 33 | + | |
| 34 | + @Schema(description = "工艺路线编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 35 | + @NotNull(message = "工艺路线不能为空") | |
| 36 | + private Long routeId; | |
| 37 | + | |
| 38 | + @Schema(description = "工序编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 39 | + @NotNull(message = "工序不能为空") | |
| 40 | + private Long processId; | |
| 41 | + | |
| 42 | + @Schema(description = "产品物料编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 43 | + @NotNull(message = "产品不能为空") | |
| 44 | + private Long itemId; | |
| 45 | + | |
| 46 | + @Schema(description = "单位编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "200") | |
| 47 | + @NotNull(message = "单位不能为空") | |
| 48 | + private Long unitMeasureId; | |
| 49 | + | |
| 50 | + @Schema(description = "排产数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | |
| 51 | + @NotNull(message = "排产数量不能为空") | |
| 52 | + private BigDecimal quantity; | |
| 53 | + | |
| 54 | + @Schema(description = "已生产数量", example = "0") | |
| 55 | + private BigDecimal producedQuantity; | |
| 56 | + | |
| 57 | + @Schema(description = "合格品数量", example = "0") | |
| 58 | + private BigDecimal qualifyQuantity; | |
| 59 | + | |
| 60 | + @Schema(description = "不良品数量", example = "0") | |
| 61 | + private BigDecimal unqualifyQuantity; | |
| 62 | + | |
| 63 | + @Schema(description = "调整数量", example = "0") | |
| 64 | + private BigDecimal changedQuantity; | |
| 65 | + | |
| 66 | + @Schema(description = "客户编号", example = "300") | |
| 67 | + private Long clientId; | |
| 68 | + | |
| 69 | + @Schema(description = "开始生产时间") | |
| 70 | + private LocalDateTime startTime; | |
| 71 | + | |
| 72 | + @Schema(description = "生产时长(工作日)", example = "3") | |
| 73 | + private Integer duration; | |
| 74 | + | |
| 75 | + @Schema(description = "结束生产时间") | |
| 76 | + private LocalDateTime endTime; | |
| 77 | + | |
| 78 | + @Schema(description = "甘特图显示颜色", example = "#00AEF3") | |
| 79 | + private String colorCode; | |
| 80 | + | |
| 81 | + @Schema(description = "备注", example = "备注") | |
| 82 | + private String remark; | |
| 83 | + | |
| 84 | + @Schema(description = "预留字段1") | |
| 85 | + private String attribute1; | |
| 86 | + | |
| 87 | + @Schema(description = "预留字段2") | |
| 88 | + private String attribute2; | |
| 89 | + | |
| 90 | + @Schema(description = "预留字段3") | |
| 91 | + private Integer attribute3; | |
| 92 | + | |
| 93 | + @Schema(description = "预留字段4") | |
| 94 | + private Integer attribute4; | |
| 95 | + | |
| 96 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/pro/task/MesProTaskDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.pro.task; | |
| 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.md.unitmeasure.MesMdUnitMeasureDO; | |
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO; | |
| 8 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.route.MesProRouteDO; | |
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; | |
| 10 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 11 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 12 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 13 | +import lombok.*; | |
| 14 | + | |
| 15 | +import java.math.BigDecimal; | |
| 16 | +import java.time.LocalDateTime; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * MES 生产任务 DO | |
| 20 | + * | |
| 21 | + * @author 芋道源码 | |
| 22 | + */ | |
| 23 | +@TableName("mes_pro_task") | |
| 24 | +@KeySequence("mes_pro_task_seq") | |
| 25 | +@Data | |
| 26 | +@EqualsAndHashCode(callSuper = true) | |
| 27 | +@ToString(callSuper = true) | |
| 28 | +@Builder | |
| 29 | +@NoArgsConstructor | |
| 30 | +@AllArgsConstructor | |
| 31 | +public class MesProTaskDO extends BaseDO { | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 编号 | |
| 35 | + */ | |
| 36 | + @TableId | |
| 37 | + private Long id; | |
| 38 | + /** | |
| 39 | + * 任务编码 | |
| 40 | + */ | |
| 41 | + private String code; | |
| 42 | + /** | |
| 43 | + * 任务名称 | |
| 44 | + */ | |
| 45 | + private String name; | |
| 46 | + /** | |
| 47 | + * 生产工单编号 | |
| 48 | + * | |
| 49 | + * 关联 {@link MesProWorkOrderDO#getId()} | |
| 50 | + */ | |
| 51 | + private Long workOrderId; | |
| 52 | + /** | |
| 53 | + * 工作站编号 | |
| 54 | + * | |
| 55 | + * 关联 {@link MesMdWorkstationDO#getId()} | |
| 56 | + */ | |
| 57 | + private Long workstationId; | |
| 58 | + /** | |
| 59 | + * 工艺路线编号 | |
| 60 | + * | |
| 61 | + * 关联 {@link MesProRouteDO#getId()} | |
| 62 | + */ | |
| 63 | + private Long routeId; | |
| 64 | + /** | |
| 65 | + * 工序编号 | |
| 66 | + * | |
| 67 | + * 关联 {@link MesProProcessDO#getId()} | |
| 68 | + */ | |
| 69 | + private Long processId; | |
| 70 | + /** | |
| 71 | + * 产品物料编号 | |
| 72 | + * | |
| 73 | + * 关联 {@link MesMdItemDO#getId()} | |
| 74 | + */ | |
| 75 | + private Long itemId; | |
| 76 | + /** | |
| 77 | + * 单位编号 | |
| 78 | + * | |
| 79 | + * 关联 {@link MesMdUnitMeasureDO#getId()} | |
| 80 | + */ | |
| 81 | + private Long unitMeasureId; | |
| 82 | + /** | |
| 83 | + * 排产数量 | |
| 84 | + */ | |
| 85 | + private BigDecimal quantity; | |
| 86 | + /** | |
| 87 | + * 已生产数量 | |
| 88 | + */ | |
| 89 | + private BigDecimal producedQuantity; | |
| 90 | + /** | |
| 91 | + * 合格品数量 | |
| 92 | + */ | |
| 93 | + private BigDecimal qualifyQuantity; | |
| 94 | + /** | |
| 95 | + * 不良品数量 | |
| 96 | + */ | |
| 97 | + private BigDecimal unqualifyQuantity; | |
| 98 | + /** | |
| 99 | + * 调整数量 | |
| 100 | + */ | |
| 101 | + private BigDecimal changedQuantity; | |
| 102 | + /** | |
| 103 | + * 客户编号 | |
| 104 | + */ | |
| 105 | + private Long clientId; | |
| 106 | + /** | |
| 107 | + * 开始生产时间 | |
| 108 | + */ | |
| 109 | + private LocalDateTime startTime; | |
| 110 | + /** | |
| 111 | + * 生产时长(工作日,1=8小时) | |
| 112 | + */ | |
| 113 | + private Integer duration; | |
| 114 | + /** | |
| 115 | + * 结束生产时间 | |
| 116 | + */ | |
| 117 | + private LocalDateTime endTime; | |
| 118 | + /** | |
| 119 | + * 甘特图显示颜色 | |
| 120 | + */ | |
| 121 | + private String colorCode; | |
| 122 | + /** | |
| 123 | + * 完成日期 | |
| 124 | + */ | |
| 125 | + private LocalDateTime finishDate; | |
| 126 | + /** | |
| 127 | + * 取消日期 | |
| 128 | + */ | |
| 129 | + private LocalDateTime cancelDate; | |
| 130 | + /** | |
| 131 | + * 任务状态 | |
| 132 | + */ | |
| 133 | + private Integer status; | |
| 134 | + /** | |
| 135 | + * 备注 | |
| 136 | + */ | |
| 137 | + private String remark; | |
| 138 | + /** | |
| 139 | + * 预留字段1 | |
| 140 | + */ | |
| 141 | + private String attribute1; | |
| 142 | + /** | |
| 143 | + * 预留字段2 | |
| 144 | + */ | |
| 145 | + private String attribute2; | |
| 146 | + /** | |
| 147 | + * 预留字段3 | |
| 148 | + */ | |
| 149 | + private Integer attribute3; | |
| 150 | + /** | |
| 151 | + * 预留字段4 | |
| 152 | + */ | |
| 153 | + private Integer attribute4; | |
| 154 | + | |
| 155 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/pro/task/MesProTaskMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.pro.task; | |
| 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.task.vo.MesProTaskPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; | |
| 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 MesProTaskMapper extends BaseMapperX<MesProTaskDO> { | |
| 19 | + | |
| 20 | + default PageResult<MesProTaskDO> selectPage(MesProTaskPageReqVO reqVO) { | |
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesProTaskDO>() | |
| 22 | + .likeIfPresent(MesProTaskDO::getCode, reqVO.getCode()) | |
| 23 | + .likeIfPresent(MesProTaskDO::getName, reqVO.getName()) | |
| 24 | + .eqIfPresent(MesProTaskDO::getWorkOrderId, reqVO.getWorkOrderId()) | |
| 25 | + .eqIfPresent(MesProTaskDO::getProcessId, reqVO.getProcessId()) | |
| 26 | + .eqIfPresent(MesProTaskDO::getWorkstationId, reqVO.getWorkstationId()) | |
| 27 | + .eqIfPresent(MesProTaskDO::getStatus, reqVO.getStatus()) | |
| 28 | + .betweenIfPresent(MesProTaskDO::getCreateTime, reqVO.getCreateTime()) | |
| 29 | + .orderByDesc(MesProTaskDO::getId)); | |
| 30 | + } | |
| 31 | + | |
| 32 | + default List<MesProTaskDO> selectListByWorkOrderId(Long workOrderId) { | |
| 33 | + return selectList(new LambdaQueryWrapperX<MesProTaskDO>() | |
| 34 | + .eqIfPresent(MesProTaskDO::getWorkOrderId, workOrderId) | |
| 35 | + .orderByDesc(MesProTaskDO::getId)); | |
| 36 | + } | |
| 37 | + | |
| 38 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/task/MesProTaskService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.pro.task; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskSaveReqVO; | |
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; | |
| 7 | +import jakarta.validation.Valid; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * MES 生产任务 Service 接口 | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +public interface MesProTaskService { | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * 创建生产任务 | |
| 20 | + * | |
| 21 | + * @param createReqVO 创建信息 | |
| 22 | + * @return 编号 | |
| 23 | + */ | |
| 24 | + Long createTask(@Valid MesProTaskSaveReqVO createReqVO); | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 更新生产任务 | |
| 28 | + * | |
| 29 | + * @param updateReqVO 更新信息 | |
| 30 | + */ | |
| 31 | + void updateTask(@Valid MesProTaskSaveReqVO updateReqVO); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 删除生产任务 | |
| 35 | + * | |
| 36 | + * @param id 编号 | |
| 37 | + */ | |
| 38 | + void deleteTask(Long id); | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 获得生产任务 | |
| 42 | + * | |
| 43 | + * @param id 编号 | |
| 44 | + * @return 生产任务 | |
| 45 | + */ | |
| 46 | + MesProTaskDO getTask(Long id); | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 获得生产任务分页 | |
| 50 | + * | |
| 51 | + * @param pageReqVO 分页查询 | |
| 52 | + * @return 生产任务分页 | |
| 53 | + */ | |
| 54 | + PageResult<MesProTaskDO> getTaskPage(MesProTaskPageReqVO pageReqVO); | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 获得生产任务精简列表 | |
| 58 | + * | |
| 59 | + * @param workOrderId 工单编号(可选) | |
| 60 | + * @return 生产任务列表 | |
| 61 | + */ | |
| 62 | + List<MesProTaskDO> getTaskSimpleList(Long workOrderId); | |
| 63 | + | |
| 64 | + /** | |
| 65 | + * 校验任务是否存在 | |
| 66 | + * | |
| 67 | + * @param id 编号 | |
| 68 | + */ | |
| 69 | + void validateTaskExists(Long id); | |
| 70 | + | |
| 71 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/task/MesProTaskServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.pro.task; | |
| 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.task.vo.MesProTaskPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.pro.task.vo.MesProTaskSaveReqVO; | |
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.task.MesProTaskDO; | |
| 8 | +import cn.iocoder.yudao.module.mes.dal.mysql.pro.task.MesProTaskMapper; | |
| 9 | +import jakarta.annotation.Resource; | |
| 10 | +import org.springframework.stereotype.Service; | |
| 11 | +import org.springframework.validation.annotation.Validated; | |
| 12 | + | |
| 13 | +import java.util.List; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 16 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.PRO_TASK_NOT_EXISTS; | |
| 17 | + | |
| 18 | +/** | |
| 19 | + * MES 生产任务 Service 实现类 | |
| 20 | + * | |
| 21 | + * @author 芋道源码 | |
| 22 | + */ | |
| 23 | +@Service | |
| 24 | +@Validated | |
| 25 | +public class MesProTaskServiceImpl implements MesProTaskService { | |
| 26 | + | |
| 27 | + @Resource | |
| 28 | + private MesProTaskMapper taskMapper; | |
| 29 | + | |
| 30 | + @Override | |
| 31 | + public Long createTask(MesProTaskSaveReqVO createReqVO) { | |
| 32 | + MesProTaskDO task = BeanUtils.toBean(createReqVO, MesProTaskDO.class); | |
| 33 | + taskMapper.insert(task); | |
| 34 | + return task.getId(); | |
| 35 | + } | |
| 36 | + | |
| 37 | + @Override | |
| 38 | + public void updateTask(MesProTaskSaveReqVO updateReqVO) { | |
| 39 | + validateTaskExists(updateReqVO.getId()); | |
| 40 | + MesProTaskDO updateObj = BeanUtils.toBean(updateReqVO, MesProTaskDO.class); | |
| 41 | + taskMapper.updateById(updateObj); | |
| 42 | + } | |
| 43 | + | |
| 44 | + @Override | |
| 45 | + public void deleteTask(Long id) { | |
| 46 | + validateTaskExists(id); | |
| 47 | + taskMapper.deleteById(id); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Override | |
| 51 | + public MesProTaskDO getTask(Long id) { | |
| 52 | + return taskMapper.selectById(id); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @Override | |
| 56 | + public PageResult<MesProTaskDO> getTaskPage(MesProTaskPageReqVO pageReqVO) { | |
| 57 | + return taskMapper.selectPage(pageReqVO); | |
| 58 | + } | |
| 59 | + | |
| 60 | + @Override | |
| 61 | + public List<MesProTaskDO> getTaskSimpleList(Long workOrderId) { | |
| 62 | + if (workOrderId != null) { | |
| 63 | + return taskMapper.selectListByWorkOrderId(workOrderId); | |
| 64 | + } | |
| 65 | + return taskMapper.selectList(); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + public void validateTaskExists(Long id) { | |
| 70 | + if (taskMapper.selectById(id) == null) { | |
| 71 | + throw exception(PRO_TASK_NOT_EXISTS); | |
| 72 | + } | |
| 73 | + } | |
| 74 | + | |
| 75 | +} | ... | ... |