feat(通知): 品牌/采集数据部分失败改为「已交付」提醒,用户不再只看到成功

BRAND 与 COLLECT_DATA 的结果里没有承载「N 行查询失败」的字段,这类任务此前一律显示成功,
用户要到 Excel 里逐行看才发现缺数据。上架模块不需要这条通道——它的历史详情已经通过
SimilarAsinHistoryAssembler 把 result.notice 透出到前端。

新增 NotificationDispatchService.pushPartialResult:复用既有 SCENE_TASK_FAILED/LEVEL_WARNING
场景与 dedupe_key 机制(task_partial:<taskId>),不新增 scene、不加迁移、不动前端枚举。
品牌侧在 finalizeTask 里 deleteTaskData 之前推送,避免统计数据被清库后读不到。
This commit is contained in:
2026-09-27 11:24:51 +08:00
parent 6e5c0df1a4
commit 486c3b2766
7 changed files with 66 additions and 4 deletions
@@ -1,6 +1,7 @@
package com.nanri.aiimage.modules.notification.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.nanri.aiimage.common.module.TaskModuleRegistry;
import com.nanri.aiimage.common.security.AdminAuthSupport;
import com.nanri.aiimage.common.mapper.AdminUserMapper;
import com.nanri.aiimage.common.model.entity.AdminUserEntity;
@@ -72,6 +73,30 @@ public class NotificationDispatchService {
return pushed;
}
/**
* 「任务成功,但有一部分行没跑出来」通知:整任务没失败、铃铛里的 task_failed 只覆盖终态失败,
* 这类部分缺失过去对用户完全不可见(品牌检测的查询失败行只躺在结果文件的一张子表里)。
*
* <p>场景沿用 {@code task_failed}(大类仍是「任务异常」),去重键按任务维度:同一任务重复
* 组装结果时刷新内容而不是刷屏。不写 task.errorMessage —— 结果组装的失败判据读那个字段,
* 写了会把任务翻成 FAILED,与「状态保持成功、只提示交付不完整」的产品口径相悖。
*/
public void pushPartialResult(Long userId, Long taskId, String moduleType, String taskNo, String detail) {
if (userId == null || userId <= 0 || taskId == null || detail == null || detail.isBlank()) {
return;
}
String title = TaskModuleRegistry.labelOf(moduleType) + "任务部分结果缺失";
String displayTaskNo = taskNo == null || taskNo.isBlank() ? "#" + taskId : taskNo.trim();
notificationService.pushOrRefresh(userId, NotificationService.AUDIENCE_USER,
NotificationService.SCENE_TASK_FAILED, NotificationService.LEVEL_WARNING,
title, "任务 " + displayTaskNo + ":" + detail + "。任务已完成,其余结果正常,可在结果文件里查看缺失清单。",
"task_partial:" + taskId);
pushToAdmins(NotificationService.SCENE_TASK_FAILED, NotificationService.LEVEL_WARNING,
"用户" + title,
"用户 " + displayNameOf(userId) + "(uid=" + userId + ")任务 " + displayTaskNo + ":" + detail,
"task_partial_admin:" + taskId, userId);
}
/** 解析管理员受众:全部超管 + 管理员(非管理员角色一律排除),并预取各管理员可见用户集。 */
public AdminAudience prepareAdminAudience() {
List<AdminUserEntity> candidates = adminUserMapper.selectList(new LambdaQueryWrapper<AdminUserEntity>()