Commit 01791790 by zwb

新增城市数据处理与二级查询

parent 14e5fe5c
...@@ -11,1568 +11,1568 @@ public class RegionConstants { ...@@ -11,1568 +11,1568 @@ public class RegionConstants {
[ [
{ {
"label": "北京", "label": "北京",
"value": "11", "value": "11"
}, },
{ {
"label": "天津", "label": "天津",
"value": "12", "value": "12"
}, },
{ {
"label": "河北", "label": "河北",
"value": "13", "value": "13"
}, },
{ {
"label": "山西", "label": "山西",
"value": "14", "value": "14"
}, },
{ {
"label": "内蒙古", "label": "内蒙古",
"value": "15", "value": "15"
}, },
{ {
"label": "辽宁", "label": "辽宁",
"value": "21", "value": "21"
}, },
{ {
"label": "吉林", "label": "吉林",
"value": "22", "value": "22"
}, },
{ {
"label": "黑龙江", "label": "黑龙江",
"value": "23", "value": "23"
}, },
{ {
"label": "上海", "label": "上海",
"value": "31", "value": "31"
}, },
{ {
"label": "江苏", "label": "江苏",
"value": "32", "value": "32"
}, },
{ {
"label": "浙江", "label": "浙江",
"value": "33", "value": "33"
}, },
{ {
"label": "安徽", "label": "安徽",
"value": "34", "value": "34"
}, },
{ {
"label": "福建", "label": "福建",
"value": "35", "value": "35"
}, },
{ {
"label": "江西", "label": "江西",
"value": "36", "value": "36"
}, },
{ {
"label": "山东", "label": "山东",
"value": "37", "value": "37"
}, },
{ {
"label": "河南", "label": "河南",
"value": "41", "value": "41"
}, },
{ {
"label": "湖北", "label": "湖北",
"value": "42", "value": "42"
}, },
{ {
"label": "湖南", "label": "湖南",
"value": "43", "value": "43"
}, },
{ {
"label": "广东", "label": "广东",
"value": "44", "value": "44"
}, },
{ {
"label": "广西", "label": "广西",
"value": "45", "value": "45"
}, },
{ {
"label": "海南", "label": "海南",
"value": "46", "value": "46"
}, },
{ {
"label": "重庆", "label": "重庆",
"value": "50", "value": "50"
}, },
{ {
"label": "四川", "label": "四川",
"value": "51", "value": "51"
}, },
{ {
"label": "贵州", "label": "贵州",
"value": "52", "value": "52"
}, },
{ {
"label": "云南", "label": "云南",
"value": "53", "value": "53"
}, },
{ {
"label": "西藏", "label": "西藏",
"value": "54", "value": "54"
}, },
{ {
"label": "陕西", "label": "陕西",
"value": "61", "value": "61"
}, },
{ {
"label": "甘肃", "label": "甘肃",
"value": "62", "value": "62"
}, },
{ {
"label": "青海", "label": "青海",
"value": "63", "value": "63"
}, },
{ {
"label": "宁夏", "label": "宁夏",
"value": "64", "value": "64"
}, },
{ {
"label": "新疆", "label": "新疆",
"value": "65", "value": "65"
}, },
{ {
"label": "台湾", "label": "台湾",
"value": "66", "value": "66"
}, },
{ {
"label": "香港", "label": "香港",
"value": "67", "value": "67"
}, },
{ {
"label": "澳门", "label": "澳门",
"value": "68", "value": "68"
}, },
{ {
"label": "北京", "label": "北京",
"value": "1101", "value": "1101"
}, },
{ {
"label": "天津", "label": "天津",
"value": "1201", "value": "1201"
}, },
{ {
"label": "石家庄", "label": "石家庄",
"value": "1301", "value": "1301"
}, },
{ {
"label": "唐山", "label": "唐山",
"value": "1302", "value": "1302"
}, },
{ {
"label": "秦皇岛", "label": "秦皇岛",
"value": "1303", "value": "1303"
}, },
{ {
"label": "邯郸", "label": "邯郸",
"value": "1304", "value": "1304"
}, },
{ {
"label": "邢台", "label": "邢台",
"value": "1305", "value": "1305"
}, },
{ {
"label": "保定", "label": "保定",
"value": "1306", "value": "1306"
}, },
{ {
"label": "张家口", "label": "张家口",
"value": "1307", "value": "1307"
}, },
{ {
"label": "承德", "label": "承德",
"value": "1308", "value": "1308"
}, },
{ {
"label": "沧州", "label": "沧州",
"value": "1309", "value": "1309"
}, },
{ {
"label": "廊坊", "label": "廊坊",
"value": "1310", "value": "1310"
}, },
{ {
"label": "衡水", "label": "衡水",
"value": "1311", "value": "1311"
}, },
{ {
"label": "太原", "label": "太原",
"value": "1401", "value": "1401"
}, },
{ {
"label": "大同", "label": "大同",
"value": "1402", "value": "1402"
}, },
{ {
"label": "阳泉", "label": "阳泉",
"value": "1403", "value": "1403"
}, },
{ {
"label": "长治", "label": "长治",
"value": "1404", "value": "1404"
}, },
{ {
"label": "晋城", "label": "晋城",
"value": "1405", "value": "1405"
}, },
{ {
"label": "朔州", "label": "朔州",
"value": "1406", "value": "1406"
}, },
{ {
"label": "晋中", "label": "晋中",
"value": "1407", "value": "1407"
}, },
{ {
"label": "运城", "label": "运城",
"value": "1408", "value": "1408"
}, },
{ {
"label": "忻州", "label": "忻州",
"value": "1409", "value": "1409"
}, },
{ {
"label": "临汾", "label": "临汾",
"value": "1410", "value": "1410"
}, },
{ {
"label": "吕梁", "label": "吕梁",
"value": "1411", "value": "1411"
}, },
{ {
"label": "呼和浩特", "label": "呼和浩特",
"value": "1501", "value": "1501"
}, },
{ {
"label": "包头", "label": "包头",
"value": "1502", "value": "1502"
}, },
{ {
"label": "乌海", "label": "乌海",
"value": "1503", "value": "1503"
}, },
{ {
"label": "赤峰", "label": "赤峰",
"value": "1504", "value": "1504"
}, },
{ {
"label": "通辽", "label": "通辽",
"value": "1505", "value": "1505"
}, },
{ {
"label": "鄂尔多斯", "label": "鄂尔多斯",
"value": "1506", "value": "1506"
}, },
{ {
"label": "呼伦贝尔", "label": "呼伦贝尔",
"value": "1507", "value": "1507"
}, },
{ {
"label": "巴彦淖尔", "label": "巴彦淖尔",
"value": "1508", "value": "1508"
}, },
{ {
"label": "乌兰察布", "label": "乌兰察布",
"value": "1509", "value": "1509"
}, },
{ {
"label": "兴安盟", "label": "兴安盟",
"value": "1522", "value": "1522"
}, },
{ {
"label": "锡林郭勒盟", "label": "锡林郭勒盟",
"value": "1525", "value": "1525"
}, },
{ {
"label": "阿拉善盟", "label": "阿拉善盟",
"value": "1529", "value": "1529"
}, },
{ {
"label": "沈阳", "label": "沈阳",
"value": "2101", "value": "2101"
}, },
{ {
"label": "大连", "label": "大连",
"value": "2102", "value": "2102"
}, },
{ {
"label": "鞍山", "label": "鞍山",
"value": "2103", "value": "2103"
}, },
{ {
"label": "抚顺", "label": "抚顺",
"value": "2104", "value": "2104"
}, },
{ {
"label": "本溪", "label": "本溪",
"value": "2105", "value": "2105"
}, },
{ {
"label": "丹东", "label": "丹东",
"value": "2106", "value": "2106"
}, },
{ {
"label": "锦州", "label": "锦州",
"value": "2107", "value": "2107"
}, },
{ {
"label": "营口", "label": "营口",
"value": "2108", "value": "2108"
}, },
{ {
"label": "阜新", "label": "阜新",
"value": "2109", "value": "2109"
}, },
{ {
"label": "辽阳", "label": "辽阳",
"value": "2110", "value": "2110"
}, },
{ {
"label": "盘锦", "label": "盘锦",
"value": "2111", "value": "2111"
}, },
{ {
"label": "铁岭", "label": "铁岭",
"value": "2112", "value": "2112"
}, },
{ {
"label": "朝阳", "label": "朝阳",
"value": "2113", "value": "2113"
}, },
{ {
"label": "葫芦岛", "label": "葫芦岛",
"value": "2114", "value": "2114"
}, },
{ {
"label": "长春", "label": "长春",
"value": "2201", "value": "2201"
}, },
{ {
"label": "吉林", "label": "吉林",
"value": "2202", "value": "2202"
}, },
{ {
"label": "四平", "label": "四平",
"value": "2203", "value": "2203"
}, },
{ {
"label": "辽源", "label": "辽源",
"value": "2204", "value": "2204"
}, },
{ {
"label": "通化", "label": "通化",
"value": "2205", "value": "2205"
}, },
{ {
"label": "白山", "label": "白山",
"value": "2206", "value": "2206"
}, },
{ {
"label": "松原", "label": "松原",
"value": "2207", "value": "2207"
}, },
{ {
"label": "白城", "label": "白城",
"value": "2208", "value": "2208"
}, },
{ {
"label": "延边朝鲜族自治州", "label": "延边朝鲜族自治州",
"value": "2224", "value": "2224"
}, },
{ {
"label": "哈尔滨", "label": "哈尔滨",
"value": "2301", "value": "2301"
}, },
{ {
"label": "齐齐哈尔", "label": "齐齐哈尔",
"value": "2302", "value": "2302"
}, },
{ {
"label": "鸡西", "label": "鸡西",
"value": "2303", "value": "2303"
}, },
{ {
"label": "鹤岗", "label": "鹤岗",
"value": "2304", "value": "2304"
}, },
{ {
"label": "双鸭山", "label": "双鸭山",
"value": "2305", "value": "2305"
}, },
{ {
"label": "大庆", "label": "大庆",
"value": "2306", "value": "2306"
}, },
{ {
"label": "伊春", "label": "伊春",
"value": "2307", "value": "2307"
}, },
{ {
"label": "佳木斯", "label": "佳木斯",
"value": "2308", "value": "2308"
}, },
{ {
"label": "七台河", "label": "七台河",
"value": "2309", "value": "2309"
}, },
{ {
"label": "牡丹江", "label": "牡丹江",
"value": "2310", "value": "2310"
}, },
{ {
"label": "黑河", "label": "黑河",
"value": "2311", "value": "2311"
}, },
{ {
"label": "绥化", "label": "绥化",
"value": "2312", "value": "2312"
}, },
{ {
"label": "大兴安岭地区", "label": "大兴安岭地区",
"value": "2327", "value": "2327"
}, },
{ {
"label": "上海", "label": "上海",
"value": "3101", "value": "3101"
}, },
{ {
"label": "南京", "label": "南京",
"value": "3201", "value": "3201"
}, },
{ {
"label": "无锡", "label": "无锡",
"value": "3202", "value": "3202"
}, },
{ {
"label": "徐州", "label": "徐州",
"value": "3203", "value": "3203"
}, },
{ {
"label": "常州", "label": "常州",
"value": "3204", "value": "3204"
}, },
{ {
"label": "苏州", "label": "苏州",
"value": "3205", "value": "3205"
}, },
{ {
"label": "南通", "label": "南通",
"value": "3206", "value": "3206"
}, },
{ {
"label": "连云港", "label": "连云港",
"value": "3207", "value": "3207"
}, },
{ {
"label": "淮安", "label": "淮安",
"value": "3208", "value": "3208"
}, },
{ {
"label": "盐城", "label": "盐城",
"value": "3209", "value": "3209"
}, },
{ {
"label": "扬州", "label": "扬州",
"value": "3210", "value": "3210"
}, },
{ {
"label": "镇江", "label": "镇江",
"value": "3211", "value": "3211"
}, },
{ {
"label": "泰州", "label": "泰州",
"value": "3212", "value": "3212"
}, },
{ {
"label": "宿迁", "label": "宿迁",
"value": "3213", "value": "3213"
}, },
{ {
"label": "杭州", "label": "杭州",
"value": "3301", "value": "3301"
}, },
{ {
"label": "宁波", "label": "宁波",
"value": "3302", "value": "3302"
}, },
{ {
"label": "温州", "label": "温州",
"value": "3303", "value": "3303"
}, },
{ {
"label": "嘉兴", "label": "嘉兴",
"value": "3304", "value": "3304"
}, },
{ {
"label": "湖州", "label": "湖州",
"value": "3305", "value": "3305"
}, },
{ {
"label": "绍兴", "label": "绍兴",
"value": "3306", "value": "3306"
}, },
{ {
"label": "金华", "label": "金华",
"value": "3307", "value": "3307"
}, },
{ {
"label": "衢州", "label": "衢州",
"value": "3308", "value": "3308"
}, },
{ {
"label": "舟山", "label": "舟山",
"value": "3309", "value": "3309"
}, },
{ {
"label": "台州", "label": "台州",
"value": "3310", "value": "3310"
}, },
{ {
"label": "丽水", "label": "丽水",
"value": "3311", "value": "3311"
}, },
{ {
"label": "合肥", "label": "合肥",
"value": "3401", "value": "3401"
}, },
{ {
"label": "芜湖", "label": "芜湖",
"value": "3402", "value": "3402"
}, },
{ {
"label": "蚌埠", "label": "蚌埠",
"value": "3403", "value": "3403"
}, },
{ {
"label": "淮南", "label": "淮南",
"value": "3404", "value": "3404"
}, },
{ {
"label": "马鞍山", "label": "马鞍山",
"value": "3405", "value": "3405"
}, },
{ {
"label": "淮北", "label": "淮北",
"value": "3406", "value": "3406"
}, },
{ {
"label": "铜陵", "label": "铜陵",
"value": "3407", "value": "3407"
}, },
{ {
"label": "安庆", "label": "安庆",
"value": "3408", "value": "3408"
}, },
{ {
"label": "黄山", "label": "黄山",
"value": "3410", "value": "3410"
}, },
{ {
"label": "滁州", "label": "滁州",
"value": "3411", "value": "3411"
}, },
{ {
"label": "阜阳", "label": "阜阳",
"value": "3412", "value": "3412"
}, },
{ {
"label": "宿州", "label": "宿州",
"value": "3413", "value": "3413"
}, },
{ {
"label": "六安", "label": "六安",
"value": "3415", "value": "3415"
}, },
{ {
"label": "亳州", "label": "亳州",
"value": "3416", "value": "3416"
}, },
{ {
"label": "池州", "label": "池州",
"value": "3417", "value": "3417"
}, },
{ {
"label": "宣城", "label": "宣城",
"value": "3418", "value": "3418"
}, },
{ {
"label": "福州", "label": "福州",
"value": "3501", "value": "3501"
}, },
{ {
"label": "厦门", "label": "厦门",
"value": "3502", "value": "3502"
}, },
{ {
"label": "莆田", "label": "莆田",
"value": "3503", "value": "3503"
}, },
{ {
"label": "三明", "label": "三明",
"value": "3504", "value": "3504"
}, },
{ {
"label": "泉州", "label": "泉州",
"value": "3505", "value": "3505"
}, },
{ {
"label": "漳州", "label": "漳州",
"value": "3506", "value": "3506"
}, },
{ {
"label": "南平", "label": "南平",
"value": "3507", "value": "3507"
}, },
{ {
"label": "龙岩", "label": "龙岩",
"value": "3508", "value": "3508"
}, },
{ {
"label": "宁德", "label": "宁德",
"value": "3509", "value": "3509"
}, },
{ {
"label": "南昌", "label": "南昌",
"value": "3601", "value": "3601"
}, },
{ {
"label": "景德镇", "label": "景德镇",
"value": "3602", "value": "3602"
}, },
{ {
"label": "萍乡", "label": "萍乡",
"value": "3603", "value": "3603"
}, },
{ {
"label": "九江", "label": "九江",
"value": "3604", "value": "3604"
}, },
{ {
"label": "新余", "label": "新余",
"value": "3605", "value": "3605"
}, },
{ {
"label": "鹰潭", "label": "鹰潭",
"value": "3606", "value": "3606"
}, },
{ {
"label": "赣州", "label": "赣州",
"value": "3607", "value": "3607"
}, },
{ {
"label": "吉安", "label": "吉安",
"value": "3608", "value": "3608"
}, },
{ {
"label": "宜春", "label": "宜春",
"value": "3609", "value": "3609"
}, },
{ {
"label": "抚州", "label": "抚州",
"value": "3610", "value": "3610"
}, },
{ {
"label": "上饶", "label": "上饶",
"value": "3611", "value": "3611"
}, },
{ {
"label": "济南", "label": "济南",
"value": "3701", "value": "3701"
}, },
{ {
"label": "青岛", "label": "青岛",
"value": "3702", "value": "3702"
}, },
{ {
"label": "淄博", "label": "淄博",
"value": "3703", "value": "3703"
}, },
{ {
"label": "枣庄", "label": "枣庄",
"value": "3704", "value": "3704"
}, },
{ {
"label": "东营", "label": "东营",
"value": "3705", "value": "3705"
}, },
{ {
"label": "烟台", "label": "烟台",
"value": "3706", "value": "3706"
}, },
{ {
"label": "潍坊", "label": "潍坊",
"value": "3707", "value": "3707"
}, },
{ {
"label": "济宁", "label": "济宁",
"value": "3708", "value": "3708"
}, },
{ {
"label": "泰安", "label": "泰安",
"value": "3709", "value": "3709"
}, },
{ {
"label": "威海", "label": "威海",
"value": "3710", "value": "3710"
}, },
{ {
"label": "日照", "label": "日照",
"value": "3711", "value": "3711"
}, },
{ {
"label": "莱芜", "label": "莱芜",
"value": "3712", "value": "3712"
}, },
{ {
"label": "临沂", "label": "临沂",
"value": "3713", "value": "3713"
}, },
{ {
"label": "德州", "label": "德州",
"value": "3714", "value": "3714"
}, },
{ {
"label": "聊城", "label": "聊城",
"value": "3715", "value": "3715"
}, },
{ {
"label": "滨州", "label": "滨州",
"value": "3716", "value": "3716"
}, },
{ {
"label": "菏泽", "label": "菏泽",
"value": "3717", "value": "3717"
}, },
{ {
"label": "郑州", "label": "郑州",
"value": "4101", "value": "4101"
}, },
{ {
"label": "开封", "label": "开封",
"value": "4102", "value": "4102"
}, },
{ {
"label": "洛阳", "label": "洛阳",
"value": "4103", "value": "4103"
}, },
{ {
"label": "平顶山", "label": "平顶山",
"value": "4104", "value": "4104"
}, },
{ {
"label": "安阳", "label": "安阳",
"value": "4105", "value": "4105"
}, },
{ {
"label": "鹤壁", "label": "鹤壁",
"value": "4106", "value": "4106"
}, },
{ {
"label": "新乡", "label": "新乡",
"value": "4107", "value": "4107"
}, },
{ {
"label": "焦作", "label": "焦作",
"value": "4108", "value": "4108"
}, },
{ {
"label": "濮阳", "label": "濮阳",
"value": "4109", "value": "4109"
}, },
{ {
"label": "许昌", "label": "许昌",
"value": "4110", "value": "4110"
}, },
{ {
"label": "漯河", "label": "漯河",
"value": "4111", "value": "4111"
}, },
{ {
"label": "三门峡", "label": "三门峡",
"value": "4112", "value": "4112"
}, },
{ {
"label": "南阳", "label": "南阳",
"value": "4113", "value": "4113"
}, },
{ {
"label": "商丘", "label": "商丘",
"value": "4114", "value": "4114"
}, },
{ {
"label": "信阳", "label": "信阳",
"value": "4115", "value": "4115"
}, },
{ {
"label": "周口", "label": "周口",
"value": "4116", "value": "4116"
}, },
{ {
"label": "驻马店", "label": "驻马店",
"value": "4117", "value": "4117"
}, },
{ {
"label": "武汉", "label": "武汉",
"value": "4201", "value": "4201"
}, },
{ {
"label": "黄石", "label": "黄石",
"value": "4202", "value": "4202"
}, },
{ {
"label": "十堰", "label": "十堰",
"value": "4203", "value": "4203"
}, },
{ {
"label": "宜昌", "label": "宜昌",
"value": "4205", "value": "4205"
}, },
{ {
"label": "襄阳", "label": "襄阳",
"value": "4206", "value": "4206"
}, },
{ {
"label": "鄂州", "label": "鄂州",
"value": "4207", "value": "4207"
}, },
{ {
"label": "荆门", "label": "荆门",
"value": "4208", "value": "4208"
}, },
{ {
"label": "孝感", "label": "孝感",
"value": "4209", "value": "4209"
}, },
{ {
"label": "荆州", "label": "荆州",
"value": "4210", "value": "4210"
}, },
{ {
"label": "黄冈", "label": "黄冈",
"value": "4211", "value": "4211"
}, },
{ {
"label": "咸宁", "label": "咸宁",
"value": "4212", "value": "4212"
}, },
{ {
"label": "随州", "label": "随州",
"value": "4213", "value": "4213"
}, },
{ {
"label": "恩施土家族苗族自治州", "label": "恩施土家族苗族自治州",
"value": "4228", "value": "4228"
}, },
{ {
"label": "长沙", "label": "长沙",
"value": "4301", "value": "4301"
}, },
{ {
"label": "株洲", "label": "株洲",
"value": "4302", "value": "4302"
}, },
{ {
"label": "湘潭", "label": "湘潭",
"value": "4303", "value": "4303"
}, },
{ {
"label": "衡阳", "label": "衡阳",
"value": "4304", "value": "4304"
}, },
{ {
"label": "邵阳", "label": "邵阳",
"value": "4305", "value": "4305"
}, },
{ {
"label": "岳阳", "label": "岳阳",
"value": "4306", "value": "4306"
}, },
{ {
"label": "常德", "label": "常德",
"value": "4307", "value": "4307"
}, },
{ {
"label": "张家界", "label": "张家界",
"value": "4308", "value": "4308"
}, },
{ {
"label": "益阳", "label": "益阳",
"value": "4309", "value": "4309"
}, },
{ {
"label": "郴州", "label": "郴州",
"value": "4310", "value": "4310"
}, },
{ {
"label": "永州", "label": "永州",
"value": "4311", "value": "4311"
}, },
{ {
"label": "怀化", "label": "怀化",
"value": "4312", "value": "4312"
}, },
{ {
"label": "娄底", "label": "娄底",
"value": "4313", "value": "4313"
}, },
{ {
"label": "湘西土家族苗族自治州", "label": "湘西土家族苗族自治州",
"value": "4331", "value": "4331"
}, },
{ {
"label": "广州", "label": "广州",
"value": "4401", "value": "4401"
}, },
{ {
"label": "韶关", "label": "韶关",
"value": "4402", "value": "4402"
}, },
{ {
"label": "深圳", "label": "深圳",
"value": "4403", "value": "4403"
}, },
{ {
"label": "珠海", "label": "珠海",
"value": "4404", "value": "4404"
}, },
{ {
"label": "汕头", "label": "汕头",
"value": "4405", "value": "4405"
}, },
{ {
"label": "佛山", "label": "佛山",
"value": "4406", "value": "4406"
}, },
{ {
"label": "江门", "label": "江门",
"value": "4407", "value": "4407"
}, },
{ {
"label": "湛江", "label": "湛江",
"value": "4408", "value": "4408"
}, },
{ {
"label": "茂名", "label": "茂名",
"value": "4409", "value": "4409"
}, },
{ {
"label": "肇庆", "label": "肇庆",
"value": "4412", "value": "4412"
}, },
{ {
"label": "惠州", "label": "惠州",
"value": "4413", "value": "4413"
}, },
{ {
"label": "梅州", "label": "梅州",
"value": "4414", "value": "4414"
}, },
{ {
"label": "汕尾", "label": "汕尾",
"value": "4415", "value": "4415"
}, },
{ {
"label": "河源", "label": "河源",
"value": "4416", "value": "4416"
}, },
{ {
"label": "阳江", "label": "阳江",
"value": "4417", "value": "4417"
}, },
{ {
"label": "清远", "label": "清远",
"value": "4418", "value": "4418"
}, },
{ {
"label": "东莞", "label": "东莞",
"value": "4419", "value": "4419"
}, },
{ {
"label": "中山", "label": "中山",
"value": "4420", "value": "4420"
}, },
{ {
"label": "潮州", "label": "潮州",
"value": "4451", "value": "4451"
}, },
{ {
"label": "揭阳", "label": "揭阳",
"value": "4452", "value": "4452"
}, },
{ {
"label": "云浮", "label": "云浮",
"value": "4453", "value": "4453"
}, },
{ {
"label": "南宁", "label": "南宁",
"value": "4501", "value": "4501"
}, },
{ {
"label": "柳州", "label": "柳州",
"value": "4502", "value": "4502"
}, },
{ {
"label": "桂林", "label": "桂林",
"value": "4503", "value": "4503"
}, },
{ {
"label": "梧州", "label": "梧州",
"value": "4504", "value": "4504"
}, },
{ {
"label": "北海", "label": "北海",
"value": "4505", "value": "4505"
}, },
{ {
"label": "防城港", "label": "防城港",
"value": "4506", "value": "4506"
}, },
{ {
"label": "钦州", "label": "钦州",
"value": "4507", "value": "4507"
}, },
{ {
"label": "贵港", "label": "贵港",
"value": "4508", "value": "4508"
}, },
{ {
"label": "玉林", "label": "玉林",
"value": "4509", "value": "4509"
}, },
{ {
"label": "百色", "label": "百色",
"value": "4510", "value": "4510"
}, },
{ {
"label": "贺州", "label": "贺州",
"value": "4511", "value": "4511"
}, },
{ {
"label": "河池", "label": "河池",
"value": "4512", "value": "4512"
}, },
{ {
"label": "来宾", "label": "来宾",
"value": "4513", "value": "4513"
}, },
{ {
"label": "崇左", "label": "崇左",
"value": "4514", "value": "4514"
}, },
{ {
"label": "海口", "label": "海口",
"value": "4601", "value": "4601"
}, },
{ {
"label": "三亚", "label": "三亚",
"value": "4602", "value": "4602"
}, },
{ {
"label": "三沙", "label": "三沙",
"value": "4603", "value": "4603"
}, },
{ {
"label": "儋州", "label": "儋州",
"value": "4604", "value": "4604"
}, },
{ {
"label": "重庆", "label": "重庆",
"value": "5001", "value": "5001"
}, },
{ {
"label": "成都", "label": "成都",
"value": "5101", "value": "5101"
}, },
{ {
"label": "自贡", "label": "自贡",
"value": "5103", "value": "5103"
}, },
{ {
"label": "攀枝花", "label": "攀枝花",
"value": "5104", "value": "5104"
}, },
{ {
"label": "泸州", "label": "泸州",
"value": "5105", "value": "5105"
}, },
{ {
"label": "德阳", "label": "德阳",
"value": "5106", "value": "5106"
}, },
{ {
"label": "绵阳", "label": "绵阳",
"value": "5107", "value": "5107"
}, },
{ {
"label": "广元", "label": "广元",
"value": "5108", "value": "5108"
}, },
{ {
"label": "遂宁", "label": "遂宁",
"value": "5109", "value": "5109"
}, },
{ {
"label": "内江", "label": "内江",
"value": "5110", "value": "5110"
}, },
{ {
"label": "乐山", "label": "乐山",
"value": "5111", "value": "5111"
}, },
{ {
"label": "南充", "label": "南充",
"value": "5113", "value": "5113"
}, },
{ {
"label": "眉山", "label": "眉山",
"value": "5114", "value": "5114"
}, },
{ {
"label": "宜宾", "label": "宜宾",
"value": "5115", "value": "5115"
}, },
{ {
"label": "广安", "label": "广安",
"value": "5116", "value": "5116"
}, },
{ {
"label": "达州", "label": "达州",
"value": "5117", "value": "5117"
}, },
{ {
"label": "雅安", "label": "雅安",
"value": "5118", "value": "5118"
}, },
{ {
"label": "巴中", "label": "巴中",
"value": "5119", "value": "5119"
}, },
{ {
"label": "资阳", "label": "资阳",
"value": "5120", "value": "5120"
}, },
{ {
"label": "阿坝藏族羌族自治州", "label": "阿坝藏族羌族自治州",
"value": "5132", "value": "5132"
}, },
{ {
"label": "甘孜藏族自治州", "label": "甘孜藏族自治州",
"value": "5133", "value": "5133"
}, },
{ {
"label": "凉山彝族自治州", "label": "凉山彝族自治州",
"value": "5134", "value": "5134"
}, },
{ {
"label": "贵阳", "label": "贵阳",
"value": "5201", "value": "5201"
}, },
{ {
"label": "六盘水", "label": "六盘水",
"value": "5202", "value": "5202"
}, },
{ {
"label": "遵义", "label": "遵义",
"value": "5203", "value": "5203"
}, },
{ {
"label": "安顺", "label": "安顺",
"value": "5204", "value": "5204"
}, },
{ {
"label": "毕节", "label": "毕节",
"value": "5205", "value": "5205"
}, },
{ {
"label": "铜仁", "label": "铜仁",
"value": "5206", "value": "5206"
}, },
{ {
"label": "黔西南布依族苗族自治州", "label": "黔西南布依族苗族自治州",
"value": "5223", "value": "5223"
}, },
{ {
"label": "黔东南苗族侗族自治州", "label": "黔东南苗族侗族自治州",
"value": "5226", "value": "5226"
}, },
{ {
"label": "黔南布依族苗族自治州", "label": "黔南布依族苗族自治州",
"value": "5227", "value": "5227"
}, },
{ {
"label": "昆明", "label": "昆明",
"value": "5301", "value": "5301"
}, },
{ {
"label": "曲靖", "label": "曲靖",
"value": "5303", "value": "5303"
}, },
{ {
"label": "玉溪", "label": "玉溪",
"value": "5304", "value": "5304"
}, },
{ {
"label": "保山", "label": "保山",
"value": "5305", "value": "5305"
}, },
{ {
"label": "昭通", "label": "昭通",
"value": "5306", "value": "5306"
}, },
{ {
"label": "丽江", "label": "丽江",
"value": "5307", "value": "5307"
}, },
{ {
"label": "普洱", "label": "普洱",
"value": "5308", "value": "5308"
}, },
{ {
"label": "临沧", "label": "临沧",
"value": "5309", "value": "5309"
}, },
{ {
"label": "楚雄彝族自治州", "label": "楚雄彝族自治州",
"value": "5323", "value": "5323"
}, },
{ {
"label": "红河哈尼族彝族自治州", "label": "红河哈尼族彝族自治州",
"value": "5325", "value": "5325"
}, },
{ {
"label": "文山壮族苗族自治州", "label": "文山壮族苗族自治州",
"value": "5326", "value": "5326"
}, },
{ {
"label": "西双版纳傣族自治州", "label": "西双版纳傣族自治州",
"value": "5328", "value": "5328"
}, },
{ {
"label": "大理白族自治州", "label": "大理白族自治州",
"value": "5329", "value": "5329"
}, },
{ {
"label": "德宏傣族景颇族自治州", "label": "德宏傣族景颇族自治州",
"value": "5331", "value": "5331"
}, },
{ {
"label": "怒江傈僳族自治州", "label": "怒江傈僳族自治州",
"value": "5333", "value": "5333"
}, },
{ {
"label": "迪庆藏族自治州", "label": "迪庆藏族自治州",
"value": "5334", "value": "5334"
}, },
{ {
"label": "拉萨", "label": "拉萨",
"value": "5401", "value": "5401"
}, },
{ {
"label": "日喀则", "label": "日喀则",
"value": "5402", "value": "5402"
}, },
{ {
"label": "昌都", "label": "昌都",
"value": "5403", "value": "5403"
}, },
{ {
"label": "林芝", "label": "林芝",
"value": "5404", "value": "5404"
}, },
{ {
"label": "山南", "label": "山南",
"value": "5405", "value": "5405"
}, },
{ {
"label": "那曲地区", "label": "那曲地区",
"value": "5424", "value": "5424"
}, },
{ {
"label": "阿里地区", "label": "阿里地区",
"value": "5425", "value": "5425"
}, },
{ {
"label": "西安", "label": "西安",
"value": "6101", "value": "6101"
}, },
{ {
"label": "铜川", "label": "铜川",
"value": "6102", "value": "6102"
}, },
{ {
"label": "宝鸡", "label": "宝鸡",
"value": "6103", "value": "6103"
}, },
{ {
"label": "咸阳", "label": "咸阳",
"value": "6104", "value": "6104"
}, },
{ {
"label": "渭南", "label": "渭南",
"value": "6105", "value": "6105"
}, },
{ {
"label": "延安", "label": "延安",
"value": "6106", "value": "6106"
}, },
{ {
"label": "汉中", "label": "汉中",
"value": "6107", "value": "6107"
}, },
{ {
"label": "榆林", "label": "榆林",
"value": "6108", "value": "6108"
}, },
{ {
"label": "安康", "label": "安康",
"value": "6109", "value": "6109"
}, },
{ {
"label": "商洛", "label": "商洛",
"value": "6110", "value": "6110"
}, },
{ {
"label": "兰州", "label": "兰州",
"value": "6201", "value": "6201"
}, },
{ {
"label": "嘉峪关", "label": "嘉峪关",
"value": "6202", "value": "6202"
}, },
{ {
"label": "金昌", "label": "金昌",
"value": "6203", "value": "6203"
}, },
{ {
"label": "白银", "label": "白银",
"value": "6204", "value": "6204"
}, },
{ {
"label": "天水", "label": "天水",
"value": "6205", "value": "6205"
}, },
{ {
"label": "武威", "label": "武威",
"value": "6206", "value": "6206"
}, },
{ {
"label": "张掖", "label": "张掖",
"value": "6207", "value": "6207"
}, },
{ {
"label": "平凉", "label": "平凉",
"value": "6208", "value": "6208"
}, },
{ {
"label": "酒泉", "label": "酒泉",
"value": "6209", "value": "6209"
}, },
{ {
"label": "庆阳", "label": "庆阳",
"value": "6210", "value": "6210"
}, },
{ {
"label": "定西", "label": "定西",
"value": "6211", "value": "6211"
}, },
{ {
"label": "陇南", "label": "陇南",
"value": "6212", "value": "6212"
}, },
{ {
"label": "临夏回族自治州", "label": "临夏回族自治州",
"value": "6229", "value": "6229"
}, },
{ {
"label": "甘南藏族自治州", "label": "甘南藏族自治州",
"value": "6230", "value": "6230"
}, },
{ {
"label": "西宁", "label": "西宁",
"value": "6301", "value": "6301"
}, },
{ {
"label": "海东", "label": "海东",
"value": "6302", "value": "6302"
}, },
{ {
"label": "海北藏族自治州", "label": "海北藏族自治州",
"value": "6322", "value": "6322"
}, },
{ {
"label": "黄南藏族自治州", "label": "黄南藏族自治州",
"value": "6323", "value": "6323"
}, },
{ {
"label": "海南藏族自治州", "label": "海南藏族自治州",
"value": "6325", "value": "6325"
}, },
{ {
"label": "果洛藏族自治州", "label": "果洛藏族自治州",
"value": "6326", "value": "6326"
}, },
{ {
"label": "玉树藏族自治州", "label": "玉树藏族自治州",
"value": "6327", "value": "6327"
}, },
{ {
"label": "海西蒙古族藏族自治州", "label": "海西蒙古族藏族自治州",
"value": "6328", "value": "6328"
}, },
{ {
"label": "银川", "label": "银川",
"value": "6401", "value": "6401"
}, },
{ {
"label": "石嘴山", "label": "石嘴山",
"value": "6402", "value": "6402"
}, },
{ {
"label": "吴忠", "label": "吴忠",
"value": "6403", "value": "6403"
}, },
{ {
"label": "固原", "label": "固原",
"value": "6404", "value": "6404"
}, },
{ {
"label": "中卫", "label": "中卫",
"value": "6405", "value": "6405"
}, },
{ {
"label": "乌鲁木齐", "label": "乌鲁木齐",
"value": "6501", "value": "6501"
}, },
{ {
"label": "克拉玛依", "label": "克拉玛依",
"value": "6502", "value": "6502"
}, },
{ {
"label": "吐鲁番", "label": "吐鲁番",
"value": "6504", "value": "6504"
}, },
{ {
"label": "哈密", "label": "哈密",
"value": "6505", "value": "6505"
}, },
{ {
"label": "昌吉回族自治州", "label": "昌吉回族自治州",
"value": "6523", "value": "6523"
}, },
{ {
"label": "博尔塔拉蒙古自治州", "label": "博尔塔拉蒙古自治州",
"value": "6527", "value": "6527"
}, },
{ {
"label": "巴音郭楞蒙古自治州", "label": "巴音郭楞蒙古自治州",
"value": "6528", "value": "6528"
}, },
{ {
"label": "阿克苏地区", "label": "阿克苏地区",
"value": "6529", "value": "6529"
}, },
{ {
"label": "克孜勒苏柯尔克孜自治州", "label": "克孜勒苏柯尔克孜自治州",
"value": "6530", "value": "6530"
}, },
{ {
"label": "喀什地区", "label": "喀什地区",
"value": "6531", "value": "6531"
}, },
{ {
"label": "和田地区", "label": "和田地区",
"value": "6532", "value": "6532"
}, },
{ {
"label": "伊犁哈萨克自治州", "label": "伊犁哈萨克自治州",
"value": "6540", "value": "6540"
}, },
{ {
"label": "塔城地区", "label": "塔城地区",
"value": "6542", "value": "6542"
}, },
{ {
"label": "阿勒泰地区", "label": "阿勒泰地区",
"value": "6543", "value": "6543"
}, },
{ {
"label": "台北", "label": "台北",
"value": "6601", "value": "6601"
}, },
{ {
"label": "高雄", "label": "高雄",
"value": "6602", "value": "6602"
}, },
{ {
"label": "基隆", "label": "基隆",
"value": "6603", "value": "6603"
}, },
{ {
"label": "台中", "label": "台中",
"value": "6604", "value": "6604"
}, },
{ {
"label": "台南", "label": "台南",
"value": "6605", "value": "6605"
}, },
{ {
"label": "新竹", "label": "新竹",
"value": "6606", "value": "6606"
}, },
{ {
"label": "嘉义", "label": "嘉义",
"value": "6607", "value": "6607"
}, },
{ {
"label": "宜兰", "label": "宜兰",
"value": "6608", "value": "6608"
}, },
{ {
"label": "桃园", "label": "桃园",
"value": "6609", "value": "6609"
}, },
{ {
"label": "苗栗", "label": "苗栗",
"value": "6610", "value": "6610"
}, },
{ {
"label": "彰化", "label": "彰化",
"value": "6611", "value": "6611"
}, },
{ {
"label": "南投", "label": "南投",
"value": "6612", "value": "6612"
}, },
{ {
"label": "云林", "label": "云林",
"value": "6613", "value": "6613"
}, },
{ {
"label": "屏东", "label": "屏东",
"value": "6614", "value": "6614"
}, },
{ {
"label": "台东", "label": "台东",
"value": "6615", "value": "6615"
}, },
{ {
"label": "花莲", "label": "花莲",
"value": "6616", "value": "6616"
}, },
{ {
"label": "澎湖", "label": "澎湖",
"value": "6617", "value": "6617"
}, },
{ {
"label": "香港", "label": "香港",
"value": "6701", "value": "6701"
}, },
{ {
"label": "澳门", "label": "澳门",
"value": "6801", "value": "6801"
}, }
] ]
"""; """;
......
...@@ -17,6 +17,13 @@ ...@@ -17,6 +17,13 @@
<dependencies> <dependencies>
<!-- Jackson JSON处理 -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.bkty</groupId> <groupId>com.bkty</groupId>
<artifactId>employmentBusiness-pc-common-nacos</artifactId> <artifactId>employmentBusiness-pc-common-nacos</artifactId>
......
...@@ -2,7 +2,6 @@ package com.bkty.system.controller; ...@@ -2,7 +2,6 @@ package com.bkty.system.controller;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.bkty.system.domain.dto.AnalysisCareerDto; import com.bkty.system.domain.dto.AnalysisCareerDto;
import com.bkty.system.init.*; import com.bkty.system.init.*;
import com.bkty.system.service.jobRecommend.AiAnalysisService; import com.bkty.system.service.jobRecommend.AiAnalysisService;
...@@ -11,15 +10,12 @@ import io.swagger.v3.oas.annotations.Operation; ...@@ -11,15 +10,12 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;
import org.dromara.common.core.exception.JxgException; import org.dromara.common.core.exception.JxgException;
import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -77,4 +73,10 @@ public class JobRecommendController { ...@@ -77,4 +73,10 @@ public class JobRecommendController {
String id = aiAnalysisService.saveAnalysisData(dto); String id = aiAnalysisService.saveAnalysisData(dto);
return new R<>(id); return new R<>(id);
} }
@Operation(summary = "城市二级分类查询")
@GetMapping("/citys")
public R<List<Level1City>> getAllCitys() {
return new R<>(categoryCacheManager.getCityCache());
}
} }
package com.bkty.system.domain.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("city_data")
public class CityData {
private Long id;
private String provinceCode;
private String provinceName;
private String cityCode;
private String cityName;
}
\ No newline at end of file
package com.bkty.system.domain.entity; package com.bkty.system.domain.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data; import lombok.Data;
/** /**
...@@ -8,6 +9,7 @@ import lombok.Data; ...@@ -8,6 +9,7 @@ import lombok.Data;
* @datetime 2025/12/3 18:22 * @datetime 2025/12/3 18:22
*/ */
@Data @Data
@TableName("positions_data")
public class PositionData { public class PositionData {
/** /**
* 主键id * 主键id
......
package com.bkty.system.init;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author Zhang Wenbiao
* @description CItyCacheInitializer
* @datetime 2025/12/4 11:15
*/
@Component
public class CItyCacheInitializer implements CommandLineRunner {
@Autowired
private CityDataService cityDataService;
@Autowired
private CategoryCacheManager categoryCacheManager;
@Override
public void run(String... args) throws Exception {
try {
List<Level1City> cityDatas = cityDataService.getCitys();
// 加载到全局缓存
categoryCacheManager.loadCityCache(cityDatas);
} catch (Exception e) {
System.err.println("加载岗位数据缓存失败: " + e.getMessage());
e.printStackTrace();
}
}
}
...@@ -13,9 +13,13 @@ public class CategoryCacheManager { ...@@ -13,9 +13,13 @@ public class CategoryCacheManager {
// 全局缓存结构: 完整的层级结构列表 // 全局缓存结构: 完整的层级结构列表
private static List<Level1Group> positionCache = new CopyOnWriteArrayList<>(); private static List<Level1Group> positionCache = new CopyOnWriteArrayList<>();
private static List<Level1City> cityCache = new CopyOnWriteArrayList<>();
// 一级分类名称到Level1Group对象的映射,便于快速查找 // 一级分类名称到Level1Group对象的映射,便于快速查找
private static Map<String, Level1Group> positionNameMap = new ConcurrentHashMap<>(); private static Map<String, Level1Group> positionNameMap = new ConcurrentHashMap<>();
private static Map<String, Level1City> cityDataMap = new ConcurrentHashMap<>();
/** /**
* 将岗位数据加载到缓存 * 将岗位数据加载到缓存
*/ */
...@@ -29,13 +33,32 @@ public class CategoryCacheManager { ...@@ -29,13 +33,32 @@ public class CategoryCacheManager {
} }
/** /**
* 获取缓存数据 * 将城市数据加载到缓存
*/
public void loadCityCache(List<Level1City> data) {
cityCache = new CopyOnWriteArrayList<>(data);
// 更新名称映射
cityDataMap.clear();
for (Level1City group : data) {
cityDataMap.put(group.getName(), group);
}
}
/**
* 获取岗位缓存数据
*/ */
public List<Level1Group> getPositionCache() { public List<Level1Group> getPositionCache() {
return positionCache; return positionCache;
} }
/** /**
* 获取城市缓存数据
*/
public List<Level1City> getCityCache() {
return cityCache;
}
/**
* 根据一级分类名称获取数据 (更新后的方法) * 根据一级分类名称获取数据 (更新后的方法)
*/ */
public Level1Group getPositionDataByName(String level1Name) { public Level1Group getPositionDataByName(String level1Name) {
......
package com.bkty.system.init;
import com.bkty.system.domain.entity.CityData;
import com.bkty.system.mapper.CityDataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @author Zhang Wenbiao
* @description 城市数据service
* @datetime 2025/12/4 10:49
*/
@Service
public class CityDataService {
@Autowired
private CityDataMapper cityDataMapper;
/**
* 查询数据并封装为二级结构
*/
public List<Level1City> getCitys() {
// 从数据库查询数据
List<CityData> cityDataList = cityDataMapper.selectList(null);
// 使用Map来组织二级结构
Map<String, Level1City> level1Map = new LinkedHashMap<>();
for (CityData cityData : cityDataList) {
String level1Name = cityData.getProvinceName();
String level1Code = cityData.getProvinceCode();
String level2Name = cityData.getCityName();
String level2Code = cityData.getCityCode();
// 如果任何一级名称为空,跳过该记录
if (level1Name == null || level2Name == null ) {
continue;
}
// 构建第一级(省份类型)
Level1City level1 = level1Map.computeIfAbsent(level1Name,
k -> new Level1City(level1Name,level1Code));
// 构建第二级(岗位类型)
Level2City level2 = findOrCreateLevel2(level1.getLevel2City(), level2Name,level2Code);
}
return new ArrayList<>(level1Map.values());
}
/**
* 在第二级列表中查找或创建新的第二级
*/
private Level2City findOrCreateLevel2(List<Level2City> level2Cities, String level2Name, String level2Code) {
// 查找是否已存在
for (Level2City level2 : level2Cities) {
if (level2.getName().equals(level2Name)) {
return level2;
}
}
// 不存在则创建并添加到列表
Level2City newLevel2 = new Level2City(level2Name,level2Code);
level2Cities.add(newLevel2);
return newLevel2;
}
}
package com.bkty.system.init;
import java.util.ArrayList;
import java.util.List;
/**
* @author Zhang Wenbiao
* @description 城市一级分类(省)
* @datetime 2025/12/4 10:55
*/
public class Level1City {
private String name;
private String code;
private List<Level2City> Level2City;
public Level1City(String name, String code) {
this.name = name;
this.code = code;
this.Level2City = new ArrayList<>();
}
// getters and setters
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getCode() { return code; }
public void setCode(String code) { this.code = code; }
public List<Level2City> getLevel2City() { return Level2City; }
public void setLevel2City(List<Level2City> Level2City) { this.Level2City = Level2City; }
}
package com.bkty.system.init;
/**
* @author Zhang Wenbiao
* @description 城市二级分类(市)
* @datetime 2025/12/4 10:55
*/
public class Level2City {
private String name;
private String code;
public Level2City(String name,String code) {
this.name = name;
this.code = code;
}
// getters and setters
public String getName() { return name; }
public String getCode() { return code; }
public void setName(String name) { this.name = name; }
public void setCode(String code) { this.code = code; }
}
package com.bkty.system.init;
import com.bkty.system.domain.entity.CityData;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import org.dromara.common.core.constant.RegionConstants;
import java.sql.*;
import java.util.*;
import java.util.stream.Collectors;
public class RegionDataProcessor {
// 用于解析JSON数据的POJO类
@Data
public static class RegionItem {
private String label;
private String value;
}
// 数据库连接配置
private static final String DB_URL = "jdbc:mariadb://123.56.87.224:3306/employment_business_pc";
private static final String DB_USER = "innovate";
private static final String DB_PASSWORD = "X3f#)2#Ul-g8Fv6D";
// 处理JSON字符串并插入数据库
public void processAndInsertData(String regionJson) throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
List<RegionItem> regionList = objectMapper.readValue(
regionJson,
new TypeReference<List<RegionItem>>() {}
);
// 分组:省级(2位编码)和市级(4位编码)
Map<String, String> provinces = regionList.stream()
.filter(item -> item.getValue().length() == 2)
.collect(Collectors.toMap(
RegionItem::getValue,
RegionItem::getLabel,
(v1, v2) -> v1 // 如果有重复,保留第一个
));
List<RegionItem> cities = regionList.stream()
.filter(item -> item.getValue().length() == 4)
.collect(Collectors.toList());
// 处理城市数据,关联省份
List<CityData> cityDataList = new ArrayList<>();
for (RegionItem city : cities) {
String cityCode = city.getValue();
String provinceCode = cityCode.substring(0, 2);
String provinceName = provinces.get(provinceCode);
if (provinceName != null) {
CityData cityData = new CityData();
cityData.setProvinceCode(provinceCode);
cityData.setProvinceName(provinceName);
cityData.setCityCode(cityCode);
cityData.setCityName(city.getLabel());
cityDataList.add(cityData);
}
}
// 插入数据库
insertIntoDatabase(cityDataList);
}
private void insertIntoDatabase(List<CityData> cityDataList) {
Connection conn = null;
PreparedStatement pstmt = null;
try {
// 1. 建立数据库连接
conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASSWORD);
// 2. 准备SQL语句
String sql = "INSERT INTO city_data (province_code, province_name, city_code, city_name) " +
"VALUES (?, ?, ?, ?)";
pstmt = conn.prepareStatement(sql);
// 3. 批量插入
int batchSize = 1000;
int count = 0;
for (CityData data : cityDataList) {
pstmt.setString(1, data.getProvinceCode());
pstmt.setString(2, data.getProvinceName());
pstmt.setString(3, data.getCityCode());
pstmt.setString(4, data.getCityName());
pstmt.addBatch();
if (++count % batchSize == 0) {
pstmt.executeBatch();
pstmt.clearBatch();
}
}
// 执行剩余批次
pstmt.executeBatch();
System.out.println("成功插入 " + count + " 条记录");
} catch (SQLException e) {
e.printStackTrace();
} finally {
// 4. 关闭资源
try {
if (pstmt != null) pstmt.close();
if (conn != null) conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
// 使用示例
public static void main(String[] args) {
try {
RegionDataProcessor processor = new RegionDataProcessor();
// 直接从你的常量类中获取JSON字符串
String jsonData = RegionConstants.REGION_JSON_ARRAY;
// 处理并插入数据
processor.processAndInsertData(jsonData);
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
package com.bkty.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bkty.system.domain.entity.CityData;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CityDataMapper extends BaseMapper<CityData> {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment