Browse Source

治超

release_0.0.1
巴林闲侠 2 years ago
parent
commit
dbc9dd6c75
  1. 109
      api/app/lib/controllers/data/overspeed.js
  2. 2
      api/app/lib/controllers/data/project.js
  3. 1
      api/app/lib/controllers/organization/user.js
  4. 65
      api/app/lib/controllers/report/index.js
  5. 187
      api/app/lib/models/overspeed.js
  6. 13
      api/app/lib/routes/data/index.js
  7. 3
      api/app/lib/routes/report/index.js
  8. 5
      api/log/development.log
  9. BIN
      scripts/0.0.1/data/工具脚本(无需执行)/data/治超/非现场处罚总台账更新至2022.7.5(最新).xlsx
  10. 7
      scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js
  11. 6
      scripts/0.0.1/data/工具脚本(无需执行)/index.js
  12. 20
      scripts/0.0.1/data/工具脚本(无需执行)/治超_字段对应.json
  13. 20
      scripts/0.0.1/data/工具脚本(无需执行)/治超_数据字段对应.json
  14. 20
      scripts/0.0.1/data/工具脚本(无需执行)/治超_数据库表对应.json
  15. 24
      scripts/0.0.1/data/工具脚本(无需执行)/治超_数据脚本对应.sql

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

