From 2d6690a5e80738d2db4d290f93a284d76353840b Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Tue, 26 Jul 2022 17:15:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/data/bridge.js | 15 ++++++- api/app/lib/controllers/data/vehicle.js | 36 ++++++++++++++--- api/app/lib/controllers/overview/building.js | 24 +++++++++++- .../lib/controllers/overview/management.js | 2 +- api/app/lib/controllers/report/index.js | 2 +- api/log/development.log | 39 +++++++++++++++++++ 6 files changed, 107 insertions(+), 11 deletions(-) diff --git a/api/app/lib/controllers/data/bridge.js b/api/app/lib/controllers/data/bridge.js index fe2a6453..46c0cb7b 100644 --- a/api/app/lib/controllers/data/bridge.js +++ b/api/app/lib/controllers/data/bridge.js @@ -3,10 +3,21 @@ async function bridgeGet (ctx) { try { const models = ctx.fs.dc.models; + const { bridgeName } = ctx.query; - const roadRes = await models.Bridge.findAll({ + let findOption = { + where: { + + }, order: [['id', 'DESC']] - }) + } + if (bridgeName) { + findOption.where.bridgeName = { + $like: `%${bridgeName}%` + } + } + + const roadRes = await models.Bridge.findAll(findOption) ctx.status = 200; ctx.body = roadRes diff --git a/api/app/lib/controllers/data/vehicle.js b/api/app/lib/controllers/data/vehicle.js index c8d76eca..4a607072 100644 --- a/api/app/lib/controllers/data/vehicle.js +++ b/api/app/lib/controllers/data/vehicle.js @@ -4,12 +4,19 @@ async function get (ctx) { try { const models = ctx.fs.dc.models; const { type } = ctx.request.body; + const { name } = ctx.query; - const vehicleRes = await models.Statistic.findAll({ + let findOption = { where: { type } - }) + } + if (name) { + findOption.where.name = { + $like: `%${name}%` + } + } + const vehicleRes = await models.Statistic.findAll(findOption) ctx.status = 200; ctx.body = vehicleRes @@ -76,12 +83,20 @@ async function specificGet (ctx) { try { const models = ctx.fs.dc.models; const { type } = ctx.query; + const { nameOfBusinessOwner } = ctx.query; - const vehicleRes = await models.MunicipalVehicle.findAll({ + let findOption = { where: { type } - }) + } + if (nameOfBusinessOwner) { + findOption.where.nameOfBusinessOwner = { + $like: `%${nameOfBusinessOwner}%` + } + } + + const vehicleRes = await models.MunicipalVehicle.findAll(findOption) ctx.status = 200; ctx.body = vehicleRes @@ -143,8 +158,19 @@ async function specificDel (ctx) { async function businessGet (ctx) { try { const models = ctx.fs.dc.models; + const { nameOfBusinessOwner } = ctx.query; - const businessRes = await models.MunicipalBusiness.findAll() + let findOption = { + where:{ + + } + } + if (nameOfBusinessOwner) { + findOption.where.nameOfBusinessOwner = { + $like: `%${nameOfBusinessOwner}%` + } + } + const businessRes = await models.MunicipalBusiness.findAll(findOption) ctx.status = 200; ctx.body = businessRes diff --git a/api/app/lib/controllers/overview/building.js b/api/app/lib/controllers/overview/building.js index 8167a9a1..aa822134 100644 --- a/api/app/lib/controllers/overview/building.js +++ b/api/app/lib/controllers/overview/building.js @@ -37,7 +37,7 @@ async function roadState (ctx) { type: 'road', }) - const bridgeCount = await models.Bridge.count({}) + const bridgeRes = await models.Bridge.findAll({}) let constructionYear = [] for (let i = 0; constructionYear.length < 4; i++) { @@ -51,7 +51,7 @@ async function roadState (ctx) { // 已建数量 buildedRoad: 0, // 桥梁数量 - bridgeCount: bridgeCount, + bridgeCount: bridgeRes.length, // 涵洞数量 culvertCount: 0, // 施工统计 @@ -64,6 +64,18 @@ async function roadState (ctx) { // 乡镇统计 townRoad: { + }, + // 县乡村涵洞 个数 + townCulvert: { + '县': 0, + '乡': 0, + '村': 0, + }, + // 桥大小 + bridgeSize: { + '大桥': 0, + '中桥': 0, + '小桥': 0, }, // 类型统计 roadType: { @@ -134,6 +146,8 @@ async function roadState (ctx) { roadState.roadType[r.level] = (roadState.roadType[r.level] || 0) + (Number(r.chainageMileage) || 0) + roadState.townCulvert[r.level] = (roadState.townCulvert[r.level] || 0) + (Number(r.numberOfCulverts) || 0) + if (roadState.roadLevel[r.technicalLevel]) { roadState.roadLevel[r.technicalLevel] += 1 } else { @@ -180,6 +194,12 @@ async function roadState (ctx) { } } + for (let { dataValues: b } of bridgeRes) { + if (roadState.bridgeSize[b.bridgeClassification] || roadState.bridgeSize[b.bridgeClassification] == 0) { + roadState.bridgeSize[b.bridgeClassification] += 1 + } + } + roadState.buildedRoad += roadCode.size for (let t of Object.keys(roadState.townRoad)) { roadState.townRoad[t].roadCount = roadState.townRoad[t].roadCode.size diff --git a/api/app/lib/controllers/overview/management.js b/api/app/lib/controllers/overview/management.js index bac1190d..3d5098b1 100644 --- a/api/app/lib/controllers/overview/management.js +++ b/api/app/lib/controllers/overview/management.js @@ -7,7 +7,7 @@ async function overSpeedList (ctx) { const { limit } = ctx.query; const overSpeedRes = await models.Overspeed.findAll({ - attributes: ['id', 'licensePlate', 'overrunRate', 'deductPoints', 'fine', 'processingTime'], + attributes: ['id', 'licensePlate', 'overrunRate', 'deductPoints', 'fine', 'processingTime', 'testTime'], order: [['testTime', 'DESC']], limit: limit || 120, }) diff --git a/api/app/lib/controllers/report/index.js b/api/app/lib/controllers/report/index.js index 2a17dc40..f780b547 100644 --- a/api/app/lib/controllers/report/index.js +++ b/api/app/lib/controllers/report/index.js @@ -9,7 +9,7 @@ async function reportList (ctx) { where: { }, - attributes: ['id', 'road', 'time', 'projectType', 'roadSectionStart', 'roadSectionEnd'], + attributes: ['id', 'road', 'time', 'projectType', 'roadSectionStart', 'roadSectionEnd', 'reportType'], include: [{ model: models.User, attributes: ['name'] diff --git a/api/log/development.log b/api/log/development.log index e257dbaa..e84a8c6b 100644 --- a/api/log/development.log +++ b/api/log/development.log @@ -8563,3 +8563,42 @@ 2022-07-26 11:43:16.204 - debug: [FS-LOGGER] Init. 2022-07-26 11:43:16.335 - info: [FS-ATTACHMENT] Inject attachment mw into router. 2022-07-26 11:43:16.335 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 15:49:07.232 - debug: [FS-LOGGER] Init. +2022-07-26 15:49:07.369 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 15:49:07.369 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 16:02:37.186 - debug: [FS-LOGGER] Init. +2022-07-26 16:02:37.323 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 16:02:37.323 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 16:28:15.800 - error: path: /publicity, error: SequelizeValidationError: notNull Violation: publicity.name cannot be null +2022-07-26 16:46:23.531 - debug: [FS-LOGGER] Init. +2022-07-26 16:46:23.669 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 16:46:23.670 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 16:47:40.073 - debug: [FS-LOGGER] Init. +2022-07-26 16:47:40.195 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 16:47:40.196 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 16:53:36.476 - debug: [FS-LOGGER] Init. +2022-07-26 16:53:36.613 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 16:53:36.613 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 16:54:23.917 - debug: [FS-LOGGER] Init. +2022-07-26 16:54:24.044 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 16:54:24.045 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 17:03:39.231 - debug: [FS-LOGGER] Init. +2022-07-26 17:03:39.355 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 17:03:39.356 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 17:09:44.833 - debug: [FS-LOGGER] Init. +2022-07-26 17:09:44.957 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 17:09:44.957 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 17:09:51.602 - debug: [FS-LOGGER] Init. +2022-07-26 17:09:51.726 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 17:09:51.726 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 17:11:52.424 - debug: [FS-LOGGER] Init. +2022-07-26 17:11:52.549 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 17:11:52.550 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 17:12:00.320 - error: path: /vehicle/business, error: TypeError: Cannot set property 'nameOfBusinessOwner' of undefined +2022-07-26 17:12:08.483 - error: path: /vehicle/business, error: TypeError: Cannot set property 'nameOfBusinessOwner' of undefined +2022-07-26 17:12:30.681 - debug: [FS-LOGGER] Init. +2022-07-26 17:12:30.811 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 17:12:30.811 - info: [FS-AUTH] Inject auth and api mv into router. +2022-07-26 17:14:08.171 - debug: [FS-LOGGER] Init. +2022-07-26 17:14:08.304 - info: [FS-ATTACHMENT] Inject attachment mw into router. +2022-07-26 17:14:08.305 - info: [FS-AUTH] Inject auth and api mv into router.