diff --git a/backend/src/services/risk.service.ts b/backend/src/services/risk.service.ts index 1db0ab4..7a2ff0d 100644 --- a/backend/src/services/risk.service.ts +++ b/backend/src/services/risk.service.ts @@ -488,7 +488,7 @@ export async function detectMonthlyTasks(orgId: string) { */ export async function detectRetirementRisks(orgId: string) { const employees = await prisma.employee.findMany({ - where: { orgId, status: 'ACTIVE', birthDate: { not: null } }, + where: { orgId, status: 'ACTIVE', birthDate: { not: null }, contracts: { some: { contractType: { in: ['FIXED', 'UNFIXED'] } } } }, select: { id: true, name: true, gender: true, birthDate: true, femaleWorkerType: true }, }) @@ -1204,12 +1204,13 @@ export async function getMonthlyCalendar(orgId: string, month: string) { }) } - // 6. 退休日期 + // 6. 退休日期(仅正式劳动合同员工) const retiringEmployees = await prisma.employee.findMany({ where: { orgId, status: 'ACTIVE', retirementDaysLeft: { gte: 0, lte: 365 }, + contracts: { some: { contractType: { in: ['FIXED', 'UNFIXED'] } } }, }, }) for (const emp of retiringEmployees) {