@ -0,0 +1,109 @@
'use strict';
async function overspeedGet (ctx) {
try {
const models = ctx.fs.dc.models;
const { limit, page, nameOfInspectionPoint, licensePlate, numberOfAxles, overrunRateUpper, overrunRateFloor, testTime } = ctx.query
let findOption = {
where: {
},
order: [['id', 'DESC']]
}
if (limit) {
findOption.limit = limit
}
if (page && limit) {
findOption.offset = page * limit
}
if (nameOfInspectionPoint) {
findOption.where.nameOfInspectionPoint = {
'$like': `%${nameOfInspectionPoint}%`
}
}
if (licensePlate) {
findOption.where.licensePlate = {
'$like': `%${licensePlate}%`
}
}
if (numberOfAxles) {
findOption.where.numberOfAxles = numberOfAxles
}
if (overrunRateUpper) {
findOption.where.overrunRate = {
$lte: overrunRateUpper
}
}
if (overrunRateFloor) {
findOption.where.overrunRate = {
$gte: overrunRateFloor
}
}
if (testTime) {
findOption.where.testTime = testTime
}
const overspeedRes = await models.Overspeed.findAll(findOption)
ctx.status = 200;
ctx.body = overspeedRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function overspeedEdit (ctx) {
try {
const models = ctx.fs.dc.models;
const data = ctx.request.body;
if (!data.overspeedId) {
await models.Overspeed.create(data)
} else {
await models.Overspeed.update(
data,
{
where: {
id: data.overspeedId
}
})
}
ctx.status = 204
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function overspeedDel (ctx) {
try {
const models = ctx.fs.dc.models;
const { overspeedId } = ctx.params;
await models.Overspeed.destroy({
where: {
id: overspeedId
}
})
ctx.status = 204
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
module.exports = {
overspeedGet, overspeedEdit, overspeedDel,
};

2
api/app/lib/controllers/data/project.js

@ -1,7 +1,5 @@
'use strict';
'use strict';
async function projectGet (ctx) {
try {
const models = ctx.fs.dc.models;

1
api/app/lib/controllers/organization/user.js

@ -114,7 +114,6 @@ async function updateUser (ctx, next) {
enable: data.enable,
delete: false,
phone: data.phone,
post: data.post,
}, {
where: {
id: userId

65
api/app/lib/controllers/report/index.js

@ -1,14 +1,15 @@
'use strict';
const { QueryTypes } = require('sequelize');
async function reportList (ctx) {
try {
const models = ctx.fs.dc.models;
const { limit, page, startTime, endTime, keyword } = ctx.query
const { limit, page, startTime, endTime, keyword, userId, reportType } = ctx.query
let findOption = {
where: {
},
attributes: ['id', 'road', 'time'],
attributes: ['id', 'road', 'time', 'projectType', 'roadSectionStart', 'roadSectionEnd'],
include: [{
model: models.User,
attributes: ['name']
@ -32,6 +33,12 @@ async function reportList (ctx) {
'$like': `%${keyword}%`
}
}
if (userId) {
findOption.where.userId = userId
}
if (reportType) {
findOption.where.reportType = reportType
}
const reportRes = await models.Report.findAll(findOption)
ctx.status = 200;
@ -45,6 +52,56 @@ async function reportList (ctx) {
}
}
async function reportPosition (ctx) {
try {
const models = ctx.fs.dc.models;
const { startTime, endTime, userId, reportType } = ctx.query
const sequelize = ctx.fs.dc.ORM;
let findMxTimeOption = {
attributes: [
'userId',
[sequelize.fn('MAX', sequelize.col('time')), 'maxTime'],
],
where: {
},
group: ['report.user_id'],
}
if (startTime && endTime) {
findMxTimeOption.where = {
time: {
'$between': [startTime, endTime]
}
}
}
if (userId) {
findMxTimeOption.where.userId = userId
}
if (reportType) {
findMxTimeOption.where.reportType = reportType
}
const reportMaxTimeRes = await models.Report.findAll(findMxTimeOption)
const timeArr = reportMaxTimeRes.map(item => item.dataValues.maxTime)
const reportRes = await models.Report.findAll({
where: {
time: { '$in': timeArr }
}
})
ctx.status = 200;
ctx.body = reportRes
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function reportDetail (ctx) {
try {
const models = ctx.fs.dc.models;
@ -113,5 +170,7 @@ async function deleteReport (ctx) {
// TODO 小程序填写道路名称的时候的道路筛选 是一起都返回 还是不断传关键字搜索返回
module.exports = {
reportList, reportDetail, createReport, deleteReport,
reportList,
reportPosition,
reportDetail, createReport, deleteReport,
};

187
api/app/lib/models/overspeed.js

@ -0,0 +1,187 @@
/* eslint-disable*/
'use strict';
module.exports = dc => {
const DataTypes = dc.ORM;
const sequelize = dc.orm;
const Overspeed = sequelize.define("overspeed", {
id: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: null,
comment: null,
primaryKey: true,
field: "id",
autoIncrement: true,
unique: "overspeed_id_uindex"
},
districtcounty: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "区/县",
primaryKey: false,
field: "districtcounty",
autoIncrement: false
},
nameOfInspectionPoint: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "检测点名称",
primaryKey: false,
field: "name_of_inspection_point",
autoIncrement: false
},
licensePlate: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "车牌号码",
primaryKey: false,
field: "license_plate",
autoIncrement: false
},
numberOfAxles: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "车轴数",
primaryKey: false,
field: "number_of_axles",
autoIncrement: false
},
overrunRate: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "超限率",
primaryKey: false,
field: "overrun_rate",
autoIncrement: false
},
overrunWeight: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "超限重量",
primaryKey: false,
field: "overrun_weight",
autoIncrement: false
},
grossVehicleWeight: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "车货总重",
primaryKey: false,
field: "gross_vehicle_weight",
autoIncrement: false
},
vehicleCargoWeightLimit: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "车货限重",
primaryKey: false,
field: "vehicle_cargo_weight_limit",
autoIncrement: false
},
testTime: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "检测时间",
primaryKey: false,
field: "test_time",
autoIncrement: false
},
nameOfBusinessOwner: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "经营业户名称",
primaryKey: false,
field: "name_of_business_owner",
autoIncrement: false
},
businessAddress: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "经营业户地址",
primaryKey: false,
field: "business_address",
autoIncrement: false
},
notifier: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "通知人",
primaryKey: false,
field: "notifier",
autoIncrement: false
},
notificationMethod: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "通知方式",
primaryKey: false,
field: "notification_method",
autoIncrement: false
},
notificationResults: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "通知结果",
primaryKey: false,
field: "notification_results",
autoIncrement: false
},
processingTime: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "处理时间",
primaryKey: false,
field: "processing_time",
autoIncrement: false
},
deductPoints: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "扣分",
primaryKey: false,
field: "deduct_points",
autoIncrement: false
},
fine: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "罚款",
primaryKey: false,
field: "fine",
autoIncrement: false
},
remarks: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: null,
comment: "备注",
primaryKey: false,
field: "remarks",
autoIncrement: false
}
}, {
tableName: "overspeed",
comment: "",
indexes: []
});
dc.models.Overspeed = Overspeed;
return Overspeed;
};

13
api/app/lib/routes/data/index.js

