feat(ip): 调整香港和澳门的行政区划层级结构

- 添加香港特别行政区和澳门特别行政区作为二级行政区
- 调整香港和澳门的行政区划层级结构
- 优化区域数据的层级映射规则
pull/247/head
chenwenke 2026-05-01 10:03:06 +08:00
parent 7951011b9c
commit d34f647040
2 changed files with 20 additions and 10 deletions

View File

@ -73,8 +73,13 @@ public class AreaDataConverterTest {
for (CsvRow row : rows) {
// id
String idStr = String.format("%-6s", Integer.parseInt(row.get(0))).replace(' ', '0');
String id = row.get(0);
String idStr;
if (id.startsWith("8")) {//香港澳门特殊处理
idStr = id;
} else {
idStr = String.format("%-6s", Integer.parseInt(id)).replace(' ', '0');
}
// 转换层级
int deep = Integer.parseInt(row.get(2));
int type = deep + 2; // 0->2省, 1->3市, 2->4区
@ -86,9 +91,14 @@ public class AreaDataConverterTest {
}
//父id
String pidStr = String.format("%-6s", Integer.parseInt(row.get(1))).replace(' ', '0');
if ("000000".equals(pidStr)) {
String pid = row.get(1);
String pidStr;
if ("0".equals(pid)) {
pidStr = "1"; // 省级,父节点为中国
} else if (pid.startsWith("8")) {//香港澳门特殊处理
pidStr = pid;
} else {
pidStr = String.format("%-6s", Integer.parseInt(pid)).replace(' ', '0');
}
areas.add(new AreaObj(Integer.parseInt(idStr), name, type, Integer.parseInt(pidStr)));

View File

@ -1,5 +1,7 @@
id,name,type,parentId
1,中国,1,0
81,香港特别行政区,2,1
82,澳门特别行政区,2,1
110000,北京市,2,1
120000,天津市,2,1
130000,河北省,2,1
@ -32,8 +34,8 @@ id,name,type,parentId
640000,宁夏回族自治区,2,1
650000,新疆维吾尔自治区,2,1
710000,台湾省,2,1
810000,香港特别行政区,2,1
820000,澳门特别行政区,2,1
8100,香港特别行政区,3,81
8200,澳门特别行政区,3,82
110100,北京市,3,110000
120100,天津市,3,120000
130100,石家庄市,3,130000
@ -424,8 +426,6 @@ id,name,type,parentId
712500,台东县,3,710000
712600,花莲县,3,710000
712700,澎湖县,3,710000
810000,香港特别行政区,3,810000
820000,澳门特别行政区,3,820000
110101,东城区,4,110100
110102,西城区,4,110100
110105,朝阳区,4,110100
@ -3601,8 +3601,8 @@ id,name,type,parentId
712710,七美乡,4,712700
712711,白沙乡,4,712700
712712,湖西乡,4,712700
810000,香港特别行政区,4,810000
820000,澳门特别行政区,4,820000
810000,香港特别行政区,4,8100
820000,澳门特别行政区,4,8200
419001000,济源市,4,419001
429004000,仙桃市,4,429004
429005000,潜江市,4,429005

1 id name type parentId
2 1 中国 1 0
3 81 香港特别行政区 2 1
4 82 澳门特别行政区 2 1
5 110000 北京市 2 1
6 120000 天津市 2 1
7 130000 河北省 2 1
34 640000 宁夏回族自治区 2 1
35 650000 新疆维吾尔自治区 2 1
36 710000 台湾省 2 1
37 810000 8100 香港特别行政区 2 3 1 81
38 820000 8200 澳门特别行政区 2 3 1 82
39 110100 北京市 3 110000
40 120100 天津市 3 120000
41 130100 石家庄市 3 130000
426 712500 台东县 3 710000
427 712600 花莲县 3 710000
428 712700 澎湖县 3 710000
810000 香港特别行政区 3 810000
820000 澳门特别行政区 3 820000
429 110101 东城区 4 110100
430 110102 西城区 4 110100
431 110105 朝阳区 4 110100
3601 712710 七美乡 4 712700
3602 712711 白沙乡 4 712700
3603 712712 湖西乡 4 712700
3604 810000 香港特别行政区 4 810000 8100
3605 820000 澳门特别行政区 4 820000 8200
3606 419001000 济源市 4 419001
3607 429004000 仙桃市 4 429004
3608 429005000 潜江市 4 429005