feat: 新增可配置通知中心,支持扫描式/埋点式通知规则与手动群发
新增通知规则实体、扫描任务、API与管理界面,重构站内通知支持用户/电工双类型,移除硬编码的证照到期提醒,新增工单派单、电工审核结果等通知触发场景,调整菜单与数据库结构适配新通知体系。
This commit is contained in:
1 parent
91aa3c06f0
commit
6cf6a3d5b9
36 files changed
+3309
-246
No files matched your search
@@ -14,6 +14,7 @@ import SysUserRole from "../entity/sysUserRole.entity";
|
||||
import SysRole from "../entity/sysRole.entity";
|
||||
import { UploadService } from "./upload.service";
|
||||
import { LogService } from "./log.service";
|
||||
import { NoticeRuleService } from "./notice_rule.service";
|
||||
|
||||
// 勘察工单状态:0待指派 1现场勘察中 2待技术复核 3已归档 4预留 5已取消
|
||||
const STATUS = { PENDING_ASSIGN: 0, SURVEYING: 1, PENDING_REVIEW: 2, ARCHIVED: 3, RESERVED: 4, CANCELED: 5 };
|
||||
@@ -61,6 +62,9 @@ export class SurveyOrderService {
|
||||
@Inject()
|
||||
logService!: LogService;
|
||||
|
||||
@Inject()
|
||||
noticeRuleService!: NoticeRuleService;
|
||||
|
||||
private async isAdmin(userId: number): Promise<boolean> {
|
||||
const userRoles = await this.userRoleModel.findAll({ where: { userId }, include: [this.roleModel] });
|
||||
return userRoles.some((ur) => (ur as any).role?.roleCode === "ADMIN");
|
||||
@@ -526,6 +530,20 @@ export class SurveyOrderService {
|
||||
};
|
||||
if (estimatedFee !== undefined && estimatedFee !== null) patch.estimatedFee = estimatedFee;
|
||||
await record.update(patch);
|
||||
// 指派站内通知(埋点式;通知失败不得阻断业务)
|
||||
try {
|
||||
await this.noticeRuleService.notifyDispatchAssign({
|
||||
orderTypeName: "勘察",
|
||||
orderNo: record.surveyNo,
|
||||
customerId: Number(record.customerId),
|
||||
workerId: Number(worker.id),
|
||||
detailText: record.taskTitle ? `任务:${record.taskTitle}。` : "",
|
||||
bizType: "survey_order",
|
||||
bizId: Number(record.id)
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("[notice] 勘察派单通知失败:", err);
|
||||
}
|
||||
const vo = this.toVO(record);
|
||||
await this.decorate([vo]);
|
||||
return { ok: true, data: vo };
|
||||
|
||||
Reference in new issue
Block a user