@ -4,6 +4,7 @@ const vehicle = require('../../controllers/data/vehicle');
const road = require('../../controllers/data/road');
const bridge = require('../../controllers/data/bridge');
const project = require('../../controllers/data/project');
const overspeed = require('../../controllers/data/overspeed');
module.exports = function (app, router, opts) {
@ -73,6 +74,16 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['DEL/project/:projectId'] = { content: '删除工程数据', visible: false };
router.del('/project/:projectId', project.projectDel);
// project END
//overspeed
app.fs.api.logAttr['GET/overspeed'] = { content: '获取治超数据', visible: true };
router.get('/overspeed', overspeed.overspeedGet);
app.fs.api.logAttr['PUT/overspeed'] = { content: '编辑治超数据', visible: true };
router.put('/overspeed', overspeed.overspeedEdit);
app.fs.api.logAttr['DEL/overspeed/:overspeedId'] = { content: '删除治超数据', visible: false };
router.del('/overspeed/:overspeedId', overspeed.overspeedDel);
//overspeed END
};

3
api/app/lib/routes/report/index.js

@ -6,6 +6,9 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['GET/report/list'] = { content: '获取上报列表', visible: false };
router.get('/report/list', report.reportList);
app.fs.api.logAttr['GET/report/position'] = { content: '获取最新上报位置', visible: false };
router.get('/report/position', report.reportPosition);
app.fs.api.logAttr['GET/report/:reportId/detail'] = { content: '获取上报详情', visible: false };
router.get('/report/:reportId//detail', report.reportDetail);

5
api/log/development.log

@ -7150,3 +7150,8 @@
2022-07-21 20:46:20.452 - debug: [FS-LOGGER] Init.
2022-07-21 20:46:20.547 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2022-07-21 20:46:20.547 - info: [FS-AUTH] Inject auth and api mv into router.
2022-07-22 15:22:09.380 - debug: [FS-LOGGER] Init.
2022-07-22 15:22:09.565 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2022-07-22 15:22:09.565 - info: [FS-AUTH] Inject auth and api mv into router.
2022-07-22 15:22:12.241 - error: path: /overspeed, error: ReferenceError: startTime is not defined
2022-07-22 15:22:51.819 - error: path: /overspeed, error: ReferenceError: startTime is not defined

BIN
scripts/0.0.1/data/工具脚本(无需执行)/data/治超/非现场处罚总台账更新至2022.7.5(最新).xlsx

Binary file not shown.

7
scripts/0.0.1/data/工具脚本(无需执行)/dataIn.js

