Commit 1cea4e584b388465d8a868fd4aed380a468d9b15

Authored by YunaiV
1 parent 91455c2d

✨ feat(mes): 优化任务名称构建逻辑,支持数量动态更新

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