c618710a52
- SocialInsuranceConfig 版本化(effectiveFrom/effectiveTo/isCurrent/adjustmentDone) - 社保配置版本管理接口(列表/新建/按月获取/当前版本) - 员工基数调整:预览全部在职员工、上年月均工资计算建议基数、可编辑表格、确认后批量保存 - payroll.service 按批次月份匹配对应版本社保配置 - risk.service / seed.ts 同步更新 - 前端社保tab重构为版本管理+调整+试算 - 加班费计算三步流程、CSV导入、批次导入 - UI组件、Dashboard、合同、薪酬等页面优化
121 lines
7.4 KiB
TypeScript
121 lines
7.4 KiB
TypeScript
import prisma from '../src/lib/prisma'
|
|
|
|
const EID = 'cmrx61v6d001oqqcwb2pu2tih'
|
|
const ORGID = 'cmrx61v3l0000qqcwo3dr3h95'
|
|
const UID = 'cmrx61v5u0002qqcwqf4vlyth'
|
|
|
|
async function main() {
|
|
// 加班记录
|
|
const otMonths = [
|
|
{ month: '2025-03', wh: 8, weh: 4, hh: 0, wp: 600, wep: 600, hp: 0, pay: 1200 },
|
|
{ month: '2025-06', wh: 12, weh: 8, hh: 0, wp: 1200, wep: 1200, hp: 0, pay: 2400 },
|
|
{ month: '2025-09', wh: 6, weh: 0, hh: 8, wp: 600, wep: 0, hp: 1200, pay: 1800 },
|
|
]
|
|
for (const o of otMonths) {
|
|
const existing = await prisma.overtimeRecord.findUnique({ where: { employeeId_month: { employeeId: EID, month: o.month } } })
|
|
if (!existing) {
|
|
await prisma.overtimeRecord.create({ data: { orgId: ORGID, employeeId: EID, month: o.month, weekdayHours: o.wh, weekendHours: o.weh, holidayHours: o.hh, weekdayPay: o.wp, weekendPay: o.wep, holidayPay: o.hp, totalPay: o.pay } })
|
|
}
|
|
}
|
|
console.log('加班记录: 完成')
|
|
|
|
// 违纪记录
|
|
const discRecords = [
|
|
{ violationDate: new Date('2025-05-12'), violationType: 'LATE', description: '月度迟到超过5次,影响团队考勤', severity: 'WARNING', action: 'ORAL_WARNING', actionDetail: '口头警告并谈话', employeeAck: true, ackDate: new Date('2025-05-13'), ackMethod: 'SIGN', witness: '王强' },
|
|
{ violationDate: new Date('2025-09-20'), violationType: 'ABSENT', description: '未经请假擅自旷工1天', severity: 'SERIOUS', action: 'DEDUCTION', actionDetail: '扣款200元', employeeAck: true, ackDate: new Date('2025-09-21'), ackMethod: 'SIGN', witness: '王强' },
|
|
]
|
|
for (const d of discRecords) {
|
|
const existing = await prisma.disciplinaryRecord.findFirst({ where: { employeeId: EID, violationDate: d.violationDate } })
|
|
if (!existing) {
|
|
await prisma.disciplinaryRecord.create({ data: { orgId: ORGID, employeeId: EID, createdBy: UID, ...d } })
|
|
}
|
|
}
|
|
console.log('违纪记录: 完成')
|
|
|
|
// 考勤记录 - 最近10个工作日
|
|
const attendance = [
|
|
{ date: '2026-07-10', status: 'NORMAL', late: 0, early: 0 },
|
|
{ date: '2026-07-11', status: 'NORMAL', late: 0, early: 0 },
|
|
{ date: '2026-07-14', status: 'NORMAL', late: 0, early: 0 },
|
|
{ date: '2026-07-15', status: 'NORMAL', late: 0, early: 0 },
|
|
{ date: '2026-07-16', status: 'LATE', late: 25, early: 0 },
|
|
{ date: '2026-07-17', status: 'NORMAL', late: 0, early: 0 },
|
|
{ date: '2026-07-18', status: 'NORMAL', late: 0, early: 0 },
|
|
{ date: '2026-07-21', status: 'NORMAL', late: 0, early: 0 },
|
|
{ date: '2026-07-22', status: 'EARLY_LEAVE', late: 0, early: 30 },
|
|
{ date: '2026-07-23', status: 'NORMAL', late: 0, early: 0 },
|
|
]
|
|
for (const a of attendance) {
|
|
const existing = await prisma.attendanceRecord.findUnique({ where: { employeeId_date: { employeeId: EID, date: new Date(a.date) } } })
|
|
if (!existing) {
|
|
await prisma.attendanceRecord.create({ data: { orgId: ORGID, employeeId: EID, createdBy: UID, date: new Date(a.date), checkInTime: '09:00', checkOutTime: '18:00', status: a.status, lateMinutes: a.late, earlyMinutes: a.early, workHours: 8, overtimeHours: 0 } })
|
|
}
|
|
}
|
|
console.log('考勤记录: 完成')
|
|
|
|
// 培训签收记录
|
|
const trainings = [
|
|
{ trainingDate: new Date('2025-03-15'), topic: '《员工手册》培训', content: '公司规章制度、考勤制度、奖惩条例', trainer: '赵敏', duration: 2, ackStatus: 'SIGNED', ackDate: new Date('2025-03-15'), remark: '新员工入职培训' },
|
|
{ trainingDate: new Date('2025-06-20'), topic: '销售技巧与合规培训', content: '销售话术规范、客户信息保护、合同签订注意事项', trainer: '王强', duration: 4, ackStatus: 'SIGNED', ackDate: new Date('2025-06-20') },
|
|
{ trainingDate: new Date('2026-01-10'), topic: '2026年度规章制度更新培训', content: '新版考勤制度、绩效考核办法、安全生产规范', trainer: '赵敏', duration: 3, ackStatus: 'PENDING', remark: '待员工签收确认' },
|
|
]
|
|
for (const t of trainings) {
|
|
const existing = await prisma.trainingRecord.findFirst({ where: { employeeId: EID, trainingDate: t.trainingDate } })
|
|
if (!existing) {
|
|
await prisma.trainingRecord.create({ data: { orgId: ORGID, employeeId: EID, createdBy: UID, ...t } })
|
|
}
|
|
}
|
|
console.log('培训记录: 完成')
|
|
|
|
// 绩效记录
|
|
const performances = [
|
|
{ period: '2025-Q1', score: 82, grade: 'B', result: 'QUALIFIED', summary: '销售业绩达标,客户维护良好,需提升新客户开发能力', improvementPlan: '', employeeAck: true, ackDate: new Date('2025-04-10'), reviewer: '王强' },
|
|
{ period: '2025-Q2', score: 75, grade: 'B', result: 'QUALIFIED', summary: '业绩略有下滑,新客户开发不足,团队协作有待加强', improvementPlan: '', employeeAck: true, ackDate: new Date('2025-07-08'), reviewer: '王强' },
|
|
{ period: '2025-Q3', score: 68, grade: 'C', result: 'NEED_IMPROVE', summary: '连续3个月未完成销售目标,客户投诉1次', improvementPlan: '调岗至客户维护岗,加强销售技巧培训1个月', employeeAck: true, ackDate: new Date('2025-10-15'), reviewer: '王强' },
|
|
{ period: '2025-Q4', score: 78, grade: 'B', result: 'QUALIFIED', summary: '改进后业绩回升,客户满意度提升', improvementPlan: '', employeeAck: false, reviewer: '王强' },
|
|
]
|
|
for (const p of performances) {
|
|
const existing = await prisma.performanceRecord.findUnique({ where: { employeeId_period: { employeeId: EID, period: p.period } } })
|
|
if (!existing) {
|
|
await prisma.performanceRecord.create({ data: { orgId: ORGID, employeeId: EID, createdBy: UID, ...p } })
|
|
}
|
|
}
|
|
console.log('绩效记录: 完成')
|
|
|
|
// 附件
|
|
const attachments = [
|
|
{ fileName: '吴芳身份证扫描件.pdf', fileType: 'ID_CARD', fileUrl: 'data:application/pdf;base64,placeholder', fileSize: 102400 },
|
|
{ fileName: '吴芳银行卡复印件.jpg', fileType: 'BANK_CARD', fileUrl: 'data:image/jpeg;base64,placeholder', fileSize: 51200 },
|
|
{ fileName: '吴芳劳动合同扫描件.pdf', fileType: 'CONTRACT_SCAN', fileUrl: 'data:application/pdf;base64,placeholder', fileSize: 204800 },
|
|
{ fileName: '吴芳学历证书.jpg', fileType: 'EDUCATION', fileUrl: 'data:image/jpeg;base64,placeholder', fileSize: 81920 },
|
|
]
|
|
for (const a of attachments) {
|
|
const existing = await prisma.employeeAttachment.findFirst({ where: { employeeId: EID, fileName: a.fileName } })
|
|
if (!existing) {
|
|
await prisma.employeeAttachment.create({ data: { ...a, orgId: ORGID, employeeId: EID, uploadedBy: UID } })
|
|
}
|
|
}
|
|
console.log('附件: 完成')
|
|
|
|
// 验证
|
|
const emp = await prisma.employee.findFirst({
|
|
where: { id: EID },
|
|
include: { contracts: true, payslips: true, overtimeRecords: true, disciplinaryRecords: true, attendanceRecords: true, trainingRecords: true, performanceRecords: true, terminations: true, attachments: true }
|
|
})
|
|
if (emp) {
|
|
console.log('--- 吴芳完整档案数据统计 ---')
|
|
console.log('contracts:', emp.contracts.length)
|
|
console.log('payslips:', emp.payslips.length)
|
|
console.log('overtimeRecords:', emp.overtimeRecords.length)
|
|
console.log('disciplinaryRecords:', emp.disciplinaryRecords.length)
|
|
console.log('attendanceRecords:', emp.attendanceRecords.length)
|
|
console.log('trainingRecords:', emp.trainingRecords.length)
|
|
console.log('performanceRecords:', emp.performanceRecords.length)
|
|
console.log('terminations:', emp.terminations.length)
|
|
console.log('attachments:', emp.attachments.length)
|
|
}
|
|
await prisma.$disconnect()
|
|
}
|
|
|
|
main().catch(console.error)
|