|
@@ -2,6 +2,7 @@ package com.skyversation.poiaddr.service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.skyversation.poiaddr.addquery.AddressQueryEngine;
|
|
|
import com.skyversation.poiaddr.addquery.Constant;
|
|
|
import com.skyversation.poiaddr.bean.*;
|
|
|
import com.skyversation.poiaddr.config.DbConnection;
|
|
@@ -55,6 +56,15 @@ public class AreaService {
|
|
|
@Value("${app.db.search_table_name}")
|
|
|
private String searchTableName;
|
|
|
|
|
|
+ @Value("${app.db.pgi_table}")
|
|
|
+ private String pgi_table;
|
|
|
+
|
|
|
+ @Value("${app.db.gr_table}")
|
|
|
+ private String gr_table;
|
|
|
+
|
|
|
+ @Value("${app.db.rp_table}")
|
|
|
+ private String rp_table;
|
|
|
+
|
|
|
WKTReader reader = new WKTReader(JTSFactoryFinder.getGeometryFactory());
|
|
|
public List<GeoJsonBean> shAllAdministrativeDivisionPolygonList = new ArrayList<>();
|
|
|
public List<GeoJsonBean> shAllToensPolygonList = new ArrayList<>();
|
|
@@ -79,10 +89,16 @@ public class AreaService {
|
|
|
Constant.setTowns(town.split(","));
|
|
|
Constant.setArea(area);
|
|
|
Constant.setSearchTableName(searchTableName);
|
|
|
+ Constant.setGrTable(gr_table);
|
|
|
+ Constant.setPgiTable(pgi_table);
|
|
|
+ Constant.setRpTable(rp_table);
|
|
|
System.out.println("<<<<<<<<------根据配置文件为AREA赋值:" + Constant.getArea());
|
|
|
System.out.println("<<<<<<<<------当前AMAP_CITY_CODE:" + Constant.getAMAP_CITY_CODE());
|
|
|
+ System.out.println("<<<<<<<<------结果总表:" + Constant.getGrTable());
|
|
|
+ System.out.println("<<<<<<<<------中间表:" + Constant.getPgiTable());
|
|
|
+ System.out.println("<<<<<<<<------回匹表:" + Constant.getRpTable());
|
|
|
// TODO 网络连通性测试,可以请求一下测试的市中心地址
|
|
|
- /*try {
|
|
|
+ try {
|
|
|
System.out.println("电脑最大线程数:" + Runtime.getRuntime().availableProcessors());
|
|
|
System.out.println("<<<<<<<<------开始网络连通性测试");
|
|
|
long startTime = System.currentTimeMillis();
|
|
@@ -93,15 +109,6 @@ public class AreaService {
|
|
|
System.out.println(">>>>>>>>------网络连通性测试完成!用时" + (endTime - startTime) / 1000 + "秒!结果:" + addressResult);
|
|
|
} catch (Exception e) {
|
|
|
System.err.println(">>>>>>>>------网络连通性测试结果:" + e);
|
|
|
- }*/
|
|
|
-// TODO 数据库连通性测试
|
|
|
- try {
|
|
|
- /*System.out.println("<<<<<<<<------开始数据库连通性测试");
|
|
|
- System.out.println("------数据库连通性测试结果:" + DbConnection.getInstance().runSqlStr("select count(*) from " + searchTableName));*/
|
|
|
-// System.out.println("<<<<<<<<------开始缓存待处理表对象");
|
|
|
-// initScheduledTasksSetAddress();
|
|
|
- } catch (Exception e) {
|
|
|
- System.err.println(">>>>>>>>------数据库连通性测试结果:" + e);
|
|
|
}
|
|
|
// 查询callback表中最大的id和添加到callBackAllErrorAddrs列表中
|
|
|
try {
|
|
@@ -195,6 +202,7 @@ public class AreaService {
|
|
|
|
|
|
/**
|
|
|
* JPA的形式加载所有地址信息到缓存
|
|
|
+ *
|
|
|
* @param maxOid
|
|
|
* @param pageSize
|
|
|
*/
|
|
@@ -203,14 +211,19 @@ public class AreaService {
|
|
|
System.out.println("maxOid:" + maxOid + "pageSize:" + pageSize);
|
|
|
long sTime = System.currentTimeMillis();
|
|
|
List<YyskDmdzAddressStandardization> dataList = yyszAddressRepository.getAllByOidPage(maxOid, pageSize);
|
|
|
- System.out.println("当前OID" + maxOid + "查询完成,用时:" + (System.currentTimeMillis() - sTime) / 1000 + "秒!");
|
|
|
+ System.out.println("当前OID" + maxOid + "查询完成,用时:" + (System.currentTimeMillis() - sTime) + "毫秒!");
|
|
|
// TODO 经测试发现一次性读全表,内存根本吃不消
|
|
|
for (YyskDmdzAddressStandardization item : dataList) {
|
|
|
if (item.getAddress() != null && StringUtils.hasText(item.getAddress())) {
|
|
|
SplitAddress splitAddress = ShanghaiAddressSplitUtil.splitBestAddress(item.getAddress());
|
|
|
putAllDmdzData(splitAddress.getAddr(), item);
|
|
|
- }
|
|
|
- if (item.getSourceaddress() != null && StringUtils.hasText(item.getSourceaddress())) {
|
|
|
+ if(item.getSourceaddress() != null&& StringUtils.hasText(item.getSourceaddress())){
|
|
|
+ SplitAddress splitAddress2 = ShanghaiAddressSplitUtil.splitBestAddress(item.getSourceaddress());
|
|
|
+ if(!splitAddress.getAddr().equals(splitAddress2.getAddr())){
|
|
|
+ putAllDmdzData(splitAddress2.getAddr(), item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if (item.getSourceaddress() != null && StringUtils.hasText(item.getSourceaddress())) {
|
|
|
SplitAddress splitAddress = ShanghaiAddressSplitUtil.splitBestAddress(item.getSourceaddress());
|
|
|
putAllDmdzData(splitAddress.getAddr(), item);
|
|
|
}
|
|
@@ -218,7 +231,7 @@ public class AreaService {
|
|
|
maxOid = item.getOid();
|
|
|
}
|
|
|
}
|
|
|
- System.out.println("当前OID" + maxOid + "查询处理完成,用时:" + (System.currentTimeMillis() - sTime) / 1000 + "秒!");
|
|
|
+ System.out.println("当前OID" + maxOid + "缓存处理完成,ScheduledTasks.allDmdzData.size():" + ScheduledTasks.allDmdzData.size() + ",用时:" + (System.currentTimeMillis() - sTime) / 1000 + "秒!");
|
|
|
if (dataList.size() > 0) {
|
|
|
getDmdzDataByPage(maxOid, pageSize);
|
|
|
} else {
|
|
@@ -389,7 +402,7 @@ public class AreaService {
|
|
|
if (splitAddress.getSearchAddr() == null) {
|
|
|
splitAddress.setSearchAddr(splitAddress.getAddr());
|
|
|
}
|
|
|
- List<YyskDmdzAddressStandardization> list = null;
|
|
|
+ List<YyskDmdzAddressStandardization> list = new ArrayList<>();
|
|
|
if (StringUtils.hasText(splitAddress.getDistrict())) {
|
|
|
// TODO 数据库查询逻辑调整为内存处理的方式
|
|
|
List<YyskDmdzAddressStandardization> dmdzList = new ArrayList<>();
|
|
@@ -414,7 +427,7 @@ public class AreaService {
|
|
|
// TODO 数据库查询的方式
|
|
|
// list = yyszAddressRepository.getAddressPoisByAddrAQX(splitAddress.getDistrict(), splitAddress.getSearchAddr());
|
|
|
}
|
|
|
- if (list == null) {
|
|
|
+ if (list.size() == 0) {
|
|
|
list = getAddressPoiOnlyDB(splitAddress.getSearchAddr());
|
|
|
}
|
|
|
return list;
|
|
@@ -422,16 +435,26 @@ public class AreaService {
|
|
|
|
|
|
public List<YyskDmdzAddressStandardization> getAddressPoiOnlyDB(String addr) {
|
|
|
// TODO 数据库查询逻辑调整为内存处理的方式
|
|
|
+ List<YyskDmdzAddressStandardization> returnDatas = new ArrayList<>();
|
|
|
if (ScheduledTasks.allDmdzData.containsKey(addr)) {
|
|
|
- return ScheduledTasks.allDmdzData.get(addr);
|
|
|
+ returnDatas = ScheduledTasks.allDmdzData.get(addr);
|
|
|
} else {
|
|
|
for (String key : ScheduledTasks.allDmdzData.keySet()) {
|
|
|
- if (addr.contains(key)) {
|
|
|
- return ScheduledTasks.allDmdzData.get(key);
|
|
|
+ if (key.contains(addr)) {
|
|
|
+ returnDatas = ScheduledTasks.allDmdzData.get(key);
|
|
|
}
|
|
|
}
|
|
|
- return null;
|
|
|
+ if (returnDatas == null || returnDatas.size() == 0) {
|
|
|
+ SplitAddress splitAddress = ShanghaiAddressSplitUtil.splitBestAddress(addr);
|
|
|
+ if (splitAddress.getAddr() != null && splitAddress.getAddr().length() > 0 && StringUtils.hasText(splitAddress.getAddr()))
|
|
|
+ for (String key : ScheduledTasks.allDmdzData.keySet()) {
|
|
|
+ if (key.contains(splitAddress.getAddr())) {
|
|
|
+ returnDatas = ScheduledTasks.allDmdzData.get(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ return returnDatas;
|
|
|
// TODO 数据库查询的方式
|
|
|
// return yyszAddressRepository.getAddressPoisByAddr(addr);
|
|
|
}
|