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