巴林闲侠
2 years ago
20 changed files with 483 additions and 27 deletions
@ -0,0 +1,153 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const areaCode = { |
||||
|
"360121100000": "莲塘镇", |
||||
|
"360121101000": "向塘镇", |
||||
|
"360121102000": "三江镇", |
||||
|
"360121103000": "塘南镇", |
||||
|
"360121104000": "幽兰镇", |
||||
|
"360121105000": "蒋巷镇", |
||||
|
"360121106000": "武阳镇", |
||||
|
"360121107000": "冈上镇", |
||||
|
"360121108000": "广福镇", |
||||
|
"360121191000": "昌东镇", |
||||
|
"360121192000": "麻丘镇", |
||||
|
"360121200000": "泾口乡", |
||||
|
"360121201000": "南新乡", |
||||
|
"360121202000": "塔城乡", |
||||
|
"360121203000": "黄马乡", |
||||
|
"360121204000": "富山乡", |
||||
|
"360121205000": "东新乡", |
||||
|
"360121206000": "八一乡", |
||||
|
"360121403000": "小蓝经济开发区", |
||||
|
"360121471000": "银三角管理委员会", |
||||
|
"360121501000": "五星垦殖场", |
||||
|
"360121572000": "良种繁殖场", |
||||
|
} |
||||
|
|
||||
|
async function roadState (ctx) { |
||||
|
try { |
||||
|
const models = ctx.fs.dc.models; |
||||
|
const { userId } = ctx.fs.api; |
||||
|
|
||||
|
const roadRes = await models.Road.findAll({}) |
||||
|
const projectRoadRes = await models.Project.findAll({ |
||||
|
type: 'road', |
||||
|
}) |
||||
|
|
||||
|
const roadState = { |
||||
|
// 在建数量
|
||||
|
buildingRoad: 0, |
||||
|
// 已建数量
|
||||
|
buildedRoad: 0, |
||||
|
// 乡镇统计
|
||||
|
townRoad: { |
||||
|
|
||||
|
}, |
||||
|
// 类型统计
|
||||
|
roadType: { |
||||
|
'县': 0, |
||||
|
'乡': 0, |
||||
|
'村': 0, |
||||
|
}, |
||||
|
// 在建项目统计
|
||||
|
townProject: { |
||||
|
|
||||
|
}, |
||||
|
// 等级统计
|
||||
|
roadLevel: { |
||||
|
|
||||
|
}, |
||||
|
// 养护周期
|
||||
|
curingPeriod: { |
||||
|
frequent: 0, |
||||
|
season: 0, |
||||
|
}, |
||||
|
// 绿化里程
|
||||
|
greenMileage: { |
||||
|
'县': { |
||||
|
canBeGreen: 0, |
||||
|
isGreen: 0, |
||||
|
}, |
||||
|
'乡': { |
||||
|
canBeGreen: 0, |
||||
|
isGreen: 0, |
||||
|
}, |
||||
|
'村': { |
||||
|
canBeGreen: 0, |
||||
|
isGreen: 0, |
||||
|
}, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
let roadCode = new Set() |
||||
|
|
||||
|
for (let r of roadRes) { |
||||
|
roadCode.add(r.routeCode) |
||||
|
let townName = areaCode[r.townshipCode] || '其他' |
||||
|
if (roadState.townRoad[townName]) { |
||||
|
roadState.townRoad[townName].roadCode.add(r.routeCode) |
||||
|
roadState.townRoad[townName].mileage += Number(r.chainageMileage) || 0 |
||||
|
} else { |
||||
|
roadState.townRoad[townName] = { |
||||
|
roadCode: new Set([r.routeCode]), |
||||
|
mileage: Number(r.chainageMileage) || 0, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
roadState.roadType[r.level] = (roadState.roadType[r.level] || 0) + (Number(r.chainageMileage) || 0) |
||||
|
|
||||
|
if (roadState.roadLevel[r.technicalLevel]) { |
||||
|
roadState.roadLevel[r.technicalLevel] += 1 |
||||
|
} else { |
||||
|
roadState.roadLevel[r.technicalLevel] = 1 |
||||
|
} |
||||
|
|
||||
|
if (r.curingTime) { |
||||
|
if (r.curingTime.indexOf('经常') > -1) { |
||||
|
roadState.curingPeriod.frequent += 1 |
||||
|
} else if (r.curingTime.indexOf('季节') > -1) { |
||||
|
roadState.curingPeriod.season += 1 |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
roadState.greenMileage[r.level].canBeGreen += (Number(r.greeningMileage) || 0) |
||||
|
roadState.greenMileage[r.level].isGreen += (Number(r.greeningMileaged) || 0) |
||||
|
} |
||||
|
for (let p of projectRoadRes) { |
||||
|
if (p.type == 'road') { |
||||
|
if (p.done) { |
||||
|
roadState.buildedRoad += 1 |
||||
|
} else { |
||||
|
roadState.buildingRoad += 1 |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
let townName = p.buildUnit.replace('人民政府', '').replace('南昌县', '').replace('管委会', '') |
||||
|
if (roadState.townProject[townName]) { |
||||
|
roadState.townProject[townName] += 1 |
||||
|
} else { |
||||
|
roadState.townProject[townName] = 1 |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
roadState.buildedRoad += roadCode.size |
||||
|
for (let t of Object.keys(roadState.townRoad)) { |
||||
|
roadState.townRoad[t].roadCount = roadState.townRoad[t].roadCode.size |
||||
|
delete roadState.townRoad[t].roadCode |
||||
|
} |
||||
|
|
||||
|
ctx.status = 200 |
||||
|
ctx.body = roadState |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { |
||||
|
message: typeof error == 'string' ? error : undefined |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
roadState, |
||||
|
}; |
@ -0,0 +1,2 @@ |
|||||
|
'use strict'; |
||||
|
|
@ -0,0 +1,68 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
async function overSpeedList (ctx) { |
||||
|
try { |
||||
|
const models = ctx.fs.dc.models; |
||||
|
const { userId } = ctx.fs.api; |
||||
|
|
||||
|
const overSpeedRes = await models.Overspeed.findAll({ |
||||
|
attributes: ['id', 'licensePlate', 'overrunRate', 'deductPoints', 'fine', 'processingTime'], |
||||
|
order: [['testTime', 'DESC']], |
||||
|
}) |
||||
|
|
||||
|
ctx.status = 200 |
||||
|
ctx.body = { |
||||
|
processed: overSpeedRes.filter(s => s.processingTime).length, |
||||
|
overSpeedList: overSpeedRes, |
||||
|
} |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { |
||||
|
message: typeof error == 'string' ? error : undefined |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
async function overSpeedProcessed (ctx) { |
||||
|
try { |
||||
|
const models = ctx.fs.dc.models; |
||||
|
const { userId } = ctx.fs.api; |
||||
|
|
||||
|
const overSpeedCountRes = await models.Overspeed.count({ |
||||
|
attributes: ['nameOfInspectionPoint'], |
||||
|
group: ['nameOfInspectionPoint'], |
||||
|
}) |
||||
|
const overSpeedCountProcessedRes = await models.Overspeed.count({ |
||||
|
attributes: ['nameOfInspectionPoint'], |
||||
|
where: { processingTime: { $ne: null } }, |
||||
|
group: ['nameOfInspectionPoint'], |
||||
|
}) |
||||
|
|
||||
|
let data = [] |
||||
|
for (let c of overSpeedCountRes) { |
||||
|
const corProcessed = overSpeedCountProcessedRes.find(d => d.nameOfInspectionPoint == c.nameOfInspectionPoint) |
||||
|
if (corProcessed) { |
||||
|
data.push({ |
||||
|
name: c.nameOfInspectionPoint, |
||||
|
processed: corProcessed.count, |
||||
|
total: c.count, |
||||
|
}) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ctx.status = 200 |
||||
|
ctx.body = data |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { |
||||
|
message: typeof error == 'string' ? error : undefined |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
overSpeedList, |
||||
|
overSpeedProcessed |
||||
|
}; |
@ -0,0 +1,49 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
async function busCarLevelList (ctx) { |
||||
|
try { |
||||
|
const models = ctx.fs.dc.models; |
||||
|
const { userId } = ctx.fs.api; |
||||
|
|
||||
|
let data = [] |
||||
|
const busCarRes = await models.BusCar.findAll({ |
||||
|
attributes: ['id', 'company', 'fleet', 'vehicleLicensePlateNumber'], |
||||
|
}) |
||||
|
for (let c of busCarRes) { |
||||
|
const { company, fleet } = c |
||||
|
const corCompany = data.find(d => d.name === company) |
||||
|
if (!corCompany) { |
||||
|
data.push({ |
||||
|
name: company, |
||||
|
child: [{ |
||||
|
name: fleet, |
||||
|
child: [{ ...c.dataValues }] |
||||
|
}] |
||||
|
}) |
||||
|
} else { |
||||
|
const corFleet = corCompany.child.find(d => d.name === fleet) |
||||
|
if (!corFleet) { |
||||
|
corCompany.child.push({ |
||||
|
name: fleet, |
||||
|
child: [{ ...c.dataValues }] |
||||
|
}) |
||||
|
} else { |
||||
|
corFleet.child.push({ ...c.dataValues }) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ctx.status = 200 |
||||
|
ctx.body = data |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { |
||||
|
message: typeof error == 'string' ? error : undefined |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
busCarLevelList |
||||
|
}; |
@ -0,0 +1,26 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const operation = require('../../controllers/overview/operation'); |
||||
|
const management = require('../../controllers/overview/management'); |
||||
|
const build = require('../../controllers/overview/building'); |
||||
|
|
||||
|
module.exports = function (app, router, opts) { |
||||
|
// 运营
|
||||
|
app.fs.api.logAttr['GET/operation/car_level'] = { content: '获取公交车辆层级信息', visible: false }; |
||||
|
router.get('/operation/car_level', operation.busCarLevelList); |
||||
|
|
||||
|
// 管理
|
||||
|
app.fs.api.logAttr['GET/manage/overspeed'] = { content: '获取治超详情列', visible: false }; |
||||
|
router.get('/manage/overspeed', management.overSpeedList); |
||||
|
|
||||
|
app.fs.api.logAttr['GET/manage/overspeed/processed'] = { content: '获取治超监测点处理数据', visible: false }; |
||||
|
router.get('/manage/overspeed/processed', management.overSpeedProcessed); |
||||
|
|
||||
|
// 建设
|
||||
|
app.fs.api.logAttr['GET/build/road_state'] = { content: '获取道路统计', visible: false }; |
||||
|
router.get('/build/road_state', build.roadState); |
||||
|
|
||||
|
// 领导驾驶
|
||||
|
|
||||
|
// 养护
|
||||
|
} |
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue