|
@@ -1,6 +1,6 @@
|
|
|
-package com.skyversation.poiaddr.util;
|
|
|
+package com.skyversation.poiaddr.util.address_spliter;
|
|
|
|
|
|
-import com.skyversation.poiaddr.bean.SplitAddress;
|
|
|
+import com.skyversation.poiaddr.util.ExcelReaderUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -193,10 +193,7 @@ public class ShanghaiAddressSplitUtil {
|
|
|
if (communityName.isEmpty())continue;
|
|
|
for(threeLevelAddress t:All_COMMUNITY_IN_SHANGHAI.get(communityName)){
|
|
|
int point = checkTLA(t);
|
|
|
- if (point==221){
|
|
|
- threeLevelAddress=t;
|
|
|
- return;
|
|
|
- }else if (point>handingPoint){
|
|
|
+ if (point>handingPoint){
|
|
|
handingPoint=point;
|
|
|
handingTLA=t;
|
|
|
}
|
|
@@ -206,10 +203,7 @@ public class ShanghaiAddressSplitUtil {
|
|
|
if (streetName.isEmpty())continue;
|
|
|
for(threeLevelAddress t:All_STREET_IN_SHANGHAI.get(streetName)){
|
|
|
int point = checkTLA(t);
|
|
|
- if (point==2111){
|
|
|
- threeLevelAddress=t;
|
|
|
- return;
|
|
|
- }else if (point>handingPoint){
|
|
|
+ if (point>handingPoint){
|
|
|
handingPoint=point;
|
|
|
handingTLA=t;
|
|
|
}
|
|
@@ -314,13 +308,21 @@ public class ShanghaiAddressSplitUtil {
|
|
|
splitAddress.setDistrict(result[2]);
|
|
|
//检查是否在外省,未找到省市或者在省市中找到上海,或者找到上海的区都算作省内
|
|
|
Map<Integer, String> districtContainResult = contain(beautyAddress, DISTRICT_TO_COMMUNITY_MAP.keySet(), 0);
|
|
|
- washResult(beautyAddress, districtContainResult,LEVEL_1_SUFFIX_PATTERN);
|
|
|
- if (!((result[0].isEmpty()|| result[0].equals("上海市")) && (result[1].isEmpty() || result[1].equals("上海市")||
|
|
|
- !districtContainResult.isEmpty()))) {
|
|
|
+ int disIndex= washResult(beautyAddress, districtContainResult,LEVEL_1_SUFFIX_PATTERN);
|
|
|
+ if (!((result[0].isEmpty()|| result[0].equals("上海市")) && (result[1].isEmpty() || result[1].equals("上海市"))||
|
|
|
+ !districtContainResult.isEmpty())) {
|
|
|
splitAddress.setStatus(2);
|
|
|
splitAddress.setAddr(result[3]);
|
|
|
return splitAddress;
|
|
|
}
|
|
|
+ if (!districtContainResult.isEmpty()){
|
|
|
+ if (disIndex!=-1){
|
|
|
+ String district=districtContainResult.get(disIndex);
|
|
|
+ threeLevelAddress disTLA = All_COMMUNITY_IN_SHANGHAI.get(DISTRICT_TO_COMMUNITY_MAP.get(district).get(0)).get(0);
|
|
|
+ splitAddress.setDistrict(disTLA.districtFullName);
|
|
|
+ splitAddress.setDistrictCode(disTLA.districtCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
splitAddress.setProvince("上海市");
|
|
|
splitAddress.setCity("上海市");
|
|
|
splitAddress.setCityCode("3101");
|
|
@@ -342,8 +344,10 @@ public class ShanghaiAddressSplitUtil {
|
|
|
splitAddress.setCommunityCode(splittingAddress.threeLevelAddress.communityCode);
|
|
|
|
|
|
}
|
|
|
- splitAddress.setDistrict(splittingAddress.threeLevelAddress.districtFullName);
|
|
|
- splitAddress.setDistrictCode(splittingAddress.threeLevelAddress.districtCode);
|
|
|
+ if (disIndex==-1){
|
|
|
+ splitAddress.setDistrict(splittingAddress.threeLevelAddress.districtFullName);
|
|
|
+ splitAddress.setDistrictCode(splittingAddress.threeLevelAddress.districtCode);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//检查是否能够分离
|
|
@@ -353,15 +357,20 @@ public class ShanghaiAddressSplitUtil {
|
|
|
splitAddress.setStatus(3);
|
|
|
return splitAddress;
|
|
|
}
|
|
|
- splitAddress.setDistrict(result[2]);
|
|
|
- splitAddress.setAddr(result[3]);
|
|
|
+
|
|
|
+ if (disIndex!=-1){
|
|
|
+ String sub = beautyAddress.substring(disIndex+districtContainResult.get(disIndex).length());
|
|
|
+ Matcher m = LEVEL_1_SUFFIX_PATTERN.matcher(sub);
|
|
|
+ if (m.find()){
|
|
|
+ sub = sub.substring(m.end());
|
|
|
+ }
|
|
|
+ splitAddress.setAddr(sub);
|
|
|
+ }
|
|
|
|
|
|
splitAddress.setStatus(1);
|
|
|
if (result[0].isEmpty()&&result[1].isEmpty()&&districtContainResult.isEmpty())splitAddress.setStatus(4);
|
|
|
return splitAddress;
|
|
|
- }
|
|
|
- //尝试分离
|
|
|
- if (splittingAddress.street> splittingAddress.community){
|
|
|
+ }else if (splittingAddress.street> splittingAddress.community){
|
|
|
String sub = beautyAddress.substring(splittingAddress.street+splittingAddress.streetMap.get(splittingAddress.street).length());
|
|
|
Matcher m = LEVEL_2_SUFFIX_PATTERN.matcher(sub);
|
|
|
if (m.find()){
|
|
@@ -379,6 +388,7 @@ public class ShanghaiAddressSplitUtil {
|
|
|
}
|
|
|
splitAddress.setAddr(sub);
|
|
|
}
|
|
|
+
|
|
|
splitAddress.setStatus(0);
|
|
|
if (result[0].isEmpty()&&result[1].isEmpty()&&districtContainResult.isEmpty())splitAddress.setStatus(4);
|
|
|
if (splitAddress.getStreet().equals("自由贸易试验区"))splitAddress.setStatus(0);
|