|
|
@ -130,7 +130,13 @@ async function addPatrolRecord (ctx, next) { |
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const data = ctx.request.body; |
|
|
|
let { patrolPlanId, lastInspectionTime, inspectionTime, points, alarm, pointId } = data |
|
|
|
let { patrolPlanId, inspectionTime, points, alarm, pointId } = data |
|
|
|
const pointRecord = await models.PatrolRecord.findAll({ |
|
|
|
where: { pointId: pointId }, |
|
|
|
order: [['inspectionTime', 'desc']], |
|
|
|
attributes: ['inspectionTime'], |
|
|
|
}); |
|
|
|
const lastInspectionTime = pointRecord.length ? pointRecord[0].dataValues.inspectionTime : null; |
|
|
|
let record = { patrolPlanId, lastInspectionTime, inspectionTime, points, alarm, pointId } |
|
|
|
|
|
|
|
await models.PatrolRecord.create(record); |
|
|
|