fix: 用工体检诊断数据修正
1. 合同管理:移除合同附件扣分(查所有历史合同导致624虚高,附件非合规问题) 2. 规章制度:democracyProgress是JSONB不能用lt查询,改用status!=PUBLISHED 3. 社保/公积金记录异常:按员工去重,避免一个员工多条记录被重复计数 4. getComplianceScore中同样的democracyProgress查询问题修复
This commit is contained in:
@@ -1419,7 +1419,7 @@ export async function getComplianceScore(orgId: string) {
|
||||
prisma.riskItem.count({ where: { orgId, status: 'PENDING' } }),
|
||||
prisma.riskItem.count({ where: { orgId, status: 'PENDING', level: 'HIGH' } }),
|
||||
prisma.riskItem.count({ where: { orgId, status: 'RESOLVED' } }),
|
||||
prisma.policyDocument.count({ where: { orgId, democracyProgress: { lt: 4 } } }),
|
||||
prisma.policyDocument.count({ where: { orgId, status: { not: 'PUBLISHED' } } }),
|
||||
prisma.attendanceConfirmation.count({ where: { orgId, status: 'PENDING' } }),
|
||||
prisma.payslip.count({ where: { orgId, confirmedAt: null } }),
|
||||
prisma.payslip.count({ where: { orgId } }),
|
||||
@@ -1589,12 +1589,14 @@ export async function getHealthCheck(orgId: string) {
|
||||
},
|
||||
}),
|
||||
prisma.laborContract.count({ where: { orgId, attachmentUrl: null, employee: { status: 'ACTIVE' } } }),
|
||||
prisma.policyDocument.count({ where: { orgId, democracyProgress: { lt: 4 } } }),
|
||||
// democracyProgress 是 JSONB,用 status 字段判断未完成
|
||||
prisma.policyDocument.count({ where: { orgId, status: { not: 'PUBLISHED' } } }),
|
||||
prisma.policyDocument.count({ where: { orgId } }),
|
||||
prisma.socialInsuranceConfig.findFirst({ where: { orgId, isCurrent: true } }),
|
||||
prisma.housingFundConfig.findFirst({ where: { orgId, isCurrent: true } }),
|
||||
prisma.employeeSocialInsRecord.count({ where: { orgId, endMonth: null } }),
|
||||
prisma.employeeHousingFundRecord.count({ where: { orgId, endMonth: null } }),
|
||||
// 社保/公积金记录按员工去重
|
||||
prisma.employeeSocialInsRecord.groupBy({ by: ['employeeId'], where: { orgId, endMonth: null }, _count: true }).then(r => r.length),
|
||||
prisma.employeeHousingFundRecord.groupBy({ by: ['employeeId'], where: { orgId, endMonth: null }, _count: true }).then(r => r.length),
|
||||
prisma.employee.count({ where: { orgId, status: 'ACTIVE', id: { notIn: [] } } }),
|
||||
prisma.overtimeRecord.count({ where: { orgId, weekdayHours: { gt: 36 } } }),
|
||||
prisma.employee.count({ where: { orgId, status: 'ACTIVE', contracts: { none: { contractType: 'FIXED' } } } }),
|
||||
|
||||
Reference in New Issue
Block a user