Browse Source

关键字搜索

release_0.0.4
巴林闲侠 3 years ago
parent
commit
2d6690a5e8
  1. 15
      api/app/lib/controllers/data/bridge.js
  2. 36
      api/app/lib/controllers/data/vehicle.js
  3. 24
      api/app/lib/controllers/overview/building.js
  4. 2
      api/app/lib/controllers/overview/management.js
  5. 2
      api/app/lib/controllers/report/index.js
  6. 39
      api/log/development.log

15
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

36
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

24
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

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

2
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']

39
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.

Loading…
Cancel
Save