|
@ -302,7 +302,6 @@ async function deleteReport(ctx) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// TODO 小程序填写道路名称的时候的道路筛选 是一起都返回 还是不断传关键字搜索返回
|
|
|
// TODO 小程序填写道路名称的时候的道路筛选 是一起都返回 还是不断传关键字搜索返回
|
|
|
|
|
|
|
|
|
async function spotPrepare(ctx) { |
|
|
async function spotPrepare(ctx) { |
|
|
try { |
|
|
try { |
|
|
const { models } = ctx.fs.dc; |
|
|
const { models } = ctx.fs.dc; |
|
@ -538,7 +537,6 @@ async function roadSpotPrepare(ctx) { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
let lastCountyPercentage = 0 // 最后一次的县道百分比
|
|
|
let lastCountyPercentage = 0 // 最后一次的县道百分比
|
|
|
|
|
|
|
|
|
let lastCountyRoadIds = [] // 上次查得的县道id
|
|
|
let lastCountyRoadIds = [] // 上次查得的县道id
|
|
|
let lastTownRoadIds = [] // 上次查得的乡镇道id
|
|
|
let lastTownRoadIds = [] // 上次查得的乡镇道id
|
|
|
let lastVillageRoadRoadIds = [] // 上次查得的村道id
|
|
|
let lastVillageRoadRoadIds = [] // 上次查得的村道id
|
|
@ -588,7 +586,6 @@ async function roadSpotPrepare(ctx) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 先查上次没查的范围内的 然后比较百分比 如果重叠 再查上次查过的
|
|
|
// 先查上次没查的范围内的 然后比较百分比 如果重叠 再查上次查过的
|
|
|
|
|
|
|
|
|
let keyMap = { |
|
|
let keyMap = { |
|
|
'县': `route_code LIKE 'X%'`, |
|
|
'县': `route_code LIKE 'X%'`, |
|
|
'乡': `route_code LIKE 'Y%'`, |
|
|
'乡': `route_code LIKE 'Y%'`, |
|
@ -1114,7 +1111,7 @@ async function roadSpotChangList(ctx) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function exportSpotRode(ctx) { |
|
|
async function exportSpotRode (ctx) { |
|
|
try { |
|
|
try { |
|
|
const { models } = ctx.fs.dc; |
|
|
const { models } = ctx.fs.dc; |
|
|
const { previewId } = ctx.query |
|
|
const { previewId } = ctx.query |
|
@ -1164,7 +1161,7 @@ async function exportSpotRode(ctx) { |
|
|
title: '养护次数(次)', |
|
|
title: '养护次数(次)', |
|
|
},] |
|
|
},] |
|
|
|
|
|
|
|
|
function judgeLevel(routeCode) { |
|
|
function judgeLevel (routeCode) { |
|
|
if (routeCode) { |
|
|
if (routeCode) { |
|
|
if (routeCode.startsWith('X')) { |
|
|
if (routeCode.startsWith('X')) { |
|
|
return '县道' |
|
|
return '县道' |
|
@ -1180,7 +1177,7 @@ async function exportSpotRode(ctx) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let exportData = listRes.map(({ dataValues: item }) => { |
|
|
let exportData = listRes.map(({ dataValues: item }) => { |
|
|
let road = item.road.dataValues |
|
|
let road = item.road && item.road.dataValues || {} |
|
|
return { |
|
|
return { |
|
|
level: |
|
|
level: |
|
|
judgeLevel(road.routeCode) |
|
|
judgeLevel(road.routeCode) |
|
@ -1197,14 +1194,15 @@ async function exportSpotRode(ctx) { |
|
|
|
|
|
|
|
|
const fileName = `${moment(previewRes.date).format('YYYY年MM月DD日HH时mm分')}道路抽查记录` + '.csv' |
|
|
const fileName = `${moment(previewRes.date).format('YYYY年MM月DD日HH时mm分')}道路抽查记录` + '.csv' |
|
|
const filePath = await xlsxDownload.simpleExcelDown({ |
|
|
const filePath = await xlsxDownload.simpleExcelDown({ |
|
|
data: exportData, header, fileName: fileName |
|
|
data: exportData, header, fileName: fileName, gather:{data: exportData, header} |
|
|
}) |
|
|
}) |
|
|
const fileData = fs.readFileSync(filePath); |
|
|
const fileData = fs.readFileSync(filePath); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
ctx.status = 200; |
|
|
ctx.set('Content-Type', 'application/x-xls'); |
|
|
ctx.set('Content-Type', 'application/x-xls'); |
|
|
ctx.set('Content-disposition', 'attachment; filename=' + encodeURI(fileName)); |
|
|
ctx.set('Content-disposition', 'attachment; filename=' + encodeURI(fileName)); |
|
|
ctx.body = fileData; |
|
|
ctx.body = fileData |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.status = 400; |
|
|
ctx.status = 400; |
|
|