wenlele
1 year ago
23 changed files with 2089 additions and 683 deletions
@ -0,0 +1,52 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const RoadSpotCheck = sequelize.define("roadSpotCheck", { |
||||
|
id: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: true, |
||||
|
field: "id", |
||||
|
autoIncrement: true, |
||||
|
unique: "report_spot_check_v2_id_uindex" |
||||
|
}, |
||||
|
roadId: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "road_id", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
maintenanceCount: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "抽查时养护次数", |
||||
|
primaryKey: false, |
||||
|
field: "maintenance_count", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
prepareId: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "抽查预览id", |
||||
|
primaryKey: false, |
||||
|
field: "prepare_id", |
||||
|
autoIncrement: false |
||||
|
} |
||||
|
}, { |
||||
|
tableName: "road_spot_check", |
||||
|
comment: "", |
||||
|
indexes: [] |
||||
|
}); |
||||
|
dc.models.RoadSpotCheck = RoadSpotCheck; |
||||
|
return RoadSpotCheck; |
||||
|
}; |
@ -0,0 +1,79 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const RoadSpotCheckChangeLog = sequelize.define("roadSpotCheckChangeLog", { |
||||
|
id: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: true, |
||||
|
field: "id", |
||||
|
autoIncrement: true, |
||||
|
unique: "road_spot_check_change_log_id_uindex" |
||||
|
}, |
||||
|
userId: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "修改者", |
||||
|
primaryKey: false, |
||||
|
field: "user_id", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
time: { |
||||
|
type: DataTypes.DATE, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "time", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
content: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "修改内容描述", |
||||
|
primaryKey: false, |
||||
|
field: "content", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
originRoadId: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "原本的道路", |
||||
|
primaryKey: false, |
||||
|
field: "origin_road_id", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
changeRoadId: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "更改后的道路", |
||||
|
primaryKey: false, |
||||
|
field: "change_road_id", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
prepareId: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "抽查预览id", |
||||
|
primaryKey: false, |
||||
|
field: "prepare_id", |
||||
|
autoIncrement: false |
||||
|
} |
||||
|
}, { |
||||
|
tableName: "road_spot_check_change_log", |
||||
|
comment: "", |
||||
|
indexes: [] |
||||
|
}); |
||||
|
dc.models.RoadSpotCheckChangeLog = RoadSpotCheckChangeLog; |
||||
|
return RoadSpotCheckChangeLog; |
||||
|
}; |
@ -0,0 +1,88 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const RoadSpotCheckPreview = sequelize.define("roadSpotCheckPreview", { |
||||
|
id: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: true, |
||||
|
field: "id", |
||||
|
autoIncrement: true, |
||||
|
unique: "report_spot_check_preview_v2_id_uindex" |
||||
|
}, |
||||
|
countyPercentage: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "县道抽查比例", |
||||
|
primaryKey: false, |
||||
|
field: "county_percentage", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
date: { |
||||
|
type: DataTypes.DATE, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "抽取时间", |
||||
|
primaryKey: false, |
||||
|
field: "date", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
countyRoadId: { |
||||
|
type: DataTypes.ARRAY(DataTypes.INTEGER), |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "抽到的县道id", |
||||
|
primaryKey: false, |
||||
|
field: "county_road_id", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
townshipRoadId: { |
||||
|
type: DataTypes.ARRAY(DataTypes.INTEGER), |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "乡道id", |
||||
|
primaryKey: false, |
||||
|
field: "township_road_id", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
checked: { |
||||
|
type: DataTypes.BOOLEAN, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "是否应用", |
||||
|
primaryKey: false, |
||||
|
field: "checked", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
villageRoadId: { |
||||
|
type: DataTypes.ARRAY(DataTypes.INTEGER), |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "村道id", |
||||
|
primaryKey: false, |
||||
|
field: "village_road_id", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
villageId: { |
||||
|
type: DataTypes.ARRAY(DataTypes.INTEGER), |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "抽到的村庄的id", |
||||
|
primaryKey: false, |
||||
|
field: "village_id", |
||||
|
autoIncrement: false |
||||
|
} |
||||
|
}, { |
||||
|
tableName: "road_spot_check_preview", |
||||
|
comment: "", |
||||
|
indexes: [] |
||||
|
}); |
||||
|
dc.models.RoadSpotCheckPreview = RoadSpotCheckPreview; |
||||
|
return RoadSpotCheckPreview; |
||||
|
}; |
@ -0,0 +1,61 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const Village = sequelize.define("village", { |
||||
|
id: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: true, |
||||
|
field: "id", |
||||
|
autoIncrement: true, |
||||
|
unique: "village_id_uindex" |
||||
|
}, |
||||
|
name: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "name", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
townshipCode: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "所属乡镇代码", |
||||
|
primaryKey: false, |
||||
|
field: "township_code", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
longitude: { |
||||
|
type: DataTypes.DOUBLE, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "经度", |
||||
|
primaryKey: false, |
||||
|
field: "longitude", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
latitude: { |
||||
|
type: DataTypes.DOUBLE, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "纬度", |
||||
|
primaryKey: false, |
||||
|
field: "latitude", |
||||
|
autoIncrement: false |
||||
|
} |
||||
|
}, { |
||||
|
tableName: "village", |
||||
|
comment: "", |
||||
|
indexes: [] |
||||
|
}); |
||||
|
dc.models.Village = Village; |
||||
|
return Village; |
||||
|
}; |
@ -0,0 +1,60 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const VillageDistance = sequelize.define("villageDistance", { |
||||
|
id: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: true, |
||||
|
field: "id", |
||||
|
autoIncrement: true, |
||||
|
unique: "village_distance_id_uindex" |
||||
|
}, |
||||
|
originVillage: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: "原点村庄", |
||||
|
primaryKey: false, |
||||
|
field: "origin_village", |
||||
|
autoIncrement: false, |
||||
|
references: { |
||||
|
key: "id", |
||||
|
model: "village" |
||||
|
} |
||||
|
}, |
||||
|
calcVillage: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "相对计算村庄", |
||||
|
primaryKey: false, |
||||
|
field: "calc_village", |
||||
|
autoIncrement: false, |
||||
|
references: { |
||||
|
key: "id", |
||||
|
model: "village" |
||||
|
} |
||||
|
}, |
||||
|
diatance: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: true, |
||||
|
defaultValue: null, |
||||
|
comment: "距离 m", |
||||
|
primaryKey: false, |
||||
|
field: "diatance", |
||||
|
autoIncrement: false |
||||
|
} |
||||
|
}, { |
||||
|
tableName: "village_distance", |
||||
|
comment: "", |
||||
|
indexes: [] |
||||
|
}); |
||||
|
dc.models.VillageDistance = VillageDistance; |
||||
|
return VillageDistance; |
||||
|
}; |
@ -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"] |
@ -0,0 +1,161 @@ |
|||||
|
try { |
||||
|
const { Pool, Client } = require('pg') |
||||
|
const request = require('superagent') |
||||
|
const path = require('path') |
||||
|
const fs = require("fs"); |
||||
|
|
||||
|
const pool = new Pool({ |
||||
|
host: '10.8.30.32', |
||||
|
port: 5432, |
||||
|
user: 'postgres', |
||||
|
password: '123', |
||||
|
database: 'highways4good', |
||||
|
}) |
||||
|
|
||||
|
function getDistance (lat1, lon1, lat2, lon2) { |
||||
|
var R = 6371000; // 半径 of the earth in meters
|
||||
|
var dLat = deg2rad(lat2 - lat1); // deg2rad below
|
||||
|
var dLon = deg2rad(lon2 - lon1); |
||||
|
var a = |
||||
|
Math.sin(dLat / 2) * Math.sin(dLat / 2) + |
||||
|
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * |
||||
|
Math.sin(dLon / 2) * Math.sin(dLon / 2) |
||||
|
; |
||||
|
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); |
||||
|
var d = R * c; // Distance in meters
|
||||
|
return d; |
||||
|
} |
||||
|
|
||||
|
function deg2rad (deg) { |
||||
|
return deg * (Math.PI / 180) |
||||
|
} |
||||
|
|
||||
|
// 两个经纬度
|
||||
|
let coord1 = { latitude: 31.2304, longitude: 121.4737 }; // 上海
|
||||
|
let coord2 = { latitude: 30.5685, longitude: 114.3055 }; // 武汉
|
||||
|
|
||||
|
// let distance = getDistance(coord1.latitude, coord1.longitude, coord2.latitude, coord2.longitude);
|
||||
|
|
||||
|
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 pageNum = 1 |
||||
|
let continueSearch = true |
||||
|
for (; continueSearch;) { |
||||
|
console.log(`查询第${pageNum}页`); |
||||
|
const res = await request.get(`https://restapi.amap.com/v5/place/text?key=21c2d970e1646bb9a795900dd00093ce&keywords=%E6%9D%91%E5%A7%94%E4%BC%9A%7C%E6%9D%91%E6%B0%91%E5%A7%94%E5%91%98%E4%BC%9A&types=130106®ion=360121&citylimit=true&page_size=25&page_num=${pageNum}&extensions=all`) |
||||
|
|
||||
|
// console.log(res.body);
|
||||
|
const data = res.body |
||||
|
console.log(`查得 ${data.pois.length} 条`); |
||||
|
if (data.count == 0) { |
||||
|
continueSearch = false |
||||
|
break; |
||||
|
} else { |
||||
|
pageNum++ |
||||
|
} |
||||
|
for await (let p of data.pois) { |
||||
|
if (p.name.includes('村委会') || p.name.includes('村民委员会')) { |
||||
|
let vName = p.name.replace('村委会', '').replace('村民委员会', '').replace(/\(.*?\)/g, '') |
||||
|
|
||||
|
if (vName.includes('乡')) { |
||||
|
let townKeyIndex = vName.indexOf('乡') |
||||
|
if (townKeyIndex >= 0) { |
||||
|
vName = vName.substring(townKeyIndex + 1) |
||||
|
} |
||||
|
} |
||||
|
if (vName.includes('镇')) { |
||||
|
let townKeyIndex = vName.indexOf('镇') |
||||
|
if (townKeyIndex >= 0) { |
||||
|
vName = vName.substring(townKeyIndex + 1) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (!vName.endsWith('村')) { |
||||
|
vName = vName + '村' |
||||
|
} |
||||
|
|
||||
|
console.log(`${vName}`); |
||||
|
let locationArr = p.location.split(',') |
||||
|
|
||||
|
// 查询镇名是否存在
|
||||
|
const existRes = await client.query( |
||||
|
`SELECT * FROM village WHERE name=$1`, |
||||
|
[vName] |
||||
|
) |
||||
|
|
||||
|
if (existRes.rowCount == 0) { |
||||
|
|
||||
|
} else { |
||||
|
let existV = existRes[0] |
||||
|
await client.query( |
||||
|
`UPDATE village SET longitude=$1, latitude=$2 WHERE id=$3`, |
||||
|
[locationArr[0], locationArr[1], existV.id] |
||||
|
) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const allVillagesRes = await client.query( |
||||
|
`SELECT * FROM village` |
||||
|
) |
||||
|
const allVillages = allVillagesRes.rows |
||||
|
for (let v of allVillages) { |
||||
|
if (!v.longitude || !v.latitude) { |
||||
|
continue |
||||
|
} |
||||
|
for (let vv of allVillages) { |
||||
|
if ( |
||||
|
v.id != vv.id |
||||
|
// 只计算一个乡镇内的村
|
||||
|
&& v.township_code == vv.township_code |
||||
|
) { |
||||
|
if (!vv.longitude || !vv.latitude) { |
||||
|
continue |
||||
|
} |
||||
|
let distance = getDistance(v.latitude, v.longitude, vv.latitude, vv.longitude) |
||||
|
console.log(`${v.name} 与 ${vv.name} 的距离为 ${distance} 米`); |
||||
|
|
||||
|
distance = Math.round(distance) |
||||
|
const existRes = await client.query( |
||||
|
`SELECT * FROM village_distance WHERE origin_village=$1 AND calc_village=$2`, |
||||
|
[v.id, vv.id] |
||||
|
) |
||||
|
if (existRes.rowCount == 0) { |
||||
|
await client.query( |
||||
|
`INSERT INTO village_distance (origin_village, calc_village, distance) VALUES ($1, $2, $3)`, |
||||
|
[v.id, vv.id, distance] |
||||
|
) |
||||
|
} else { |
||||
|
await client.query( |
||||
|
`UPDATE village_distance SET distance=$1 WHERE origin_village=$2 AND calc_village=$` |
||||
|
, [distance, v.id, vv.id] |
||||
|
) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 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", |
||||
|
"superagent": "^8.1.2" |
||||
|
} |
||||
|
} |
@ -0,0 +1,91 @@ |
|||||
|
create table if not exists road_spot_check_preview |
||||
|
( |
||||
|
id serial not null |
||||
|
constraint report_spot_check_preview_v2_pk |
||||
|
primary key, |
||||
|
county_percentage integer not null, |
||||
|
date timestamp with time zone, |
||||
|
county_road_id integer[], |
||||
|
township_road_id integer[], |
||||
|
checked boolean default false not null, |
||||
|
village_road_id integer[], |
||||
|
village_id integer[] |
||||
|
); |
||||
|
|
||||
|
comment on table road_spot_check_preview is '道路抽查预览表'; |
||||
|
|
||||
|
comment on column road_spot_check_preview.county_percentage is '县道抽查比例'; |
||||
|
|
||||
|
comment on column road_spot_check_preview.date is '抽取时间'; |
||||
|
|
||||
|
comment on column road_spot_check_preview.county_road_id is '抽到的县道id'; |
||||
|
|
||||
|
comment on column road_spot_check_preview.township_road_id is '乡道id'; |
||||
|
|
||||
|
comment on column road_spot_check_preview.checked is '是否应用'; |
||||
|
|
||||
|
comment on column road_spot_check_preview.village_road_id is '村道id'; |
||||
|
|
||||
|
comment on column road_spot_check_preview.village_id is '抽到的村庄的id'; |
||||
|
|
||||
|
create unique index if not exists report_spot_check_preview_v2_id_uindex |
||||
|
on road_spot_check_preview (id); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
create table if not exists road_spot_check |
||||
|
( |
||||
|
id serial not null |
||||
|
constraint report_spot_check_v2_pk |
||||
|
primary key, |
||||
|
road_id integer not null, |
||||
|
maintenance_count integer, |
||||
|
prepare_id integer not null |
||||
|
); |
||||
|
|
||||
|
comment on table road_spot_check is '抽查结果表'; |
||||
|
|
||||
|
comment on column road_spot_check.maintenance_count is '抽查时养护次数'; |
||||
|
|
||||
|
comment on column road_spot_check.prepare_id is '抽查预览id'; |
||||
|
|
||||
|
create unique index if not exists report_spot_check_v2_id_uindex |
||||
|
on road_spot_check (id); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
create table if not exists road_spot_check_change_log |
||||
|
( |
||||
|
id serial not null |
||||
|
constraint road_spot_check_change_log_pk |
||||
|
primary key, |
||||
|
user_id integer not null, |
||||
|
time timestamp with time zone not null, |
||||
|
content varchar(1024), |
||||
|
origin_road_id integer not null, |
||||
|
change_road_id integer not null, |
||||
|
prepare_id integer |
||||
|
constraint road_spot_check_change_log_road_spot_check_preview_id_fk |
||||
|
references road_spot_check_preview |
||||
|
); |
||||
|
|
||||
|
comment on table road_spot_check_change_log is '道路养护抽查调整日志'; |
||||
|
|
||||
|
comment on column road_spot_check_change_log.user_id is '修改者'; |
||||
|
|
||||
|
comment on column road_spot_check_change_log.content is '修改内容描述'; |
||||
|
|
||||
|
comment on column road_spot_check_change_log.origin_road_id is '原本的道路'; |
||||
|
|
||||
|
comment on column road_spot_check_change_log.change_road_id is '更改后的道路'; |
||||
|
|
||||
|
comment on column road_spot_check_change_log.prepare_id is '抽查预览id'; |
||||
|
|
||||
|
create unique index if not exists road_spot_check_change_log_id_uindex |
||||
|
on road_spot_check_change_log (id); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,50 @@ |
|||||
|
create table if not exists village |
||||
|
( |
||||
|
id serial not null |
||||
|
constraint village_pk |
||||
|
primary key, |
||||
|
name varchar(256) not null, |
||||
|
township_code varchar(256), |
||||
|
longitude double precision, |
||||
|
latitude double precision |
||||
|
); |
||||
|
|
||||
|
comment on table village is '村'; |
||||
|
|
||||
|
comment on column village.township_code is '所属乡镇代码'; |
||||
|
|
||||
|
comment on column village.longitude is '经度'; |
||||
|
|
||||
|
comment on column village.latitude is '纬度'; |
||||
|
|
||||
|
create unique index if not exists village_id_uindex |
||||
|
on village (id); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
create table if not exists village_distance |
||||
|
( |
||||
|
id serial not null |
||||
|
constraint village_distance_pk |
||||
|
primary key, |
||||
|
origin_village integer not null |
||||
|
constraint village_distance_village_id_fk |
||||
|
references village, |
||||
|
calc_village integer |
||||
|
constraint village_distance_village_id_fk_2 |
||||
|
references village, |
||||
|
diatance integer |
||||
|
); |
||||
|
|
||||
|
comment on table village_distance is '村之间的距离'; |
||||
|
|
||||
|
comment on column village_distance.origin_village is '原点村庄'; |
||||
|
|
||||
|
comment on column village_distance.calc_village is '相对计算村庄'; |
||||
|
|
||||
|
comment on column village_distance.diatance is '距离 m'; |
||||
|
|
||||
|
create unique index if not exists village_distance_id_uindex |
||||
|
on village_distance (id); |
||||
|
|
@ -0,0 +1,9 @@ |
|||||
|
alter table road |
||||
|
add village_id int; |
||||
|
|
||||
|
comment on column road.village_id is '所属村'; |
||||
|
|
||||
|
alter table road |
||||
|
add constraint road_village_id_fk |
||||
|
foreign key (village_id) references village; |
||||
|
|
@ -0,0 +1,6 @@ |
|||||
|
alter table report |
||||
|
add road_id int; |
||||
|
|
||||
|
alter table report |
||||
|
add constraint report_road_id_fk |
||||
|
foreign key (road_id) references road; |
Loading…
Reference in new issue