|
|
@ -176,19 +176,30 @@ async function addPatrolRecord (ctx, next) { |
|
|
|
attributes: ['inspectionTime'], |
|
|
|
}); |
|
|
|
const lastInspectionTime = pointRecord.length ? pointRecord[0].dataValues.inspectionTime : null; |
|
|
|
let record = { patrolPlanId, lastInspectionTime, inspectionTime, points, alarm, pointId } |
|
|
|
|
|
|
|
const recordRes = await models.PatrolRecord.create(record, transaction); |
|
|
|
const recordRes = await models.PatrolRecord.create( |
|
|
|
// record
|
|
|
|
{ |
|
|
|
patrolPlanId: patrolPlanId, |
|
|
|
lastInspectionTime, |
|
|
|
inspectionTime, |
|
|
|
points, |
|
|
|
alarm, |
|
|
|
pointId: pointId |
|
|
|
} |
|
|
|
, { |
|
|
|
transaction |
|
|
|
}); |
|
|
|
|
|
|
|
if (alarm) { |
|
|
|
await models.PatrolRecord.create({ |
|
|
|
await models.PatrolRecordIssueHandle.create({ |
|
|
|
patrolRecordId: recordRes.id, |
|
|
|
state: 1, |
|
|
|
}, transaction); |
|
|
|
}, { transaction }); |
|
|
|
} |
|
|
|
// 更新巡检次数统计
|
|
|
|
const curPlanRecord = await models.PatrolRecord.findAndCountAll({ |
|
|
|
where: { patrolPlanId } |
|
|
|
where: { patrolPlanId: patrolPlanId } |
|
|
|
}); |
|
|
|
|
|
|
|
const patrolCount = curPlanRecord.count; |
|
|
|