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: { where: {
checked: true checked: true
}, },
attributes: ['id', 'countyPercentage', 'date',], // attributes: ['id', 'countyPercentage', 'date',],
order: [['date', 'DESC']], order: [['date', 'DESC']],
include: [{ // include: [{
model: models.RoadSpotCheck, // model: models.RoadSpotCheck,
include: [{ // include: [{
model: models.Road, // model: models.Road,
// attributes: ['id', 'name'] // // attributes: ['id', 'name']
}] // }]
}] // }]
}) })
let lastCountyPercentage = 0 // 最后一次的县道百分比 let lastCountyPercentage = 0 // 最后一次的县道百分比
let lastCountyRoadIds = [] // 上次查得的县道id let lastCountyRoadIds = [] // 上次查得的县道id
@ -542,11 +543,45 @@ async function roadSpotPrepare (ctx) {
if (lastSpotRes) { if (lastSpotRes) {
lastCountyPercentage = lastSpotRes.countyPercentage lastCountyPercentage = lastSpotRes.countyPercentage
// 遍历 RoadSpotCheck,保存上次查询的路的id
lastCountyRoadIds = lastSpotRes.countyRoadId || [] lastCountyRoadIds = lastSpotRes.countyRoadId || []
lastTownRoadIds = lastSpotRes.townshipRoadId || []
lastVillageRoadRoadIds = lastSpotRes.villageRoadId || [] let lastCounty = await models.RoadSpotCheckPreview.findAll({
lastVillageIds = lastSpotRes.villageId || [] 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