Commit 91455c2d5bfd57e4716c22457d9a18c3903ea9a0
1 parent
63bccf89
✨ feat(mes): 优化生产任务保存请求和验证逻辑
调整生产任务保存请求的字段为可选,简化编辑时的请求参数。更新任务验证逻辑,确保在更新时只校验存在的字段,提升用户体验和代码可维护性。同时,新增甘特图编辑页面,支持批量保存任务修改。
Showing
3 changed files
with
37 additions
and
27 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/pro/task/vo/MesProTaskSaveReqVO.java
| ... | ... | @@ -16,30 +16,24 @@ public class MesProTaskSaveReqVO { |
| 16 | 16 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 17 | 17 | private Long id; |
| 18 | 18 | |
| 19 | - @Schema(description = "生产工单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 20 | - @NotNull(message = "生产工单不能为空") | |
| 21 | - private Long workOrderId; | |
| 19 | + @Schema(description = "生产工单编号", example = "1") | |
| 20 | + private Long workOrderId; // 编辑时,可不传递 | |
| 22 | 21 | |
| 23 | - @Schema(description = "工作站编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 24 | - @NotNull(message = "工作站不能为空") | |
| 25 | - private Long workstationId; | |
| 22 | + @Schema(description = "工作站编号", example = "1") | |
| 23 | + private Long workstationId; // 编辑时,可不传递 | |
| 26 | 24 | |
| 27 | - @Schema(description = "工艺路线编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 28 | - @NotNull(message = "工艺路线不能为空") | |
| 29 | - private Long routeId; | |
| 25 | + @Schema(description = "工艺路线编号", example = "1") | |
| 26 | + private Long routeId; // 编辑时,可不传递 | |
| 30 | 27 | |
| 31 | - @Schema(description = "工序编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 32 | - @NotNull(message = "工序不能为空") | |
| 33 | - private Long processId; | |
| 28 | + @Schema(description = "工序编号", example = "1") | |
| 29 | + private Long processId; // 编辑时,可不传递 | |
| 34 | 30 | |
| 35 | - @Schema(description = "产品物料编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 36 | - @NotNull(message = "产品不能为空") | |
| 37 | - private Long itemId; | |
| 31 | + @Schema(description = "产品物料编号", example = "100") | |
| 32 | + private Long itemId; // 编辑时,可不传递 | |
| 38 | 33 | |
| 39 | - @Schema(description = "排产数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00") | |
| 40 | - @NotNull(message = "排产数量不能为空") | |
| 34 | + @Schema(description = "排产数量", example = "100.00") | |
| 41 | 35 | @DecimalMin(value = "0", inclusive = false, message = "排产数量必须大于 0") |
| 42 | - private BigDecimal quantity; | |
| 36 | + private BigDecimal quantity; // 编辑时,可不传递 | |
| 43 | 37 | |
| 44 | 38 | @Schema(description = "开始生产时间") |
| 45 | 39 | private LocalDateTime startTime; | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/task/MesProTaskService.java
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/task/MesProTaskServiceImpl.java
| ... | ... | @@ -78,13 +78,26 @@ public class MesProTaskServiceImpl implements MesProTaskService { |
| 78 | 78 | @Override |
| 79 | 79 | public void updateTask(MesProTaskSaveReqVO updateReqVO) { |
| 80 | 80 | // 1.1 校验存在 |
| 81 | - validateTaskExists(updateReqVO.getId()); | |
| 81 | + MesProTaskDO task = validateTaskExists(updateReqVO.getId()); | |
| 82 | 82 | // 1.2 校验关联数据存在 |
| 83 | - workOrderService.validateWorkOrderExists(updateReqVO.getWorkOrderId()); | |
| 84 | - workstationService.validateWorkstationExists(updateReqVO.getWorkstationId()); | |
| 85 | - routeService.validateRouteExists(updateReqVO.getRouteId()); | |
| 86 | - processService.validateProcessExists(updateReqVO.getProcessId()); | |
| 87 | - MesMdItemDO item = itemService.validateItemExists(updateReqVO.getItemId()); | |
| 83 | + if (updateReqVO.getWorkOrderId() != null) { | |
| 84 | + workOrderService.validateWorkOrderExists(updateReqVO.getWorkOrderId()); | |
| 85 | + } | |
| 86 | + if (updateReqVO.getWorkstationId() != null) { | |
| 87 | + workstationService.validateWorkstationExists(updateReqVO.getWorkstationId()); | |
| 88 | + } | |
| 89 | + if (updateReqVO.getRouteId() != null) { | |
| 90 | + routeService.validateRouteExists(updateReqVO.getRouteId()); | |
| 91 | + } | |
| 92 | + if (updateReqVO.getProcessId() != null) { | |
| 93 | + processService.validateProcessExists(updateReqVO.getProcessId()); | |
| 94 | + } | |
| 95 | + MesMdItemDO item; | |
| 96 | + if (updateReqVO.getItemId() != null) { | |
| 97 | + item = itemService.validateItemExists(updateReqVO.getItemId()); | |
| 98 | + } else { | |
| 99 | + item = itemService.validateItemExists(task.getItemId()); | |
| 100 | + } | |
| 88 | 101 | |
| 89 | 102 | // 2. 更新 |
| 90 | 103 | MesProTaskDO updateObj = BeanUtils.toBean(updateReqVO, MesProTaskDO.class) |
| ... | ... | @@ -124,10 +137,12 @@ public class MesProTaskServiceImpl implements MesProTaskService { |
| 124 | 137 | } |
| 125 | 138 | |
| 126 | 139 | @Override |
| 127 | - public void validateTaskExists(Long id) { | |
| 128 | - if (taskMapper.selectById(id) == null) { | |
| 140 | + public MesProTaskDO validateTaskExists(Long id) { | |
| 141 | + MesProTaskDO task = taskMapper.selectById(id); | |
| 142 | + if (task == null) { | |
| 129 | 143 | throw exception(PRO_TASK_NOT_EXISTS); |
| 130 | 144 | } |
| 145 | + return task; | |
| 131 | 146 | } |
| 132 | 147 | |
| 133 | 148 | @Override | ... | ... |