feature(地址清洗)重构
This commit is contained in:
parent
ee82313818
commit
27db250c13
@ -0,0 +1,8 @@
|
|||||||
|
package com.ruoyi.project.tool.address;
|
||||||
|
|
||||||
|
public class AddressResult {
|
||||||
|
private String district;
|
||||||
|
private String region;
|
||||||
|
private Boolean multi;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.ruoyi.project.tool.address.model;
|
||||||
|
|
||||||
|
public enum AddressType {
|
||||||
|
CONDO(1, "单套"), BUILDING(2, "楼栋"), COMMUNITY(3, "小区");
|
||||||
|
private Integer code;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private AddressType(int code, String name) {
|
||||||
|
this.code = code;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,8 +14,12 @@ public class BuildingAddress extends PartialAddress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PartialAddress> getPartialAddress() {
|
public AddressType getAddressType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean multiAddress() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.ruoyi.project.tool.address.model;
|
package com.ruoyi.project.tool.address.model;
|
||||||
|
|
||||||
import com.ruoyi.project.tool.address.service.impl.SignalAddressHandler;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -44,14 +42,6 @@ public class CleanAddress {
|
|||||||
* (和地下有关系)
|
* (和地下有关系)
|
||||||
*/
|
*/
|
||||||
private String floor;
|
private String floor;
|
||||||
/**
|
|
||||||
* 小区地址
|
|
||||||
*/
|
|
||||||
private PartialAddress communityAddress;
|
|
||||||
/**
|
|
||||||
* 楼栋地址
|
|
||||||
*/
|
|
||||||
private PartialAddress buildingAddress;
|
|
||||||
/**
|
/**
|
||||||
* 单套地址
|
* 单套地址
|
||||||
*/
|
*/
|
||||||
@ -154,22 +144,6 @@ public class CleanAddress {
|
|||||||
this.floor = floor;
|
this.floor = floor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PartialAddress getCommunityAddress() {
|
|
||||||
return communityAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCommunityAddress(PartialAddress communityAddress) {
|
|
||||||
this.communityAddress = communityAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PartialAddress getBuildingAddress() {
|
|
||||||
return buildingAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBuildingAddress(PartialAddress buildingAddress) {
|
|
||||||
this.buildingAddress = buildingAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PartialAddress getCondoAddress() {
|
public PartialAddress getCondoAddress() {
|
||||||
return condoAddress;
|
return condoAddress;
|
||||||
}
|
}
|
||||||
@ -231,8 +205,6 @@ public class CleanAddress {
|
|||||||
", road='" + road + '\'' +
|
", road='" + road + '\'' +
|
||||||
", communityName='" + communityName + '\'' +
|
", communityName='" + communityName + '\'' +
|
||||||
", floor=" + floor +
|
", floor=" + floor +
|
||||||
", communityAddress=" + communityAddress +
|
|
||||||
", buildingAddress=" + buildingAddress +
|
|
||||||
", condoAddress=" + condoAddress +
|
", condoAddress=" + condoAddress +
|
||||||
", propertyType='" + propertyType + '\'' +
|
", propertyType='" + propertyType + '\'' +
|
||||||
", independent=" + independent +
|
", independent=" + independent +
|
||||||
|
@ -206,12 +206,8 @@ public class CleanAddressBuilder {
|
|||||||
String buildingAddressText = condoAddressText.substring(0, haoIndex + 1);
|
String buildingAddressText = condoAddressText.substring(0, haoIndex + 1);
|
||||||
BuildingAddress buildingAddress = new BuildingAddress(buildingAddressText);
|
BuildingAddress buildingAddress = new BuildingAddress(buildingAddressText);
|
||||||
// 楼栋
|
// 楼栋
|
||||||
cleanAddress.setBuildingAddress(buildingAddress);
|
condoAddress.addPartialAddress(buildingAddress);
|
||||||
cleanAddress.addAddress(condoAddress);
|
cleanAddress.addAddress(condoAddress);
|
||||||
cleanAddress.addAddress(buildingAddress);
|
|
||||||
|
|
||||||
cleanAddress.addAddress(condoAddress);
|
|
||||||
cleanAddress.addAddress(buildingAddress);
|
|
||||||
getCommunityAddress(buildingAddressText);
|
getCommunityAddress(buildingAddressText);
|
||||||
} else if (!StringUtils.isEmpty(cleanAddress.getCommunityName())) {
|
} else if (!StringUtils.isEmpty(cleanAddress.getCommunityName())) {
|
||||||
|
|
||||||
|
@ -14,8 +14,12 @@ public class CommunityAddress extends PartialAddress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PartialAddress> getPartialAddress() {
|
public AddressType getAddressType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean multiAddress() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 室地址
|
* 单套地址
|
||||||
*
|
*
|
||||||
* @author lihe
|
* @author lihe
|
||||||
*/
|
*/
|
||||||
@ -19,7 +19,25 @@ public class CondoAddress extends PartialAddress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PartialAddress> getPartialAddress() {
|
public AddressType getAddressType() {
|
||||||
return null;
|
return AddressType.CONDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean multiAddress() {
|
||||||
|
return childrenAddress.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHao() {
|
||||||
|
return hao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShi() {
|
||||||
|
return shi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getFloor() {
|
||||||
|
return floor;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.ruoyi.common.exception.CustomException;
|
|||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import io.swagger.models.auth.In;
|
import io.swagger.models.auth.In;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -18,34 +19,32 @@ public abstract class PartialAddress {
|
|||||||
protected String hao;
|
protected String hao;
|
||||||
protected String shi;
|
protected String shi;
|
||||||
protected Integer floor;
|
protected Integer floor;
|
||||||
|
|
||||||
|
protected final int HUNDRED = 100;
|
||||||
|
protected final int TEN_THOUSAND = 10 * 1000;
|
||||||
protected final static String SHI_PATTERN = "([\\dA-Za-z]+)室$";
|
protected final static String SHI_PATTERN = "([\\dA-Za-z]+)室$";
|
||||||
protected final static String HAO_PATTERN = "([\\dA-Za-z]+)(甲乙丙丁戊己庚辛仍亏)?号";
|
protected final static String HAO_PATTERN = "([\\dA-Za-z]+)(甲乙丙丁戊己庚辛仍亏)?号";
|
||||||
protected final static String NUMBER_PATTERN = "\\d+";
|
protected final static String NUMBER_PATTERN = "\\d+";
|
||||||
protected final int HUNDRED = 100;
|
|
||||||
protected final int TEN_THOUSAND = 10 * 1000;
|
|
||||||
|
|
||||||
public PartialAddress(String address) {
|
public PartialAddress(String address) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHao() {
|
/**
|
||||||
return hao;
|
* @return
|
||||||
}
|
*/
|
||||||
|
public abstract AddressType getAddressType();
|
||||||
|
|
||||||
public String getShi() {
|
|
||||||
return shi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getFloor() {
|
|
||||||
return floor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取地址(单套、楼栋、小区)
|
* 获取地址(单套、楼栋、小区)
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract List<PartialAddress> getPartialAddress();
|
protected List<PartialAddress> childrenAddress = new LinkedList<>();
|
||||||
|
|
||||||
|
public abstract Boolean multiAddress();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 室解析
|
* 室解析
|
||||||
@ -102,6 +101,15 @@ public abstract class PartialAddress {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加地址
|
||||||
|
*
|
||||||
|
* @param partialAddress
|
||||||
|
*/
|
||||||
|
protected void addPartialAddress(PartialAddress partialAddress) {
|
||||||
|
this.childrenAddress.add(partialAddress);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PartialAddress{" +
|
return "PartialAddress{" +
|
||||||
|
@ -0,0 +1,103 @@
|
|||||||
|
package com.ruoyi.project.tool.address.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址分段
|
||||||
|
*/
|
||||||
|
public class SegmentAddress {
|
||||||
|
/**
|
||||||
|
* 弄、支弄
|
||||||
|
*/
|
||||||
|
private String nong;
|
||||||
|
/**
|
||||||
|
* 号
|
||||||
|
*/
|
||||||
|
private String hao;
|
||||||
|
/**
|
||||||
|
* 是否有多个号
|
||||||
|
*/
|
||||||
|
private Boolean multiHao;
|
||||||
|
/**
|
||||||
|
* 楼层(包含复式)
|
||||||
|
*/
|
||||||
|
private String floor;
|
||||||
|
/**
|
||||||
|
* 是否多楼层
|
||||||
|
*/
|
||||||
|
private Boolean multiFloor;
|
||||||
|
/**
|
||||||
|
* 栋、幢、座
|
||||||
|
*/
|
||||||
|
private String dong;
|
||||||
|
/**
|
||||||
|
* 室号
|
||||||
|
*/
|
||||||
|
private String shi;
|
||||||
|
/**
|
||||||
|
* 多个室号
|
||||||
|
*/
|
||||||
|
private Boolean multiShi;
|
||||||
|
|
||||||
|
public String getNong() {
|
||||||
|
return nong;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNong(String nong) {
|
||||||
|
this.nong = nong;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHao() {
|
||||||
|
return hao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHao(String hao) {
|
||||||
|
this.hao = hao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getMultiHao() {
|
||||||
|
return multiHao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultiHao(Boolean multiHao) {
|
||||||
|
this.multiHao = multiHao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFloor() {
|
||||||
|
return floor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFloor(String floor) {
|
||||||
|
this.floor = floor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getMultiFloor() {
|
||||||
|
return multiFloor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultiFloor(Boolean multiFloor) {
|
||||||
|
this.multiFloor = multiFloor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDong() {
|
||||||
|
return dong;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDong(String dong) {
|
||||||
|
this.dong = dong;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShi() {
|
||||||
|
return shi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShi(String shi) {
|
||||||
|
this.shi = shi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getMultiShi() {
|
||||||
|
return multiShi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultiShi(Boolean multiShi) {
|
||||||
|
this.multiShi = multiShi;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.ruoyi.project.tool.address.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址构建者模式
|
||||||
|
*/
|
||||||
|
public interface AddressBuilder {
|
||||||
|
|
||||||
|
String parseDistrict();
|
||||||
|
String parseRegion();
|
||||||
|
String parseBlock();
|
||||||
|
String parseRoad();
|
||||||
|
String parseCommunityName();
|
||||||
|
String parseNONG();
|
||||||
|
String parseHao();
|
||||||
|
String parseShi();
|
||||||
|
String parseFloor();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.ruoyi.project.tool.address.service;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class AddressModel {
|
||||||
|
private String district;
|
||||||
|
private String region;
|
||||||
|
private String block;
|
||||||
|
private String road;
|
||||||
|
private String communityName;
|
||||||
|
private String nong;
|
||||||
|
private String complexHao;
|
||||||
|
/**
|
||||||
|
* 泛化的号(号、幢、座、连号)
|
||||||
|
*/
|
||||||
|
private String hao;
|
||||||
|
/**
|
||||||
|
* 是否有多个号
|
||||||
|
* x号y号=x弄y号
|
||||||
|
* x号y幢=x号
|
||||||
|
* x幢y号=y号
|
||||||
|
* x幢y号=x幢
|
||||||
|
*/
|
||||||
|
private Boolean multiHao;
|
||||||
|
/**
|
||||||
|
* 是否包含楼层
|
||||||
|
* 复式、多层
|
||||||
|
*/
|
||||||
|
private String floor;
|
||||||
|
private String shi;
|
||||||
|
/**
|
||||||
|
* 是否独栋
|
||||||
|
*/
|
||||||
|
private Boolean dependency;
|
||||||
|
/**
|
||||||
|
* 层级(每个层级只有一个,一对一)
|
||||||
|
*/
|
||||||
|
private AddressModel hierarchy;
|
||||||
|
// /**
|
||||||
|
// * 兄弟节点
|
||||||
|
// */
|
||||||
|
// private List<AddressModel> sibling = new LinkedList<>();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.ruoyi.project.tool.address.service;
|
||||||
|
|
||||||
|
import com.ruoyi.project.tool.address.model.AddressType;
|
||||||
|
|
||||||
|
public abstract class BaseAddressBuilder implements AddressBuilder {
|
||||||
|
|
||||||
|
protected StringBuilder stringBuilder;
|
||||||
|
|
||||||
|
public BaseAddressBuilder(String text) {
|
||||||
|
this.stringBuilder = new StringBuilder(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract AddressType getAddressType();
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.ruoyi.project.tool.address.service;
|
||||||
|
|
||||||
|
public class CleanContext {
|
||||||
|
private StringBuilder sb;
|
||||||
|
private Boolean multiHao;
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
public StringBuilder getSb() {
|
||||||
|
return sb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSb(StringBuilder sb) {
|
||||||
|
this.sb = sb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getMultiHao() {
|
||||||
|
return multiHao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultiHao(Boolean multiHao) {
|
||||||
|
this.multiHao = multiHao;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(String address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.ruoyi;
|
|||||||
|
|
||||||
|
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.LoadUtil;
|
||||||
import com.ruoyi.project.data.cases.domain.*;
|
import com.ruoyi.project.data.cases.domain.*;
|
||||||
import com.ruoyi.project.data.price.domain.ComputeResidenceSaleBasePrice;
|
import com.ruoyi.project.data.price.domain.ComputeResidenceSaleBasePrice;
|
||||||
import com.ruoyi.project.data.price.domain.UltimateOfficeBasePrice;
|
import com.ruoyi.project.data.price.domain.UltimateOfficeBasePrice;
|
||||||
|
@ -9,8 +9,6 @@ import com.microsoft.sqlserver.jdbc.spatialdatatypes.Point;
|
|||||||
import com.ruoyi.RuoYiApplication;
|
import com.ruoyi.RuoYiApplication;
|
||||||
import com.ruoyi.project.data.basis.domain.*;
|
import com.ruoyi.project.data.basis.domain.*;
|
||||||
import com.ruoyi.project.data.basis.mapper.UvCommunityGeoMapper;
|
import com.ruoyi.project.data.basis.mapper.UvCommunityGeoMapper;
|
||||||
import com.sun.org.apache.regexp.internal.RE;
|
|
||||||
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
@ -18,9 +16,6 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
|
||||||
import org.springframework.jdbc.core.RowMapper;
|
|
||||||
import org.springframework.security.web.PortResolverImpl;
|
|
||||||
import org.springframework.test.context.ActiveProfiles;
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user