From 93c1d58f7c993b3ed053415ae88124eeb5b01345 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 24 Jan 2026 11:45:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BF=E4=BB=BB=E5=8A=A1=E7=AC=AC=E4=BA=8C=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E9=A2=84=E5=85=88=E6=8C=87=E5=AE=9A=E7=9A=84=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=B8=88=E7=8E=B0=E5=9C=A8=E4=BC=9A=E6=94=B6=E5=88=B0=E8=A7=A3?= =?UTF-8?q?=E9=94=81=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:当流水线任务(如建模+美工)的第一个节点完成后,如果第二个节点已预先指定了设计师, 该设计师不会收到通知,导致不知道任务已解锁。 修复:在子任务解锁逻辑中,区分处理已预先指定设计师和未指定设计师的子任务: 1. 已预先指定设计师的子任务:直接设为待接单状态(pending),并立即通知该设计师 2. 未指定设计师的子任务:设为待审核状态(pending_approval),通知接单部门负责人审核分配 --- .../designhub/service/TaskItemService.java | 123 +++++++++++++----- 1 file changed, 89 insertions(+), 34 deletions(-) diff --git a/backend/src/main/java/com/designhub/service/TaskItemService.java b/backend/src/main/java/com/designhub/service/TaskItemService.java index 40fdb36..288c164 100644 --- a/backend/src/main/java/com/designhub/service/TaskItemService.java +++ b/backend/src/main/java/com/designhub/service/TaskItemService.java @@ -678,54 +678,109 @@ public class TaskItemService { .collect(java.util.stream.Collectors.toList()); if (!nextDeptItems.isEmpty()) { - // 批量解锁下一个部门的所有子任务,状态设为待审核,并传递前置环节的下载链接 + // 🔥 分类处理:已预先指定设计师的 vs 未指定的 + List preAssignedItems = new ArrayList<>(); // 已预先指定设计师的子任务 + List unassignedItems = new ArrayList<>(); // 未指定的子任务 + for (TaskItem nextItem : nextDeptItems) { - nextItem.setStatus("pending_approval"); // 待接单部门负责人审核 + if (nextItem.getReceiverId() != null) { + preAssignedItems.add(nextItem); + } else { + unassignedItems.add(nextItem); + } + } + + LocalDateTime now = LocalDateTime.now(); + + // 🔥 处理已预先指定设计师的子任务:直接设为待接单状态,并通知设计师 + Set notifiedDesignerIds = new HashSet<>(); + for (TaskItem nextItem : preAssignedItems) { + nextItem.setStatus("pending"); // 待接单(设计师需要点击接单确认) nextItem.setIsLocked(0); - nextItem.setPrevDownloadUrl(prevDownloadUrlStr); // 🔥 传递前置环节的下载链接 - nextItem.setUpdateTime(LocalDateTime.now()); + nextItem.setPrevDownloadUrl(prevDownloadUrlStr); + nextItem.setUpdateTime(now); taskItemMapper.updateById(nextItem); - log.info("✅ 解锁子任务: {} (部门序号: {}, ID: {}),待接单部门负责人审核,已传递前置素材链接", + log.info("✅ 解锁预先指定的子任务: {} -> 设计师 {} (ID: {}),状态设为待接单", + nextItem.getItemNo(), nextItem.getReceiverName(), nextItem.getReceiverId()); + + // 通知预先指定的设计师 + if (!notifiedDesignerIds.contains(nextItem.getReceiverId())) { + notifiedDesignerIds.add(nextItem.getReceiverId()); + + Notification notification = new Notification(); + notification.setReceiverId(nextItem.getReceiverId()); + notification.setNotificationType("task"); + notification.setTitle("指派任务已解锁"); + notification.setContent("任务《" + mainTask.getTitle() + "》的子任务 " + nextItem.getItemNo() + + " 已解锁,请尽快接单处理!"); + notification.setRelatedId(nextItem.getId()); + notification.setRelatedType("task_item"); + notification.setPriority(2); // 重要 + notification.setPushDingtalk(1); // 推送到钉钉 + notificationService.sendNotification(notification); + + log.info("已通知预先指定的设计师 {} (ID: {}) 子任务已解锁", + nextItem.getReceiverName(), nextItem.getReceiverId()); + } + } + + // 🔥 处理未指定设计师的子任务:设为待审核,通知接单部门负责人 + for (TaskItem nextItem : unassignedItems) { + nextItem.setStatus("pending_approval"); // 待接单部门负责人审核 + nextItem.setIsLocked(0); + nextItem.setPrevDownloadUrl(prevDownloadUrlStr); + nextItem.setUpdateTime(now); + taskItemMapper.updateById(nextItem); + + log.info("✅ 解锁未指定的子任务: {} (部门序号: {}, ID: {}),待接单部门负责人审核", nextItem.getItemNo(), nextDeptIndex, nextItem.getId()); } result.put("unlockedDeptIndex", nextDeptIndex); result.put("unlockedCount", nextDeptItems.size()); + result.put("preAssignedCount", preAssignedItems.size()); + result.put("unassignedCount", unassignedItems.size()); - // 发送通知给接单部门负责人 - // 从子任务的任务类型配置中获取allowed_dept_ids - Set notifiedLeaderIds = new HashSet<>(); - for (TaskItem nextItem : nextDeptItems) { - Long targetDeptId = getTargetDeptIdFromTaskType(nextItem.getTaskTypeId()); - if (targetDeptId != null) { - com.designhub.entity.Department receiverDept = departmentMapper.selectById(targetDeptId); - if (receiverDept != null && receiverDept.getLeaderId() != null - && !notifiedLeaderIds.contains(receiverDept.getLeaderId())) { - notifiedLeaderIds.add(receiverDept.getLeaderId()); - - Notification notification = new Notification(); - notification.setReceiverId(receiverDept.getLeaderId()); - notification.setNotificationType("task_approval"); - notification.setTitle("新子任务组待审核"); - notification.setContent("任务《" + mainTask.getTitle() + "》第 " + nextDeptIndex + " 个部门共 " + - nextDeptItems.size() + " 个子任务已解锁,请审核并分配!"); - notification.setRelatedId(item.getTaskId()); - notification.setRelatedType("task"); - notification.setPriority(2); // 重要 - notification.setPushDingtalk(1); // 推送到钉钉 - notificationService.sendNotification(notification); - - log.info("已通知接单部门负责人(部门: {}, 负责人ID: {})审核第 {} 个部门子任务", - receiverDept.getDeptName(), receiverDept.getLeaderId(), nextDeptIndex); + // 只有未指定设计师的子任务才需要通知接单部门负责人审核 + if (!unassignedItems.isEmpty()) { + Set notifiedLeaderIds = new HashSet<>(); + for (TaskItem nextItem : unassignedItems) { + Long targetDeptId = getTargetDeptIdFromTaskType(nextItem.getTaskTypeId()); + if (targetDeptId != null) { + com.designhub.entity.Department receiverDept = departmentMapper.selectById(targetDeptId); + if (receiverDept != null && receiverDept.getLeaderId() != null + && !notifiedLeaderIds.contains(receiverDept.getLeaderId())) { + notifiedLeaderIds.add(receiverDept.getLeaderId()); + + Notification notification = new Notification(); + notification.setReceiverId(receiverDept.getLeaderId()); + notification.setNotificationType("task_approval"); + notification.setTitle("新子任务组待审核"); + notification.setContent("任务《" + mainTask.getTitle() + "》第 " + nextDeptIndex + " 个部门共 " + + unassignedItems.size() + " 个子任务已解锁,请审核并分配!"); + notification.setRelatedId(item.getTaskId()); + notification.setRelatedType("task"); + notification.setPriority(2); // 重要 + notification.setPushDingtalk(1); // 推送到钉钉 + notificationService.sendNotification(notification); + + log.info("已通知接单部门负责人(部门: {}, 负责人ID: {})审核第 {} 个部门子任务", + receiverDept.getDeptName(), receiverDept.getLeaderId(), nextDeptIndex); + } + } else { + log.warn("子任务 {} 的任务类型未配置接单部门", nextItem.getItemNo()); } - } else { - log.warn("子任务 {} 的任务类型未配置接单部门", nextItem.getItemNo()); } + + log.info("第 {} 个部门 {} 个未指定子任务已解锁,等待接单部门负责人审核,已通知 {} 个部门负责人", + nextDeptIndex, unassignedItems.size(), notifiedLeaderIds.size()); } - log.info("第 {} 个部门 {} 个子任务已解锁,等待接单部门负责人审核,已通知 {} 个部门负责人", - nextDeptIndex, nextDeptItems.size(), notifiedLeaderIds.size()); + if (!preAssignedItems.isEmpty()) { + log.info("第 {} 个部门 {} 个预先指定的子任务已解锁,已通知 {} 个设计师", + nextDeptIndex, preAssignedItems.size(), notifiedDesignerIds.size()); + } } else { log.info("没有更多部门的子任务需要解锁"); }