修复顺序流水线指派模式下同部门多设计师子任务状态更新问题

- 修改updateAssignedPipelineTaskItems方法
- 基于部门序号(从itemNo解析)而不是groupNo来判断第一个部门
- 第一个部门的所有子任务都更新为in_progress状态
- 保留每个子任务预先指定的接收人
This commit is contained in:
Your Name 2026-01-14 19:09:19 +08:00
parent d3d1320bf4
commit cb2c468513

View File

@ -3140,28 +3140,68 @@ public class TaskService {
}
log.info("并行流水线任务的所有子任务已更新为in_progress:count={}", taskItems.size());
} else {
// 顺序模式:只有第一组进入in_progress状态,并设置接收人
Integer firstGroupNo = taskItems.get(0).getGroupNo();
// 顺序模式:第一个部门的所有子任务进入in_progress状态
// 从子任务编号解析部门序号,找出第一个部门的所有子任务
int firstDeptIndex = -1;
for (TaskItem item : taskItems) {
if (item.getGroupNo().equals(firstGroupNo)) {
int deptIndex = parseDeptIndexFromItemNo(item.getItemNo());
if (firstDeptIndex == -1 || deptIndex < firstDeptIndex) {
firstDeptIndex = deptIndex;
}
}
log.info("顺序流水线任务,第一个部门序号: {}", firstDeptIndex);
for (TaskItem item : taskItems) {
int itemDeptIndex = parseDeptIndexFromItemNo(item.getItemNo());
if (itemDeptIndex == firstDeptIndex) {
item.setStatus("in_progress");
item.setIsLocked(0);
// 指派模式下:强制更新第一组子任务的接收人为主任务的接收人
if (receiverId != null) {
// 指派模式下:如果子任务已有预先指定的接收人,保留;否则使用主任务的接收人
if (item.getReceiverId() == null && receiverId != null) {
item.setReceiverId(receiverId);
if (receiverDeptId != null) {
item.setReceiverDeptId(receiverDeptId);
}
log.info("顺序流水线第一组子任务 {} 已设置/更新接收人: receiverId={}, deptId={}",
log.info("顺序流水线第一部门子任务 {} 设置接收人: receiverId={}, deptId={}",
item.getId(), receiverId, receiverDeptId);
} else {
log.info("顺序流水线第一部门子任务 {} 保留预先指定的接收人: receiverId={}",
item.getId(), item.getReceiverId());
}
taskItemMapper.updateById(item);
log.info("顺序流水线任务第一组子任务已更新为in_progress:itemId={}", item.getId());
log.info("顺序流水线任务第一部门子任务已更新为in_progress:itemId={}, itemNo={}",
item.getId(), item.getItemNo());
}
}
}
}
/**
* 从子任务编号解析部门序号
* 编号格式:任务编号-部门序号-部门内序号,例如 TASK20260114-01-02
*/
private int parseDeptIndexFromItemNo(String itemNo) {
if (itemNo == null || itemNo.isEmpty()) {
return 1;
}
String[] parts = itemNo.split("-");
if (parts.length >= 3) {
try {
// 新格式:TASK...-部门序号-部门内序号
// 倒数第二段是部门序号
return Integer.parseInt(parts[parts.length - 2]);
} catch (NumberFormatException e) {
log.warn("解析子任务编号部门序号失败: {}", itemNo);
}
} else if (parts.length == 2) {
// 旧格式:TASK...-序号,认为是第一个部门
return 1;
}
return 1;
}
/**
* 获取指定部门及其所有子部门的ID列表
*/