fix: 年度价值报告只统计人工解决的风险,排除系统自动关闭

- 员工离职时系统自动将PENDING风险标记为RESOLVED(resolvedBy=null)
- 这些风险并未被真正解决,不应计入规避损失
- 年度报告所有RESOLVED查询加 resolvedBy: { not: null } 条件
- 只有用户在待办中点击完成的才算真正规避
This commit is contained in:
selfrelease
2026-07-31 09:49:40 +08:00
parent c7f270e8df
commit de73d20d68
+4 -1
View File
@@ -1557,12 +1557,14 @@ export async function getAnnualValueReport(orgId: string, year: number) {
prisma.riskItem.count({
where: {
orgId, status: 'RESOLVED',
resolvedBy: { not: null },
resolvedAt: { gte: yearStart, lte: yearEnd },
},
}),
prisma.riskItem.aggregate({
where: {
orgId, status: 'RESOLVED', estimatedLoss: { gt: 0 },
resolvedBy: { not: null },
resolvedAt: { gte: yearStart, lte: yearEnd },
},
_sum: { estimatedLoss: true },
@@ -1615,10 +1617,11 @@ export async function getAnnualValueReport(orgId: string, year: number) {
}).then((count) => ({ month: m + 1, count })),
),
),
// 按员工维度的解决风险明细
// 按员工维度的人工解决风险明细(排除系统自动关闭的,只算用户真正处理过的)
prisma.riskItem.findMany({
where: {
orgId, status: 'RESOLVED',
resolvedBy: { not: null },
resolvedAt: { gte: yearStart, lte: yearEnd },
},
include: {