Browse Source

接口数据

release_0.0.4
巴林闲侠 2 years ago
parent
commit
eeead59378
  1. 17
      api/app/lib/controllers/data/overspeed.js
  2. 5
      api/app/lib/controllers/data/road.js
  3. 34
      api/app/lib/controllers/overview/operation.js
  4. 2
      api/app/lib/models/publicity.js

17
api/app/lib/controllers/data/overspeed.js

@ -4,12 +4,12 @@ async function overspeedGet (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { limit, page, nameOfInspectionPoint, licensePlate, numberOfAxles, overrunRateUpper, overrunRateFloor, testTime } = ctx.query const { limit, page, nameOfInspectionPoint, licensePlate, numberOfAxles, overrunRateUpper, overrunRateFloor, testTime } = ctx.query
const sequelize = ctx.fs.dc.ORM;
let findOption = { let findOption = {
where: { where: {
}, },
order: [['id', 'DESC']] order: [['id', 'DESC']],
} }
if (limit) { if (limit) {
findOption.limit = limit findOption.limit = limit
@ -17,16 +17,19 @@ async function overspeedGet (ctx) {
if (page && limit) { if (page && limit) {
findOption.offset = page * limit findOption.offset = page * limit
} }
if (nameOfInspectionPoint || licensePlate) {
findOption.where['$or'] = {}
if (nameOfInspectionPoint) { if (nameOfInspectionPoint) {
findOption.where.nameOfInspectionPoint = { findOption.where['$or'].
'$like': `%${nameOfInspectionPoint}%` nameOfInspectionPoint = { $like: `%${nameOfInspectionPoint}%` }
}
} }
if (licensePlate) { if (licensePlate) {
findOption.where.licensePlate = { findOption.where['$or'].
'$like': `%${licensePlate}%` licensePlate = { $like: `%${licensePlate}%` }
} }
} }
if (numberOfAxles) { if (numberOfAxles) {
findOption.where.numberOfAxles = numberOfAxles findOption.where.numberOfAxles = numberOfAxles
} }

5
api/app/lib/controllers/data/road.js

@ -92,9 +92,8 @@ async function getRoadSection (ctx) {
if (road || sectionStart || sectionEnd) { if (road || sectionStart || sectionEnd) {
findOption.where['$or'] = {} findOption.where['$or'] = {}
if (road) { if (road) {
findOption.where['$or'].push = { findOption.where['$or'].
routeName: { $like: `%${road}%` } routeName = { $like: `%${road}%` }
}
} }
if (sectionStart) { if (sectionStart) {
findOption.where['$or']. findOption.where['$or'].

34
api/app/lib/controllers/overview/operation.js

@ -10,14 +10,20 @@ async function busCarLevelList (ctx) {
attributes: ['id', 'company', 'fleet', 'vehicleLicensePlateNumber', 'line'], attributes: ['id', 'company', 'fleet', 'vehicleLicensePlateNumber', 'line'],
}) })
for (let c of busCarRes) { for (let c of busCarRes) {
const { company, fleet, line } = c const { company, fleet, vehicleLicensePlateNumber, line } = c
const corCompany = data.find(d => d.name === company) const corCompany = data.find(d => d.name === company)
if (!corCompany) { if (!corCompany) {
data.push({ data.push({
name: company, name: company,
child: [{ child: [{
name: fleet, name: fleet,
child: [{ ...c.dataValues }] child: [{
name: line,
child: [{
id: c.id,
name: vehicleLicensePlateNumber,
}]
}]
}] }]
}) })
} else { } else {
@ -25,10 +31,30 @@ async function busCarLevelList (ctx) {
if (!corFleet) { if (!corFleet) {
corCompany.child.push({ corCompany.child.push({
name: fleet, name: fleet,
child: [{ ...c.dataValues }] child: [{
name: line,
child: [{
id: c.id,
name: vehicleLicensePlateNumber,
}]
}]
}) })
} else { } 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,
})
}
} }
} }
} }

2
api/app/lib/models/publicity.js

@ -28,7 +28,7 @@ module.exports = dc => {
}, },
video: { video: {
index: 3, index: 3,
type: DataTypes.ARRAY(DataTypes.INTEGER), type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
comment: null, comment: null,

Loading…
Cancel
Save