|
|
@ -701,6 +701,77 @@ async function addMembersBulk(ctx) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//岗位评级
|
|
|
|
async function getPositionRating(ctx) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { limit, page } = ctx.query; |
|
|
|
|
|
|
|
const findObj = {}; |
|
|
|
if (Number(limit) > 0 && Number(page) >= 0) { |
|
|
|
findObj.limit = Number(limit); |
|
|
|
findObj.offset = Number(page) * Number(limit); |
|
|
|
} |
|
|
|
|
|
|
|
const list = await models.PositionRating.findAndCountAll(findObj); |
|
|
|
if (list.rows.length) { |
|
|
|
const userIds = list.rows.map(u => u.pepUserId); |
|
|
|
/**查询user信息 */ |
|
|
|
const { clickHouse } = ctx.app.fs |
|
|
|
const { database: pepEmis } = clickHouse.pepEmis.opts.config |
|
|
|
|
|
|
|
const userRes = await clickHouse.hr.query(` |
|
|
|
SELECT |
|
|
|
user.id as userId, |
|
|
|
user.name AS userName, |
|
|
|
user.people_code AS userCode, |
|
|
|
basicDataPost.name AS userPost, |
|
|
|
department.name AS depName, |
|
|
|
department.id AS depId, |
|
|
|
user.job AS userJob, |
|
|
|
user.active_status AS userActiveStatus, |
|
|
|
user.organization AS userOrganization |
|
|
|
FROM ${pepEmis}.user AS user |
|
|
|
LEFT JOIN ${pepEmis}.basicdata_post AS basicDataPost |
|
|
|
ON ${pepEmis}.basicdata_post.id = user.post |
|
|
|
LEFT JOIN ${pepEmis}.department_user AS department_user |
|
|
|
ON department_user.user = user.id |
|
|
|
LEFT JOIN ${pepEmis}.department AS department |
|
|
|
ON department.id = department_user.department |
|
|
|
where user.id in (${userIds.join(",")} ) |
|
|
|
`).toPromise();
|
|
|
|
|
|
|
|
const rslt = []; |
|
|
|
list.rows.map(item => { |
|
|
|
const userInfo = userRes && userRes.filter(u => item.pepUserId == u.userId); |
|
|
|
item.dataValues.department = userInfo.map(u => { return { depName: u.depName, depId: u.depId } }); |
|
|
|
item.dataValues.userName = userInfo.length && userInfo[0].userName; |
|
|
|
item.d |
|
|
|
rslt.push({ |
|
|
|
...item.dataValues, |
|
|
|
department: userInfo.map(u => { return { depName: u.depName, depId: u.depId } }), |
|
|
|
userName: userInfo.length && userInfo[0].userName, |
|
|
|
userPost: userInfo.length && userInfo[0].userPost |
|
|
|
}); |
|
|
|
}) |
|
|
|
|
|
|
|
ctx.body = { |
|
|
|
rows: rslt, |
|
|
|
count: list.count |
|
|
|
} |
|
|
|
} else { |
|
|
|
ctx.body = list; |
|
|
|
} |
|
|
|
ctx.status = 200; |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { |
|
|
|
message: typeof error == 'string' ? error : undefined |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
module.exports = { |
|
|
|
add, |
|
|
|
edit, |
|
|
@ -714,4 +785,5 @@ module.exports = { |
|
|
|
nativePlaceList, |
|
|
|
workPlaceList, |
|
|
|
maritalList, |
|
|
|
getPositionRating |
|
|
|
} |