Commit 1cea4e584b388465d8a868fd4aed380a468d9b15
1 parent
91455c2d
✨ feat(mes): 优化任务名称构建逻辑,支持数量动态更新
重构任务名称构建逻辑,使用独立方法生成任务名称,确保在创建和更新任务时数量信息正确显示。更新甘特图配置,允许在编辑状态下拖动和调整任务持续时间,提升用户交互体验。
Showing
1 changed file
with
8 additions
and
3 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/task/MesProTaskServiceImpl.java
| ... | ... | @@ -21,6 +21,7 @@ import org.springframework.context.annotation.Lazy; |
| 21 | 21 | import org.springframework.stereotype.Service; |
| 22 | 22 | import org.springframework.validation.annotation.Validated; |
| 23 | 23 | |
| 24 | +import java.math.BigDecimal; | |
| 24 | 25 | import java.time.LocalDateTime; |
| 25 | 26 | import java.util.Collection; |
| 26 | 27 | import java.util.Collections; |
| ... | ... | @@ -67,7 +68,7 @@ public class MesProTaskServiceImpl implements MesProTaskService { |
| 67 | 68 | |
| 68 | 69 | // 2.1 构建任务 DO |
| 69 | 70 | MesProTaskDO task = BeanUtils.toBean(createReqVO, MesProTaskDO.class) |
| 70 | - .setName(item.getName() + "【" + createReqVO.getQuantity() + "】") | |
| 71 | + .setName(buildTaskName(item.getName(), createReqVO.getQuantity())) | |
| 71 | 72 | .setCode(autoCodeRecordService.generateAutoCode(MesMdAutoCodeRuleCodeEnum.TASK_CODE.getCode())) |
| 72 | 73 | .setStatus(MesProTaskStatusEnum.PREPARE.getStatus()); |
| 73 | 74 | // 2.2 插入 |
| ... | ... | @@ -98,13 +99,18 @@ public class MesProTaskServiceImpl implements MesProTaskService { |
| 98 | 99 | } else { |
| 99 | 100 | item = itemService.validateItemExists(task.getItemId()); |
| 100 | 101 | } |
| 102 | + BigDecimal quantity = updateReqVO.getQuantity() != null ? updateReqVO.getQuantity() : task.getQuantity(); | |
| 101 | 103 | |
| 102 | 104 | // 2. 更新 |
| 103 | 105 | MesProTaskDO updateObj = BeanUtils.toBean(updateReqVO, MesProTaskDO.class) |
| 104 | - .setName(item.getName() + "【" + updateReqVO.getQuantity() + "】"); | |
| 106 | + .setName(buildTaskName(item.getName(), quantity)); | |
| 105 | 107 | taskMapper.updateById(updateObj); |
| 106 | 108 | } |
| 107 | 109 | |
| 110 | + private String buildTaskName(String itemName, BigDecimal quantity) { | |
| 111 | + return itemName + "【" + quantity + "】"; | |
| 112 | + } | |
| 113 | + | |
| 108 | 114 | @Override |
| 109 | 115 | public void deleteTask(Long id) { |
| 110 | 116 | // 1. 校验存在 |
| ... | ... | @@ -181,4 +187,3 @@ public class MesProTaskServiceImpl implements MesProTaskService { |
| 181 | 187 | } |
| 182 | 188 | |
| 183 | 189 | } |
| 184 | - | ... | ... |