From eeead593787a36bf964e21c0ae8ca7237146df2a Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 28 Jul 2022 14:22:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/data/overspeed.js | 23 +++++++------ api/app/lib/controllers/data/road.js | 5 ++- api/app/lib/controllers/overview/operation.js | 34 ++++++++++++++++--- api/app/lib/models/publicity.js | 2 +- 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/api/app/lib/controllers/data/overspeed.js b/api/app/lib/controllers/data/overspeed.js index b123b4ba..0da8d491 100644 --- a/api/app/lib/controllers/data/overspeed.js +++ b/api/app/lib/controllers/data/overspeed.js @@ -4,12 +4,12 @@ async function overspeedGet (ctx) { try { const models = ctx.fs.dc.models; const { limit, page, nameOfInspectionPoint, licensePlate, numberOfAxles, overrunRateUpper, overrunRateFloor, testTime } = ctx.query - + const sequelize = ctx.fs.dc.ORM; let findOption = { where: { }, - order: [['id', 'DESC']] + order: [['id', 'DESC']], } if (limit) { findOption.limit = limit @@ -17,16 +17,19 @@ async function overspeedGet (ctx) { if (page && limit) { findOption.offset = page * limit } - if (nameOfInspectionPoint) { - findOption.where.nameOfInspectionPoint = { - '$like': `%${nameOfInspectionPoint}%` + + if (nameOfInspectionPoint || licensePlate) { + findOption.where['$or'] = {} + if (nameOfInspectionPoint) { + findOption.where['$or']. + nameOfInspectionPoint = { $like: `%${nameOfInspectionPoint}%` } } - } - if (licensePlate) { - findOption.where.licensePlate = { - '$like': `%${licensePlate}%` + if (licensePlate) { + findOption.where['$or']. + licensePlate = { $like: `%${licensePlate}%` } } } + if (numberOfAxles) { findOption.where.numberOfAxles = numberOfAxles } @@ -38,7 +41,7 @@ async function overspeedGet (ctx) { if (overrunRateFloor) { findOption.where.overrunRate = { $gte: overrunRateFloor - } + } } if (testTime) { findOption.where.testTime = testTime diff --git a/api/app/lib/controllers/data/road.js b/api/app/lib/controllers/data/road.js index 71ece58e..842c92b6 100644 --- a/api/app/lib/controllers/data/road.js +++ b/api/app/lib/controllers/data/road.js @@ -92,9 +92,8 @@ async function getRoadSection (ctx) { if (road || sectionStart || sectionEnd) { findOption.where['$or'] = {} if (road) { - findOption.where['$or'].push = { - routeName: { $like: `%${road}%` } - } + findOption.where['$or']. + routeName = { $like: `%${road}%` } } if (sectionStart) { findOption.where['$or']. diff --git a/api/app/lib/controllers/overview/operation.js b/api/app/lib/controllers/overview/operation.js index 975760d3..91ede643 100644 --- a/api/app/lib/controllers/overview/operation.js +++ b/api/app/lib/controllers/overview/operation.js @@ -10,14 +10,20 @@ async function busCarLevelList (ctx) { attributes: ['id', 'company', 'fleet', 'vehicleLicensePlateNumber', 'line'], }) for (let c of busCarRes) { - const { company, fleet, line } = c + const { company, fleet, vehicleLicensePlateNumber, line } = c const corCompany = data.find(d => d.name === company) if (!corCompany) { data.push({ name: company, child: [{ name: fleet, - child: [{ ...c.dataValues }] + child: [{ + name: line, + child: [{ + id: c.id, + name: vehicleLicensePlateNumber, + }] + }] }] }) } else { @@ -25,10 +31,30 @@ async function busCarLevelList (ctx) { if (!corFleet) { corCompany.child.push({ name: fleet, - child: [{ ...c.dataValues }] + child: [{ + name: line, + child: [{ + id: c.id, + name: vehicleLicensePlateNumber, + }] + }] }) } else { - corFleet.child.push({ ...c.dataValues }) + const corLine = corFleet.child.find(d => d.name === line) + if (!corLine) { + corFleet.child.push({ + name: line, + child: [{ + id: c.id, + name: vehicleLicensePlateNumber, + }] + }) + } else { + corLine.child.push({ + id: c.id, + name: vehicleLicensePlateNumber, + }) + } } } } diff --git a/api/app/lib/models/publicity.js b/api/app/lib/models/publicity.js index 62a1c77a..a9ceef05 100644 --- a/api/app/lib/models/publicity.js +++ b/api/app/lib/models/publicity.js @@ -28,7 +28,7 @@ module.exports = dc => { }, video: { index: 3, - type: DataTypes.ARRAY(DataTypes.INTEGER), + type: DataTypes.ARRAY(DataTypes.STRING), allowNull: true, defaultValue: null, comment: null,