R50 通知推送:dispatcher 投递服务、业务事件接入与员工推送开关
这个提交包含在:
@@ -3,11 +3,11 @@ const { z } = require("zod");
|
||||
const { AppError } = require("../utils/AppError");
|
||||
const { buildAuditLogData } = require("../utils/audit");
|
||||
const { issueDocumentNumber } = require("../services/documentSequence");
|
||||
const { createNotifications, resolveRecipientsForAssignee } = require("../services/notifications");
|
||||
const { enqueueImNotifications } = require("../services/notifications/imEnqueue");
|
||||
const { createNotificationsWithRecords, resolveRecipientsForAssignee } = require("../services/notifications");
|
||||
const { sendNotificationEmailSafe } = require("../services/email");
|
||||
const { NOTIFICATION_TYPES } = require("../constants/notificationTypes");
|
||||
const { sendData } = require("../utils/reply");
|
||||
const { flushNotificationDispatchTasks } = require("../services/notificationDispatcher");
|
||||
|
||||
const UUID_SCHEMA = z.string().uuid();
|
||||
const INVENTORY_SCOPE_TYPES = ["all", "legal_entity", "cost_center", "location"];
|
||||
@@ -517,6 +517,7 @@ async function inventoryChecksRoutes(fastify) {
|
||||
async (request, reply) => {
|
||||
const inventoryCheckId = parseUuid("id", request.params?.id);
|
||||
const emailTasks = [];
|
||||
const dispatchTasks = [];
|
||||
const inventoryCheck = await fastify.prisma.$transaction(async (tx) => {
|
||||
const current = await ensureInventoryCheck(tx, inventoryCheckId);
|
||||
ensureCheckStatus(current, "counting");
|
||||
@@ -581,7 +582,7 @@ async function inventoryChecksRoutes(fastify) {
|
||||
const title = `【盘点完成】盘点单 ${updated.check_no}`;
|
||||
const bodyText = `盘点单 ${updated.check_no} 已完成,请在资产盘点中查看结果。`;
|
||||
|
||||
await createNotifications(tx, {
|
||||
const notifications = await createNotificationsWithRecords(tx, {
|
||||
recipientEmployeeIds: recipients,
|
||||
type: NOTIFICATION_TYPES.inventoryCheckCompleted,
|
||||
title,
|
||||
@@ -589,19 +590,14 @@ async function inventoryChecksRoutes(fastify) {
|
||||
targetType: "inventory_check",
|
||||
targetId: updated.id,
|
||||
});
|
||||
|
||||
await enqueueImNotifications(tx, {
|
||||
config: fastify.config,
|
||||
logger: fastify.log,
|
||||
recipientEmployeeIds: recipients,
|
||||
dispatchTasks.push({
|
||||
notifications,
|
||||
type: NOTIFICATION_TYPES.inventoryCheckCompleted,
|
||||
title,
|
||||
body: bodyText,
|
||||
targetType: "inventory_check",
|
||||
targetId: updated.id,
|
||||
targetPath: "/inventory-checks",
|
||||
entityType: "inventory_check",
|
||||
entityId: updated.id,
|
||||
actorId: request.employee.id,
|
||||
});
|
||||
|
||||
@@ -625,6 +621,13 @@ async function inventoryChecksRoutes(fastify) {
|
||||
...task,
|
||||
});
|
||||
}
|
||||
await flushNotificationDispatchTasks({
|
||||
prisma: fastify.prisma,
|
||||
config: fastify.config,
|
||||
logger: fastify.log,
|
||||
requestId: request.id,
|
||||
tasks: dispatchTasks,
|
||||
});
|
||||
|
||||
return sendData(reply, request, { inventoryCheck: mapInventoryCheck(inventoryCheck) });
|
||||
},
|
||||
|
||||
在新工单中引用
屏蔽一个用户