CODE
1 year ago
18 changed files with 11137 additions and 310 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
@ -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,64 @@ |
|||
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 fun = async () => { |
|||
// note: we don't try/catch this because if connecting throws an exception
|
|||
// we don't need to dispose of the client (it will be undefined)
|
|||
const client = await pool.connect() |
|||
try { |
|||
await client.query('BEGIN') |
|||
console.log(`开始`); |
|||
|
|||
let allVillageRes = (await client.query(`SELECT * FROM village`)).rows |
|||
// console.log(allVillageRes);
|
|||
|
|||
// 读取数据文件
|
|||
let workbook = XLSX.readFile(path.join(__dirname, './data/村.xlsx')); |
|||
let firstSheetName = workbook.SheetNames[0]; |
|||
let worksheet = workbook.Sheets[firstSheetName]; |
|||
let res = XLSX.utils.sheet_to_json(worksheet, { |
|||
defval: '' |
|||
}); |
|||
|
|||
let insertSql = '' |
|||
|
|||
for (let r of res) { |
|||
console.log(r); |
|||
if (r.v_n) { |
|||
let village = allVillageRes.find(v => v.name === r.v_n) |
|||
if (!village) { |
|||
insertSql += `INSERT INTO village (name,township_code) VALUES ('${r.v_n}',${r.t_c});\n` |
|||
} |
|||
} |
|||
} |
|||
|
|||
fs.writeFileSync('village.sql', insertSql, 'utf-8'); |
|||
|
|||
// await client.query('ROLLBACK')
|
|||
await client.query('COMMIT') |
|||
console.log('执行完毕~') |
|||
} catch (e) { |
|||
await client.query('ROLLBACK') |
|||
console.log('执行错误~') |
|||
throw e |
|||
} finally { |
|||
client.release(); |
|||
} |
|||
} |
|||
|
|||
fun() |
|||
} catch (error) { |
|||
console.error(error) |
|||
} |
@ -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,87 @@ |
|||
INSERT INTO village (name,township_code) VALUES ('协城村',360121103000); |
|||
INSERT INTO village (name,township_code) VALUES ('后曲',360121206000); |
|||
INSERT INTO village (name,township_code) VALUES ('若岗村',360121204000); |
|||
INSERT INTO village (name,township_code) VALUES ('张坊村',360121204000); |
|||
INSERT INTO village (name,township_code) VALUES ('南溪村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('沙港村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('宋洲村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('广福村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('荷山村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('官塘村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('漳溪村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('北头村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('万洲村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('吴石村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('木山村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('江家村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('潭岗村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('板湖村',360121108000); |
|||
INSERT INTO village (name,township_code) VALUES ('北旺村',360121105000); |
|||
INSERT INTO village (name,township_code) VALUES ('塔田村',360121000000); |
|||
INSERT INTO village (name,township_code) VALUES ('樟栖',360121000000); |
|||
INSERT INTO village (name,township_code) VALUES ('流芳村',360121200000); |
|||
INSERT INTO village (name,township_code) VALUES ('埂头村',360121100000); |
|||
INSERT INTO village (name,township_code) VALUES ('街上村',360121100000); |
|||
INSERT INTO village (name,township_code) VALUES ('墨山村',360121100000); |
|||
INSERT INTO village (name,township_code) VALUES ('定岗村',360121100000); |
|||
INSERT INTO village (name,township_code) VALUES ('小蓝村',360121100000); |
|||
INSERT INTO village (name,township_code) VALUES ('丰州村',360121201000); |
|||
INSERT INTO village (name,township_code) VALUES ('南坊村 ',360121106000); |
|||
INSERT INTO village (name,township_code) VALUES ('璜溪村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('荆山',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('丁坊村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('南店村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('山背村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('沙潭',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('高田',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('合乞村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('剑霞',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('梁西',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('黄堂',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('棠墅',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('河头',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('黄山',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('西洛村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('浃溪村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('东风社区',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('向塘村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('东风路社区',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('新村村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('新村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('辜坊村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('翠林村',360121101000); |
|||
INSERT INTO village (name,township_code) VALUES ('敷林村',360121471000); |
|||
INSERT INTO village (name,township_code) VALUES ('棠左村',360121471000); |
|||
INSERT INTO village (name,township_code) VALUES ('浒南村',360121471000); |
|||
INSERT INTO village (name,township_code) VALUES ('万湖村',360121471000); |
|||
INSERT INTO village (name,township_code) VALUES ('春溪村',360121471000); |
|||
INSERT INTO village (name,township_code) VALUES ('翠林村',360121471000); |
|||
INSERT INTO village (name,township_code) VALUES ('蛟溪村',360121471000); |
|||
INSERT INTO village (name,township_code) VALUES ('江陂村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('新庄村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('灌溪村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('流芳村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('南山村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('南湖村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('潭林村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('田坪村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('黄坊村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('杨树村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('牌坊村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('胡陶村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('涂村村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('少城村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('青塘村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('竹林村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('东田村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('厚田村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('幽兰村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('马游村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('枫林村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('渡头村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('新荣村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('东联村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('亭山村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('桃岭村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('涂洲村',360121104000); |
|||
INSERT INTO village (name,township_code) VALUES ('罗舍村',360121104000); |
File diff suppressed because it is too large
File diff suppressed because it is too large
Loading…
Reference in new issue