Browse Source

道路抽查调整

dev
wenlele 1 year ago
parent
commit
e23268b048
  1. 59
      api/app/lib/controllers/report/index.js

59
api/app/lib/controllers/report/index.js

@ -523,16 +523,17 @@ async function roadSpotPrepare (ctx) {
where: {
checked: true
},
attributes: ['id', 'countyPercentage', 'date',],
// attributes: ['id', 'countyPercentage', 'date',],
order: [['date', 'DESC']],
include: [{
model: models.RoadSpotCheck,
include: [{
model: models.Road,
// attributes: ['id', 'name']
}]
}]
// include: [{
// model: models.RoadSpotCheck,
// include: [{
// model: models.Road,
// // attributes: ['id', 'name']
// }]
// }]
})
let lastCountyPercentage = 0 // 最后一次的县道百分比
let lastCountyRoadIds = [] // 上次查得的县道id
@ -542,11 +543,45 @@ async function roadSpotPrepare (ctx) {
if (lastSpotRes) {
lastCountyPercentage = lastSpotRes.countyPercentage
// 遍历 RoadSpotCheck,保存上次查询的路的id
lastCountyRoadIds = lastSpotRes.countyRoadId || []
lastTownRoadIds = lastSpotRes.townshipRoadId || []
lastVillageRoadRoadIds = lastSpotRes.villageRoadId || []
lastVillageIds = lastSpotRes.villageId || []
let lastCounty = await models.RoadSpotCheckPreview.findAll({
where: {
checked: true,
id: { $lt: lastSpotRes.id }
},
limit: 3,
order: [['date', 'DESC']],
})
if (lastCounty) {
lastCounty.forEach(d => {
lastTownRoadIds = lastTownRoadIds.concat(d.townshipRoadId) || []
})
}
let lastVillage = await models.RoadSpotCheckPreview.findAll({
where: {
checked: true,
id: { $lt: lastSpotRes.id }
},
limit: 9,
order: [['date', 'DESC']],
})
if (lastVillage) {
lastVillage.forEach(d => {
lastVillageRoadRoadIds = lastVillageRoadRoadIds.concat(d.villageRoadId) || []
lastVillageIds = lastVillageIds.concat(d.villageId) || []
})
}
// lastTownRoadIds = lastSpotRes.townshipRoadId || []
// lastVillageRoadRoadIds = lastSpotRes.villageRoadId || []
// lastVillageIds = lastSpotRes.villageId || []
}
// 先查上次没查的范围内的 然后比较百分比 如果重叠 再查上次查过的

Loading…
Cancel
Save