新增地址标准化批量测试
This commit is contained in:
+60
@@ -0,0 +1,60 @@
|
|||||||
|
package com.fangjia.script.temp.shenjian.address
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject
|
||||||
|
import com.fangjia.core.util.HttpRequest
|
||||||
|
import com.fangjia.script.util.ExcelUtils
|
||||||
|
|
||||||
|
import java.util.concurrent.CountDownLatch
|
||||||
|
import java.util.concurrent.ExecutorService
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 地址标准化测试
|
||||||
|
*
|
||||||
|
* @author shenjian
|
||||||
|
* @since 2021/6/22
|
||||||
|
*/
|
||||||
|
class StandardTest {
|
||||||
|
|
||||||
|
static ExecutorService executorService = Executors.newFixedThreadPool(10)
|
||||||
|
|
||||||
|
static void main(String[] args) {
|
||||||
|
AtomicLong count = new AtomicLong(0)
|
||||||
|
List<List<String>> data = ExcelUtils.read("F:\\工作\\基础建设\\标准化\\标准化融合后测试数据.xlsx")
|
||||||
|
CountDownLatch latch = new CountDownLatch(data.size())
|
||||||
|
for (List<String> rowT : data) {
|
||||||
|
final row = rowT;
|
||||||
|
executorService.submit(new Runnable() {
|
||||||
|
@Override
|
||||||
|
void run() {
|
||||||
|
try {
|
||||||
|
def address = row[0]
|
||||||
|
def city = row[2]
|
||||||
|
HttpRequest request = new HttpRequest()
|
||||||
|
|
||||||
|
String result = request.get("http://192.168.20.86:8082/structure?city=" + URLEncoder.encode(city, "utf-8") + "&address=" + URLEncoder.encode(address, "utf-8"), "utf-8")
|
||||||
|
JSONObject object = JSONObject.parse(result);
|
||||||
|
if (object.get("status") == 0) {
|
||||||
|
row[7] = (((JSONObject) object.get("result")).get("formatAddress"))
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
ex.printStackTrace()
|
||||||
|
} finally {
|
||||||
|
latch.countDown()
|
||||||
|
count.incrementAndGet()
|
||||||
|
if (count.intValue() % 1000 == 0) {
|
||||||
|
Thread.sleep(5000)
|
||||||
|
println(count)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
latch.await()
|
||||||
|
def headers = ["原始地址", "XH", "城市", "区域","小区名", "标注", "备注", "标准化地址"]
|
||||||
|
data.add(0, headers)
|
||||||
|
ExcelUtils.write("F:\\工作\\基础建设\\标准化\\标准化融合后测试数据(标准化后).xlsx", data, "测试数据")
|
||||||
|
executorService.shutdown()
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user