Browse Source

人员编码

master
巴林闲侠 2 years ago
parent
commit
d5a722b1ff
  1. 16
      api/.vscode/launch.json
  2. 16
      api/app/lib/controllers/member/index.js
  3. 15
      api/app/lib/utils/member.js

16
api/.vscode/launch.json

@ -28,9 +28,9 @@
// "--qndmn http://resources.anxinyun.cn", // "--qndmn http://resources.anxinyun.cn",
"--qndmn http://rjkwed13l.hn-bkt.clouddn.com", "--qndmn http://rjkwed13l.hn-bkt.clouddn.com",
// click // click
"--clickHouseUrl http://10.8.30.71", // "--clickHouseUrl http://10.8.30.71",
// click // click
// "--clickHouseUrl http://10.8.30.161", "--clickHouseUrl http://10.8.30.161",
// "--clickHouseUrl https://clickhouse01.anxinyun.cn/play", // "--clickHouseUrl https://clickhouse01.anxinyun.cn/play",
"--clickHousePort 30123", "--clickHousePort 30123",
@ -39,14 +39,14 @@
// "--clickHousePassword ", // "--clickHousePassword ",
// //
"--clickHousePepEmis pepca10", // "--clickHousePepEmis pepca10",
"--clickHouseCamworkflow camworkflow",
"--clickHouseHr hr_dev",
//
// "--clickHousePepEmis pepca8",
// "--clickHouseCamworkflow camworkflow", // "--clickHouseCamworkflow camworkflow",
// "--clickHouseHr hr_dev", // "--clickHouseHr hr_dev",
//
"--clickHousePepEmis pepca8",
"--clickHouseCamworkflow camworkflow",
"--clickHouseHr hr_dev",
] ]
}, },
{ {

16
api/app/lib/controllers/member/index.js

@ -89,17 +89,21 @@ async function searchPepMember (ctx) {
try { try {
const { models } = ctx.fs.dc; const { models } = ctx.fs.dc;
const { clickHouse } = ctx.app.fs const { clickHouse } = ctx.app.fs
const { keyword } = ctx.query const { keyword, code } = ctx.query
let whereOption = [] let whereOption = []
if (keyword) { if (keyword) {
whereOption.push(`user.id = ${keyword}`) // whereOption.push(`user.id = ${keyword}`)
whereOption.push(`user.name LIKE '${keyword}'`) // whereOption.push(`user.name LIKE '${keyword}'`)
}
if (code) {
whereOption.push(`user.people_code = '${code}'`)
} }
const userRes = await clickHouse.pepEmis.query(` const userRes = await clickHouse.pepEmis.query(`
SELECT SELECT
user.id AS pepUserId, user.id AS pepUserId,
user.people_code AS userCode,
user.name AS userName, user.name AS userName,
role.name AS roleName, role.name AS roleName,
role.id AS roleId, role.id AS roleId,
@ -115,7 +119,10 @@ async function searchPepMember (ctx) {
ON department_user.user = user.id ON department_user.user = user.id
LEFT JOIN department LEFT JOIN department
ON department.id = department_user.department ON department.id = department_user.department
${whereOption.length ? `WHERE ${whereOption.join(' OR ')}` : ''} WHERE
user.delete = 0
${whereOption.length ? `AND ${whereOption.join(' OR ')}` : ''}
`).toPromise() `).toPromise()
let returnD = [] let returnD = []
@ -138,6 +145,7 @@ async function searchPepMember (ctx) {
returnD.push({ returnD.push({
pepUserId: u.pepUserId, pepUserId: u.pepUserId,
name: u.userName, name: u.userName,
userCode: u.userCode,
departmrnt: u.depId ? [{ departmrnt: u.depId ? [{
id: u.depId, id: u.depId,
name: u.depName name: u.depName

15
api/app/lib/utils/member.js

@ -13,6 +13,7 @@ module.exports = function (app, opts) {
const nowTime = moment() const nowTime = moment()
let whereOption = [] let whereOption = []
let whereFromSelectOption = [] let whereFromSelectOption = []
let returnEmpty = false
if (state == 'inOffice') { if (state == 'inOffice') {
// 在岗 // 在岗
const holidayJudge = await judgeHoliday(curDay) const holidayJudge = await judgeHoliday(curDay)
@ -25,10 +26,10 @@ module.exports = function (app, opts) {
// 在工作日的工作时间范围 无请假记录 // 在工作日的工作时间范围 无请假记录
whereFromSelectOption.push(`vacateStartTime = '1970-01-01 00:00:00.000000'`) whereFromSelectOption.push(`vacateStartTime = '1970-01-01 00:00:00.000000'`)
} else { } else {
return [] returnEmpty = true
} }
} else { } else {
return [] returnEmpty = true
} }
} }
if (state == 'dayoff') { if (state == 'dayoff') {
@ -41,10 +42,16 @@ module.exports = function (app, opts) {
// 在休息日范围内且无加班申请 // 在休息日范围内且无加班申请
whereFromSelectOption.push(`overtimeStartTime = '1970-01-01 00:00:00.000000'`) whereFromSelectOption.push(`overtimeStartTime = '1970-01-01 00:00:00.000000'`)
} else { } else {
return [] returnEmpty = true
} }
} else { } else {
return [] returnEmpty = true
}
}
if (returnEmpty) {
return {
count: 0,
rows: []
} }
} }

Loading…
Cancel
Save