Browse Source

接口数据

release_0.0.4
巴林闲侠 2 years ago
parent
commit
eeead59378
  1. 23
      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

23
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

5
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'].

34
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,
})
}
}
}
}

2
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,

Loading…
Cancel
Save