|
|
@ -202,7 +202,7 @@ async function exportVacateStatistic (ctx) { |
|
|
|
} = ctx.query |
|
|
|
|
|
|
|
const vacateTypeRes = await clickHouse.hr.query(` |
|
|
|
SELECT type FROM vacate GROUP BY type |
|
|
|
SELECT type FROM vacate GROUP BY type ORDER BY type DESC |
|
|
|
`).toPromise()
|
|
|
|
|
|
|
|
const userRes = await memberList({ |
|
|
@ -223,8 +223,19 @@ async function exportVacateStatistic (ctx) { |
|
|
|
}) |
|
|
|
|
|
|
|
returnD.forEach(u => { |
|
|
|
u.vacateStatistic = sumRes.filter(s => s.pepUserId == u.pepUserId) |
|
|
|
u.vacateDayStatisticDuration = (u.vacateDayStatisticDuration) || 0 / 3600 |
|
|
|
u.departmrnt = u.departmrnt.map(dep => dep.name).join('、') |
|
|
|
u.role = u.role.map(r => r.name).join('、') |
|
|
|
|
|
|
|
let vacateStatistic = sumRes.filter(s => s.pepUserId == u.pepUserId) |
|
|
|
for (let { type } of vacateTypeRes) { |
|
|
|
u[type] = vacateStatistic.reduce((sum, v) => { |
|
|
|
if (v.type == type) { |
|
|
|
sum += v.duration / 3600 |
|
|
|
} |
|
|
|
return sum |
|
|
|
}, 0) |
|
|
|
} |
|
|
|
u.vacateDayStatisticDuration = (u.vacateDayStatisticDuration || 0) / 3600 |
|
|
|
}) |
|
|
|
|
|
|
|
const header = [{ |
|
|
@ -239,15 +250,25 @@ async function exportVacateStatistic (ctx) { |
|
|
|
}, { |
|
|
|
title: '职位', |
|
|
|
key: 'role', |
|
|
|
}, { |
|
|
|
title: '合计请假次数(次)', |
|
|
|
key: 'vacateCount', |
|
|
|
defaultValue: 0, |
|
|
|
}, { |
|
|
|
title: '合计请假时长(小时)', |
|
|
|
key: 'vacateDayStatisticDuration', |
|
|
|
defaultValue: 0, |
|
|
|
}] |
|
|
|
},] |
|
|
|
.concat(vacateTypeRes.map(v => { |
|
|
|
return { |
|
|
|
title: `${v.type}请假时长(小时)`, |
|
|
|
key: v.type, |
|
|
|
defaultValue: '0', |
|
|
|
} |
|
|
|
})) |
|
|
|
.concat( |
|
|
|
[{ |
|
|
|
title: '合计请假次数(次)', |
|
|
|
key: 'vacateCount', |
|
|
|
defaultValue: '0', |
|
|
|
}, { |
|
|
|
title: '合计请假时长(小时)', |
|
|
|
key: 'vacateDayStatisticDuration', |
|
|
|
defaultValue: '0', |
|
|
|
}] |
|
|
|
) |
|
|
|
|
|
|
|
const fileName = `请假统计_${startDate ? moment(startDate).format('YYYY-MM-DD') : ''}-${endDate ? moment(endDate).format('YYYY-MM-DD') : ''}_${moment().format('YYYYMMDDHHmmss')}` + '.csv' |
|
|
|
const filePath = await simpleExcelDown({ data: returnD, header, fileName: fileName }) |
|
|
|