38 changed files with 424 additions and 12 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,17 @@ |
|||
{ |
|||
// 使用 IntelliSense 了解相关属性。 |
|||
// 悬停以查看现有属性的描述。 |
|||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 |
|||
"version": "0.2.0", |
|||
"configurations": [ |
|||
{ |
|||
"type": "node", |
|||
"request": "launch", |
|||
"name": "启动程序", |
|||
"skipFiles": [ |
|||
"<node_internals>/**" |
|||
], |
|||
"program": "${workspaceFolder}\\index.js" |
|||
} |
|||
] |
|||
} |
@ -0,0 +1,11 @@ |
|||
FROM repository.anxinyun.cn/base-images/nodejs12:20.10.12.2 |
|||
|
|||
COPY . /var/app |
|||
|
|||
WORKDIR /var/app |
|||
|
|||
RUN npm cache clean -f |
|||
RUN rm -rf package-lock.json |
|||
RUN npm install --registry http://10.8.30.22:7000 |
|||
|
|||
CMD ["node", "index.js"] |
@ -0,0 +1,7 @@ |
|||
FROM repository.anxinyun.cn/base-images/nodejs12:20.10.12.2 |
|||
COPY ./scripts/1.3.1/data/1_insert_report_data /var/app |
|||
WORKDIR /var/app |
|||
RUN npm cache clean -f |
|||
RUN rm -rf package-lock.json |
|||
RUN npm install --registry https://nexus.ngaiot.com/repository/fs-npm/ |
|||
CMD ["node", "index.js"] |
Binary file not shown.
@ -0,0 +1,269 @@ |
|||
try { |
|||
const { Pool, Client } = require('pg') |
|||
const XLSX = require('xlsx') |
|||
const path = require('path') |
|||
const fs = require("fs"); |
|||
|
|||
//开发
|
|||
const pool = new Pool({ |
|||
user: 'postgres', |
|||
host: '10.8.30.32', |
|||
database: 'highways4good', |
|||
password: '123', |
|||
port: 5432, |
|||
}) |
|||
|
|||
// 测试环境
|
|||
// const pool = new Pool({
|
|||
// user: 'highwayadmin',
|
|||
// host: '10.8.40.223',
|
|||
// database: 'highway4good',
|
|||
// password: 'highway123',
|
|||
// port: 5432,
|
|||
// })
|
|||
|
|||
// 商用环境
|
|||
// const pool = new Pool({
|
|||
// user: 'highwayadmin',
|
|||
// host: '10.8.40.223',
|
|||
// database: 'highway4good',
|
|||
// password: 'highway123',
|
|||
// port: 5432,
|
|||
// })
|
|||
// const userId = ''
|
|||
|
|||
const fun = async () => { |
|||
const client = await pool.connect() |
|||
try { |
|||
await client.query('BEGIN') |
|||
console.log(`开始`); |
|||
|
|||
let allVillageRes = (await client.query(`SELECT * FROM village`)).rows |
|||
let allRoads = (await client.query(`SELECT * FROM road`)).rows |
|||
let towns = (await client.query(`SELECT * FROM town`)).rows |
|||
|
|||
// 读取数据文件
|
|||
let workbook = XLSX.readFile(path.join(__dirname, './data/sihao.xlsx')); |
|||
let firstSheetName = workbook.SheetNames[0]; |
|||
let worksheet = workbook.Sheets[firstSheetName]; |
|||
let res = XLSX.utils.sheet_to_json(worksheet, { |
|||
defval: '' |
|||
}); |
|||
|
|||
let villageSql = '' |
|||
let noExistVillage = '' |
|||
let noExistVillageObj = {} |
|||
let delSql = '' |
|||
allRoads.forEach(r => { |
|||
let isExit = res.find(s => s.route_code == r.route_code && s.section_no == r.section_no && s.route_name == r.route_name) |
|||
if (!isExit) { |
|||
delSql += `UPDATE road SET del = true WHERE id = ${r.id};\n` |
|||
} |
|||
}) |
|||
if (delSql) fs.writeFileSync('delete_road.sql', delSql, 'utf-8'); |
|||
|
|||
for (let r of [...res]) { |
|||
console.log(r); |
|||
// if (r.id == 3259) {
|
|||
// console.log(r);
|
|||
// }
|
|||
let villageId = null |
|||
if (r['所属行政村']) { |
|||
let v = r['所属行政村'] |
|||
v = v.split(' ')[0] |
|||
v = v.trim() |
|||
if (v) { |
|||
let noExist = false |
|||
let corV = allVillageRes.find(village => village.name === v) |
|||
if (corV) { |
|||
villageId = corV.id |
|||
} else { |
|||
|
|||
if (!v.endsWith('村')) { |
|||
v += '村' |
|||
let corV = allVillageRes.find(village => village.name === v) |
|||
if (corV) { |
|||
villageId = corV.id |
|||
} else { |
|||
noExist = true |
|||
} |
|||
} else { |
|||
noExist = true |
|||
} |
|||
} |
|||
|
|||
if (noExist) { |
|||
if (!noExistVillageObj[v]) { |
|||
noExistVillage += `${v}\n` |
|||
noExistVillageObj[v] = true |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
let del = false |
|||
let spot = false |
|||
|
|||
let isDel = r['isdelete'] |
|||
|
|||
if (isDel) { |
|||
isDel = isDel.toString() |
|||
isDel = isDel.trim() |
|||
if (isDel) { |
|||
if (isDel == 1) { |
|||
del = true |
|||
} |
|||
} |
|||
} |
|||
|
|||
let mark = r['mark'] |
|||
if (mark) { |
|||
spot = true |
|||
} else { |
|||
spot = false |
|||
} |
|||
|
|||
let rId = r.id |
|||
if (rId) { |
|||
rId = rId.toString() |
|||
rId = rId.trim() |
|||
if (rId) { |
|||
r.id = rId |
|||
} |
|||
} |
|||
|
|||
let town = towns.find(x => x.name == r['乡镇定稿']) |
|||
let township_code = town ? town.code : '' |
|||
const arr = [] |
|||
Object.keys(r).forEach(key => { |
|||
arr.push(key) |
|||
}) |
|||
console.log(arr) |
|||
let isExit = allRoads.find(s => s.route_code == r.route_code && s.section_no == r.section_no && s.route_name == r.route_name) |
|||
if (isExit) { |
|||
villageSql += `UPDATE road SET village_id = ${villageId}, "del" = ${del}, spot = ${spot}, "township_code" = ${township_code ? township_code : `null`} WHERE id = ${r.id};\n` |
|||
} else { |
|||
const { |
|||
route_name = `null`, route_code = `null`, section_no = `null`, township_code = `null`, starting_place_name = `null`, |
|||
start_station = `null`, category_of_starting_point_and_dividing_point = `null`, stop_place_name = `null`, |
|||
category_of_dead_center_and_dividing_point = `null`, stop_station = `null`, section_type = `null`, |
|||
route_code_before_road_network_adjustment = `null`, serial_number_of_original_section = `null`, |
|||
starting_stake_number_of_the_original_road_section = `null`, ending_point_stake_no_of_the_original_road_section = `null`, |
|||
route_level = `null`, nature_of_road_section = `null`, completion_time = `null`, reconstruction_time = `null`, nature_of_construction = `null`, |
|||
gbm_and_civilized_model_road = `null`, landforms = `null`, nature_of_charges = `null`, toll_station = `null`, number_of_culverts = `null`, |
|||
technical_level = `null`, pavement_type = `null`, pavement_width = `null`, subgrade_width = `null`, lane_characteristics = `null`, |
|||
whether_it_is_open_to_traffic_in_sunny_or_rainy_days = `null`, design_speed_per_hour = `null`, urban_management_section_or_not = `null`, |
|||
management_and_maintenance_unit = `null`, road_administration_unit = `null`, alimentation = `null`, source_of_listed_maintenance_funds = `null`, |
|||
curing_time = `null`, greening_mileage = `null`, greening_mileaged = `null`, type_of_repeated_road_section = `null`, |
|||
serial_number_of_repeated_section = `null`, repeated_section_route_code = `null`, planned_fund_category = `null`, |
|||
planned_year = `null`, plan_document_no = `null`, plan_item_unique_code = `null`, planned_project_route_code = `null`, |
|||
plan_project_name = `null`, planned_project_type = `null`, completion_status = `null`, year_of_completion = `null`, planned_fund_category__one = `null`, |
|||
planned_year__one = `null`, plan_document_no__one = `null`, plan_item_unique_code__one = `null`, plan_project_name__one = `null`, |
|||
completion_status__one = `null`, year_of_completion__one = `null`, station_range = `null`, reporting_unit = `null`, reason_for_change = `null`, |
|||
change_time = `null`, last_repair_and_maintenance_year = `null`, whether_maintenance_managed_highway = `null`, remarks = `null`, |
|||
route_code_of_last_year = `null`, route_name_of_last_year = `null`, starting_station_of_last_year = `null`, |
|||
last_years_ending_point_stake_number = `null`, graphic_mileage = `null`, chainage_mileage = `null`, districtcounty = `null`, |
|||
location_city = `null`, level = `null`, surface_thickness = `null`, |
|||
} = r; |
|||
villageSql += ` |
|||
INSERT INTO road ( |
|||
village_id, |
|||
"del", |
|||
spot, |
|||
route_name, route_code, section_no, township_code, starting_place_name, |
|||
start_station, category_of_starting_point_and_dividing_point, stop_place_name, |
|||
category_of_dead_center_and_dividing_point, stop_station, section_type, |
|||
route_code_before_road_network_adjustment, serial_number_of_original_section, |
|||
starting_stake_number_of_the_original_road_section, ending_point_stake_no_of_the_original_road_section, |
|||
route_level, nature_of_road_section, completion_time, reconstruction_time, nature_of_construction, |
|||
gbm_and_civilized_model_road, landforms, nature_of_charges, toll_station, number_of_culverts, |
|||
technical_level, pavement_type, pavement_width, subgrade_width, lane_characteristics, |
|||
whether_it_is_open_to_traffic_in_sunny_or_rainy_days, design_speed_per_hour, urban_management_section_or_not, |
|||
management_and_maintenance_unit, road_administration_unit, alimentation, source_of_listed_maintenance_funds, |
|||
curing_time, greening_mileage, greening_mileaged, type_of_repeated_road_section, |
|||
serial_number_of_repeated_section, repeated_section_route_code, planned_fund_category, |
|||
planned_year, plan_document_no, plan_item_unique_code, planned_project_route_code, |
|||
plan_project_name, planned_project_type, completion_status, year_of_completion, planned_fund_category__one, |
|||
planned_year__one, plan_document_no__one, plan_item_unique_code__one, plan_project_name__one, |
|||
completion_status__one, year_of_completion__one, station_range, reporting_unit, reason_for_change, |
|||
change_time, last_repair_and_maintenance_year, whether_maintenance_managed_highway, remarks, |
|||
route_code_of_last_year, route_name_of_last_year, starting_station_of_last_year, |
|||
last_years_ending_point_stake_number, graphic_mileage, chainage_mileage, districtcounty, |
|||
location_city, level, surface_thickness |
|||
) VALUES ( |
|||
${villageId || `null`}, |
|||
${del}, |
|||
${spot}, |
|||
${route_name ? `'${r.route_name}'` : `null`}, ${route_code ? `'${r.route_code}'` : `null`}, |
|||
${section_no ? `'${r.section_no}'` : `null`}, ${township_code ? `'${r.township_code}'` : `null`}, |
|||
${starting_place_name ? `'${r.starting_place_name}'` : `null`}, |
|||
${start_station ? `'${r.start_station}'` : `null`}, ${category_of_starting_point_and_dividing_point ? `'${r.category_of_starting_point_and_dividing_point}'` : `null`}, |
|||
${stop_place_name ? `'${r.stop_place_name}'` : `null`}, |
|||
${category_of_dead_center_and_dividing_point ? `'${r.category_of_dead_center_and_dividing_point}'` : `null`}, ${stop_station ? `'${r.stop_station}'` : `null`}, |
|||
${section_type ? `'${r.section_type}'` : `null`}, |
|||
${route_code_before_road_network_adjustment ? `'${r.route_code_before_road_network_adjustment}'` : `null`}, ${serial_number_of_original_section ? `'${r.serial_number_of_original_section}'` : `null`}, |
|||
${starting_stake_number_of_the_original_road_section ? `'${r.starting_stake_number_of_the_original_road_section}'` : `null`}, |
|||
${ending_point_stake_no_of_the_original_road_section ? `'${r.ending_point_stake_no_of_the_original_road_section}'` : `null`}, |
|||
${route_level ? `'${r.route_level}'` : `null`}, ${nature_of_road_section ? `'${r.nature_of_road_section}'` : `null`}, |
|||
${completion_time ? `'${r.completion_time}'` : `null`}, |
|||
${reconstruction_time ? `'${r.reconstruction_time}'` : `null`}, ${nature_of_construction ? `'${r.nature_of_construction}'` : `null`}, |
|||
${gbm_and_civilized_model_road ? `'${r.gbm_and_civilized_model_road}'` : `null`}, ${landforms ? `'${r.landforms}'` : `null`}, |
|||
${nature_of_charges ? `'${r.nature_of_charges}'` : `null`}, |
|||
${toll_station ? `'${r.toll_station}'` : `null`}, ${number_of_culverts ? `'${r.number_of_culverts}'` : `null`}, |
|||
${technical_level ? `'${r.technical_level}'` : `null`}, ${pavement_type ? `'${r.pavement_type}'` : `null`}, |
|||
${pavement_width ? `'${r.pavement_width}'` : `null`}, |
|||
${subgrade_width ? `'${r.subgrade_width}'` : `null`}, ${lane_characteristics ? `'${r.lane_characteristics}'` : `null`}, |
|||
${whether_it_is_open_to_traffic_in_sunny_or_rainy_days ? `'${r.whether_it_is_open_to_traffic_in_sunny_or_rainy_days}'` : `null`}, |
|||
${design_speed_per_hour ? `'${r.design_speed_per_hour}'` : `null`}, ${urban_management_section_or_not ? `'${r.urban_management_section_or_not}'` : `null`}, |
|||
${management_and_maintenance_unit ? `'${r.management_and_maintenance_unit}'` : `null`}, ${road_administration_unit ? `'${r.road_administration_unit}'` : `null`}, |
|||
${alimentation ? `'${r.alimentation}'` : `null`}, ${source_of_listed_maintenance_funds ? `'${r.source_of_listed_maintenance_funds}'` : `null`}, |
|||
${curing_time ? `'${r.curing_time}'` : `null`}, ${greening_mileage ? `'${r.greening_mileage}'` : `null`}, |
|||
${greening_mileaged ? `'${r.greening_mileaged}'` : `null`}, |
|||
${type_of_repeated_road_section ? `'${r.type_of_repeated_road_section}'` : `null`}, |
|||
${serial_number_of_repeated_section ? `'${r.serial_number_of_repeated_section}'` : `null`}, |
|||
${repeated_section_route_code ? `'${r.repeated_section_route_code}'` : `null`}, |
|||
${planned_fund_category ? `'${r.planned_fund_category}'` : `null`}, |
|||
${planned_year ? `'${r.planned_year}'` : `null`}, ${plan_document_no ? `'${r.plan_document_no}'` : `null`}, |
|||
${plan_item_unique_code ? `'${r.plan_item_unique_code}'` : `null`}, |
|||
${planned_project_route_code ? `'${r.planned_project_route_code}'` : `null`}, |
|||
${plan_project_name ? `'${r.plan_project_name}'` : `null`}, ${planned_project_type ? `'${r.planned_project_type}'` : `null`}, |
|||
${completion_status ? `'${r.completion_status}'` : `null`}, |
|||
${year_of_completion ? `'${r.year_of_completion}'` : `null`}, ${planned_fund_category__one ? `'${r.planned_fund_category__one}'` : `null`}, |
|||
${planned_year__one ? `'${r.planned_year__one}'` : `null`}, ${plan_document_no__one ? `'${r.plan_document_no__one}'` : `null`}, |
|||
${plan_item_unique_code__one ? `'${r.plan_item_unique_code__one}'` : `null`}, |
|||
${plan_project_name__one ? `'${r.plan_project_name__one}'` : `null`}, |
|||
${completion_status__one ? `'${r.completion_status__one}'` : `null`}, ${year_of_completion__one ? `'${r.year_of_completion__one}'` : `null`}, |
|||
${station_range ? `'${r.station_range}'` : `null`}, ${reporting_unit ? `'${r.reporting_unit}'` : `null`}, |
|||
${reason_for_change ? `'${r.reason_for_change}'` : `null`}, |
|||
${change_time ? `'${r.change_time}'` : `null`}, ${last_repair_and_maintenance_year ? `'${r.last_repair_and_maintenance_year}'` : `null`}, |
|||
${whether_maintenance_managed_highway ? `'${r.whether_maintenance_managed_highway}'` : `null`}, ${remarks ? `'${r.remarks}'` : `null`}, |
|||
${route_code_of_last_year ? `'${r.route_code_of_last_year}'` : `null`}, ${route_name_of_last_year ? `'${r.route_name_of_last_year}'` : `null`}, |
|||
${starting_station_of_last_year ? `'${r.starting_station_of_last_year}'` : `null`}, |
|||
${last_years_ending_point_stake_number ? `'${r.last_years_ending_point_stake_number}'` : `null`}, ${graphic_mileage ? `'${r.graphic_mileage}'` : `null`}, |
|||
${chainage_mileage ? `'${r.chainage_mileage}'` : `null`}, ${districtcounty ? `'${r.districtcounty}'` : `null`}, |
|||
${location_city ? `'${r.location_city}'` : `null`}, ${level ? `'${r.level}'` : `null`}, |
|||
${surface_thickness ? `'${r.surface_thickness}'` : `null`} |
|||
);\n` |
|||
} |
|||
} |
|||
|
|||
|
|||
fs.writeFileSync('road_update.sql', villageSql, 'utf-8'); |
|||
// fs.writeFileSync('no_exist_village.txt', noExistVillage, 'utf-8');
|
|||
|
|||
// await client.query('ROLLBACK')
|
|||
await client.query('COMMIT') |
|||
console.log('执行完毕~') |
|||
} catch (e) { |
|||
await client.query('ROLLBACK') |
|||
console.log('执行错误~' + JSON.stringify(e)) |
|||
throw e |
|||
} finally { |
|||
client.release(); |
|||
} |
|||
} |
|||
|
|||
fun() |
|||
} catch (error) { |
|||
console.error(error) |
|||
} |
@ -0,0 +1,36 @@ |
|||
|
|||
INSERT INTO town(name,code) VALUES ('八一乡', 360121206000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('东新乡', 360121205000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('富山乡', 360121204000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('冈上镇', 360121107000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('广福镇', 360121108000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('黄马乡', 360121203000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('蒋巷镇', 360121105000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('金湖管理处', 330052); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('泾口乡', 360121200000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('莲塘镇', 360121100000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('南新乡', 360121201000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('三江镇', 360121102000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('塔城乡', 360121202000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('塘南镇', 360121103000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('武阳镇', 360121106000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('向塘镇', 360121101000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('银三角管委会', 360121471000); |
|||
|
|||
INSERT INTO town(name,code) VALUES ('幽兰镇', 360121104000); |
@ -0,0 +1,17 @@ |
|||
{ |
|||
"name": "appkey-generator", |
|||
"version": "1.0.0", |
|||
"description": "tool", |
|||
"main": "index.js", |
|||
"scripts": { |
|||
"test": "mocha", |
|||
"start": "set NODE_ENV=development&&node index" |
|||
}, |
|||
"author": "liu", |
|||
"license": "ISC", |
|||
"dependencies": { |
|||
"crypto-js": "^4.1.1", |
|||
"pg": "^7.18.2", |
|||
"xlsx": "^0.17.1" |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
create table town |
|||
( |
|||
id serial |
|||
constraint table_name_pk |
|||
primary key, |
|||
name varchar, |
|||
code varchar |
|||
); |
|||
|
|||
create unique index town_id_uindex |
|||
on town (id); |
@ -0,0 +1,8 @@ |
|||
alter table road_spot_check_preview |
|||
add village_mil float; |
|||
|
|||
alter table road_spot_check_preview |
|||
add town_mil float; |
|||
|
|||
alter table road_spot_check_preview |
|||
add country_mil float; |
Loading…
Reference in new issue