巴林闲侠
3 years ago
15 changed files with 474 additions and 8 deletions
@ -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, |
||||
|
}; |
@ -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; |
||||
|
}; |
Binary file not shown.
@ -0,0 +1,20 @@ |
|||||
|
{ |
||||
|
"区/县": "districtcounty", |
||||
|
"检测点名称": "nameOfInspectionPoint", |
||||
|
"车牌号码": "licensePlate", |
||||
|
"车轴数": "numberOfAxles", |
||||
|
"超限率": "overrunRate", |
||||
|
"超限重量": "overrunWeight", |
||||
|
"车货总重": "grossVehicleWeight", |
||||
|
"车货限重": "vehicleCargoWeightLimit", |
||||
|
"检测时间": "testTime", |
||||
|
"经营业户名称": "nameOfBusinessOwner", |
||||
|
"经营业户地址": "businessAddress", |
||||
|
"通知人": "notifier", |
||||
|
"通知方式": "notificationMethod", |
||||
|
"通知结果": "notificationResults", |
||||
|
"处理时间": "processingTime", |
||||
|
"扣分": "deductPoints", |
||||
|
"罚款": "fine", |
||||
|
"备注": "remarks" |
||||
|
} |
@ -0,0 +1,20 @@ |
|||||
|
{ |
||||
|
"districtcounty": "区/县", |
||||
|
"nameOfInspectionPoint": "检测点名称", |
||||
|
"licensePlate": "车牌号码", |
||||
|
"numberOfAxles": "车轴数", |
||||
|
"overrunRate": "超限率", |
||||
|
"overrunWeight": "超限重量", |
||||
|
"grossVehicleWeight": "车货总重", |
||||
|
"vehicleCargoWeightLimit": "车货限重", |
||||
|
"testTime": "检测时间", |
||||
|
"nameOfBusinessOwner": "经营业户名称", |
||||
|
"businessAddress": "经营业户地址", |
||||
|
"notifier": "通知人", |
||||
|
"notificationMethod": "通知方式", |
||||
|
"notificationResults": "通知结果", |
||||
|
"processingTime": "处理时间", |
||||
|
"deductPoints": "扣分", |
||||
|
"fine": "罚款", |
||||
|
"remarks": "备注" |
||||
|
} |
@ -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" |
||||
|
} |
@ -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…
Reference in new issue