|
|
@ -151,8 +151,14 @@ async function addPatrolRecord(ctx, next) { |
|
|
|
const lastInspectionTime = pointRecord.length ? pointRecord[0].dataValues.inspectionTime : null; |
|
|
|
let record = { patrolPlanId, lastInspectionTime, inspectionTime, points, alarm, pointId } |
|
|
|
|
|
|
|
await models.PatrolRecord.create(record, transaction); |
|
|
|
const recordRes = await models.PatrolRecord.create(record, transaction); |
|
|
|
|
|
|
|
if (alarm) { |
|
|
|
await models.PatrolRecord.create({ |
|
|
|
patrolRecordId: recordRes.id, |
|
|
|
state: 1, |
|
|
|
}, transaction); |
|
|
|
} |
|
|
|
// 更新巡检次数统计
|
|
|
|
const curPlanRecord = await models.PatrolRecord.findAndCountAll({ |
|
|
|
where: { patrolPlanId } |
|
|
@ -177,6 +183,49 @@ async function addPatrolRecord(ctx, next) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function getPatrolRecordIssueHandle (ctx) { |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { userId, userInfo } = ctx.fs.api |
|
|
|
|
|
|
|
const { type, } = ctx.query |
|
|
|
|
|
|
|
let findOption = { |
|
|
|
where: { |
|
|
|
|
|
|
|
}, |
|
|
|
include: [{ |
|
|
|
model: models.PatrolRecord |
|
|
|
}] |
|
|
|
} |
|
|
|
|
|
|
|
if (type == 'backlog') { |
|
|
|
// 待办
|
|
|
|
let stateArr = [] |
|
|
|
if (userInfo) { |
|
|
|
|
|
|
|
} |
|
|
|
findOption.where = { |
|
|
|
...findOption.where, |
|
|
|
|
|
|
|
} |
|
|
|
} else if (type == 'haveDone') { |
|
|
|
// 已办
|
|
|
|
} |
|
|
|
|
|
|
|
const res = await models.findAll(findOption) |
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
|
ctx.body = {} |
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { |
|
|
|
message: typeof error == 'string' ? error : undefined |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 新建维修处理计划成功
|
|
|
|
function addPatrolRecordIssueHandle (opts) { |
|
|
|
return async function (ctx, next) { |
|
|
@ -222,6 +271,7 @@ function editPatrolRecordIssueHandle(opts) { |
|
|
|
module.exports = { |
|
|
|
findPatrolRecord, |
|
|
|
addPatrolRecord, |
|
|
|
getPatrolRecordIssueHandle, |
|
|
|
addPatrolRecordIssueHandle, |
|
|
|
editPatrolRecordIssueHandle |
|
|
|
|
|
|
|