diff --git a/api/app/lib/controllers/patrolRecord/patrolRecord.js b/api/app/lib/controllers/patrolRecord/patrolRecord.js index 8f5893c..cc1dd8b 100644 --- a/api/app/lib/controllers/patrolRecord/patrolRecord.js +++ b/api/app/lib/controllers/patrolRecord/patrolRecord.js @@ -11,13 +11,25 @@ async function findPatrolRecord (ctx, next) { /* 如果有startTime && endTime,查询所有符合条件的数据 */ if (startTime !== 'null' && endTime !== 'null') { if (pointId) { - rslt = await models.PatrolRecord.findAll({ - where: { alarm, inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, - }); + if (alarm == 'null') { + rslt = await models.PatrolRecord.findAll({ + where: { inspectionTime: { $between: [startTime, endTime] }, pointId: { $in: pointId.split(',') } }, + }); + } else { + 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] } }, - }); + if (alarm == 'null') { + rslt = await models.PatrolRecord.findAll({ + where: { inspectionTime: { $between: [startTime, endTime] } }, + }); + } else { + rslt = await models.PatrolRecord.findAll({ + where: { alarm, inspectionTime: { $between: [startTime, endTime] } }, + }); + } } } else { /* 如果没有startTime && endTime,查询每个点位最新一条符合条件的数据 */