From 72f23a782ae494a022a8b1ed0d694a97ce9870a3 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 30 Jan 2026 11:08:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=BC=BA=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=9F=A5=E8=AF=A2-=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=E5=AD=90=E4=BB=BB=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E8=AF=A6=E7=BB=86=E8=8A=82=E7=82=B9=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为流水线任务添加每个节点的执行状态展示 - 显示节点完成情况(如 已完成 1/1 项) - 显示接单人信息 - 支持待审批、进行中、等待中等状态 --- .../com/designhub/service/TaskService.java | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/backend/src/main/java/com/designhub/service/TaskService.java b/backend/src/main/java/com/designhub/service/TaskService.java index b8c12b2..de89556 100644 --- a/backend/src/main/java/com/designhub/service/TaskService.java +++ b/backend/src/main/java/com/designhub/service/TaskService.java @@ -5019,6 +5019,88 @@ public class TaskService { node3.setStatus("waiting"); } timeline.add(node3); + + // 4. 如果是流水线任务,添加每个节点的详细进度 + boolean isPipeline = task.getIsPipeline() != null && task.getIsPipeline() == 1; + if (isPipeline && ("in_progress".equals(status) || "completed".equals(status))) { + // 查询所有子任务,按 group_no 分组 + java.util.List taskItems = taskItemMapper.selectList( + new LambdaQueryWrapper() + .eq(TaskItem::getTaskId, task.getId()) + .orderByAsc(TaskItem::getGroupNo) + .orderByAsc(TaskItem::getSortOrder) + ); + + // 按 group_no 分组统计 + java.util.Map> groupedItems = taskItems.stream() + .collect(java.util.stream.Collectors.groupingBy( + item -> item.getGroupNo() != null ? item.getGroupNo() : 1 + )); + + // 为每个节点创建时间线项 + java.util.List sortedGroupNos = groupedItems.keySet().stream() + .sorted() + .collect(java.util.stream.Collectors.toList()); + + for (Integer groupNo : sortedGroupNos) { + java.util.List groupItems = groupedItems.get(groupNo); + if (groupItems == null || groupItems.isEmpty()) continue; + + // 统计该节点的完成情况 + int totalItems = groupItems.size(); + int completedItems = 0; + int inProgressItems = 0; + int pendingApprovalItems = 0; + TaskItem firstItem = groupItems.get(0); + String receiverName = null; + java.time.LocalDateTime completeTime = null; + + for (TaskItem item : groupItems) { + if ("completed".equals(item.getStatus())) { + completedItems++; + if (completeTime == null || (item.getCompleteTime() != null && item.getCompleteTime().isAfter(completeTime))) { + completeTime = item.getCompleteTime(); + } + } else if ("in_progress".equals(item.getStatus())) { + inProgressItems++; + } else if ("pending_approval".equals(item.getStatus())) { + pendingApprovalItems++; + } + if (receiverName == null && item.getReceiverName() != null) { + receiverName = item.getReceiverName(); + } + } + + // 创建节点时间线 + com.designhub.vo.TaskFlowStatusVO.FlowTimelineNode pipelineNode = new com.designhub.vo.TaskFlowStatusVO.FlowTimelineNode(); + pipelineNode.setNodeName("节点" + groupNo + "执行"); + + if (completedItems == totalItems) { + // 所有子任务都完成 + pipelineNode.setStatus("completed"); + pipelineNode.setTime(completeTime); + pipelineNode.setComment("已完成 " + completedItems + "/" + totalItems + " 项"); + } else if (completedItems > 0 || inProgressItems > 0) { + // 有进行中的子任务 + pipelineNode.setStatus("pending"); + pipelineNode.setComment("进行中 " + (completedItems + inProgressItems) + "/" + totalItems + " 项"); + } else if (pendingApprovalItems > 0) { + // 等待审批 + pipelineNode.setStatus("pending"); + pipelineNode.setComment("待审批 " + pendingApprovalItems + " 项"); + } else { + // 等待中 + pipelineNode.setStatus("waiting"); + pipelineNode.setComment("等待前置节点完成"); + } + + if (receiverName != null) { + pipelineNode.setOperatorName(receiverName); + } + + timeline.add(pipelineNode); + } + } } return timeline;