|
|
@ -25,39 +25,46 @@ async function getMaintenancePlan(ctx) { |
|
|
|
}) |
|
|
|
//console.log('res1', res)
|
|
|
|
const arrayUserId = [] |
|
|
|
res.rows.forEach((item) => { item.maintenancePlanExecuteUsers.forEach((item1) => { arrayUserId.push(item1.pepUserId) }) }) |
|
|
|
const arrayUserIdCopy = [...new Set(arrayUserId)] |
|
|
|
//(${ [...pepProjectIds].join(',') }, -1)
|
|
|
|
const userRes = await clickHouse.pepEmis.query(` |
|
|
|
SELECT * FROM user |
|
|
|
WHERE id IN (${[...arrayUserIdCopy].join(',')},-1) |
|
|
|
`).toPromise()
|
|
|
|
//console.log('userRes', userRes)
|
|
|
|
//console.log('res.rows', res.rows)
|
|
|
|
const responseRes = res.rows.map((item) => { |
|
|
|
return { |
|
|
|
id: item.id, |
|
|
|
missionName: item.missionName, |
|
|
|
remark: item.remark, |
|
|
|
reason: item.reason, |
|
|
|
planFinishTime: item.planFinishTime, |
|
|
|
actualFinishTime: item.actualFinishTime, |
|
|
|
type: item.type, |
|
|
|
state: item.state, |
|
|
|
maintenancePlanExecuteUsers: |
|
|
|
item.maintenancePlanExecuteUsers.map((item1) => { |
|
|
|
return { |
|
|
|
id: item1.id, |
|
|
|
maintenancePlanId: item1.maintenancePlanId, |
|
|
|
pepUserId: item1.pepUserId, |
|
|
|
name: userRes.filter((ac) => { return ac.id == item1.pepUserId })[0].name |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
ctx.body = { count: resCount, responseRes } |
|
|
|
//console.log('responseRes', responseRes)
|
|
|
|
ctx.status = 200 |
|
|
|
if (res.rows.length > 0) { |
|
|
|
res.rows.forEach((item) => { item.maintenancePlanExecuteUsers.forEach((item1) => { arrayUserId.push(item1.pepUserId) }) }) |
|
|
|
const arrayUserIdCopy = [...new Set(arrayUserId)] |
|
|
|
//(${ [...pepProjectIds].join(',') }, -1)
|
|
|
|
const userRes = await clickHouse.pepEmis.query(` |
|
|
|
SELECT * FROM user |
|
|
|
WHERE id IN (${[...arrayUserIdCopy].join(',')},-1)`).toPromise()
|
|
|
|
//console.log('userRes', userRes)
|
|
|
|
//console.log('res.rows', res.rows)
|
|
|
|
const responseRes = res.rows.map((item) => { |
|
|
|
return { |
|
|
|
id: item.id, |
|
|
|
missionName: item.missionName, |
|
|
|
remark: item.remark, |
|
|
|
reason: item.reason, |
|
|
|
planFinishTime: item.planFinishTime, |
|
|
|
actualFinishTime: item.actualFinishTime, |
|
|
|
type: item.type, |
|
|
|
state: item.state, |
|
|
|
maintenancePlanExecuteUsers: |
|
|
|
item.maintenancePlanExecuteUsers.map((item1) => { |
|
|
|
const nameArr = userRes.filter((ac) => { return ac.id == item1.pepUserId })[0] |
|
|
|
return { |
|
|
|
id: item1.id, |
|
|
|
maintenancePlanId: item1.maintenancePlanId, |
|
|
|
pepUserId: item1.pepUserId, |
|
|
|
name: nameArr ? nameArr.name : '' |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
ctx.body = { count: resCount, responseRes } |
|
|
|
//console.log('responseRes', responseRes)
|
|
|
|
ctx.status = 200 |
|
|
|
} else { |
|
|
|
ctx.body = { count: resCount, responseRes: [] } |
|
|
|
ctx.status = 200 |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`) |
|
|
|