作者原创:转载请注明出处。https://www.cnblogs.com/yunqing/p/9486923.html

先放数据,t_city表 //津京冀地区行政区划数据

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for t_city
-- ----------------------------
DROP TABLE IF EXISTS `t_city`;
CREATE TABLE `t_city` (
`f_id` bigint(11) NOT NULL COMMENT '主键id',
`f_code` varchar(20) NOT NULL COMMENT '城市代码(级别代码)',
`f_name` varchar(50) NOT NULL COMMENT '城市名称',
`f_map_pack` int(11) NOT NULL COMMENT
`f_crossing_pack` int(11) NOT NULL COMMENT
`f_region_code` varchar(20) NOT NULL COMMENT '对应行政区划代码',
`f_descr` varchar(255) DEFAULT NULL COMMENT '备注',
PRIMARY KEY (`f_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='城市表'; -- ----------------------------
-- Records of t_city
-- ----------------------------
INSERT INTO `t_city` VALUES ('1', '中国', '中国', '0', '0', '中国', 'Zhong Guo');
INSERT INTO `t_city` VALUES ('2', '110000', '北京市', '0', '0', '110000', 'Beijing Shi');
INSERT INTO `t_city` VALUES ('3', '120000', '天津市', '0', '0', '120000', 'Tianjin Shi');
INSERT INTO `t_city` VALUES ('4', '130000', '河北省', '0', '0', '130000', 'Hebei Sheng');
INSERT INTO `t_city` VALUES ('33', '110100', '市辖区', '0', '0', '110100', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('34', '110200', '县', '0', '0', '110200', 'Xian');
INSERT INTO `t_city` VALUES ('35', '120100', '市辖区', '0', '0', '120100', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('36', '120200', '县', '0', '0', '120200', 'Xian');
INSERT INTO `t_city` VALUES ('37', '130100', '石家庄市', '0', '0', '130100', 'Shijiazhuang Shi');
INSERT INTO `t_city` VALUES ('38', '130200', '唐山市', '0', '0', '130200', 'Tangshan Shi');
INSERT INTO `t_city` VALUES ('39', '130300', '秦皇岛市', '0', '0', '130300', 'Qinhuangdao Shi');
INSERT INTO `t_city` VALUES ('40', '130400', '邯郸市', '0', '0', '130400', 'Handan Shi');
INSERT INTO `t_city` VALUES ('41', '130500', '邢台市', '0', '0', '130500', 'Xingtai Shi');
INSERT INTO `t_city` VALUES ('42', '130600', '保定市', '0', '0', '130600', 'Baoding Shi');
INSERT INTO `t_city` VALUES ('43', '130700', '张家口市', '0', '0', '130700', 'Zhangjiakou Shi ');
INSERT INTO `t_city` VALUES ('44', '130800', '承德市', '0', '0', '130800', 'Chengde Shi');
INSERT INTO `t_city` VALUES ('45', '130900', '沧州市', '0', '0', '130900', 'Cangzhou Shi');
INSERT INTO `t_city` VALUES ('46', '131000', '廊坊市', '0', '0', '131000', 'Langfang Shi');
INSERT INTO `t_city` VALUES ('47', '131100', '衡水市', '0', '0', '131100', 'Hengshui Shi ');
INSERT INTO `t_city` VALUES ('378', '110101', '东城区', '0', '0', '110101', 'Dongcheng Qu');
INSERT INTO `t_city` VALUES ('379', '110102', '西城区', '0', '0', '110102', 'Xicheng Qu');
INSERT INTO `t_city` VALUES ('382', '110105', '朝阳区', '0', '0', '110105', 'Chaoyang Qu');
INSERT INTO `t_city` VALUES ('383', '110106', '丰台区', '0', '0', '110106', 'Fengtai Qu');
INSERT INTO `t_city` VALUES ('384', '110107', '石景山区', '0', '0', '110107', 'Shijingshan Qu');
INSERT INTO `t_city` VALUES ('385', '110108', '海淀区', '0', '0', '110108', 'Haidian Qu');
INSERT INTO `t_city` VALUES ('386', '110109', '门头沟区', '0', '0', '110109', 'Mentougou Qu');
INSERT INTO `t_city` VALUES ('387', '110111', '房山区', '0', '0', '110111', 'Fangshan Qu');
INSERT INTO `t_city` VALUES ('388', '110112', '通州区', '0', '0', '110112', 'Tongzhou Qu');
INSERT INTO `t_city` VALUES ('389', '110113', '顺义区', '0', '0', '110113', 'Shunyi Qu');
INSERT INTO `t_city` VALUES ('390', '110114', '昌平区', '0', '0', '110114', 'Changping Qu');
INSERT INTO `t_city` VALUES ('391', '110115', '大兴区', '0', '0', '110115', 'Daxing Qu');
INSERT INTO `t_city` VALUES ('392', '110116', '怀柔区', '0', '0', '110116', 'Huairou Qu');
INSERT INTO `t_city` VALUES ('393', '110117', '平谷区', '0', '0', '110117', 'Pinggu Qu');
INSERT INTO `t_city` VALUES ('394', '110228', '密云县', '0', '0', '110228', 'Miyun Xian ');
INSERT INTO `t_city` VALUES ('395', '110229', '延庆县', '0', '0', '110229', 'Yanqing Xian');
INSERT INTO `t_city` VALUES ('396', '120101', '和平区', '0', '0', '120101', 'Heping Qu');
INSERT INTO `t_city` VALUES ('397', '120102', '河东区', '0', '0', '120102', 'Hedong Qu');
INSERT INTO `t_city` VALUES ('398', '120103', '河西区', '0', '0', '120103', 'Hexi Qu');
INSERT INTO `t_city` VALUES ('399', '120104', '南开区', '0', '0', '120104', 'Nankai Qu');
INSERT INTO `t_city` VALUES ('400', '120105', '河北区', '0', '0', '120105', 'Hebei Qu');
INSERT INTO `t_city` VALUES ('401', '120106', '红桥区', '0', '0', '120106', 'Hongqiao Qu');
INSERT INTO `t_city` VALUES ('404', '120116', '滨海新区', '0', '0', '120116', 'Dagang Qu');
INSERT INTO `t_city` VALUES ('405', '120110', '东丽区', '0', '0', '120110', 'Dongli Qu');
INSERT INTO `t_city` VALUES ('406', '120111', '西青区', '0', '0', '120111', 'Xiqing Qu');
INSERT INTO `t_city` VALUES ('407', '120112', '津南区', '0', '0', '120112', 'Jinnan Qu');
INSERT INTO `t_city` VALUES ('408', '120113', '北辰区', '0', '0', '120113', 'Beichen Qu');
INSERT INTO `t_city` VALUES ('409', '120114', '武清区', '0', '0', '120114', 'Wuqing Qu');
INSERT INTO `t_city` VALUES ('410', '120115', '宝坻区', '0', '0', '120115', 'Baodi Qu');
INSERT INTO `t_city` VALUES ('411', '120221', '宁河县', '0', '0', '120221', 'Ninghe Xian');
INSERT INTO `t_city` VALUES ('412', '120223', '静海县', '0', '0', '120223', 'Jinghai Xian');
INSERT INTO `t_city` VALUES ('413', '120225', '蓟县', '0', '0', '120225', 'Ji Xian');
INSERT INTO `t_city` VALUES ('414', '130101', '市辖区', '0', '0', '130101', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('415', '130102', '长安区', '0', '0', '130102', 'Chang,an Qu');
INSERT INTO `t_city` VALUES ('416', '130103', '桥东区', '0', '0', '130103', 'Qiaodong Qu');
INSERT INTO `t_city` VALUES ('417', '130104', '桥西区', '0', '0', '130104', 'Qiaoxi Qu');
INSERT INTO `t_city` VALUES ('418', '130105', '新华区', '0', '0', '130105', 'Xinhua Qu');
INSERT INTO `t_city` VALUES ('419', '130107', '井陉矿区', '0', '0', '130107', 'Jingxing Kuangqu');
INSERT INTO `t_city` VALUES ('420', '130108', '裕华区', '0', '0', '130108', 'Yuhua Qu');
INSERT INTO `t_city` VALUES ('421', '130121', '井陉县', '0', '0', '130121', 'Jingxing Xian');
INSERT INTO `t_city` VALUES ('422', '130123', '正定县', '0', '0', '130123', 'Zhengding Xian');
INSERT INTO `t_city` VALUES ('423', '130124', '栾城县', '0', '0', '130124', 'Luancheng Xian');
INSERT INTO `t_city` VALUES ('424', '130125', '行唐县', '0', '0', '130125', 'Xingtang Xian');
INSERT INTO `t_city` VALUES ('425', '130126', '灵寿县', '0', '0', '130126', 'Lingshou Xian ');
INSERT INTO `t_city` VALUES ('426', '130127', '高邑县', '0', '0', '130127', 'Gaoyi Xian');
INSERT INTO `t_city` VALUES ('427', '130128', '深泽县', '0', '0', '130128', 'Shenze Xian');
INSERT INTO `t_city` VALUES ('428', '130129', '赞皇县', '0', '0', '130129', 'Zanhuang Xian');
INSERT INTO `t_city` VALUES ('429', '130130', '无极县', '0', '0', '130130', 'Wuji Xian');
INSERT INTO `t_city` VALUES ('430', '130131', '平山县', '0', '0', '130131', 'Pingshan Xian');
INSERT INTO `t_city` VALUES ('431', '130132', '元氏县', '0', '0', '130132', 'Yuanshi Xian');
INSERT INTO `t_city` VALUES ('432', '130133', '赵县', '0', '0', '130133', 'Zhao Xian');
INSERT INTO `t_city` VALUES ('433', '130181', '辛集市', '0', '0', '130181', 'Xinji Shi');
INSERT INTO `t_city` VALUES ('434', '130182', '藁城市', '0', '0', '130182', 'Gaocheng Shi');
INSERT INTO `t_city` VALUES ('435', '130183', '晋州市', '0', '0', '130183', 'Jinzhou Shi');
INSERT INTO `t_city` VALUES ('436', '130184', '新乐市', '0', '0', '130184', 'Xinle Shi');
INSERT INTO `t_city` VALUES ('437', '130185', '鹿泉市', '0', '0', '130185', 'Luquan Shi');
INSERT INTO `t_city` VALUES ('438', '130201', '市辖区', '0', '0', '130201', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('439', '130202', '路南区', '0', '0', '130202', 'Lunan Qu');
INSERT INTO `t_city` VALUES ('440', '130203', '路北区', '0', '0', '130203', 'Lubei Qu');
INSERT INTO `t_city` VALUES ('441', '130204', '古冶区', '0', '0', '130204', 'Guye Qu');
INSERT INTO `t_city` VALUES ('442', '130205', '开平区', '0', '0', '130205', 'Kaiping Qu');
INSERT INTO `t_city` VALUES ('443', '130207', '丰南区', '0', '0', '130207', 'Fengnan Qu');
INSERT INTO `t_city` VALUES ('444', '130208', '丰润区', '0', '0', '130208', 'Fengrun Qu');
INSERT INTO `t_city` VALUES ('445', '130223', '滦县', '0', '0', '130223', 'Luan Xian');
INSERT INTO `t_city` VALUES ('446', '130224', '滦南县', '0', '0', '130224', 'Luannan Xian');
INSERT INTO `t_city` VALUES ('447', '130225', '乐亭县', '0', '0', '130225', 'Leting Xian');
INSERT INTO `t_city` VALUES ('448', '130227', '迁西县', '0', '0', '130227', 'Qianxi Xian');
INSERT INTO `t_city` VALUES ('449', '130229', '玉田县', '0', '0', '130229', 'Yutian Xian');
INSERT INTO `t_city` VALUES ('450', '130230', '唐海县', '0', '0', '130230', 'Tanghai Xian ');
INSERT INTO `t_city` VALUES ('451', '130281', '遵化市', '0', '0', '130281', 'Zunhua Shi');
INSERT INTO `t_city` VALUES ('452', '130283', '迁安市', '0', '0', '130283', 'Qian,an Shi');
INSERT INTO `t_city` VALUES ('453', '130301', '市辖区', '0', '0', '130301', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('454', '130302', '海港区', '0', '0', '130302', 'Haigang Qu');
INSERT INTO `t_city` VALUES ('455', '130303', '山海关区', '0', '0', '130303', 'Shanhaiguan Qu');
INSERT INTO `t_city` VALUES ('456', '130304', '北戴河区', '0', '0', '130304', 'Beidaihe Qu');
INSERT INTO `t_city` VALUES ('457', '130321', '青龙满族自治县', '0', '0', '130321', 'Qinglong Manzu Zizhixian');
INSERT INTO `t_city` VALUES ('458', '130322', '昌黎县', '0', '0', '130322', 'Changli Xian');
INSERT INTO `t_city` VALUES ('459', '130323', '抚宁县', '0', '0', '130323', 'Funing Xian ');
INSERT INTO `t_city` VALUES ('460', '130324', '卢龙县', '0', '0', '130324', 'Lulong Xian');
INSERT INTO `t_city` VALUES ('461', '130401', '市辖区', '0', '0', '130401', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('462', '130402', '邯山区', '0', '0', '130402', 'Hanshan Qu');
INSERT INTO `t_city` VALUES ('463', '130403', '丛台区', '0', '0', '130403', 'Congtai Qu');
INSERT INTO `t_city` VALUES ('464', '130404', '复兴区', '0', '0', '130404', 'Fuxing Qu');
INSERT INTO `t_city` VALUES ('465', '130406', '峰峰矿区', '0', '0', '130406', 'Fengfeng Kuangqu');
INSERT INTO `t_city` VALUES ('466', '130421', '邯郸县', '0', '0', '130421', 'Handan Xian ');
INSERT INTO `t_city` VALUES ('467', '130423', '临漳县', '0', '0', '130423', 'Linzhang Xian ');
INSERT INTO `t_city` VALUES ('468', '130424', '成安县', '0', '0', '130424', 'Cheng,an Xian');
INSERT INTO `t_city` VALUES ('469', '130425', '大名县', '0', '0', '130425', 'Daming Xian');
INSERT INTO `t_city` VALUES ('470', '130426', '涉县', '0', '0', '130426', 'She Xian');
INSERT INTO `t_city` VALUES ('471', '130427', '磁县', '0', '0', '130427', 'Ci Xian');
INSERT INTO `t_city` VALUES ('472', '130428', '肥乡县', '0', '0', '130428', 'Feixiang Xian');
INSERT INTO `t_city` VALUES ('473', '130429', '永年县', '0', '0', '130429', 'Yongnian Xian');
INSERT INTO `t_city` VALUES ('474', '130430', '邱县', '0', '0', '130430', 'Qiu Xian');
INSERT INTO `t_city` VALUES ('475', '130431', '鸡泽县', '0', '0', '130431', 'Jize Xian');
INSERT INTO `t_city` VALUES ('476', '130432', '广平县', '0', '0', '130432', 'Guangping Xian ');
INSERT INTO `t_city` VALUES ('477', '130433', '馆陶县', '0', '0', '130433', 'Guantao Xian');
INSERT INTO `t_city` VALUES ('478', '130434', '魏县', '0', '0', '130434', 'Wei Xian ');
INSERT INTO `t_city` VALUES ('479', '130435', '曲周县', '0', '0', '130435', 'Quzhou Xian ');
INSERT INTO `t_city` VALUES ('480', '130481', '武安市', '0', '0', '130481', 'Wu,an Shi');
INSERT INTO `t_city` VALUES ('481', '130501', '市辖区', '0', '0', '130501', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('482', '130502', '桥东区', '0', '0', '130502', 'Qiaodong Qu');
INSERT INTO `t_city` VALUES ('483', '130503', '桥西区', '0', '0', '130503', 'Qiaoxi Qu');
INSERT INTO `t_city` VALUES ('484', '130521', '邢台县', '0', '0', '130521', 'Xingtai Xian');
INSERT INTO `t_city` VALUES ('485', '130522', '临城县', '0', '0', '130522', 'Lincheng Xian ');
INSERT INTO `t_city` VALUES ('486', '130523', '内丘县', '0', '0', '130523', 'Neiqiu Xian ');
INSERT INTO `t_city` VALUES ('487', '130524', '柏乡县', '0', '0', '130524', 'Baixiang Xian');
INSERT INTO `t_city` VALUES ('488', '130525', '隆尧县', '0', '0', '130525', 'Longyao Xian');
INSERT INTO `t_city` VALUES ('489', '130526', '任县', '0', '0', '130526', 'Ren Xian');
INSERT INTO `t_city` VALUES ('490', '130527', '南和县', '0', '0', '130527', 'Nanhe Xian');
INSERT INTO `t_city` VALUES ('491', '130528', '宁晋县', '0', '0', '130528', 'Ningjin Xian');
INSERT INTO `t_city` VALUES ('492', '130529', '巨鹿县', '0', '0', '130529', 'Julu Xian');
INSERT INTO `t_city` VALUES ('493', '130530', '新河县', '0', '0', '130530', 'Xinhe Xian ');
INSERT INTO `t_city` VALUES ('494', '130531', '广宗县', '0', '0', '130531', 'Guangzong Xian ');
INSERT INTO `t_city` VALUES ('495', '130532', '平乡县', '0', '0', '130532', 'Pingxiang Xian');
INSERT INTO `t_city` VALUES ('496', '130533', '威县', '0', '0', '130533', 'Wei Xian ');
INSERT INTO `t_city` VALUES ('497', '130534', '清河县', '0', '0', '130534', 'Qinghe Xian');
INSERT INTO `t_city` VALUES ('498', '130535', '临西县', '0', '0', '130535', 'Linxi Xian');
INSERT INTO `t_city` VALUES ('499', '130581', '南宫市', '0', '0', '130581', 'Nangong Shi');
INSERT INTO `t_city` VALUES ('500', '130582', '沙河市', '0', '0', '130582', 'Shahe Shi');
INSERT INTO `t_city` VALUES ('501', '130601', '市辖区', '0', '0', '130601', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('502', '130600', '新市区', '0', '0', '130600', 'Xinshi Qu');
INSERT INTO `t_city` VALUES ('503', '130603', '北市区', '0', '0', '130603', 'Beishi Qu');
INSERT INTO `t_city` VALUES ('504', '130604', '南市区', '0', '0', '130604', 'Nanshi Qu');
INSERT INTO `t_city` VALUES ('505', '130621', '满城县', '0', '0', '130621', 'Mancheng Xian ');
INSERT INTO `t_city` VALUES ('506', '130622', '清苑县', '0', '0', '130622', 'Qingyuan Xian');
INSERT INTO `t_city` VALUES ('507', '130623', '涞水县', '0', '0', '130623', 'Laishui Xian');
INSERT INTO `t_city` VALUES ('508', '130624', '阜平县', '0', '0', '130624', 'Fuping Xian ');
INSERT INTO `t_city` VALUES ('509', '130625', '徐水县', '0', '0', '130625', 'Xushui Xian ');
INSERT INTO `t_city` VALUES ('510', '130626', '定兴县', '0', '0', '130626', 'Dingxing Xian ');
INSERT INTO `t_city` VALUES ('511', '130627', '唐县', '0', '0', '130627', 'Tang Xian ');
INSERT INTO `t_city` VALUES ('512', '130628', '高阳县', '0', '0', '130628', 'Gaoyang Xian ');
INSERT INTO `t_city` VALUES ('513', '130629', '容城县', '0', '0', '130629', 'Rongcheng Xian ');
INSERT INTO `t_city` VALUES ('514', '130630', '涞源县', '0', '0', '130630', 'Laiyuan Xian ');
INSERT INTO `t_city` VALUES ('515', '130631', '望都县', '0', '0', '130631', 'Wangdu Xian ');
INSERT INTO `t_city` VALUES ('516', '130632', '安新县', '0', '0', '130632', 'Anxin Xian ');
INSERT INTO `t_city` VALUES ('517', '130633', '易县', '0', '0', '130633', 'Yi Xian');
INSERT INTO `t_city` VALUES ('518', '130634', '曲阳县', '0', '0', '130634', 'Quyang Xian ');
INSERT INTO `t_city` VALUES ('519', '130635', '蠡县', '0', '0', '130635', 'Li Xian');
INSERT INTO `t_city` VALUES ('520', '130636', '顺平县', '0', '0', '130636', 'Shunping Xian ');
INSERT INTO `t_city` VALUES ('521', '130637', '博野县', '0', '0', '130637', 'Boye Xian ');
INSERT INTO `t_city` VALUES ('522', '130638', '雄县', '0', '0', '130638', 'Xiong Xian');
INSERT INTO `t_city` VALUES ('523', '130681', '涿州市', '0', '0', '130681', 'Zhuozhou Shi');
INSERT INTO `t_city` VALUES ('524', '130682', '定州市', '0', '0', '130682', 'Dingzhou Shi ');
INSERT INTO `t_city` VALUES ('525', '130683', '安国市', '0', '0', '130683', 'Anguo Shi ');
INSERT INTO `t_city` VALUES ('526', '130684', '高碑店市', '0', '0', '130684', 'Gaobeidian Shi');
INSERT INTO `t_city` VALUES ('527', '130701', '市辖区', '0', '0', '130701', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('528', '130702', '桥东区', '0', '0', '130702', 'Qiaodong Qu');
INSERT INTO `t_city` VALUES ('529', '130703', '桥西区', '0', '0', '130703', 'Qiaoxi Qu');
INSERT INTO `t_city` VALUES ('530', '130705', '宣化区', '0', '0', '130705', 'Xuanhua Qu');
INSERT INTO `t_city` VALUES ('531', '130706', '下花园区', '0', '0', '130706', 'Xiahuayuan Qu ');
INSERT INTO `t_city` VALUES ('532', '130721', '宣化县', '0', '0', '130721', 'Xuanhua Xian ');
INSERT INTO `t_city` VALUES ('533', '130722', '张北县', '0', '0', '130722', 'Zhangbei Xian ');
INSERT INTO `t_city` VALUES ('534', '130723', '康保县', '0', '0', '130723', 'Kangbao Xian');
INSERT INTO `t_city` VALUES ('535', '130724', '沽源县', '0', '0', '130724', 'Guyuan Xian');
INSERT INTO `t_city` VALUES ('536', '130725', '尚义县', '0', '0', '130725', 'Shangyi Xian');
INSERT INTO `t_city` VALUES ('537', '130726', '蔚县', '0', '0', '130726', 'Yu Xian');
INSERT INTO `t_city` VALUES ('538', '130727', '阳原县', '0', '0', '130727', 'Yangyuan Xian');
INSERT INTO `t_city` VALUES ('539', '130728', '怀安县', '0', '0', '130728', 'Huai,an Xian');
INSERT INTO `t_city` VALUES ('540', '130729', '万全县', '0', '0', '130729', 'Wanquan Xian ');
INSERT INTO `t_city` VALUES ('541', '130730', '怀来县', '0', '0', '130730', 'Huailai Xian');
INSERT INTO `t_city` VALUES ('542', '130731', '涿鹿县', '0', '0', '130731', 'Zhuolu Xian ');
INSERT INTO `t_city` VALUES ('543', '130732', '赤城县', '0', '0', '130732', 'Chicheng Xian');
INSERT INTO `t_city` VALUES ('544', '130733', '崇礼县', '0', '0', '130733', 'Chongli Xian');
INSERT INTO `t_city` VALUES ('545', '130801', '市辖区', '0', '0', '130801', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('546', '130802', '双桥区', '0', '0', '130802', 'Shuangqiao Qu ');
INSERT INTO `t_city` VALUES ('547', '130803', '双滦区', '0', '0', '130803', 'Shuangluan Qu');
INSERT INTO `t_city` VALUES ('548', '130804', '鹰手营子矿区', '0', '0', '130804', 'Yingshouyingzi Kuangqu');
INSERT INTO `t_city` VALUES ('549', '130821', '承德县', '0', '0', '130821', 'Chengde Xian');
INSERT INTO `t_city` VALUES ('550', '130822', '兴隆县', '0', '0', '130822', 'Xinglong Xian');
INSERT INTO `t_city` VALUES ('551', '130823', '平泉县', '0', '0', '130823', 'Pingquan Xian');
INSERT INTO `t_city` VALUES ('552', '130824', '滦平县', '0', '0', '130824', 'Luanping Xian ');
INSERT INTO `t_city` VALUES ('553', '130825', '隆化县', '0', '0', '130825', 'Longhua Xian');
INSERT INTO `t_city` VALUES ('554', '130826', '丰宁满族自治县', '0', '0', '130826', 'Fengning Manzu Zizhixian');
INSERT INTO `t_city` VALUES ('555', '130827', '宽城满族自治县', '0', '0', '130827', 'Kuancheng Manzu Zizhixian');
INSERT INTO `t_city` VALUES ('556', '130828', '围场满族蒙古族自治县', '0', '0', '130828', 'Weichang Manzu Menggolzu Zizhixian');
INSERT INTO `t_city` VALUES ('557', '130901', '市辖区', '0', '0', '130901', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('558', '130902', '新华区', '0', '0', '130902', 'Xinhua Qu');
INSERT INTO `t_city` VALUES ('559', '130903', '运河区', '0', '0', '130903', 'Yunhe Qu');
INSERT INTO `t_city` VALUES ('560', '130921', '沧县', '0', '0', '130921', 'Cang Xian');
INSERT INTO `t_city` VALUES ('561', '130922', '青县', '0', '0', '130922', 'Qing Xian');
INSERT INTO `t_city` VALUES ('562', '130923', '东光县', '0', '0', '130923', 'Dongguang Xian ');
INSERT INTO `t_city` VALUES ('563', '130924', '海兴县', '0', '0', '130924', 'Haixing Xian');
INSERT INTO `t_city` VALUES ('564', '130925', '盐山县', '0', '0', '130925', 'Yanshan Xian');
INSERT INTO `t_city` VALUES ('565', '130926', '肃宁县', '0', '0', '130926', 'Suning Xian ');
INSERT INTO `t_city` VALUES ('566', '130927', '南皮县', '0', '0', '130927', 'Nanpi Xian');
INSERT INTO `t_city` VALUES ('567', '130928', '吴桥县', '0', '0', '130928', 'Wuqiao Xian ');
INSERT INTO `t_city` VALUES ('568', '130929', '献县', '0', '0', '130929', 'Xian Xian ');
INSERT INTO `t_city` VALUES ('569', '130930', '孟村回族自治县', '0', '0', '130930', 'Mengcun Huizu Zizhixian');
INSERT INTO `t_city` VALUES ('570', '130981', '泊头市', '0', '0', '130981', 'Botou Shi ');
INSERT INTO `t_city` VALUES ('571', '130982', '任丘市', '0', '0', '130982', 'Renqiu Shi');
INSERT INTO `t_city` VALUES ('572', '130983', '黄骅市', '0', '0', '130983', 'Huanghua Shi');
INSERT INTO `t_city` VALUES ('573', '130984', '河间市', '0', '0', '130984', 'Hejian Shi');
INSERT INTO `t_city` VALUES ('574', '131001', '市辖区', '0', '0', '131001', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('575', '131002', '安次区', '0', '0', '131002', 'Anci Qu');
INSERT INTO `t_city` VALUES ('576', '131003', '广阳区', '0', '0', '131003', 'Guangyang Qu');
INSERT INTO `t_city` VALUES ('577', '131022', '固安县', '0', '0', '131022', 'Gu,an Xian');
INSERT INTO `t_city` VALUES ('578', '131023', '永清县', '0', '0', '131023', 'Yongqing Xian ');
INSERT INTO `t_city` VALUES ('579', '131024', '香河县', '0', '0', '131024', 'Xianghe Xian');
INSERT INTO `t_city` VALUES ('580', '131025', '大城县', '0', '0', '131025', 'Dacheng Xian');
INSERT INTO `t_city` VALUES ('581', '131026', '文安县', '0', '0', '131026', 'Wen,an Xian');
INSERT INTO `t_city` VALUES ('582', '131028', '大厂回族自治县', '0', '0', '131028', 'Dachang Huizu Zizhixian');
INSERT INTO `t_city` VALUES ('583', '131081', '霸州市', '0', '0', '131081', 'Bazhou Shi');
INSERT INTO `t_city` VALUES ('584', '131082', '三河市', '0', '0', '131082', 'Sanhe Shi');
INSERT INTO `t_city` VALUES ('585', '131101', '市辖区', '0', '0', '131101', 'Shixiaqu');
INSERT INTO `t_city` VALUES ('586', '131102', '桃城区', '0', '0', '131102', 'Taocheng Qu');
INSERT INTO `t_city` VALUES ('587', '131121', '枣强县', '0', '0', '131121', 'Zaoqiang Xian ');
INSERT INTO `t_city` VALUES ('588', '131122', '武邑县', '0', '0', '131122', 'Wuyi Xian');
INSERT INTO `t_city` VALUES ('589', '131123', '武强县', '0', '0', '131123', 'Wuqiang Xian ');
INSERT INTO `t_city` VALUES ('590', '131124', '饶阳县', '0', '0', '131124', 'Raoyang Xian');
INSERT INTO `t_city` VALUES ('591', '131125', '安平县', '0', '0', '131125', 'Anping Xian');
INSERT INTO `t_city` VALUES ('592', '131126', '故城县', '0', '0', '131126', 'Gucheng Xian');
INSERT INTO `t_city` VALUES ('593', '131127', '景县', '0', '0', '131127', 'Jing Xian ');
INSERT INTO `t_city` VALUES ('594', '131128', '阜城县', '0', '0', '131128', 'Fucheng Xian ');
INSERT INTO `t_city` VALUES ('595', '131181', '冀州市', '0', '0', '131181', 'Jizhou Shi ');
INSERT INTO `t_city` VALUES ('596', '131182', '深州市', '0', '0', '131182', 'Shenzhou Shi');

1.创建一个树形结构类

public class TreeVo {

	private Long id;
private String code;
private String name;
private List<TreeVo> nodes; @Override
public Long id() {
return id;
} @Override
public TreeVo id(Long id) {
this.id = id;
return (TreeVo) this;
} public Long getId() {
return id;
} public void setId(Long id) {
this.id = id;
} public String getCode() {
return code;
} public void setCode(String code) {
this.code = code;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public List<TreeVo> getNodes() {
return nodes;
} public void setNodes(List<TreeVo> nodes) {
this.nodes = nodes;
} }  

2.城市实体类

略。。。看数据库自己建立

3.数据处理----查询出来city信息,装进TreeVo中

     @RequestMapping(value = "/findTree", method = { RequestMethod.GET })
public Map<String,Object> findTree() { Map<String,Object> map = new HashMap<String, Object>();
List<City> citys=cityService.findAll(Sort.by(Direction.ASC, "code"), null);
List<TreeVo> baseTreeList=findTree(citys);
map.put("tree", baseTreeList);
return map; } public List<TreeVo> findTree(List<City> citys) {
//过滤掉顶级中国
List<City> cityList = citys.stream().filter(e->!e.getName().equals("中国") && !e.equals(null)).collect(Collectors.toList()); List<TreeVo> baseTreeList = new ArrayList<>();
List<TreeVo> secondTreeList = new ArrayList<>();
List<TreeVo> thirdTreeList = new ArrayList<>(); for (City city : cityList) {
//String codeTmp1 = city.getCode().substring(0, 2);
String codeTmp2 = city.getCode().substring(2, 4);
String codeTmp3 = city.getCode().substring(4, 6);
//找到根节点。
if (codeTmp2.equals("00") && codeTmp3.equals("00")) {
TreeVo baseTree = new TreeVo();
baseTree.setCode(city.getCode());
baseTree.setName(city.getName());
baseTreeList.add(baseTree);
}else if(codeTmp3.equals("00")) {//找到二级节点
TreeVo secondTree = new TreeVo();
secondTree.setCode(city.getCode());
secondTree.setName(city.getName());
secondTreeList.add(secondTree);
}else {//剩下的是三级节点
TreeVo thirdTree = new TreeVo();
thirdTree.setCode(city.getCode());
thirdTree.setName(city.getName());
thirdTreeList.add(thirdTree);
}
}
//遍历二级节点
for(TreeVo secondTree : secondTreeList) {
//获取二级节点前4位
String secondTree0_4 = secondTree.getCode().substring(0, 4);
//遍历3级节点,找出前4位与2级节点相同的
List<TreeVo> tempList = thirdTreeList.stream()
                           .filter(e->e.getCode().substring(0, 4).equals(secondTree0_4))
   .collect(Collectors.toList());
//设置二级节点的三级节点
secondTree.setNodes(tempList);
}
//遍历根节点
for(TreeVo baseTree : baseTreeList) {
//获取根节点的前两位
String baseTree0_2 = baseTree.getCode().substring(0, 2);
//遍历2级节点,找出前两位与根节点相同的
List<TreeVo> tempList = secondTreeList.stream()
    .filter(e->e.getCode().substring(0, 2).equals(baseTree0_2))
.collect(Collectors.toList());
//设置根节点的二级节点
baseTree.setNodes(tempList);
}
return baseTreeList;
}

  

4.最后得到的json数据:https://www.json.cn/ 拷贝到此查看结果

{"tree":[{"id":null,"code":"110000","name":"北京市","nodes":[{"id":null,"code":"110100","name":"市辖区","nodes":[{"id":null,"code":"110101","name":"东城区","nodes":null},{"id":null,"code":"110102","name":"西城区","nodes":null},
{"id":null,"code":"110105","name":"朝阳区","nodes":null},{"id":null,"code":"110106","name":"丰台区","nodes":null},{"id":null,"code":"110107","name":"石景山区","nodes":null},{"id":null,"code":"110108","name":"海淀区","nodes":null},
{"id":null,"code":"110109","name":"门头沟区","nodes":null},{"id":null,"code":"110111","name":"房山区","nodes":null},{"id":null,"code":"110112","name":"通州区","nodes":null},{"id":null,"code":"110113","name":"顺义区","nodes":null},
{"id":null,"code":"110114","name":"昌平区","nodes":null},{"id":null,"code":"110115","name":"大兴区","nodes":null},{"id":null,"code":"110116","name":"怀柔区","nodes":null},{"id":null,"code":"110117","name":"平谷区","nodes":null}]},
{"id":null,"code":"110200","name":"县","nodes":[{"id":null,"code":"110228","name":"密云县","nodes":null},{"id":null,"code":"110229","name":"延庆县","nodes":null}]}]},{"id":null,"code":"120000","name":"天津市",
"nodes":[{"id":null,"code":"120100","name":"市辖区","nodes":[{"id":null,"code":"120101","name":"和平区","nodes":null},{"id":null,"code":"120102","name":"河东区","nodes":null},{"id":null,"code":"120103","name":"河西区","nodes":null},
{"id":null,"code":"120104","name":"南开区","nodes":null},{"id":null,"code":"120105","name":"河北区","nodes":null},{"id":null,"code":"120106","name":"红桥区","nodes":null},{"id":null,"code":"120110","name":"东丽区","nodes":null},
{"id":null,"code":"120111","name":"西青区","nodes":null},{"id":null,"code":"120112","name":"津南区","nodes":null},{"id":null,"code":"120113","name":"北辰区","nodes":null},{"id":null,"code":"120114","name":"武清区","nodes":null},
{"id":null,"code":"120115","name":"宝坻区","nodes":null},{"id":null,"code":"120116","name":"滨海新区","nodes":null}]},{"id":null,"code":"120200","name":"县","nodes":[{"id":null,"code":"120221","name":"宁河县","nodes":null},
{"id":null,"code":"120223","name":"静海县","nodes":null},{"id":null,"code":"120225","name":"蓟县","nodes":null}]}]},{"id":null,"code":"130000","name":"河北省","nodes":[{"id":null,"code":"130100","name":"石家庄市",
"nodes":[{"id":null,"code":"130101","name":"市辖区","nodes":null},{"id":null,"code":"130102","name":"长安区","nodes":null},{"id":null,"code":"130103","name":"桥东区","nodes":null},{"id":null,"code":"130104",
"name":"桥西区","nodes":null},{"id":null,"code":"130105","name":"新华区","nodes":null},{"id":null,"code":"130107","name":"井陉矿区","nodes":null},{"id":null,"code":"130108","name":"裕华区","nodes":null},
{"id":null,"code":"130121","name":"井陉县","nodes":null},{"id":null,"code":"130123","name":"正定县","nodes":null},{"id":null,"code":"130124","name":"栾城县","nodes":null},{"id":null,"code":"130125","name":"行唐县","nodes":null},
{"id":null,"code":"130126","name":"灵寿县","nodes":null},{"id":null,"code":"130127","name":"高邑县","nodes":null},{"id":null,"code":"130128","name":"深泽县","nodes":null},{"id":null,"code":"130129","name":"赞皇县","nodes":null},
{"id":null,"code":"130130","name":"无极县","nodes":null},{"id":null,"code":"130131","name":"平山县","nodes":null},{"id":null,"code":"130132","name":"元氏县","nodes":null},{"id":null,"code":"130133","name":"赵县","nodes":null},
{"id":null,"code":"130181","name":"辛集市","nodes":null},{"id":null,"code":"130182","name":"藁城市","nodes":null},{"id":null,"code":"130183","name":"晋州市","nodes":null},{"id":null,"code":"130184","name":"新乐市","nodes":null},
{"id":null,"code":"130185","name":"鹿泉市","nodes":null}]},{"id":null,"code":"130200","name":"唐山市","nodes":[{"id":null,"code":"130201","name":"市辖区","nodes":null},{"id":null,"code":"130202","name":"路南区","nodes":null},
{"id":null,"code":"130203","name":"路北区","nodes":null},{"id":null,"code":"130204","name":"古冶区","nodes":null},{"id":null,"code":"130205","name":"开平区","nodes":null},{"id":null,"code":"130207","name":"丰南区","nodes":null},
{"id":null,"code":"130208","name":"丰润区","nodes":null},{"id":null,"code":"130223","name":"滦县","nodes":null},{"id":null,"code":"130224","name":"滦南县","nodes":null},{"id":null,"code":"130225","name":"乐亭县","nodes":null},
{"id":null,"code":"130227","name":"迁西县","nodes":null},{"id":null,"code":"130229","name":"玉田县","nodes":null},{"id":null,"code":"130230","name":"唐海县","nodes":null},{"id":null,"code":"130281","name":"遵化市","nodes":null},
{"id":null,"code":"130283","name":"迁安市","nodes":null}]},{"id":null,"code":"130300","name":"秦皇岛市","nodes":[{"id":null,"code":"130301","name":"市辖区","nodes":null},{"id":null,"code":"130302","name":"海港区","nodes":null},
{"id":null,"code":"130303","name":"山海关区","nodes":null},{"id":null,"code":"130304","name":"北戴河区","nodes":null},{"id":null,"code":"130321","name":"青龙满族自治县","nodes":null},{"id":null,"code":"130322","name":"昌黎县",
"nodes":null},{"id":null,"code":"130323","name":"抚宁县","nodes":null},{"id":null,"code":"130324","name":"卢龙县","nodes":null}]},{"id":null,"code":"130400","name":"邯郸市","nodes":[{"id":null,"code":"130401","name":"市辖区",
"nodes":null},{"id":null,"code":"130402","name":"邯山区","nodes":null},{"id":null,"code":"130403","name":"丛台区","nodes":null},{"id":null,"code":"130404","name":"复兴区","nodes":null},{"id":null,"code":"130406","name":"峰峰矿区",
"nodes":null},{"id":null,"code":"130421","name":"邯郸县","nodes":null},{"id":null,"code":"130423","name":"临漳县","nodes":null},{"id":null,"code":"130424","name":"成安县","nodes":null},{"id":null,"code":"130425","name":"大名县",
"nodes":null},{"id":null,"code":"130426","name":"涉县","nodes":null},{"id":null,"code":"130427","name":"磁县","nodes":null},{"id":null,"code":"130428","name":"肥乡县","nodes":null},{"id":null,"code":"130429","name":"永年县",
"nodes":null},{"id":null,"code":"130430","name":"邱县","nodes":null},{"id":null,"code":"130431","name":"鸡泽县","nodes":null},{"id":null,"code":"130432","name":"广平县","nodes":null},{"id":null,"code":"130433","name":"馆陶县",
"nodes":null},{"id":null,"code":"130434","name":"魏县","nodes":null},{"id":null,"code":"130435","name":"曲周县","nodes":null},{"id":null,"code":"130481","name":"武安市","nodes":null}]},{"id":null,"code":"130500","name":"邢台市",
"nodes":[{"id":null,"code":"130501","name":"市辖区","nodes":null},{"id":null,"code":"130502","name":"桥东区","nodes":null},{"id":null,"code":"130503","name":"桥西区","nodes":null},{"id":null,"code":"130521","name":"邢台县",
"nodes":null},{"id":null,"code":"130522","name":"临城县","nodes":null},{"id":null,"code":"130523","name":"内丘县","nodes":null},{"id":null,"code":"130524","name":"柏乡县","nodes":null},{"id":null,"code":"130525","name":"隆尧县",
"nodes":null},{"id":null,"code":"130526","name":"任县","nodes":null},{"id":null,"code":"130527","name":"南和县","nodes":null},{"id":null,"code":"130528","name":"宁晋县","nodes":null},{"id":null,"code":"130529","name":"巨鹿县",
"nodes":null},{"id":null,"code":"130530","name":"新河县","nodes":null},{"id":null,"code":"130531","name":"广宗县","nodes":null},{"id":null,"code":"130532","name":"平乡县","nodes":null},{"id":null,"code":"130533","name":"威县",
"nodes":null},{"id":null,"code":"130534","name":"清河县","nodes":null},{"id":null,"code":"130535","name":"临西县","nodes":null},{"id":null,"code":"130581","name":"南宫市","nodes":null},{"id":null,"code":"130582","name":"沙河市",
"nodes":null}]},{"id":null,"code":"130600","name":"保定市","nodes":[{"id":null,"code":"130601","name":"市辖区","nodes":null},{"id":null,"code":"130603","name":"北市区","nodes":null},{"id":null,"code":"130604","name":"南市区",
"nodes":null},{"id":null,"code":"130621","name":"满城县","nodes":null},{"id":null,"code":"130622","name":"清苑县","nodes":null},{"id":null,"code":"130623","name":"涞水县","nodes":null},{"id":null,"code":"130624","name":"阜平县",
"nodes":null},{"id":null,"code":"130625","name":"徐水县","nodes":null},{"id":null,"code":"130626","name":"定兴县","nodes":null},{"id":null,"code":"130627","name":"唐县","nodes":null},{"id":null,"code":"130628","name":"高阳县",
"nodes":null},{"id":null,"code":"130629","name":"容城县","nodes":null},{"id":null,"code":"130630","name":"涞源县","nodes":null},{"id":null,"code":"130631","name":"望都县","nodes":null},{"id":null,"code":"130632","name":"安新县",
"nodes":null},{"id":null,"code":"130633","name":"易县","nodes":null},{"id":null,"code":"130634","name":"曲阳县","nodes":null},{"id":null,"code":"130635","name":"蠡县","nodes":null},{"id":null,"code":"130636","name":"顺平县",
"nodes":null},{"id":null,"code":"130637","name":"博野县","nodes":null},{"id":null,"code":"130638","name":"雄县","nodes":null},{"id":null,"code":"130681","name":"涿州市","nodes":null},{"id":null,"code":"130682","name":"定州市",
"nodes":null},{"id":null,"code":"130683","name":"安国市","nodes":null},{"id":null,"code":"130684","name":"高碑店市","nodes":null}]},{"id":null,"code":"130600","name":"新市区","nodes":[{"id":null,"code":"130601","name":"市辖区",
"nodes":null},{"id":null,"code":"130603","name":"北市区","nodes":null},{"id":null,"code":"130604","name":"南市区","nodes":null},{"id":null,"code":"130621","name":"满城县","nodes":null},{"id":null,"code":"130622","name":"清苑县",
"nodes":null},{"id":null,"code":"130623","name":"涞水县","nodes":null},{"id":null,"code":"130624","name":"阜平县","nodes":null},{"id":null,"code":"130625","name":"徐水县","nodes":null},{"id":null,"code":"130626","name":"定兴县",
"nodes":null},{"id":null,"code":"130627","name":"唐县","nodes":null},{"id":null,"code":"130628","name":"高阳县","nodes":null},{"id":null,"code":"130629","name":"容城县","nodes":null},{"id":null,"code":"130630","name":"涞源县",
"nodes":null},{"id":null,"code":"130631","name":"望都县","nodes":null},{"id":null,"code":"130632","name":"安新县","nodes":null},{"id":null,"code":"130633","name":"易县","nodes":null},{"id":null,"code":"130634","name":"曲阳县",
"nodes":null},{"id":null,"code":"130635","name":"蠡县","nodes":null},{"id":null,"code":"130636","name":"顺平县","nodes":null},{"id":null,"code":"130637","name":"博野县","nodes":null},{"id":null,"code":"130638","name":"雄县",
"nodes":null},{"id":null,"code":"130681","name":"涿州市","nodes":null},{"id":null,"code":"130682","name":"定州市","nodes":null},{"id":null,"code":"130683","name":"安国市","nodes":null},{"id":null,"code":"130684","name":"高碑店市",
"nodes":null}]},{"id":null,"code":"130700","name":"张家口市","nodes":[{"id":null,"code":"130701","name":"市辖区","nodes":null},{"id":null,"code":"130702","name":"桥东区","nodes":null},{"id":null,"code":"130703","name":"桥西区",
"nodes":null},{"id":null,"code":"130705","name":"宣化区","nodes":null},{"id":null,"code":"130706","name":"下花园区","nodes":null},{"id":null,"code":"130721","name":"宣化县","nodes":null},{"id":null,"code":"130722","name":"张北县",
"nodes":null},{"id":null,"code":"130723","name":"康保县","nodes":null},{"id":null,"code":"130724","name":"沽源县","nodes":null},{"id":null,"code":"130725","name":"尚义县","nodes":null},{"id":null,"code":"130726","name":"蔚县",
"nodes":null},{"id":null,"code":"130727","name":"阳原县","nodes":null},{"id":null,"code":"130728","name":"怀安县","nodes":null},{"id":null,"code":"130729","name":"万全县","nodes":null},{"id":null,"code":"130730","name":"怀来县",
"nodes":null},{"id":null,"code":"130731","name":"涿鹿县","nodes":null},{"id":null,"code":"130732","name":"赤城县","nodes":null},{"id":null,"code":"130733","name":"崇礼县","nodes":null}]},{"id":null,"code":"130800","name":"承德市",
"nodes":[{"id":null,"code":"130801","name":"市辖区","nodes":null},{"id":null,"code":"130802","name":"双桥区","nodes":null},{"id":null,"code":"130803","name":"双滦区","nodes":null},{"id":null,"code":"130804","name":"鹰手营子矿区",
"nodes":null},{"id":null,"code":"130821","name":"承德县","nodes":null},{"id":null,"code":"130822","name":"兴隆县","nodes":null},{"id":null,"code":"130823","name":"平泉县","nodes":null},{"id":null,"code":"130824","name":"滦平县",
"nodes":null},{"id":null,"code":"130825","name":"隆化县","nodes":null},{"id":null,"code":"130826","name":"丰宁满族自治县","nodes":null},{"id":null,"code":"130827","name":"宽城满族自治县","nodes":null},{"id":null,"code":"130828",
"name":"围场满族蒙古族自治县","nodes":null}]},{"id":null,"code":"130900","name":"沧州市","nodes":[{"id":null,"code":"130901","name":"市辖区","nodes":null},{"id":null,"code":"130902","name":"新华区","nodes":null},
{"id":null,"code":"130903","name":"运河区","nodes":null},{"id":null,"code":"130921","name":"沧县","nodes":null},{"id":null,"code":"130922","name":"青县","nodes":null},{"id":null,"code":"130923","name":"东光县","nodes":null},
{"id":null,"code":"130924","name":"海兴县","nodes":null},{"id":null,"code":"130925","name":"盐山县","nodes":null},{"id":null,"code":"130926","name":"肃宁县","nodes":null},{"id":null,"code":"130927","name":"南皮县","nodes":null},
{"id":null,"code":"130928","name":"吴桥县","nodes":null},{"id":null,"code":"130929","name":"献县","nodes":null},{"id":null,"code":"130930","name":"孟村回族自治县","nodes":null},{"id":null,"code":"130981","name":"泊头市","nodes":null},
{"id":null,"code":"130982","name":"任丘市","nodes":null},{"id":null,"code":"130983","name":"黄骅市","nodes":null},{"id":null,"code":"130984","name":"河间市","nodes":null}]},{"id":null,"code":"131000","name":"廊坊市",
"nodes":[{"id":null,"code":"131001","name":"市辖区","nodes":null},{"id":null,"code":"131002","name":"安次区","nodes":null},{"id":null,"code":"131003","name":"广阳区","nodes":null},{"id":null,"code":"131022","name":"固安县",
"nodes":null},{"id":null,"code":"131023","name":"永清县","nodes":null},{"id":null,"code":"131024","name":"香河县","nodes":null},{"id":null,"code":"131025","name":"大城县","nodes":null},{"id":null,"code":"131026","name":"文安县",
"nodes":null},{"id":null,"code":"131028","name":"大厂回族自治县","nodes":null},{"id":null,"code":"131081","name":"霸州市","nodes":null},{"id":null,"code":"131082","name":"三河市","nodes":null}]},{"id":null,"code":"131100",
"name":"衡水市","nodes":[{"id":null,"code":"131101","name":"市辖区","nodes":null},{"id":null,"code":"131102","name":"桃城区","nodes":null},{"id":null,"code":"131121","name":"枣强县","nodes":null},{"id":null,"code":"131122",
"name":"武邑县","nodes":null},{"id":null,"code":"131123","name":"武强县","nodes":null},{"id":null,"code":"131124","name":"饶阳县","nodes":null},{"id":null,"code":"131125","name":"安平县","nodes":null},{"id":null,"code":"131126",
"name":"故城县","nodes":null},{"id":null,"code":"131127","name":"景县","nodes":null},{"id":null,"code":"131128","name":"阜城县","nodes":null},{"id":null,"code":"131181","name":"冀州市","nodes":null},{"id":null,"code":"131182",
"name":"深州市","nodes":null}]}]}]}

  显示在页面

var togt=rock.initializeServices("tonsel-togt","../../togt-vehicle-manager/",["trafficInfo"]);
window.onload = function() { map = new AMap.Map('container', {
resizeEnable : true,
center : [116.397428, 39.90923], // 地图中心点
zoom : 13,
});
}
//获取树形菜单的数据
var service=togt.findService("trafficInfo");
service.addMethod("findTree","GET",true);
service.findTree({},function(jsonResult,status){
if (jsonResult.hasError)
{
alert(jsonResult.errorText);
}else if (jsonResult.notNull)
{
var tableDate = jsonResult.result;
selectMume(tableDate); }else
{
alert("数据查询失败!");
}
});
var cityCode,timer;
//以树形显示出来,包括模糊查询
function selectMume(tableDate){
var initSearchableTree = function() {
return $('#treeview-searchable').treeview({
data: tableDate,
nodeIcon: 'glyphicon glyphicon-globe',
emptyIcon: '', //没有子节点的节点图标
//collapsed: true,
onNodeSelected:function(event,data) {
cityCode=data.code;
if(timer){
//删除定时器
clearTimeout(timer);
}
if(cityCode!=null){
window.onload();
moveMap(cityCode);
showDrivingRecond();
//定义一个定时器
timer = window.setInterval(showDrivingRecond,10000);
} }
});
};
var $searchableTree = initSearchableTree();
$('#treeview-searchable').treeview('collapseAll', {
silent : false//设置初始化节点关闭
});
var findSearchableNodes = function() {
return $searchableTree.treeview('search', [ $.trim($('#input-search').val()), { ignoreCase: false, exactMatch: false } ]);
};
var searchableNodes = findSearchableNodes();
// Select/unselect/toggle nodes
$('#input-search').on('keyup', function (e) {
var str = $('#input-search').val();
if($.trim(str).length>0){
searchableNodes = findSearchableNodes();
} else {
$('#treeview-searchable').treeview('collapseAll', {
silent : false //设置初始化节点关闭
});
}
//$('.select-node').prop('disabled', !(searchableNodes.length >= 1));
});
var search = function(e) {
var pattern = $.trim($('#input-search').val());
var options = {
ignoreCase: $('#chk-ignore-case').is(':checked'),
exactMatch: $('#chk-exact-match').is(':checked'),
revealResults: $('#chk-reveal-results').is(':checked')
};
var results = $searchableTree.treeview('search', [ pattern, options ]);
var output = '<p>' + results.length + ' 匹配的搜索结果</p>';
$.each(results, function (index, result) {
output += '<p>- <span style="color:red;">' + result.name + '</span></p>';
});
$('#search-output').html(output);
}
$('#btn-search').on('click', search);
$('#input-search').on('keyup', search);
$('#btn-clear-search').on('click', function (e) {
$searchableTree.treeview('clearSearch');
$('#input-search').val('');
$('#search-output').html('');
$('#treeview-searchable').treeview('collapseAll', {
silent : false//设置初始化节点关闭
});
});
}
//根据所选的地区移动地图到指定区域
function moveMap(regionName){
//加载行政区划插件
AMap.service('AMap.DistrictSearch', function() {
var opts = {
subdistrict: 1, //返回下一级行政区
extensions: 'all', //返回行政区边界坐标组等具体信息
level: 'city' //查询行政级别为 市
};
//实例化DistrictSearch
district = new AMap.DistrictSearch(opts);
district.setLevel('district');
//行政区查询
district.search(regionName, function(status, result) {
var bounds = result.districtList[0].boundaries;
var polygons = [];
if (bounds) {
for (var i = 0, l = bounds.length; i < l; i++) {
//生成行政区划polygon
var polygon = new AMap.Polygon({
map: map,
strokeWeight: 1,
path: bounds[i],
fillOpacity: 0.3,
fillColor: '#CCF3FF',
strokeColor: '#000000', });
polygons.push(polygon);
}
map.setFitView();//地图自适应
}
});
});
}
var markerList=[];//定义一个点组
function showDrivingRecond(){
var service=togt.findService("trafficInfo");
service.addMethod("findDrivingRecond","GET",true);
service.findDrivingRecond({cityCode:cityCode},function(jsonResult,status){
if (jsonResult.hasError)
{
alert(jsonResult.errorText);
}else if (jsonResult.notNull)
{
var img;
img = "http://webapi.amap.com/theme/v1.3/markers/n/mark_r.png";
var listLonLat = jsonResult.result;
map.remove(markerList);//删除地图上的所有marker点,即markerList点组
$.each(listLonLat, function(index, value, array) {
addMarker(value.lon, value.lat, img);
});
}else
{
alert("数据查询失败!");
}
});
}
//加点
function addMarker(lng, lat, imgUrl) {
if (imgUrl == null) {
imgUrl = "http://webapi.amap.com/theme/v1.3/markers/n/mark_b.png";
} marker1 = new AMap.Marker({
icon : imgUrl,
position : [ lng, lat ]
});
marker1.setMap(map);
markerList.push(marker1);
return marker1;
}

  html

<div class="row">
<div class=" col-lg-3 col-md-3 col-sm-3" style="margin-top:30px;height:770px;overflow:auto">
<input type="input"class="form-control"id="input-search" placeholder="请输入要查询的节点信息">
<div class="col-lg-12 col-md-12 col-sm-12" style="margin-top:20px">
<div id="treeview-searchable" class=""></div>
</div>
<div class="col-lg-12 col-md-12 col-sm-12">
<div id="search-output" style="display: none"></div>
</div>
<!-- <div id="treeview3" class=""></div> -->
</div>
<div class=" col-lg-9 col-md-9 col-sm-9" style="height:770px">
<div class="row" >
<!-- 地图 -->
<div id="container"></div>
</div> </div>
</div>

  页面效果:

java把行政区划放到一个节点树形中的更多相关文章

  1. 4.产生10个1-100的随机数,并放到一个数组中 (1)把数组中大于等于10的数字放到一个list集合中,并打印到控制台。 (2)把数组中的数字放到当前文件夹的numArr.txt文件中

    package cn.it.text; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayLis ...

  2. 用Java实现将多级文件夹下的所有文件统一放到一个文件夹中

    每次下了电影(男生懂得呦),每部电影都放在一个单独的文件夹里,看的时候很是不方便啊,一直重复着进入文件夹.后退,再进.再退的操作,而手动把这些电影全部复制出来又太繁琐.因此为了解决这个问题,用IO写了 ...

  3. windows 批处理把所有java源码导入一个txt文件中

    首先在src下搜*.java,把搜到的文件全拷出来放在allsrc目录下, 然后在allsrc目录下建个run.bat,键入以下内容for %%i in (*.java)  do type %%i&g ...

  4. 多个.txt文件合并到一个.txt文件中

    如果想要将多个.txt文件合并到一个.txt文件中,可以先将所有.txt文件放到一个文件夹中,然后使用.bat文件完成任务. 例如,在一个文件夹下有1.txt, 2.txt, 3.txt三个文件,想把 ...

  5. MPMoviePlayerViewController的使用 (不直接将播放器放到主视图控制器,而是放到一个内部模态视图控制器中)

    其实MPMoviePlayerController如果不作为嵌入视频来播放(例如在新闻中嵌入一个视频),通常在播放时都是占满一个屏幕的,特别是在 iPhone.iTouch上.因此从iOS3.2以后苹 ...

  6. Linux 在 i 节点表中的磁盘地址表中,若一个文件的长度是从磁盘地址表的第 1 块到第 11 块 解析?

    面试题: 在 i 节点表中的磁盘地址表中,若一个文件的长度是从磁盘地址表的第 1 块到第 11块,则该文件共占有 B  块号.A 256 B 266 C 11 D 256×10 linux文件系统是L ...

  7. 软件工程结对开发——返回一个整数数组中最大子数组的和(JAVA)

    题目:返回一个整数数组中最大子数组的和. 要求: 输入一个整型数组,数组里有正数也有负数: 数组中连续的一个或多个整数组成一个子数组,每个子数组都有一个和: 求所有子数组的和的最大值.要求时间复杂度为 ...

  8. spring事务 将多个connection放到一个线程中

    spring事务 将多个connection放到一个线程中

  9. C# TreeView 拖拽节点到另一个容器Panel中简单实现

    C# TreeView 拖拽节点到另一个容器Panel中简单实现 用了这么久C#拖拽功能一直没有用到也就没用过,今天因为项目需要,领导特地给我简单讲解了下拖拽功能,真是的大师讲解一点通啊.特地写一篇博 ...

随机推荐

  1. ETL第二篇 调用webservice

    ETL第一篇(Kettle Spoon) 初遇 ETL第二篇 调用webservice 前言 这里使用ETL [Java代码] 实现 代码中使用axis调用webservice 在ETL提供了 Pro ...

  2. java 并发(七)--- ThreadLocal

         文章部分图片来自参考资料 问题 : ThreadLocal 底层原理 ThreadLocal 需要注意什么问题,造成问题的原因是什么,防护措施是什么 ThreadLocal 概述 Threa ...

  3. 1142 奖学金 sort做法

    个人博客:doubleq.win 1142 奖学金 2007年NOIP全国联赛普及组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 白银 Silver 题解       题目 ...

  4. 001Spring Boot中使用MongoDB

    01.下载MongoDB 点击标题链接,下载windows可用的MongoDB. 02.解压 将下载的压缩包放入C盘根目录(根据自己需要调整目录)---->解压到当前文件夹---->重命名 ...

  5. 一次线上bug引起的反思

    今天线上又出现了一个bug,而且代码是我写的.之前这个问题也出现过,不过由于每次情况都不同,改来改去总是改不完.之后领导知道后也很恼火,让测试把每种情况都测试了下,而我也又一次重新检查了下代码.当时确 ...

  6. cmd pyhton

    在cmd中运行python解释器: 1.同时执行多条指令,可在多条指令中间使用 & 连接 >>> print('123') &print('223') 123 223

  7. swift 数组部分排序

    数组自带排序函数,如果想实现部分排序,先对数组进行部分截取,然后对截取部分替换位排序好的子序列 var nums = [,,,,,,] var sub = nums[...] nums.replace ...

  8. December 13th 2016 Week 51st Tuesday

    Life is a sail trip full of chances and challenges. 人生的旅途中充满了机遇和挑战. A boat sails on the sea, the vas ...

  9. 在python中逐行读取大文件

    在我们日常工作中,难免会有处理日志文件的时候,当文件小的时候,基本不用当心什么,直接用file.read()或readlines()就可以了,但是如果是将一个10G大小的日志文件读取,即文件大于内存的 ...

  10. git操作:

    error: Your local changes to the following files would be overwritten by merge: **/**/**.php Please, ...