@ -117,6 +117,11 @@ try {
// defaultKey: ['done', 'type'],
// defaultValue: [false, 'bridge'],
// },
// {
// path: ['./data/治超/非现场处罚总台账更新至2022.7.5(最新).xlsx'],
// n: '治超',
// tableName: 'overspeed',
// },
]
for (let f of fileList) {
@ -151,7 +156,7 @@ try {
insertStr += insertKeys.join(',') + ') VALUES (';
insertStr += insertKeys.map((k, i) => `$${i + 1}`).join(',') + ')';
// console.log(insertStr, insertValues);
// console.log(`插入 ${f.tableName}:${insertStr}`);
console.log(`插入 ${insertValues}`);
await client.query(insertStr, insertValues);
// break;
}

6
scripts/0.0.1/data/工具脚本(无需执行)/index.js

@ -43,6 +43,7 @@ try {
let upperCaseRslt = rslt[0].dst
.replace(/\//g, ' ')
.replace(/'/g, '')
.trim()
.replace(/\s{2,}/g, '')
.replace(/-/g, ' ');
console.log(`翻译结果:${upperCaseRslt}`);
@ -85,6 +86,11 @@ try {
// n: '工程一览',
// tableName: 'project'
// },
// {
// path: './data/治超/非现场处罚总台账更新至2022.7.5(最新).xlsx',
// n: '治超',
// tableName: 'overspeed'
// },
]
for (let f of fileList) {

20
scripts/0.0.1/data/工具脚本(无需执行)/治超_字段对应.json

@ -0,0 +1,20 @@
{
"区/县": "districtcounty",
"检测点名称": "nameOfInspectionPoint",
"车牌号码": "licensePlate",
"车轴数": "numberOfAxles",
"超限率": "overrunRate",
"超限重量": "overrunWeight",
"车货总重": "grossVehicleWeight",
"车货限重": "vehicleCargoWeightLimit",
"检测时间": "testTime",
"经营业户名称": "nameOfBusinessOwner",
"经营业户地址": "businessAddress",
"通知人": "notifier",
"通知方式": "notificationMethod",
"通知结果": "notificationResults",
"处理时间": "processingTime",
"扣分": "deductPoints",
"罚款": "fine",
"备注": "remarks"
}

20
scripts/0.0.1/data/工具脚本(无需执行)/治超_数据字段对应.json

@ -0,0 +1,20 @@
{
"districtcounty": "区/县",
"nameOfInspectionPoint": "检测点名称",
"licensePlate": "车牌号码",
"numberOfAxles": "车轴数",
"overrunRate": "超限率",
"overrunWeight": "超限重量",
"grossVehicleWeight": "车货总重",
"vehicleCargoWeightLimit": "车货限重",
"testTime": "检测时间",
"nameOfBusinessOwner": "经营业户名称",
"businessAddress": "经营业户地址",
"notifier": "通知人",
"notificationMethod": "通知方式",
"notificationResults": "通知结果",
"processingTime": "处理时间",
"deductPoints": "扣分",
"fine": "罚款",
"remarks": "备注"
}

20
scripts/0.0.1/data/工具脚本(无需执行)/治超_数据库表对应.json

@ -0,0 +1,20 @@
{
"区/县": "districtcounty",
"检测点名称": "name_of_inspection_point",
"车牌号码": "license_plate",
"车轴数": "number_of_axles",
"超限率": "overrun_rate",
"超限重量": "overrun_weight",
"车货总重": "gross_vehicle_weight",
"车货限重": "vehicle_cargo_weight_limit",
"检测时间": "test_time",
"经营业户名称": "name_of_business_owner",
"经营业户地址": "business_address",
"通知人": "notifier",
"通知方式": "notification_method",
"通知结果": "notification_results",
"处理时间": "processing_time",
"扣分": "deduct_points",
"罚款": "fine",
"备注": "remarks"
}

24
scripts/0.0.1/data/工具脚本(无需执行)/治超_数据脚本对应.sql

@ -0,0 +1,24 @@
-- 治超
CREATE TABLE if not exists "overspeed" ( id serial not null );
CREATE unique index if not exists overspeed_id_uindex
ON overspeed (id); alter TABLE overspeed add constraint overspeed_pk primary key (id); alter TABLE overspeed add Districtcounty varchar(1024); comment
ON column overspeed.Districtcounty is '区/县'; alter TABLE overspeed add Name_Of_Inspection_Point varchar(1024); comment
ON column overspeed.Name_Of_Inspection_Point is '检测点名称'; alter TABLE overspeed add License_Plate varchar(1024); comment
ON column overspeed.License_Plate is '车牌号码'; alter TABLE overspeed add Number_Of_Axles varchar(1024); comment
ON column overspeed.Number_Of_Axles is '车轴数'; alter TABLE overspeed add Overrun_Rate varchar(1024); comment
ON column overspeed.Overrun_Rate is '超限率'; alter TABLE overspeed add Overrun_Weight varchar(1024); comment
ON column overspeed.Overrun_Weight is '超限重量'; alter TABLE overspeed add Gross_Vehicle_Weight varchar(1024); comment
ON column overspeed.Gross_Vehicle_Weight is '车货总重'; alter TABLE overspeed add Vehicle_Cargo_Weight_Limit varchar(1024); comment
ON column overspeed.Vehicle_Cargo_Weight_Limit is '车货限重'; alter TABLE overspeed add Test_Time varchar(1024); comment
ON column overspeed.Test_Time is '检测时间'; alter TABLE overspeed add Name_Of_Business_Owner varchar(1024); comment
ON column overspeed.Name_Of_Business_Owner is '经营业户名称'; alter TABLE overspeed add Business_Address varchar(1024); comment
ON column overspeed.Business_Address is '经营业户地址'; alter TABLE overspeed add Notifier varchar(1024); comment
ON column overspeed.Notifier is '通知人'; alter TABLE overspeed add Notification_Method varchar(1024); comment
ON column overspeed.Notification_Method is '通知方式'; alter TABLE overspeed add Notification_Results varchar(1024); comment
ON column overspeed.Notification_Results is '通知结果'; alter TABLE overspeed add Processing_Time varchar(1024); comment
ON column overspeed.Processing_Time is '处理时间'; alter TABLE overspeed add Deduct_Points varchar(1024); comment
ON column overspeed.Deduct_Points is '扣分'; alter TABLE overspeed add Fine varchar(1024); comment
ON column overspeed.Fine is '罚款'; alter TABLE overspeed add Remarks varchar(1024); comment
ON column overspeed.Remarks is '备注';
Loading…
Cancel
Save