|
@@ -50,7 +50,7 @@ public class 松江地名地址库治理 {
|
|
|
executorService.shutdown();
|
|
|
}
|
|
|
|
|
|
- public void sjAddressZL(int threadSize, String path, String outPath, String addressParam){
|
|
|
+ public void sjAddressZL(int threadSize, String path, String outPath, String addressParam) {
|
|
|
|
|
|
List<Map<String, Object>> listAddr = null;
|
|
|
try {
|
|
@@ -73,90 +73,90 @@ public class 松江地名地址库治理 {
|
|
|
int size = (listAddr.size() / threadSize) + 1;
|
|
|
System.out.println("<<<<<<< " + size + " >>>>>>>>>");
|
|
|
// ExecutorService executor = Executors.newFixedThreadPool(size);
|
|
|
- for(int i = 0; i < size; i ++){
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
|
|
|
- List<Map<String, Object>> list = listAddr.subList(i * threadSize, (i+1)*threadSize > listAddr.size() ? listAddr.size(): (i+1)*threadSize);
|
|
|
+ List<Map<String, Object>> list = listAddr.subList(i * threadSize, (i + 1) * threadSize > listAddr.size() ? listAddr.size() : (i + 1) * threadSize);
|
|
|
|
|
|
// executor.execute(() ->{
|
|
|
|
|
|
int jj = 1;
|
|
|
- List<Map<String, Object>> result = new ArrayList<>();
|
|
|
- for (Map<String, Object> map : list) {
|
|
|
- String address = map.get(addressParam) + "";
|
|
|
-
|
|
|
- if(StringUtils.hasText(address)){
|
|
|
- String[] addr = AddressMatcher.matchProvinceAndCity(address);
|
|
|
- if (addr != null && !addr[0].contains("上海")) {// 外地数据,记录省、市
|
|
|
- map.put("provinces", addr[0]);
|
|
|
- map.put("market", addr[1]);
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>();
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ String address = map.get(addressParam) + "";
|
|
|
+
|
|
|
+ if (StringUtils.hasText(address)) {
|
|
|
+ String[] addr = AddressMatcher.matchProvinceAndCity(address);
|
|
|
+ if (addr != null && !addr[0].contains("上海")) {// 外地数据,记录省、市
|
|
|
+ map.put("provinces", addr[0]);
|
|
|
+ map.put("market", addr[1]);
|
|
|
+ map.put("distinguish", "");
|
|
|
+ map.put("streetTown", "");
|
|
|
+ map.put("residentialCommittee", "");
|
|
|
+
|
|
|
+ map.put("address", address);
|
|
|
+ map.put("standardAddress", address);
|
|
|
+ map.put("returnAddress", "");
|
|
|
+ map.put("matchLevel", "rule_0");
|
|
|
+ map.put("lon", "");
|
|
|
+ map.put("lat", "");
|
|
|
+ result.add(map);
|
|
|
+ } else {// 上海市数据
|
|
|
+ String strs[] = AddressTools.parseAddressJZ(address);
|
|
|
+ map.put("provinces", strs[0] == null ? "" : strs[0]);
|
|
|
+ map.put("market", strs[0] == null ? "" : strs[0]);
|
|
|
+ map.put("distinguish", strs[1] == null ? "" : strs[1]);
|
|
|
+ map.put("streetTown", strs[2] == null ? "" : strs[2]);
|
|
|
+ map.put("address", address);
|
|
|
+
|
|
|
+ if (!StringUtils.hasText(address)) {
|
|
|
+ map.put("provinces", "");
|
|
|
+ map.put("market", "");
|
|
|
map.put("distinguish", "");
|
|
|
map.put("streetTown", "");
|
|
|
map.put("residentialCommittee", "");
|
|
|
+ resultYc(map, address, result);
|
|
|
+ } else {
|
|
|
+ String addressN = strs[3] == null ? address : strs[3];
|
|
|
+ if (addressN.startsWith("中山") && !addressN.startsWith("中山街道")) {
|
|
|
+ addressN = addressN.replace("中山", "中山街道");
|
|
|
+ }
|
|
|
+ System.out.println("《《《 查询地址是: " + addressN + " 》》》");
|
|
|
+ System.out.println("<<<<<<< 当前条数是: " + jj + " 条 >>>>>>>>>");
|
|
|
|
|
|
- map.put("address", address);
|
|
|
- map.put("standardAddress", address);
|
|
|
- map.put("returnAddress", "");
|
|
|
- map.put("matchLevel", "rule_0");
|
|
|
- map.put("lon", "");
|
|
|
- map.put("lat", "");
|
|
|
- result.add(map);
|
|
|
- } else {// 上海市数据
|
|
|
- String strs[] = AddressTools.parseAddressJZ(address);
|
|
|
- map.put("provinces", strs[0] == null ? "" : strs[0]);
|
|
|
- map.put("market", strs[0] == null ? "" : strs[0]);
|
|
|
- map.put("distinguish", strs[1] == null ? "" : strs[1]);
|
|
|
- map.put("streetTown", strs[2] == null ? "" : strs[2]);
|
|
|
- map.put("address", address);
|
|
|
-
|
|
|
- if(!StringUtils.hasText(address)){
|
|
|
- map.put("provinces", "");
|
|
|
- map.put("market", "");
|
|
|
- map.put("distinguish", "");
|
|
|
- map.put("streetTown", "");
|
|
|
- map.put("residentialCommittee", "");
|
|
|
- resultYc(map, address, result);
|
|
|
- } else {
|
|
|
- String addressN = strs[3] == null ? address : strs[3];
|
|
|
- if(addressN.startsWith("中山") && !addressN.startsWith("中山街道")){
|
|
|
- addressN = addressN.replace("中山", "中山街道");
|
|
|
- }
|
|
|
- System.out.println("《《《 查询地址是: " + addressN + " 》》》");
|
|
|
- System.out.println("<<<<<<< 当前条数是: " + jj + " 条 >>>>>>>>>");
|
|
|
-
|
|
|
- AddressResult addressResult = AddressQueryEngine.getInstance().szxSearchByName(addressN);// 使用四中心接口
|
|
|
- if(addressResult == null || addressResult.getData() == null || addressResult.getData().size() < 1){
|
|
|
- addressResult = mutchNet(addressN);
|
|
|
- }
|
|
|
+ AddressResult addressResult = AddressQueryEngine.getInstance().szxSearchByName(addressN);// 使用四中心接口
|
|
|
+ if (addressResult == null || addressResult.getData() == null || addressResult.getData().size() < 1) {
|
|
|
+ addressResult = mutchNet(addressN);
|
|
|
+ }
|
|
|
|
|
|
- // 使用高德接口
|
|
|
- if(addressResult == null || addressResult.getData() == null || addressResult.getData().size() < 1){
|
|
|
- addressResult = AddressQueryEngine.getInstance().gdV3SearchByName(addressN);
|
|
|
- }
|
|
|
+ // 使用高德接口
|
|
|
+ if (addressResult == null || addressResult.getData() == null || addressResult.getData().size() < 1) {
|
|
|
+ addressResult = AddressQueryEngine.getInstance().gdV3SearchByName(addressN);
|
|
|
+ }
|
|
|
|
|
|
- if (addressResult != null) {
|
|
|
- addressResult.setCode(AddressResultEnum.SZX_SUCCESS);
|
|
|
- addressResult.setMessage("成功");
|
|
|
- addressResult = AddressQueryEngine.getInstance().getCjWgWgwByLoc(addressResult);
|
|
|
- if(addressResult.getData() != null && addressResult.getData().size() > 0 && addressResult.getData().get(0) != null){
|
|
|
- setResult(addressResult, map);
|
|
|
- result.add(map);
|
|
|
- } else {
|
|
|
- resultYc(map, address, result);
|
|
|
- }
|
|
|
+ if (addressResult != null) {
|
|
|
+ addressResult.setCode(AddressResultEnum.SZX_SUCCESS);
|
|
|
+ addressResult.setMessage("成功");
|
|
|
+ addressResult = AddressQueryEngine.getInstance().getCjWgWgwByLoc(addressResult);
|
|
|
+ if (addressResult.getData() != null && addressResult.getData().size() > 0 && addressResult.getData().get(0) != null) {
|
|
|
+ setResult(addressResult, map);
|
|
|
+ result.add(map);
|
|
|
} else {
|
|
|
resultYc(map, address, result);
|
|
|
}
|
|
|
+ } else {
|
|
|
+ resultYc(map, address, result);
|
|
|
}
|
|
|
}
|
|
|
- } else {
|
|
|
- map.put("provinces", "");
|
|
|
- map.put("market", "");
|
|
|
- map.put("distinguish", "");
|
|
|
- map.put("streetTown", "");
|
|
|
- map.put("residentialCommittee", "");
|
|
|
- resultYc(map, address, result);
|
|
|
}
|
|
|
- jj ++;
|
|
|
+ } else {
|
|
|
+ map.put("provinces", "");
|
|
|
+ map.put("market", "");
|
|
|
+ map.put("distinguish", "");
|
|
|
+ map.put("streetTown", "");
|
|
|
+ map.put("residentialCommittee", "");
|
|
|
+ resultYc(map, address, result);
|
|
|
+ }
|
|
|
+ jj++;
|
|
|
|
|
|
// if(result.size() % 10000 == 9999){
|
|
|
// System.out.println("<<<<<<< 写入数据,第" + num[0] + " 条 >>>>>>>>>");
|
|
@@ -171,17 +171,17 @@ public class 松江地名地址库治理 {
|
|
|
//
|
|
|
// }
|
|
|
|
|
|
- }
|
|
|
- System.out.println("<<<<<<< 写入数据,第" + num + " 条 >>>>>>>>>");
|
|
|
- try {
|
|
|
+ }
|
|
|
+ System.out.println("<<<<<<< 写入数据,第" + num + " 条 >>>>>>>>>");
|
|
|
+ try {
|
|
|
// ExcelReaderUtils.writeToExcel(result, outPath + "880w数据结果-" + num[0] + ".xlsx");
|
|
|
- ExcelReaderUtils.writeToExcel(result, outPath);
|
|
|
- num++;
|
|
|
- } catch (IOException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- } finally {
|
|
|
+ ExcelReaderUtils.writeToExcel(result, outPath);
|
|
|
+ num++;
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ } finally {
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
// });
|
|
|
|
|
@@ -190,16 +190,16 @@ public class 松江地名地址库治理 {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public AddressResult mutchNet(String addressN){
|
|
|
- for(int i = 0; i < 5; i ++){
|
|
|
+ public AddressResult mutchNet(String addressN) {
|
|
|
+ for (int i = 0; i < 5; i++) {
|
|
|
AddressResult addressResult = AddressQueryEngine.getInstance().szxSearchByName(addressN);
|
|
|
- if(addressResult != null)
|
|
|
+ if (addressResult != null)
|
|
|
return addressResult;
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public void resultYc(Map<String, Object> map, String address, List<Map<String, Object>> result){
|
|
|
+ public void resultYc(Map<String, Object> map, String address, List<Map<String, Object>> result) {
|
|
|
map.put("residentialCommittee", "");
|
|
|
map.put("standardAddress", "");
|
|
|
map.put("returnAddress", "");
|
|
@@ -209,7 +209,7 @@ public class 松江地名地址库治理 {
|
|
|
result.add(map);
|
|
|
}
|
|
|
|
|
|
- public void setResult(AddressResult addressResult, Map<String, Object> map){
|
|
|
+ public void setResult(AddressResult addressResult, Map<String, Object> map) {
|
|
|
if (addressResult == null || addressResult.getData() == null || addressResult.getData().size() < 1) {
|
|
|
map.put("matchLevel", "异常");
|
|
|
map.put("returnAddress", "未匹配到符合规则的结果");
|
|
@@ -241,7 +241,7 @@ public class 松江地名地址库治理 {
|
|
|
map.put("distinguish", "");
|
|
|
}
|
|
|
// 写入sh2000坐标系
|
|
|
- if(contentBean.getLat() != null && contentBean.getLon() != null){
|
|
|
+ if (contentBean.getLat() != null && contentBean.getLon() != null) {
|
|
|
// double[] coord = CoordTransform2.getInstance().wgs84_to_shcj(contentBean.getLon(), contentBean.getLat());
|
|
|
// map.put("lon", coord[0]);
|
|
|
// map.put("lat", coord[1]);
|
|
@@ -262,7 +262,7 @@ public class 松江地名地址库治理 {
|
|
|
String oldAddress = AddressTools.parseAddressJZ(contentBean.getSearchAddress())[3].
|
|
|
replaceAll(map.get("market") + "", "").replaceAll(map.get("distinguish") + "", "").
|
|
|
replaceAll(map.get("streetTown") + "", "").replaceAll(map.get("residentialCommittee") + "", "");
|
|
|
- map.put("standardAddress", "" + map.get("market") + map.get("distinguish") + map.get("streetTown") + AddressQueryEngine.townReplace_ct(oldAddress));
|
|
|
+ map.put("standardAddress", "" + map.get("market") + map.get("distinguish") + map.get("streetTown") + AddressQueryEngine.townReplace_ct(oldAddress));
|
|
|
break;
|
|
|
} else {
|
|
|
map.put("matchLevel", "异常");
|