|
@@ -1,21 +1,32 @@
|
|
|
package com.skyversation.poiaddr.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.skyversation.poiaddr.addquery.AddressQueryEngine;
|
|
|
import com.skyversation.poiaddr.bean.AddressResult;
|
|
|
+import com.skyversation.poiaddr.bean.GeoJsonBean;
|
|
|
+import com.skyversation.poiaddr.bean.SplitAddress;
|
|
|
import com.skyversation.poiaddr.config.DbConnection;
|
|
|
-import com.skyversation.poiaddr.entity.AmapAddressV3;
|
|
|
-import com.skyversation.poiaddr.entity.FusionKjdlTydzWf;
|
|
|
-import com.skyversation.poiaddr.entity.YyskAddressStandardization;
|
|
|
-import com.skyversation.poiaddr.entity.YyskDmdzAddressStandardization;
|
|
|
+import com.skyversation.poiaddr.entity.*;
|
|
|
import com.skyversation.poiaddr.service.AreaService;
|
|
|
import com.skyversation.poiaddr.util.*;
|
|
|
+import com.skyversation.poiaddr.util.lmrTools.initAddrMap;
|
|
|
import com.skyversation.poiaddr.util.tasks.ScheduledTasks;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.FileReader;
|
|
|
+import java.io.FileWriter;
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.sql.PreparedStatement;
|
|
|
import java.sql.SQLException;
|
|
|
import java.sql.Types;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
@@ -230,7 +241,329 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void readFileToPg(String fileRootPath, Integer startFileIndex, Integer endFileIndex, Integer sort) {
|
|
|
+ /**
|
|
|
+ * 需要迭代获取数据库中的数据
|
|
|
+ * 然后首先判断是否存在街镇数据,存在的话根据经纬度落点判断点位是否在这个镇里面
|
|
|
+ * 不存在街镇数据的话直接重新请求
|
|
|
+ * 最后把新的数据更新到数据库里面
|
|
|
+ *
|
|
|
+ * @param page 当前页码
|
|
|
+ * @param pageSize 每页数量
|
|
|
+ */
|
|
|
+ public void dataCleaning(Integer page, Integer pageSize) {
|
|
|
+ System.out.println("page:" + page + "pageSize:" + pageSize);
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ Page<AmapAddressV3> datas = AreaService.getInstance().getAmapDataByPage(page, pageSize);
|
|
|
+ List<AmapAddressV3> amapAddressV3List = datas.getContent();
|
|
|
+// 待重跑数据列表
|
|
|
+ List<YyskDmdzAddressStandardization> yyskDmdzAddressStandardizationArrayList = new ArrayList<>();
|
|
|
+// 查询地址和amapid的绑定关系
|
|
|
+ Map<String, String> addr_amapId = new HashMap<>();
|
|
|
+// 要更新的数据列表
|
|
|
+ List<AmapAddressV3> updateDatas = new ArrayList<>();
|
|
|
+ for (AmapAddressV3 amapAddressV3 : amapAddressV3List) {
|
|
|
+ boolean reRun = false;
|
|
|
+ if (amapAddressV3.getStreetTown() == null || amapAddressV3.getStreetTown().isEmpty() || amapAddressV3.getStreetTown().contains("[]")) {
|
|
|
+// 街镇异常,直接重跑
|
|
|
+ reRun = true;
|
|
|
+ } else if (amapAddressV3.getStreetTown() != null && !amapAddressV3.getStreetTown().isEmpty() && !amapAddressV3.getStreetTown().contains("[]")) {
|
|
|
+// 传入街镇和经纬度判断是否属于这个镇(有三种情况:经纬度为空,直接重跑;经纬度为wgs84,如果在所属镇的话转换一下坐标直接update;经纬度为gd,不在所属镇,重跑)
|
|
|
+ if (amapAddressV3.getLat() == null || amapAddressV3.getLon() == null || amapAddressV3.getLat().isEmpty() || amapAddressV3.getLon().isEmpty()) {
|
|
|
+ reRun = true;
|
|
|
+ } else {
|
|
|
+ String town = amapAddressV3.getStreetTown();
|
|
|
+ double[] wgs84lonlat = CoordTransform2.getInstance().shcj_to_wgs84(Double.parseDouble(amapAddressV3.getLon()), Double.parseDouble(amapAddressV3.getLat()));
|
|
|
+ GeoJsonBean townBean = AreaService.getInstance().isInTownPolygon(wgs84lonlat[0], wgs84lonlat[1]);
|
|
|
+ if (townBean == null || !townBean.getProperties().getString("name").contains(town)) {
|
|
|
+ reRun = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (reRun) {
|
|
|
+ YyskDmdzAddressStandardization yyskDmdzAddressStandardization = new YyskDmdzAddressStandardization();
|
|
|
+ yyskDmdzAddressStandardization.setAddress(amapAddressV3.getAddress());
|
|
|
+ addr_amapId.put(amapAddressV3.getAddress(), amapAddressV3.getId());
|
|
|
+ yyskDmdzAddressStandardizationArrayList.add(yyskDmdzAddressStandardization);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<YyskDmdzAddressStandardization> resultDataList = runExecutorService(yyskDmdzAddressStandardizationArrayList);
|
|
|
+
|
|
|
+ for (YyskDmdzAddressStandardization yyskDmdzAddressStandardization : resultDataList) {
|
|
|
+ if (!yyskDmdzAddressStandardization.getMatchLevel().contains("异常") && yyskDmdzAddressStandardization.getLat() != null && yyskDmdzAddressStandardization.getLon() != null) {
|
|
|
+ AmapAddressV3 amapAddressV3 = new AmapAddressV3();
|
|
|
+ amapAddressV3.setId(addr_amapId.get(yyskDmdzAddressStandardization.getAddress()));
|
|
|
+ amapAddressV3.setType("数据清洗");
|
|
|
+ amapAddressV3.setAddress(yyskDmdzAddressStandardization.getAddress());
|
|
|
+ double[] gdLonLat = CoordTransform2.getInstance().wgs84_to_shcj(Double.parseDouble(yyskDmdzAddressStandardization.getLon()), Double.parseDouble(yyskDmdzAddressStandardization.getLat()));
|
|
|
+ amapAddressV3.setLon(String.valueOf(gdLonLat[0]));
|
|
|
+ amapAddressV3.setLat(String.valueOf(gdLonLat[1]));
|
|
|
+ amapAddressV3.setLocation(yyskDmdzAddressStandardization.getLon() + "," + yyskDmdzAddressStandardization.getLat());
|
|
|
+ amapAddressV3.setPname(yyskDmdzAddressStandardization.getProvinces());
|
|
|
+ amapAddressV3.setCityname(yyskDmdzAddressStandardization.getMarket());
|
|
|
+ amapAddressV3.setAdname(yyskDmdzAddressStandardization.getDistinguish());
|
|
|
+ amapAddressV3.setStreetTown(yyskDmdzAddressStandardization.getStreetTown());
|
|
|
+ amapAddressV3.setResidentialCommittee(yyskDmdzAddressStandardization.getResidentialCommittee());
|
|
|
+ updateDatas.add(amapAddressV3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("要处理的数据条数:" + updateDatas.size());
|
|
|
+ if (updateDatas.size() > 0) {
|
|
|
+ AreaService.getInstance().saveAmapAddressV3(updateDatas);
|
|
|
+ }
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ System.out.println("单批数据处理完成,用时:" + (endTime - startTime) / 1000 + "秒!");
|
|
|
+ if (datas.getTotalPages() > page) {
|
|
|
+ page++;
|
|
|
+ dataCleaning(page, pageSize);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 需要迭代获取数据库中的数据
|
|
|
+ * 然后首先判断是否存在街镇数据,存在的话根据经纬度落点判断点位是否在这个镇里面
|
|
|
+ * 不存在街镇数据的话直接重新请求
|
|
|
+ * 最后把新的数据更新到数据库里面
|
|
|
+ *
|
|
|
+ * @param page 当前页码
|
|
|
+ * @param pageSize 每页数量
|
|
|
+ */
|
|
|
+ public void amapV3ToQp(Integer page, Integer pageSize) {
|
|
|
+ System.out.println("page:" + page + "pageSize:" + pageSize);
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ Page<AmapAddressV3> datas = AreaService.getInstance().getAmapDataByPage(page, pageSize);
|
|
|
+ List<AmapAddressV3> amapAddressV3List = datas.getContent();
|
|
|
+// 要更新的数据列表
|
|
|
+ List<YyszAddressQp> updateDatas = new ArrayList<>();
|
|
|
+ for (AmapAddressV3 amapAddressV3 : amapAddressV3List) {
|
|
|
+ try {
|
|
|
+ if (amapAddressV3.getLon() != null && amapAddressV3.getLat() != null) {
|
|
|
+ YyszAddressQp yyszAddressQp = new YyszAddressQp();
|
|
|
+ yyszAddressQp.setOid(ScheduledTasks.OID_TAG);
|
|
|
+ ScheduledTasks.OID_TAG++;
|
|
|
+ yyszAddressQp.setSourceaddress(amapAddressV3.getAddress());
|
|
|
+ yyszAddressQp.setCity(amapAddressV3.getCityname());
|
|
|
+ yyszAddressQp.setCounty(amapAddressV3.getAdname());
|
|
|
+ yyszAddressQp.setTown(amapAddressV3.getStreetTown());
|
|
|
+ yyszAddressQp.setCommunity(amapAddressV3.getResidentialCommittee());
|
|
|
+ String sh2000Lon = amapAddressV3.getLon();
|
|
|
+ String sh2000Lat = amapAddressV3.getLat();
|
|
|
+ double[] points = CoordTransform2.getInstance().shcj_to_wgs84(
|
|
|
+ Double.parseDouble(sh2000Lon), Double.parseDouble(sh2000Lat));
|
|
|
+// wgs84
|
|
|
+ yyszAddressQp.setLon(BigDecimal.valueOf(points[0]));
|
|
|
+ yyszAddressQp.setLat(BigDecimal.valueOf(points[1]));
|
|
|
+ yyszAddressQp.setCreatetime(new Date());
|
|
|
+ yyszAddressQp.setX(amapAddressV3.getLon());
|
|
|
+ yyszAddressQp.setY(amapAddressV3.getLat());
|
|
|
+ yyszAddressQp.setMatchLevel("amap");
|
|
|
+ updateDatas.add(yyszAddressQp);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("要处理的数据条数:" + updateDatas.size());
|
|
|
+ if (updateDatas.size() > 0) {
|
|
|
+ AreaService.getInstance().saveYyszAddressQp(updateDatas);
|
|
|
+ }
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ System.out.println("单批数据处理完成,用时:" + (endTime - startTime) / 1000 + "秒!");
|
|
|
+ updateDatas.clear();
|
|
|
+ if (datas.getTotalPages() > page) {
|
|
|
+ page++;
|
|
|
+ amapV3ToQp(page, pageSize);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ try {
|
|
|
+ JSONObject fileDatas = parseJsonFile("C:\\Users\\Liumouren\\Desktop\\香花桥农业、资产一张图实-中间数据2.geojson");
|
|
|
+ JSONArray features = fileDatas.getJSONArray("features");
|
|
|
+ for (int i = 0; i < features.size(); i++) {
|
|
|
+ JSONObject item = features.getJSONObject(i);
|
|
|
+ JSONObject properties = item.getJSONObject("properties");
|
|
|
+ if (properties.getString("合同到期日期").contains("CST")) {
|
|
|
+ properties.put("合同到期日期", convertToChineseDate(properties.getString("合同到期日期")));
|
|
|
+ }
|
|
|
+ if (properties.getString("合同签订日期").contains("CST")) {
|
|
|
+ properties.put("合同签订日期", convertToChineseDate(properties.getString("合同签订日期")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("完成!");
|
|
|
+ saveJsonToFile(fileDatas, "C:\\Users\\Liumouren\\Desktop\\香花桥农业、资产一张图实-中间数据3.geojson");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 保存JSONObject到文件
|
|
|
+ public static void saveJsonToFile(JSONObject jsonObject, String filePath) throws IOException {
|
|
|
+ try (FileWriter file = new FileWriter(filePath)) {
|
|
|
+ file.write(jsonObject.toString()); // 使用缩进2空格格式化JSON
|
|
|
+ file.flush();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject parseJsonFile(String filePath) throws IOException {
|
|
|
+ StringBuilder contentBuilder = new StringBuilder();
|
|
|
+ try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
|
|
|
+ String line;
|
|
|
+ while ((line = reader.readLine()) != null) {
|
|
|
+ contentBuilder.append(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return JSONObject.parseObject(contentBuilder.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ public void saveFiles(String fileRootPath) {
|
|
|
+ try {
|
|
|
+/*// 读取经纬度文件
|
|
|
+ List<Map<String, Object>> fileData = ExcelReaderUtils.readExcel(fileRootPath + "经纬度文件.xlsx");
|
|
|
+// 地址和信息的对应关系
|
|
|
+ Map<String, Map<String, Object>> lonLatDatas = new HashMap<>();
|
|
|
+ for (Map<String, Object> fileDataItem : fileData) {
|
|
|
+ if (fileDataItem.get("streetTown") != null && fileDataItem.get("streetTown").toString().contains("香花桥")) {
|
|
|
+ lonLatDatas.put(fileDataItem.get("address").toString(), fileDataItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+// 读取合作社和村居文件
|
|
|
+ List<Map<String, Object>> fileData2 = ExcelReaderUtils.readExcel(fileRootPath + "合作社与村居对应关系.xlsx");
|
|
|
+ // 合作社和村居的对应关系
|
|
|
+ Map<String, String> hezuoshe_cunju = new HashMap<>();
|
|
|
+ for (Map<String, Object> fileDataItem : fileData2) {
|
|
|
+ hezuoshe_cunju.put(fileDataItem.get("合作社名称").toString(), fileDataItem.get("村居名称").toString());
|
|
|
+ }*/
|
|
|
+// 读取原始文件(有返回地址的替换掉,没有返回地址的保留)
|
|
|
+ List<Map<String, Object>> outDatas = ExcelReaderUtils.readExcel(fileRootPath + "香花桥农业、资产一张图实-中间数据3.xlsx");
|
|
|
+ for (Map<String, Object> item : outDatas) {
|
|
|
+ if (item != null) {
|
|
|
+ if (item.containsKey("合同到期日期") && item.get("合同到期日期") != null && !item.get("合同到期日期").toString().isEmpty() && item.get("合同到期日期").toString().contains("CST")) {
|
|
|
+ item.put("合同到期日期", convertToChineseDate(item.get("合同到期日期").toString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.containsKey("合同签订日期") && item.get("合同签订日期") != null && !item.get("合同签订日期").toString().isEmpty() && item.get("合同签订日期").toString().contains("CST")) {
|
|
|
+ item.put("合同签订日期", convertToChineseDate(item.get("合同签订日期").toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*if (listData.size() > 0) {
|
|
|
+// 批量更新处理后的数据
|
|
|
+ List<YyskDmdzAddressStandardization> resultDataList = runExecutorService(listData);
|
|
|
+ Map<String, YyskDmdzAddressStandardization> resltItems = new HashMap<>();
|
|
|
+ for (YyskDmdzAddressStandardization item : resultDataList) {
|
|
|
+ resltItems.put(item.getAddress(), item);
|
|
|
+ }
|
|
|
+ for (Map<String, Object> item : outDatas) {
|
|
|
+ if (item != null && item.containsKey("资产地址") && item.get("资产地址") != null && !item.get("资产地址").toString().isEmpty()) {
|
|
|
+ String addr = "上海市青浦区香花桥街道" + item.get("资产地址").toString();
|
|
|
+ if (resltItems.containsKey(addr) && resltItems.get(addr).getStreetTown() != null && resltItems.get(addr).getStreetTown().contains("香花桥")) {
|
|
|
+ String lon = resltItems.containsKey(addr) ? resltItems.get(addr).getLon() : "";
|
|
|
+ String lat = resltItems.containsKey(addr) ? resltItems.get(addr).getLat() : "";
|
|
|
+ String returnAddress = resltItems.containsKey(addr) ? resltItems.get(addr).getReturnAddress() : "";
|
|
|
+ String residentialCommittee = resltItems.containsKey(addr) ? resltItems.get(addr).getResidentialCommittee() : "";
|
|
|
+ item.put("经度", lon);
|
|
|
+ item.put("纬度", lat);
|
|
|
+ item.put("返回地址", returnAddress);
|
|
|
+ item.put("返回村居", residentialCommittee);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+// 输出
|
|
|
+ ExcelReaderUtils.writeToExcel(outDatas, fileRootPath + "输出文件2.xlsx");
|
|
|
+ System.out.println("处理完成");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String convertToChineseDate(String inputDate) {
|
|
|
+ try {
|
|
|
+ // 解析原始日期字符串
|
|
|
+ SimpleDateFormat inputFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
|
|
|
+ Date date = inputFormat.parse(inputDate);
|
|
|
+
|
|
|
+ // 转换为中文日期格式
|
|
|
+ SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy年MM月dd日", Locale.CHINA);
|
|
|
+ return outputFormat.format(date);
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("日期解析错误: " + e.getMessage());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<YyskAddressStandardization> AmapAddressV3_to_YyskAddressStandardization(List<AmapAddressV3> datas) {
|
|
|
+ List<YyskAddressStandardization> yyskAddressStandardizations = new ArrayList<>();
|
|
|
+ for (AmapAddressV3 amapAddressV3 : datas) {
|
|
|
+ YyskAddressStandardization item = new YyskAddressStandardization();
|
|
|
+ item.setAddress(amapAddressV3.getAddress());
|
|
|
+ item.setDataTag(amapAddressV3.getType());
|
|
|
+ item.setMarket(amapAddressV3.getCityname());
|
|
|
+ item.setDistinguish(amapAddressV3.getAdname());
|
|
|
+ item.setResidentialCommittee(amapAddressV3.getResidentialCommittee());
|
|
|
+ item.setLon(amapAddressV3.getLon());
|
|
|
+ item.setLat(amapAddressV3.getLat());
|
|
|
+ item.setStreetTown(amapAddressV3.getStreetTown());
|
|
|
+ item.setProvinces(amapAddressV3.getPname());
|
|
|
+ yyskAddressStandardizations.add(item);
|
|
|
+ }
|
|
|
+ return yyskAddressStandardizations;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void readFileToPg2(String fileRootPath, Integer pageSize) {
|
|
|
+ try {
|
|
|
+ List<Map<String, Object>> fileData = ExcelReaderUtils.readExcel(fileRootPath);
|
|
|
+ JSONObject dataList = new JSONObject();
|
|
|
+// 操作类型 1:新增,2:更新3:删除
|
|
|
+ dataList.put("optFlag", 1);
|
|
|
+ JSONArray datas = new JSONArray();
|
|
|
+ // 定义输入格式并解析字符串
|
|
|
+ DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
+ for (int i = 0; i < fileData.size(); i++) {
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ Map<String, Object> item = fileData.get(i);
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ for (String key : item.keySet()) {
|
|
|
+ if (key.equals("dsjzx_taskid")) {
|
|
|
+ LocalDate date = LocalDate.parse(item.get(key).toString(), inputFormatter);
|
|
|
+ // 转换为 LocalDateTime(默认时间为 00:00:00)
|
|
|
+ LocalDateTime dateTime = date.atStartOfDay();
|
|
|
+ // 定义输出格式并格式化日期时间
|
|
|
+ DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
|
|
|
+ String output = dateTime.format(outputFormatter);
|
|
|
+ data.put(key, output);
|
|
|
+ } else {
|
|
|
+ data.put(key, item.get(key));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ datas.add(data);
|
|
|
+ if (i != 0 && (i % (pageSize - 1) == 0 || i == datas.size() - 1)) {
|
|
|
+ dataList.put("data", datas);
|
|
|
+ try {
|
|
|
+ System.out.println(AddressQueryEngine.getInstance().putDataToSJ_Big_Data2(dataList));
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ System.out.println("处理单批次用时" + (endTime - startTime) / 1000 + "秒!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ datas.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getCurrentDateTime() {
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
+ return now.format(formatter);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void readFileToPg(String fileRootPath, Integer startFileIndex, Integer endFileIndex, Integer sort, Integer pageSize) {
|
|
|
System.out.println("<<<<<<<<------readFileToPg{fileIndex:" + startFileIndex + "}");
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
List<YyskAddressStandardization> listData = new ArrayList<>();
|
|
@@ -240,19 +573,19 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
YyskAddressStandardization yyskAddressStandardization = new YyskAddressStandardization();
|
|
|
String matchLevel = item.get("matchLevel").toString();
|
|
|
if (matchLevel != null && !matchLevel.isEmpty() && !"异常".equals(matchLevel) && !"rule_0".equals(matchLevel) && item.get("lat") != null && item.get("lon") != null) {
|
|
|
- if ("rule_2".equals(matchLevel) || "rule_3".equals(matchLevel) || "rule_4".equals(matchLevel) || Float.parseFloat(matchLevel) > 1.8) {
|
|
|
- yyskAddressStandardization.setAddress(item.get("address").toString());
|
|
|
- yyskAddressStandardization.setReturnAddress(item.get("returnAddress").toString());
|
|
|
- yyskAddressStandardization.setStandardAddress(item.get("standardAddress").toString());
|
|
|
- yyskAddressStandardization.setProvinces(item.get("provinces").toString());
|
|
|
- yyskAddressStandardization.setMarket(item.get("market").toString());
|
|
|
- yyskAddressStandardization.setDistinguish(item.get("distinguish").toString());
|
|
|
- yyskAddressStandardization.setStreetTown(item.get("streetTown").toString());
|
|
|
- yyskAddressStandardization.setResidentialCommittee(item.get("residentialCommittee").toString());
|
|
|
- yyskAddressStandardization.setLon(item.get("lat").toString());
|
|
|
- yyskAddressStandardization.setLat(item.get("lon").toString());
|
|
|
- listData.add(yyskAddressStandardization);
|
|
|
- }
|
|
|
+ yyskAddressStandardization.setAddress(item.get("address").toString());
|
|
|
+ yyskAddressStandardization.setReturnAddress(item.get("returnAddress").toString());
|
|
|
+ yyskAddressStandardization.setStandardAddress(item.get("standardAddress").toString());
|
|
|
+ yyskAddressStandardization.setProvinces(item.get("provinces").toString());
|
|
|
+ yyskAddressStandardization.setMarket(item.get("market").toString());
|
|
|
+ yyskAddressStandardization.setDistinguish(item.get("distinguish").toString());
|
|
|
+ yyskAddressStandardization.setStreetTown(item.get("streetTown").toString());
|
|
|
+ yyskAddressStandardization.setMatchLevel(matchLevel);
|
|
|
+ yyskAddressStandardization.setResidentialCommittee(item.get("residentialCommittee").toString());
|
|
|
+ yyskAddressStandardization.setLon(item.get("lat").toString());
|
|
|
+ yyskAddressStandardization.setLat(item.get("lon").toString());
|
|
|
+ yyskAddressStandardization.setDataTag(item.get("dataTag").toString());
|
|
|
+ listData.add(yyskAddressStandardization);
|
|
|
}
|
|
|
}
|
|
|
fileData.clear();
|
|
@@ -260,49 +593,109 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
listData = null;
|
|
|
}
|
|
|
if (listData != null && listData.size() > 0) {
|
|
|
- List<AmapAddressV3> amapAddressV3List = new ArrayList<>();
|
|
|
- for (YyskAddressStandardization yyskAddressStandardization : listData) {
|
|
|
- AmapAddressV3 amapAddressV3 = new AmapAddressV3();
|
|
|
- amapAddressV3.setId(UUID.randomUUID().toString());
|
|
|
- amapAddressV3.setAddress(yyskAddressStandardization.getReturnAddress());
|
|
|
- amapAddressV3.setLon(yyskAddressStandardization.getLon());
|
|
|
- amapAddressV3.setLat(yyskAddressStandardization.getLat());
|
|
|
- amapAddressV3.setPname(yyskAddressStandardization.getProvinces());
|
|
|
- amapAddressV3.setCityname(yyskAddressStandardization.getMarket());
|
|
|
- amapAddressV3.setAdname(yyskAddressStandardization.getDistinguish());
|
|
|
- amapAddressV3.setStreetTown(yyskAddressStandardization.getStreetTown());
|
|
|
- amapAddressV3.setResidentialCommittee(yyskAddressStandardization.getResidentialCommittee());
|
|
|
-// 上海2000转高德
|
|
|
- double[] gcjLocation = Coordinate.shcj_to_gcj02(Double.parseDouble(yyskAddressStandardization.getLon()), Double.parseDouble(yyskAddressStandardization.getLat()));
|
|
|
- amapAddressV3.setLocation(gcjLocation[0] + "," + gcjLocation[1]);
|
|
|
- amapAddressV3.setCreateTime(new Date());
|
|
|
- amapAddressV3List.add(amapAddressV3);
|
|
|
-
|
|
|
- AmapAddressV3 amapAddressV32 = new AmapAddressV3();
|
|
|
- amapAddressV32.setId(UUID.randomUUID().toString());
|
|
|
- amapAddressV32.setAddress(yyskAddressStandardization.getStandardAddress());
|
|
|
- amapAddressV32.setLon(amapAddressV3.getLon());
|
|
|
- amapAddressV32.setLat(amapAddressV3.getLat());
|
|
|
- amapAddressV32.setPname(amapAddressV3.getPname());
|
|
|
- amapAddressV32.setCityname(amapAddressV3.getCityname());
|
|
|
- amapAddressV32.setAdname(amapAddressV3.getAdname());
|
|
|
- amapAddressV32.setStreetTown(amapAddressV3.getStreetTown());
|
|
|
- amapAddressV32.setResidentialCommittee(amapAddressV3.getResidentialCommittee());
|
|
|
- amapAddressV32.setLocation(amapAddressV3.getLocation());
|
|
|
- amapAddressV32.setCreateTime(new Date());
|
|
|
- amapAddressV3List.add(amapAddressV32);
|
|
|
+ JSONObject dataList = new JSONObject();
|
|
|
+// 操作类型 1:新增,2:更新3:删除
|
|
|
+ dataList.put("optFlag", 1);
|
|
|
+ JSONArray datas = new JSONArray();
|
|
|
+ for (int i = 0; i < listData.size(); i++) {
|
|
|
+ YyskAddressStandardization yyskAddressStandardization = listData.get(i);
|
|
|
+ JSONObject dataItem = new JSONObject();
|
|
|
+ dataItem.put("oid", ScheduledTasks.OID_TAG);
|
|
|
+ ScheduledTasks.OID_TAG++;
|
|
|
+ dataItem.put("address", yyskAddressStandardization.getAddress());
|
|
|
+ dataItem.put("sourceaddress", yyskAddressStandardization.getStandardAddress());
|
|
|
+ dataItem.put("city", yyskAddressStandardization.getMarket());
|
|
|
+ dataItem.put("county", yyskAddressStandardization.getDistinguish());
|
|
|
+ dataItem.put("town", yyskAddressStandardization.getStreetTown());
|
|
|
+ dataItem.put("community", yyskAddressStandardization.getResidentialCommittee());
|
|
|
+ dataItem.put("lon", yyskAddressStandardization.getLon());
|
|
|
+ dataItem.put("lat", yyskAddressStandardization.getLat());
|
|
|
+ dataItem.put("address_type", yyskAddressStandardization.getDataTag());
|
|
|
+ dataItem.put("createtime", getCurrentDateTime());
|
|
|
+ dataItem.put("updatetime", getCurrentDateTime());
|
|
|
+ dataItem.put("match_level", yyskAddressStandardization.getMatchLevel());
|
|
|
+ datas.add(dataItem);
|
|
|
+ /*if (i != 0 && (i % (pageSize - 1) == 0 || i == listData.size() - 1)) {
|
|
|
+ dataList.put("data", datas);
|
|
|
+ try {
|
|
|
+// System.out.println(AddressQueryEngine.getInstance().putDataToSJ_Big_Data(dataList));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ datas.clear();
|
|
|
+ }*/
|
|
|
}
|
|
|
- // 写入到数据库中
|
|
|
- AreaService.getInstance().saveAmapAddressV3(amapAddressV3List);
|
|
|
+ dataList.put("data", datas);
|
|
|
+ try {
|
|
|
+ System.out.println(AddressQueryEngine.getInstance().putDataToSJ_Big_Data(dataList));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ datas.clear();
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
+ dataList.clear();
|
|
|
System.out.println("处理单批次用时" + (endTime - startTime) / 1000 + "秒!");
|
|
|
- amapAddressV3List.clear();
|
|
|
} else {
|
|
|
System.out.println("该文件无有效数据!");
|
|
|
}
|
|
|
if (startFileIndex + sort != endFileIndex) {
|
|
|
startFileIndex += sort;
|
|
|
- readFileToPg(fileRootPath, startFileIndex, endFileIndex, sort);
|
|
|
+ readFileToPg(fileRootPath, startFileIndex, endFileIndex, sort, pageSize);
|
|
|
+ } else {
|
|
|
+ System.out.println("<<<<<<<<------任务处理完成!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void searchLoadFileData2(String fileRootPath, Integer startFileIndex, Integer endFileIndex, Integer sort) {
|
|
|
+ System.out.println("<<<<<<<<------readFileToPg{fileIndex:" + startFileIndex + "}");
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+// 要更新的数据列表
|
|
|
+ List<YyszAddressQp> updateDatas = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ List<Map<String, Object>> fileData = ExcelReaderUtils.readExcel(fileRootPath + startFileIndex + ".xlsx");
|
|
|
+ for (Map<String, Object> item : fileData) {
|
|
|
+ String matchLevel = item.get("matchLevel").toString();
|
|
|
+ if (matchLevel != null && !matchLevel.isEmpty() && !"异常".equals(matchLevel) && !"rule_0".equals(matchLevel) && item.get("lat") != null && item.get("lon") != null) {
|
|
|
+ try {
|
|
|
+ YyszAddressQp yyszAddressQp = new YyszAddressQp();
|
|
|
+ yyszAddressQp.setOid(ScheduledTasks.OID_TAG);
|
|
|
+ ScheduledTasks.OID_TAG++;
|
|
|
+ yyszAddressQp.setSourceaddress(item.get("standardAddress").toString());
|
|
|
+ yyszAddressQp.setCity(item.get("market").toString());
|
|
|
+ yyszAddressQp.setCounty(item.get("distinguish").toString());
|
|
|
+ yyszAddressQp.setTown(item.get("streetTown").toString());
|
|
|
+ yyszAddressQp.setCommunity(item.get("residentialCommittee").toString());
|
|
|
+ String sh2000Lon = item.get("lat").toString();
|
|
|
+ String sh2000Lat = item.get("lon").toString();
|
|
|
+ double[] points = CoordTransform2.getInstance().shcj_to_wgs84(
|
|
|
+ Double.parseDouble(sh2000Lon), Double.parseDouble(sh2000Lat));
|
|
|
+// wgs84
|
|
|
+ yyszAddressQp.setLon(BigDecimal.valueOf(points[0]));
|
|
|
+ yyszAddressQp.setLat(BigDecimal.valueOf(points[1]));
|
|
|
+ yyszAddressQp.setCreatetime(new Date());
|
|
|
+ yyszAddressQp.setX(sh2000Lon);
|
|
|
+ yyszAddressQp.setY(sh2000Lat);
|
|
|
+ yyszAddressQp.setMatchLevel(matchLevel);
|
|
|
+ updateDatas.add(yyszAddressQp);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ fileData.clear();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (updateDatas.size() > 0) {
|
|
|
+ AreaService.getInstance().saveYyszAddressQp(updateDatas);
|
|
|
+ }
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ System.out.println("单批数据处理完成,用时:" + (endTime - startTime) / 1000 + "秒!");
|
|
|
+ updateDatas.clear();
|
|
|
+ if (startFileIndex + sort != endFileIndex) {
|
|
|
+ startFileIndex += sort;
|
|
|
+ searchLoadFileData2(fileRootPath, startFileIndex, endFileIndex, sort);
|
|
|
} else {
|
|
|
System.out.println("<<<<<<<<------任务处理完成!");
|
|
|
}
|
|
@@ -316,8 +709,8 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
int taskId = sort * i + startFileIndex;
|
|
|
// 任务执行
|
|
|
- startMutilExecutor(taskId, fileRootPath + "output8\\yysk_dmdz_address_standardization_200000_" + taskId + ".xlsx",
|
|
|
- fileRootPath + "output9\\yysk_dmdz_address_standardization_200000_" + taskId + ".xlsx");
|
|
|
+ startMutilExecutor(taskId, fileRootPath + "output1\\yysk_dmdz_address_standardization_200000_" + taskId + ".xlsx",
|
|
|
+ fileRootPath + "output2\\yysk_dmdz_address_standardization_200000_" + taskId + ".xlsx");
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
ScheduledTasks.taskRunStatus = false;
|
|
|
System.out.println("单个文件处理完成!用时" + (endTime - startTime) / 1000 + "秒!");
|
|
@@ -331,22 +724,27 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
try {
|
|
|
List<Map<String, Object>> fileData = ExcelReaderUtils.readExcel(filePath);
|
|
|
for (Map<String, Object> item : fileData) {
|
|
|
- YyskDmdzAddressStandardization yyskAddressStandardization = new YyskDmdzAddressStandardization();
|
|
|
- yyskAddressStandardization.setAddress(item.getOrDefault("address", "").toString());
|
|
|
- yyskAddressStandardization.setDataTag(item.getOrDefault("dataTag", "").toString());
|
|
|
- yyskAddressStandardization.setMatchLevel(item.getOrDefault("matchLevel", "").toString());
|
|
|
- yyskAddressStandardization.setReturnAddress(item.getOrDefault("returnAddress", "").toString());
|
|
|
- yyskAddressStandardization.setStandardAddress(item.getOrDefault("standardAddress", "").toString());
|
|
|
- yyskAddressStandardization.setProvinces(item.getOrDefault("provinces", "").toString());
|
|
|
- yyskAddressStandardization.setMarket(item.getOrDefault("market", "").toString());
|
|
|
- yyskAddressStandardization.setDistinguish(item.getOrDefault("distinguish", "").toString());
|
|
|
- yyskAddressStandardization.setStreetTown(item.getOrDefault("streetTown", "").toString());
|
|
|
- yyskAddressStandardization.setResidentialCommittee(item.getOrDefault("residentialCommittee", "").toString());
|
|
|
- yyskAddressStandardization.setLon(item.getOrDefault("lat", "").toString());
|
|
|
- yyskAddressStandardization.setLat(item.getOrDefault("lon", "").toString());
|
|
|
- listData.add(yyskAddressStandardization);
|
|
|
+ try {
|
|
|
+ YyskDmdzAddressStandardization yyskAddressStandardization = new YyskDmdzAddressStandardization();
|
|
|
+ yyskAddressStandardization.setAddress(item.getOrDefault("address", "").toString());
|
|
|
+ yyskAddressStandardization.setDataTag(item.getOrDefault("dataTag", "").toString());
|
|
|
+ yyskAddressStandardization.setMatchLevel(item.getOrDefault("matchLevel", "").toString());
|
|
|
+ yyskAddressStandardization.setReturnAddress(item.getOrDefault("returnAddress", "").toString());
|
|
|
+ yyskAddressStandardization.setStandardAddress(item.getOrDefault("standardAddress", "").toString());
|
|
|
+ yyskAddressStandardization.setProvinces(item.getOrDefault("provinces", "").toString());
|
|
|
+ yyskAddressStandardization.setMarket(item.getOrDefault("market", "").toString());
|
|
|
+ yyskAddressStandardization.setDistinguish(item.getOrDefault("distinguish", "").toString());
|
|
|
+ yyskAddressStandardization.setStreetTown(item.getOrDefault("streetTown", "").toString());
|
|
|
+ yyskAddressStandardization.setResidentialCommittee(item.getOrDefault("residentialCommittee", "").toString());
|
|
|
+ yyskAddressStandardization.setLon(item.getOrDefault("lon", "").toString());
|
|
|
+ yyskAddressStandardization.setLat(item.getOrDefault("lat", "").toString());
|
|
|
+ listData.add(yyskAddressStandardization);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
listData = null;
|
|
|
}
|
|
|
if (listData != null && listData.size() > 0) {
|
|
@@ -363,7 +761,7 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
// System.err.println("第" + startFileIndex + "个文件入库异常:" + e);
|
|
|
// }
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
- System.out.println("处理单批次用时" + (endTime - startTime) / 1000 + "秒!已调用市中心接口个数" + ScheduledTasks.szxRequestSize + ";已調用高德接口个数:" + ScheduledTasks.gdRequestSize);
|
|
|
+ System.out.println("处理单批次用时" + (endTime - startTime) / 1000 + "秒!");
|
|
|
} else {
|
|
|
System.out.println("<<<<<<<<------ 第" + startFileIndex + "个文件 -----任务处理完成!结果为空。。。--->>>>" + outPath);
|
|
|
}
|
|
@@ -433,50 +831,62 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
int finalI = i;
|
|
|
futures.add(executorService.submit(() -> {
|
|
|
System.out.print(finalI + ">");
|
|
|
- List<String> addrList = new ArrayList<>();
|
|
|
- addrList.add(item.getAddress());
|
|
|
- boolean ifSearchTag = true;
|
|
|
-// 首先判断是否为非上海市地址
|
|
|
- String[] ams = AddressMatcher.matchProvinceAndCity(item.getAddress());
|
|
|
- if (ams != null && ams[0] != null) {
|
|
|
- if (!ams[0].equals("上海市")) {
|
|
|
- item.setMatchLevel("rule_0");
|
|
|
- item.setProvinces(ams[0]);
|
|
|
- if (ScheduledTasks.errorCount.containsKey("外地数据")) {
|
|
|
- ScheduledTasks.errorCount.put("外地数据", ScheduledTasks.errorCount.get("外地数据") + 1);
|
|
|
- } else {
|
|
|
- ScheduledTasks.errorCount.put("外地数据", 1);
|
|
|
- }
|
|
|
- if (ams[1] != null) {
|
|
|
- item.setMarket(ams[1]);
|
|
|
- }
|
|
|
- ifSearchTag = false;
|
|
|
- }
|
|
|
- }
|
|
|
- if (item.getAddress().contains("http")) {
|
|
|
- ifSearchTag = false;
|
|
|
- item.setMatchLevel("异常");
|
|
|
- if (ScheduledTasks.errorCount.containsKey("链接数据")) {
|
|
|
- ScheduledTasks.errorCount.put("链接数据", ScheduledTasks.errorCount.get("链接数据") + 1);
|
|
|
- } else {
|
|
|
- ScheduledTasks.errorCount.put("链接数据", 1);
|
|
|
- }
|
|
|
- }
|
|
|
- if (item.getStandardAddress() != null && !item.getStandardAddress().isEmpty() && item.getProvinces().equals("上海市") && item.getStandardAddress().contains(item.getDistinguish())) {
|
|
|
- ifSearchTag = false;
|
|
|
- String newStandardAddress = item.getProvinces() + item.getDistinguish() + item.getStreetTown() + AddressTools.returnAddress(item.getAddress());
|
|
|
- if (!item.getStandardAddress().equals(newStandardAddress)) {
|
|
|
- if (ScheduledTasks.errorCount.containsKey("分词错误")) {
|
|
|
- ScheduledTasks.errorCount.put("分词错误", ScheduledTasks.errorCount.get("分词错误") + 1);
|
|
|
+ boolean reSearch = false;
|
|
|
+ List<String> addrs = new ArrayList<>();
|
|
|
+// TODO output12规则
|
|
|
+ if (item.getAddress() != null && item.getReturnAddress() != null) {
|
|
|
+ AddrBean addrBean1 = initAddrMap.outAddrMapInAddr(item.getAddress());
|
|
|
+ AddrBean addrBean2 = initAddrMap.outAddrMapInAddr(item.getReturnAddress());
|
|
|
+ boolean ifError = false;
|
|
|
+ try {
|
|
|
+ if (addrBean1.getRule() != null && Integer.parseInt(addrBean1.getRule()) > 0) {
|
|
|
+ if (addrBean1.getMarket() != null || addrBean2.getMarket() != null) {
|
|
|
+ item.setProvinces(addrBean1.getProvinces() == null ? addrBean2.getProvinces() : addrBean1.getProvinces());
|
|
|
+ item.setMarket(addrBean1.getMarket() == null ? addrBean2.getMarket() : addrBean1.getMarket());
|
|
|
+ }
|
|
|
+ if (addrBean1.getStreetTown() != null) {
|
|
|
+ item.setDistinguish(addrBean1.getDistinguish());
|
|
|
+ item.setStreetTown(addrBean1.getStreetTown());
|
|
|
+ } else if (addrBean2.getStreetTown() != null) {
|
|
|
+ if (addrBean1.getDistinguish() != null && addrBean2.getDistinguish().contains(addrBean1.getDistinguish())) {
|
|
|
+ item.setDistinguish(addrBean2.getDistinguish());
|
|
|
+ item.setStreetTown(addrBean2.getStreetTown());
|
|
|
+ } else {
|
|
|
+ ifError = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ addrs.add(item.getAddress());
|
|
|
+ reSearch = true;
|
|
|
+ ifError = true;
|
|
|
+ }
|
|
|
+ if (ifError) {
|
|
|
+ item.setMatchLevel("异常");
|
|
|
+ item.setStandardAddress(null);
|
|
|
+ } else {
|
|
|
+ item.setStandardAddress(item.getMarket() + item.getDistinguish() + item.getStreetTown() + addrBean1.getAddress());
|
|
|
+ if (item.getMatchLevel().contains("异常") || item.getMatchLevel().contains("rule_0")) {
|
|
|
+ item.setMatchLevel("rule_5");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (item.getAddress() == null) {
|
|
|
+ addrs.add(item.getAddress());
|
|
|
+ reSearch = true;
|
|
|
} else {
|
|
|
- ScheduledTasks.errorCount.put("分词错误", 1);
|
|
|
+ item.setMatchLevel("rule_0");
|
|
|
+// item.setProvinces(addrBean1.getProvinces());
|
|
|
+// item.setMarket(addrBean1.getMarket());
|
|
|
+// item.setDistinguish(addrBean1.getDistinguish());
|
|
|
+// item.setResidentialCommittee(null);
|
|
|
+// item.setStandardAddress(null);
|
|
|
+// item.setReturnAddress(null);
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- item.setStandardAddress(newStandardAddress);
|
|
|
}
|
|
|
- if (ifSearchTag) {
|
|
|
+ if (reSearch) {
|
|
|
// TODO 开始查询
|
|
|
- AddressResult addressResult = AddressQueryEngine.getInstance().commonSearchByName(addrList);
|
|
|
+ AddressResult addressResult = AddressQueryEngine.getInstance().commonSearchByName(addrs);
|
|
|
if (addressResult == null || addressResult.getData() == null || addressResult.getData().size() < 1) {
|
|
|
item.setMatchLevel("异常");
|
|
|
item.setReturnAddress("未匹配到符合规则的结果");
|
|
@@ -490,10 +900,7 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
for (AddressResult.ContentBean contentBean : addressResult.getData()) {
|
|
|
String resultAddrKey = contentBean.getAddress();
|
|
|
if (resultAddrKey != null && contentBean.getLon() != null && contentBean.getLat() != null && AddressTools.isOtherDistrictThanSongJiang2(resultAddrKey)) {
|
|
|
-// 去除特殊字符
|
|
|
- resultAddrKey = AddressTools.reOutDistinguish(contentBean.getAddress());
|
|
|
-// 根据地名地址返回到街镇一级分词,
|
|
|
- String[] strs = AddressTools.parseAddressJZ(resultAddrKey);
|
|
|
+ AddrBean addrBean3 = initAddrMap.outAddrMapInAddr(resultAddrKey);
|
|
|
// 遍历全国省份名称得到省名
|
|
|
item.setProvinces(AddressTools.isOtherDistrictThanShangHai(resultAddrKey));
|
|
|
// 写入街镇数据
|
|
@@ -501,8 +908,8 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
item.setStreetTown(contentBean.getAdname());
|
|
|
} else if (contentBean.getTownJson() != null && contentBean.getTownJson().getString("name") != null) {
|
|
|
item.setStreetTown(contentBean.getTownJson().getString("name"));
|
|
|
- } else if (strs != null && strs[2] != null) {
|
|
|
- item.setStreetTown(strs[2]);
|
|
|
+ } else if (addrBean3.getRule() != null && addrBean3.getStreetTown() != null) {
|
|
|
+ item.setStreetTown(addrBean3.getStreetTown());
|
|
|
} else {
|
|
|
item.setStreetTown("");
|
|
|
}
|
|
@@ -513,8 +920,8 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
item.setDistinguish(contentBean.getCityname());
|
|
|
} else if (contentBean.getAdJson() != null && contentBean.getAdJson().getString("name") != null) {
|
|
|
item.setDistinguish(contentBean.getAdJson().getString("name"));
|
|
|
- } else if (strs != null && strs[1] != null) {
|
|
|
- item.setDistinguish(strs[1]);
|
|
|
+ } else if (addrBean3.getRule() != null && addrBean3.getDistinguish() != null) {
|
|
|
+ item.setDistinguish(addrBean3.getDistinguish());
|
|
|
} else {
|
|
|
item.setDistinguish("");
|
|
|
}
|
|
@@ -524,6 +931,8 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
item.setLat(latLonStr[0]);
|
|
|
item.setLon(latLonStr[1]);
|
|
|
}
|
|
|
+// item.setLat(contentBean.getLat().toString());
|
|
|
+// item.setLon(contentBean.getLon().toString());
|
|
|
item.setReturnAddress(resultAddrKey);
|
|
|
item.setMatchLevel(contentBean.getScore());
|
|
|
// 判断并写入居委
|
|
@@ -534,7 +943,7 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
} else {
|
|
|
item.setResidentialCommittee("");
|
|
|
}
|
|
|
- item.setStandardAddress(item.getMarket() + item.getDistinguish() + item.getStreetTown() + AddressTools.returnAddress(contentBean.getSearchAddress()));
|
|
|
+ item.setStandardAddress(item.getMarket() + item.getDistinguish() + item.getStreetTown() + initAddrMap.outAddrMapInAddr(contentBean.getSearchAddress()).getAddress());
|
|
|
break;
|
|
|
} else {
|
|
|
item.setMatchLevel("异常");
|
|
@@ -566,26 +975,28 @@ public class YyskAddressStandardizationServiceImpl {
|
|
|
try {
|
|
|
future.get();
|
|
|
} catch (InterruptedException | ExecutionException e) {
|
|
|
-// e.printStackTrace();
|
|
|
+ e.printStackTrace();
|
|
|
// System.err.println("线程异常:" + e);
|
|
|
}
|
|
|
}
|
|
|
+ System.out.println("线程任务处理完成!");
|
|
|
// 关闭线程池
|
|
|
executorService.shutdown();
|
|
|
- List<YyskDmdzAddressStandardization> dataList = new ArrayList<>();
|
|
|
+ return listData;
|
|
|
+ /*List<YyskDmdzAddressStandardization> dataList = new ArrayList<>();
|
|
|
List<YyskDmdzAddressStandardization> errData = new ArrayList<>();
|
|
|
for (YyskDmdzAddressStandardization item : listData) {
|
|
|
- if (item.getMatchLevel() == null || item.getMatchLevel().isEmpty()) {
|
|
|
+ if (item.getMatchLevel() == null || item.getMatchLevel().isEmpty() || item.getMatchLevel().contains("异常")) {
|
|
|
errData.add(item);
|
|
|
} else {
|
|
|
dataList.add(item);
|
|
|
}
|
|
|
}
|
|
|
listData.clear();
|
|
|
- if (errData.size() > 0) {
|
|
|
+ if (errData.size() > 0 && dataList.size() > 0) {
|
|
|
dataList.addAll(runExecutorService(errData));
|
|
|
}
|
|
|
- return dataList;
|
|
|
+ return dataList;*/
|
|
|
}
|
|
|
}
|
|
|
|