|
|
@ -47,22 +47,8 @@ module.exports = function (app, opts) { |
|
|
|
return [] |
|
|
|
} |
|
|
|
} |
|
|
|
const userRes = await clickHouse.hr.query(` |
|
|
|
SELECT |
|
|
|
hrMember."member.pep_user_id" AS pepUserId, |
|
|
|
hrMember.*, |
|
|
|
user.name AS userName, |
|
|
|
role.name AS roleName, |
|
|
|
role.id AS roleId, |
|
|
|
department.name AS depName, |
|
|
|
department.id AS depId |
|
|
|
FROM ( |
|
|
|
SELECT |
|
|
|
member.*, |
|
|
|
hrVacate.vacateStartTime AS vacateStartTime, |
|
|
|
hrVacate.vacateEndTime AS vacateEndTime, |
|
|
|
hrOvertime.overtimeStartTime AS overtimeStartTime, |
|
|
|
hrOvertime.overtimeEndTime AS overtimeEndTime |
|
|
|
|
|
|
|
const innerSelectQuery = ` |
|
|
|
FROM member |
|
|
|
INNER JOIN ${pepEmis}.user AS user |
|
|
|
ON member.pep_user_id = user.id |
|
|
@ -88,7 +74,7 @@ module.exports = function (app, opts) { |
|
|
|
LEFT JOIN ( |
|
|
|
SELECT |
|
|
|
pep_user_id, |
|
|
|
any(toString(start_time)) AS overtimeStartTime, |
|
|
|
any(start_time) AS overtimeStartTime, |
|
|
|
any(end_time) AS overtimeEndTime |
|
|
|
FROM overtime |
|
|
|
WHERE |
|
|
@ -118,9 +104,28 @@ module.exports = function (app, opts) { |
|
|
|
AND department.name LIKE '%${keyword}%' |
|
|
|
) |
|
|
|
` : ''}
|
|
|
|
${state == 'dimission' ? `AND member.dimission_date IS NOT null` : ''} |
|
|
|
${state == 'onJob' ? `AND member.dimission_date IS null` : ''} |
|
|
|
${state == 'dimission' ? `AND member.dimission_date != '1970-01-01 00:00:00.000000'` : ''} |
|
|
|
${state == 'onJob' ? `AND member.dimission_date = '1970-01-01 00:00:00.000000'` : ''} |
|
|
|
${whereFromSelectOption.length ? `AND ${whereFromSelectOption.join('AND')}` : ''} |
|
|
|
` |
|
|
|
|
|
|
|
const userRes = await clickHouse.hr.query(` |
|
|
|
SELECT |
|
|
|
hrMember."member.pep_user_id" AS pepUserId, |
|
|
|
hrMember.*, |
|
|
|
user.name AS userName, |
|
|
|
role.name AS roleName, |
|
|
|
role.id AS roleId, |
|
|
|
department.name AS depName, |
|
|
|
department.id AS depId |
|
|
|
FROM ( |
|
|
|
SELECT |
|
|
|
member.*, |
|
|
|
hrVacate.vacateStartTime AS vacateStartTime, |
|
|
|
hrVacate.vacateEndTime AS vacateEndTime, |
|
|
|
hrOvertime.overtimeStartTime AS overtimeStartTime, |
|
|
|
hrOvertime.overtimeEndTime AS overtimeEndTime |
|
|
|
${innerSelectQuery} |
|
|
|
${limit ? `LIMIT ${limit}` : ''} |
|
|
|
${limit && page ? 'OFFSET ' + parseInt(limit) * parseInt(page) : ''} |
|
|
|
) AS hrMember |
|
|
@ -138,9 +143,16 @@ module.exports = function (app, opts) { |
|
|
|
${whereOption.length ? `WHERE ${whereOption.join(' AND ')}` : ''} |
|
|
|
`).toPromise()
|
|
|
|
|
|
|
|
const countRes = await clickHouse.hr.query(` |
|
|
|
SELECT |
|
|
|
count(member.pep_user_id) AS count |
|
|
|
${innerSelectQuery} |
|
|
|
`).toPromise()
|
|
|
|
|
|
|
|
|
|
|
|
return userRes |
|
|
|
return { |
|
|
|
count: countRes[0].count, |
|
|
|
rows: userRes |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return { |
|
|
|