diff --git a/api/app/lib/controllers/overview/building.js b/api/app/lib/controllers/overview/building.js index 68611d5e..4b362c8b 100644 --- a/api/app/lib/controllers/overview/building.js +++ b/api/app/lib/controllers/overview/building.js @@ -1,5 +1,7 @@ 'use strict'; +const moment = require("moment"); + const areaCode = { "360121100000": "莲塘镇", "360121101000": "向塘镇", @@ -35,11 +37,30 @@ async function roadState (ctx) { type: 'road', }) + const bridgeCount = await models.Bridge.count({}) + + let constructionYear = [] + for (let i = 0; constructionYear.length < 4; i++) { + constructionYear.push(moment().subtract(i, 'year').format('YYYY')) + } + constructionYear.reverse() + const roadState = { // 在建数量 buildingRoad: 0, // 已建数量 buildedRoad: 0, + // 桥梁数量 + bridgeCount: bridgeCount, + // 涵洞数量 + culvertCount: 0, + // 施工统计 + construction: constructionYear.map(year => { + return { + year, + count: 0, + } + }), // 乡镇统计 townRoad: { @@ -84,6 +105,22 @@ async function roadState (ctx) { for (let r of roadRes) { roadCode.add(r.routeCode) + + roadState.culvertCount += Number(r.numberOfCulverts) || 0; + + // 建成年份 + let buildYear = r.completionTime ? moment(r.completionTime).format('YYYY') : null + // 改建年份 + let rebuildYear = r.reconstructionTime ? moment(r.reconstructionTime).format('YYYY') : null + let corBuildConstruction = roadState.construction.find(item => item.year === buildYear) + if (corBuildConstruction) { + corBuildConstruction.count += Number(r.chainageMileage) || 0 + } + let corReBuildConstruction = roadState.construction.find(item => item.year === rebuildYear) + if (corReBuildConstruction) { + corReBuildConstruction.count += Number(r.chainageMileage) || 0 + } + let townName = areaCode[r.townshipCode] || '其他' if (roadState.townRoad[townName]) { roadState.townRoad[townName].roadCode.add(r.routeCode) @@ -114,8 +151,16 @@ async function roadState (ctx) { roadState.greenMileage[r.level].canBeGreen += (Number(r.greeningMileage) || 0) roadState.greenMileage[r.level].isGreen += (Number(r.greeningMileaged) || 0) } + + let corBuildConstruction2022 = roadState.construction.find(item => item.year == 2022) + for (let p of projectRoadRes) { if (p.type == 'road') { + + if (corBuildConstruction2022) { + corBuildConstruction2022.count += Number(p.projectMileage) || 0 + } + if (p.done) { roadState.buildedRoad += 1 } else { diff --git a/api/app/lib/controllers/overview/conserve.js b/api/app/lib/controllers/overview/conserve.js new file mode 100644 index 00000000..687b4bfb --- /dev/null +++ b/api/app/lib/controllers/overview/conserve.js @@ -0,0 +1,42 @@ +'use strict'; + +async function statistic (ctx) { + try { + const models = ctx.fs.dc.models; + const { userId } = ctx.fs.api; + const { projectType } = ctx.query; + + let findOption = { + where: { + reportType: 'conserve', + }, + attributes: ['id', 'road', 'time', 'projectType', 'projectType'], + include: [{ + model: models.User, + attributes: ['name'] + }], + } + + if (projectType) { + findOption.where.projectType = projectType; + } + + const reportRes = await await models.Report.findAll(findOption) + + ctx.status = 200 + ctx.body = { + processed: reportRes.length, + reportList: reportRes, + } + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { + message: typeof error == 'string' ? error : undefined + } + } +} + +module.exports = { + statistic, +}; \ No newline at end of file diff --git a/api/app/lib/controllers/overview/operation.js b/api/app/lib/controllers/overview/operation.js index 7744768f..4d6e84b8 100644 --- a/api/app/lib/controllers/overview/operation.js +++ b/api/app/lib/controllers/overview/operation.js @@ -44,6 +44,59 @@ async function busCarLevelList (ctx) { } } +async function vehicleStatistic (ctx) { + try { + const models = ctx.fs.dc.models; + const { userId } = ctx.fs.api; + + const taxiBusiness = await models.MunicipalBusiness.findAll({ + where: { + type: '出租车' + }, + attributes: ['id', 'nameOfBusinessOwner'] + }) + const hazardousGoodsBusiness = await models.MunicipalBusiness.findAll({ + where: { + type: '危货' + }, + attributes: ['id', 'nameOfBusinessOwner'] + }) + const passengerTransport = await models.Statistic.findOne({ + where: { + type: 'vehicle' + } + }) + + const vehicleState = { + passengerTransport: passengerTransport ? passengerTransport.count : 0, + taxi: await models.MunicipalVehicle.count({ + where: { + type: '出租车' + }, + }), + hazardousGoods: await models.MunicipalVehicle.count({ + where: { + type: '危货' + } + }), + bus: await models.BusCar.count(), + taxiBusiness: taxiBusiness, + hazardousGoodsBusiness: hazardousGoodsBusiness, + } + + ctx.status = 200 + ctx.body = vehicleState + } 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 + busCarLevelList, + vehicleStatistic, }; \ No newline at end of file diff --git a/api/app/lib/routes/overview/index.js b/api/app/lib/routes/overview/index.js index 3def0d6a..1d37acaf 100644 --- a/api/app/lib/routes/overview/index.js +++ b/api/app/lib/routes/overview/index.js @@ -3,24 +3,24 @@ const operation = require('../../controllers/overview/operation'); const management = require('../../controllers/overview/management'); const build = require('../../controllers/overview/building'); +const conserve = require('../../controllers/overview/conserve'); 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); - // 领导驾驶 + app.fs.api.logAttr['GET/conserve/statistic'] = { content: '获取道路养护统计及列表', visible: false }; + router.get('/conserve/statistic', conserve.statistic); - // 养护 + app.fs.api.logAttr['GET/transportation/statistic'] = { content: '获取运政统计', visible: false }; + router.get('/transportation/statistic', operation.vehicleStatistic); } \ No newline at end of file diff --git a/api/log/development.log b/api/log/development.log index 0c8e8e9d..58fe7dc7 100644 --- a/api/log/development.log +++ b/api/log/development.log @@ -7268,3 +7268,37 @@ 2022-07-23 17:44:52.238 - debug: [FS-LOGGER] Init. 2022-07-23 17:44:52.386 - info: [FS-ATTACHMENT] Inject attachment mw into router. 2022-07-23 17:44:52.387 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-25 10:08:50.950 - debug: [FS-LOGGER] Init. +2022-07-25 10:08:51.117 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-25 10:08:51.117 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-25 10:47:17.059 - debug: [FS-LOGGER] Init. +2022-07-25 10:47:17.224 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-25 10:47:17.224 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-25 10:56:44.872 - debug: [FS-LOGGER] Init. +2022-07-25 10:56:45.027 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-25 10:56:45.027 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-25 11:06:22.520 - debug: [FS-LOGGER] Init. +2022-07-25 11:06:22.625 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-25 11:06:22.625 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-25 11:18:32.406 - debug: [FS-LOGGER] Init. +2022-07-25 11:18:32.483 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-25 11:18:32.483 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-25 11:22:30.726 - debug: [FS-LOGGER] Init. +2022-07-25 11:22:30.802 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-25 11:22:30.802 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-25 11:23:03.672 - debug: [FS-LOGGER] Init. +2022-07-25 11:23:03.765 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-25 11:23:03.765 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-25 11:23:07.584 - error: path: /build/road_state, error: ReferenceError: r is not defined +2022-07-25 11:23:14.647 - error: path: /build/road_state, error: ReferenceError: r is not defined +2022-07-25 11:23:34.344 - debug: [FS-LOGGER] Init. +2022-07-25 11:23:34.430 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-25 11:23:34.430 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-25 11:51:12.541 - debug: [FS-LOGGER] Init. +2022-07-25 11:51:12.639 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-25 11:51:12.639 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-25 11:51:21.718 - error: path: /transportation/statistic, error: SequelizeDatabaseError: 字段 "name" 不存在 +2022-07-25 11:51:27.861 - error: path: /transportation/statistic, error: SequelizeDatabaseError: 字段 "name" 不存在 +2022-07-25 11:52:00.697 - debug: [FS-LOGGER] Init. +2022-07-25 11:52:00.795 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-25 11:52:00.796 - info: [FS-AUTH] Inject auth and api mv into router. diff --git a/scripts/0.0.1/data/1_update_statistic_data.sql b/scripts/0.0.1/data/1_update_statistic_data.sql index e69de29b..3e4840af 100644 --- a/scripts/0.0.1/data/1_update_statistic_data.sql +++ b/scripts/0.0.1/data/1_update_statistic_data.sql @@ -0,0 +1,9 @@ +INSERT INTO statistic (name, count, type) values ('客运车', 0, 'vehicle'); +INSERT INTO statistic (name, count, type) values ('标线', 0, 'road_manage'); +INSERT INTO statistic (name, count, type) values ('人行道', 0, 'road_manage'); +INSERT INTO statistic (name, count, type) values ('标志牌', 0, 'road_manage'); +INSERT INTO statistic (name, count, type) values ('防护栏', 0, 'road_manage'); +INSERT INTO statistic (name, count, type) values ('检查井', 0, 'road_manage'); +INSERT INTO statistic (name, count, type) values ('雨水口', 0, 'road_manage'); +INSERT INTO statistic (name, count, type) values ('路排名', 0, 'road_manage'); +INSERT INTO statistic (name, count, type) values ('养护责任牌', 0, 'road_manage'); \ No newline at end of file diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/出租车/事业发展中心巡游出租业户信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/出租车/事业发展中心巡游出租业户信息表.xlsx new file mode 100644 index 00000000..58c13780 Binary files /dev/null and b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/出租车/事业发展中心巡游出租业户信息表.xlsx differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/出租车/运输事业发展中心巡游出租车辆信息表.xlsx b/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/出租车/运输事业发展中心巡游出租车辆信息表.xlsx deleted file mode 100644 index e080922d..00000000 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/运政/业户/出租车/运输事业发展中心巡游出租车辆信息表.xlsx and /dev/null differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/乡道第三方.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/乡道第三方.xls index 577906e9..cf53b8d6 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/乡道第三方.xls and b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/乡道第三方.xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/县道第三方.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/县道第三方.xls index 0e3a1aa7..4d61104b 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/县道第三方.xls and b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/县道第三方.xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/村道第三方.xls b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/村道第三方.xls index 9a7dc066..d23427d4 100644 Binary files a/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/村道第三方.xls and b/scripts/0.0.1/data/工具脚本(无需执行)/data/道路/村道第三方.xls differ diff --git a/scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js b/scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js index 62a5da80..2ffc5e75 100644 --- a/scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js +++ b/scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js @@ -71,6 +71,26 @@ try { // defaultKey: ['type'], // defaultValue: ['危货'], // }, + { + path: ['./data/运政/业户/出租车/事业发展中心巡游出租业户信息表.xlsx'], + n: '运政业户', + tableName: 'municipal_business', + defaultKey: ['type'], + defaultValue: ['出租车'], + }, + { + path: (() => { + let p = []; + fs.readdirSync(path.join(__dirname, '/data/运政/业户/危货')).forEach((filename) => { + p.push(`./data/运政/业户/危货/${filename}`) + }); + return p; + })(), + n: '运政业户', + tableName: 'municipal_business', + defaultKey: ['type'], + defaultValue: ['危货'], + }, // { // path: ['./data/工程一览/道路.xls'], // n: '工程一览',