test(地址拆分):地址清洗测试
This commit is contained in:
69
ruoyi/src/test/java/com/ruoyi/AddressUtilDBTests.java
Normal file
69
ruoyi/src/test/java/com/ruoyi/AddressUtilDBTests.java
Normal file
@ -0,0 +1,69 @@
|
||||
package com.ruoyi;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.ruoyi.common.utils.LoadUtil;
|
||||
import com.ruoyi.project.data.basis.domain.ClosingCaseAddress;
|
||||
import com.ruoyi.project.data.basis.mapper.ClosingCaseAddressMapper;
|
||||
import com.ruoyi.project.tool.address.AddressResult;
|
||||
import com.ruoyi.project.tool.address.utils.AddressUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RuoYiApplication.class)
|
||||
@ActiveProfiles("uat")
|
||||
public class AddressUtilDBTests {
|
||||
|
||||
@Autowired
|
||||
private ClosingCaseAddressMapper mapper;
|
||||
|
||||
/**
|
||||
* 地址清洗测试
|
||||
*/
|
||||
@Test
|
||||
public void testClear() {
|
||||
// 5000
|
||||
Integer total = mapper.selectCount();
|
||||
|
||||
int div = total / 5000;
|
||||
if (0 != total % 5000) {
|
||||
div += 1;
|
||||
}
|
||||
|
||||
Arrays.stream(IntStream.range(0, div).toArray()).parallel().forEach(pageIndex -> {
|
||||
System.out.println(pageIndex);
|
||||
List<ClosingCaseAddress> list = mapper.selectPageList(pageIndex * 5000, 5000);
|
||||
list.forEach(item -> {
|
||||
try {
|
||||
AddressResult addressResult = AddressUtil.clear(item.getAddress());
|
||||
if (null == addressResult.getCleanAddress()) {
|
||||
return;
|
||||
}
|
||||
String address = String.join(",", addressResult.getCleanAddress());
|
||||
item.setCleanAddress(address);
|
||||
mapper.clear(item);
|
||||
} catch (Exception e) {
|
||||
System.out.println(item.getAddress());
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,48 @@ public class AddressUtilTests {
|
||||
}
|
||||
Assert.assertEquals("北华路168弄35号1002室", addressResult.getCleanAddress().get(0));
|
||||
Assert.assertEquals(addressResult.getDistrict(), "闵行");
|
||||
|
||||
addressResult = AddressUtil.clear("西藏北路1308弄8号地下1层车位(人防)27室");
|
||||
if (null == addressResult.getCleanAddress()) {
|
||||
return;
|
||||
}
|
||||
Assert.assertEquals("西藏北路1308弄8号", addressResult.getCleanAddress().get(0));
|
||||
Assert.assertEquals(addressResult.getDistrict(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 号号楼
|
||||
*/
|
||||
@Test
|
||||
public void testHaoLou() {
|
||||
AddressResult addressResult = AddressUtil.clear("四平路283号6号楼2802室");
|
||||
if (null == addressResult.getCleanAddress()) {
|
||||
return;
|
||||
}
|
||||
Assert.assertEquals("四平路283号6号2802室", addressResult.getCleanAddress().get(0));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 复式
|
||||
*/
|
||||
@Test
|
||||
public void testFUSHI() {
|
||||
AddressResult addressResult = AddressUtil.clear("硕望路188弄21号101(复式)");
|
||||
if (null == addressResult.getCleanAddress()) {
|
||||
return;
|
||||
}
|
||||
Assert.assertEquals("硕望路188弄21号101室", addressResult.getCleanAddress().get(0));
|
||||
Assert.assertEquals(addressResult.getDistrict(), null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZhenJieFang() {
|
||||
AddressResult addressResult = AddressUtil.clear("南翔镇7街坊255/2丘19幢1单元1203室");
|
||||
if (null == addressResult.getCleanAddress()) {
|
||||
return;
|
||||
}
|
||||
Assert.assertFalse(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,10 +186,10 @@ public class AddressUtilTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void printStreet() {
|
||||
public void printStreetOrRoad() {
|
||||
List<String> textList = LoadUtil.loadList("jie.dict");
|
||||
textList.forEach(item -> {
|
||||
if (!item.contains("路") && item.contains("街") && !item.contains("街坊")) {
|
||||
if ((item.contains("路") || item.contains("街")) && !item.contains("街坊")) {
|
||||
System.out.println(item);
|
||||
}
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user