liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/schedule/RoutineTaskNotificationScheduleTask.java
@@ -48,7 +48,7 @@
    /**
     * 推送标题
     */
    private static final String PUSH_TITLE = "常规任务提醒";
    private static final String PUSH_TITLE = "待完成日常任务提示";
    /**
     * 通知内容模板
@@ -81,13 +81,13 @@
                return;
            }
            Map<Long, Integer> userTaskCountMap = buildUserTaskCountMap(tasks);
            if (userTaskCountMap.isEmpty()) {
            Map<Long, List<Long>> userTaskIdsMap = buildUserTaskIdsMap(tasks);
            if (userTaskIdsMap.isEmpty()) {
                log.warn("任务接收人为空,跳过通知");
                return;
            }
            Set<Long> allUserIds = userTaskCountMap.keySet();
            Set<Long> allUserIds = userTaskIdsMap.keySet();
            Map<Long, XpOperationsUser> userMap = fetchOperationUsers(allUserIds);
            if (CollectionUtils.isEmpty(userMap)) {
@@ -98,10 +98,11 @@
            List<XpOperationsUserNotification> notifications = new ArrayList<>();
            int pushCount = 0;
            for (Map.Entry<Long, Integer> entry : userTaskCountMap.entrySet()) {
            for (Map.Entry<Long, List<Long>> entry : userTaskIdsMap.entrySet()) {
                Long userId = entry.getKey();
                Integer taskCount = entry.getValue();
                if (taskCount == null || taskCount <= 0) {
                List<Long> taskIds = entry.getValue();
                int taskCount = taskIds == null ? 0 : taskIds.size();
                if (taskCount <= 0) {
                    continue;
                }
@@ -110,6 +111,9 @@
                    continue;
                }
                // 只有一个待完成任务时 dataId 赋值为该任务 ID,多个则赋值为 0
                long dataId = taskCount == 1 ? taskIds.get(0) : 0L;
                String content = buildContent(taskCount);
                String bodyJson = buildPushBodyJson(content);
@@ -117,7 +121,7 @@
                notification.setNotificationType(NotificationTypeEnum.TASK_NEW.getCode());
                notification.setNotificationContent(content);
                notification.setOperationsUserId(userId);
                notification.setDataId(0L);
                notification.setDataId(dataId);
                notification.setReadStatus(0);
                notification.setNotificationExt(bodyJson);
                notifications.add(notification);
@@ -148,19 +152,20 @@
    }
    /**
     * 构建用户待办数量映射
     * 构建用户待办任务 ID 列表映射
     * key: 运维人员 ID,value: 该用户名下的待办任务 ID 列表
     */
    private Map<Long, Integer> buildUserTaskCountMap(List<XpTask> tasks) {
        Map<Long, Integer> userTaskCountMap = new HashMap<>();
    private Map<Long, List<Long>> buildUserTaskIdsMap(List<XpTask> tasks) {
        Map<Long, List<Long>> userTaskIdsMap = new HashMap<>();
        for (XpTask task : tasks) {
            Set<Long> userIds = parseUserIds(task.getHandleUserId());
            if (!CollectionUtils.isEmpty(userIds)) {
                for (Long userId : userIds) {
                    userTaskCountMap.put(userId, userTaskCountMap.getOrDefault(userId, 0) + 1);
                    userTaskIdsMap.computeIfAbsent(userId, k -> new ArrayList<>()).add(task.getId());
                }
            }
        }
        return userTaskCountMap;
        return userTaskIdsMap;
    }
    /**