|
@ -10,28 +10,52 @@ async function findPatrolRecord (ctx, next) { |
|
|
if (patrolPlanId == 'all') { |
|
|
if (patrolPlanId == 'all') { |
|
|
/* 如果有startTime && endTime,查询所有符合条件的数据 */ |
|
|
/* 如果有startTime && endTime,查询所有符合条件的数据 */ |
|
|
if (startTime && endTime) { |
|
|
if (startTime && endTime) { |
|
|
rslt = await models.PatrolRecord.findAll({ |
|
|
if (pointId) { |
|
|
where: { alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, |
|
|
rslt = await models.PatrolRecord.findAll({ |
|
|
}); |
|
|
where: { alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
rslt = await models.PatrolRecord.findAll({ |
|
|
|
|
|
where: { alarm, inspectionTime: { $between: [startTime, endTime] } }, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
/* 如果没有startTime && endTime,查询每个点位最新一条符合条件的数据 */ |
|
|
/* 如果没有startTime && endTime,查询每个点位最新一条符合条件的数据 */ |
|
|
a = await models.PatrolRecord.findAll({ |
|
|
let a = [] |
|
|
where: { alarm, pointId: { $in: pointId.split(',') } }, |
|
|
if (pointId) { |
|
|
}); |
|
|
a = await models.PatrolRecord.findAll({ |
|
|
|
|
|
where: { pointId: { $in: pointId.split(',') } }, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
rslt = pointId.split(',').map(i => { |
|
|
rslt = pointId.split(',').map(i => { |
|
|
return a.filter(t => t.pointId === i).sort((a, b) => b.id - a.id)[0] || null |
|
|
return a.filter(t => t.pointId === i).sort((a, b) => b.id - a.id)[0] || null |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
if (startTime && endTime) { |
|
|
if (startTime && endTime) { |
|
|
rslt = await models.PatrolRecord.findAll({ |
|
|
if (pointId) { |
|
|
where: { patrolPlanId: { $in: patrolPlanId.split(',') }, alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, |
|
|
rslt = await models.PatrolRecord.findAll({ |
|
|
}); |
|
|
where: { patrolPlanId: { $in: patrolPlanId.split(',') }, alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
rslt = await models.PatrolRecord.findAll({ |
|
|
|
|
|
where: { patrolPlanId: { $in: patrolPlanId.split(',') }, alarm, inspectionTime: { $between: [startTime, endTime] } }, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
|
|
|
let a = [] |
|
|
/* 如果没有startTime && endTime,查询每个点位最新一条符合条件的数据 */ |
|
|
/* 如果没有startTime && endTime,查询每个点位最新一条符合条件的数据 */ |
|
|
a = await models.PatrolRecord.findAll({ |
|
|
if (pointId) { |
|
|
where: { patrolPlanId: { $in: patrolPlanId.split(',') }, alarm, pointId: { $in: pointId.split(',') } }, |
|
|
a = await models.PatrolRecord.findAll({ |
|
|
}); |
|
|
where: { patrolPlanId: { $in: patrolPlanId.split(',') }, pointId: { $in: pointId.split(',') } }, |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
a = await models.PatrolRecord.findAll({ |
|
|
|
|
|
where: { patrolPlanId: { $in: patrolPlanId.split(',') } }, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
rslt = pointId.split(',').map(i => { |
|
|
rslt = pointId.split(',').map(i => { |
|
|
return a.filter(t => t.pointId === i).sort((a, b) => b.id - a.id)[0] || null |
|
|
return a.filter(t => t.pointId === i).sort((a, b) => b.id - a.id)[0] || null |
|
|
}) |
|
|
}) |
|
|