|
|
@ -176,14 +176,32 @@ async function del (ctx) { |
|
|
|
async function list (ctx) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { judgeHoliday } = ctx.app.fs.utils |
|
|
|
const { clickHouse } = ctx.app.fs |
|
|
|
const { database: pepEmis } = clickHouse.pepEmis.opts.config |
|
|
|
const { keywordTarget, keyword, limit, page, state } = ctx.query |
|
|
|
|
|
|
|
let nowTime = moment() |
|
|
|
let whereOption = [] |
|
|
|
if (state == 'dimission') { |
|
|
|
whereOption.push(`member.dimission_date IS NOT null`) |
|
|
|
} |
|
|
|
if (state == 'inOffice') { |
|
|
|
const curDay = moment().format('YYYY-MM-DD') |
|
|
|
const holidayJudge = await judgeHoliday(curDay) |
|
|
|
if (holidayJudge) { |
|
|
|
if ( |
|
|
|
holidayJudge.workday |
|
|
|
&& nowTime.isAfter(moment(curDay + ' 08:30')) |
|
|
|
&& nowTime.isBefore(moment(curDay + ' 17:30')) |
|
|
|
) { |
|
|
|
// 在工作日的工作时间范围
|
|
|
|
} |
|
|
|
} else { |
|
|
|
ctx.body = [] |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
const userRes = await clickHouse.hr.query(` |
|
|
|
SELECT |
|
|
|
member.pep_user_id AS pepUserId, |
|
|
@ -192,7 +210,8 @@ async function list (ctx) { |
|
|
|
role.name AS roleName, |
|
|
|
role.id AS roleId, |
|
|
|
department.name AS depName, |
|
|
|
department.id AS depId |
|
|
|
department.id AS depId, |
|
|
|
vacate.id AS vacateId |
|
|
|
FROM member |
|
|
|
LEFT JOIN ${pepEmis}.user AS user |
|
|
|
ON member.pep_user_id = user.id |
|
|
@ -209,6 +228,7 @@ async function list (ctx) { |
|
|
|
AND vacate.start_time <= '${moment().format('YYYY-MM-DD HH:mm:ss')}' |
|
|
|
AND vacate.end_time > '${moment().format('YYYY-MM-DD HH:mm:ss')}' |
|
|
|
${whereOption.length ? `WHERE ${whereOption.join(' AND ')}` : ''} |
|
|
|
${/** limit 错啦*/''} |
|
|
|
${limit ? `LIMIT ${limit}` : ''} |
|
|
|
${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} |
|
|
|
`).toPromise()
|
|
|
|