Browse Source

道路数据 导入 30%

release_0.0.1
巴林闲侠 3 years ago
parent
commit
0136103753
  1. 16
      api/app/lib/controllers/data/road.js
  2. 50
      api/app/lib/controllers/data/road.json
  3. 7
      api/app/lib/routes/data/index.js
  4. 3
      api/log/development.log

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

@ -1,14 +1,24 @@
'use strict';
const roadKeyMap = require('./road.json')
console.log(roadKeyMap);
async function importIn (ctx) {
try {
const models = ctx.fs.dc.models;
const { level } = ctx.query;
const data = ctx.request.body;
const roadRes = await models.Road.findAll({
where: {
level
}
})
let preCreateArr = []
for (let d of data) {
d.level = level;
await models.User.create(d);
if (roadRes.some(r => r.routeCode + r.sectionNo == d['路线代码'] + d['路段序号'])) {
//repeat
} else {
// await models.Road.create(d);
}
}
ctx.status = 204

50
api/app/lib/controllers/data/road.json

@ -0,0 +1,50 @@
{
"路线名称": "routeName",
"路线代码": "routeCode",
"路段序号": "sectionNo",
"乡镇编码": "townshipCode",
"起点地名": "startingPlaceName",
"起点桩号": "startStation",
"起点分界点类别": "categoryOfStartingPointAndDividingPoint",
"止点地名": "stopPlaceName",
"止点分界点类别": "categoryOfDeadCenterAndDividingPoint",
"止点桩号": "stopStation",
"路段类型": "sectionType",
"路段性质": "natureOfRoadSection",
"建成时间": "completionTime",
"GBM及文明样板路": "gBMAndCivilizedModelRoad",
"地貌": "landforms",
"收费性质": "natureOfCharges",
"涵洞数量": "numberOfCulverts",
"技术等级": "technicalLevel",
"路面类型": "pavementType",
"路面宽度": "pavementWidth",
"路基宽度": "subgradeWidth",
"车道特征": "laneCharacteristics",
"是否晴雨通车": "whetherItIsOpenToTrafficInSunnyOrRainyDays",
"设计时速": "designSpeedPerHour",
"是否城管路段": "urbanManagementSectionOrNot",
"管养单位": "managementAndMaintenanceUnit",
"路政管理单位": "roadAdministrationUnit",
"列养情况": "alimentation",
"列养资金来源": "sourceOfListedMaintenanceFunds",
"养护时间": "curingTime",
"可绿化里程": "greeningMileage",
"已绿化里程": "greeningMileaged",
"重复道路路段类型": "typeOfRepeatedRoadSection",
"重复路段序号": "serialNumberOfRepeatedSection",
"重复路段路线编码": "repeatedSectionRouteCode",
"填报单位": "reportingUnit",
"变更原因": "reasonForChange",
"变更时间": "changeTime",
"是否按干线公路管理接养": "whetherMaintenanceManagedHighway",
"备注": "remarks",
"上年路线编码": "routeCodeOfLastYear",
"上年路线名称": "routeNameOfLastYear",
"上年起点桩号": "startingStationOfLastYear",
"上年止点桩号": "lastYearsEndingPointStakeNumber",
"图形里程": "graphicMileage",
"桩号里程": "chainageMileage",
"所在区县": "districtcounty",
"所在地市": "locationCity"
}

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

@ -1,9 +1,10 @@
'use strict';
const vehicle = require('../../controllers/data/vehicle');
const road = require('../../controllers/data/road');
module.exports = function (app, router, opts) {
// 路政 废弃
app.fs.api.logAttr['GET/vehicle'] = { content: '获取运政列表', visible: true };
router.get('/vehicle', vehicle.get);
@ -12,4 +13,8 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['DEL/vehicle/:vehicleId'] = { content: '删除运政数据', visible: false };
router.del('/vehicle/:vehicleId', vehicle.del);
// 路政 END 废弃
app.fs.api.logAttr['POST/road/import'] = { content: '导入道路数据', visible: true };
router.post('/road/import', road.importIn);
};

3
api/log/development.log

@ -6951,3 +6951,6 @@
2022-07-20 20:48:16.746 - debug: [FS-LOGGER] Init.
2022-07-20 20:48:16.819 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2022-07-20 20:48:16.819 - info: [FS-AUTH] Inject auth and api mv into router.
2022-07-20 21:00:55.063 - debug: [FS-LOGGER] Init.
2022-07-20 21:00:55.128 - info: [FS-ATTACHMENT] Inject attachment mw into router.
2022-07-20 21:00:55.129 - info: [FS-AUTH] Inject auth and api mv into router.

Loading…
Cancel
Save