From 5dd92a0e2052821e261a60ffecdc859b5c2ce421 Mon Sep 17 00:00:00 2001 From: selfrelease Date: Sat, 1 Aug 2026 15:14:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=88=E5=90=8C=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=9C=AA=E7=AD=BE=E5=90=88=E5=90=8C=E7=BB=9F=E8=AE=A1=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原查询查contractType=UNSIGNED的合同数(=0),但实际有12名员工完全无合同记录。 改为查contracts: { none: {} }的在职员工数,getHealthCheck和getComplianceScore均修复。 --- backend/src/services/risk.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/src/services/risk.service.ts b/backend/src/services/risk.service.ts index eae8a1d..727fa34 100644 --- a/backend/src/services/risk.service.ts +++ b/backend/src/services/risk.service.ts @@ -1408,7 +1408,8 @@ export async function getComplianceScore(orgId: string) { lastMonthRisks, ] = await Promise.all([ prisma.employee.count({ where: { orgId, status: 'ACTIVE' } }), - prisma.laborContract.count({ where: { orgId, contractType: 'UNSIGNED', employee: { status: 'ACTIVE' } } }), + // 未签合同:完全无合同记录的在职员工 + prisma.employee.count({ where: { orgId, status: 'ACTIVE', contracts: { none: {} } } }), prisma.laborContract.count({ where: { orgId, @@ -1583,7 +1584,8 @@ export async function getHealthCheck(orgId: string) { totalPayslips, ] = await Promise.all([ prisma.employee.count({ where: { orgId, status: 'ACTIVE' } }), - prisma.laborContract.count({ where: { orgId, contractType: 'UNSIGNED', employee: { status: 'ACTIVE' } } }), + // 未签合同:完全无合同记录的在职员工 + prisma.employee.count({ where: { orgId, status: 'ACTIVE', contracts: { none: {} } } }), prisma.laborContract.count({ where: { orgId,