diff --git a/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/StandardTest.groovy b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/StandardTest.groovy new file mode 100644 index 000000000..3b3cca4f5 --- /dev/null +++ b/projects/fangjia-script/src/main/groovy/com/fangjia/script/temp/shenjian/address/StandardTest.groovy @@ -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> data = ExcelUtils.read("F:\\工作\\基础建设\\标准化\\标准化融合后测试数据.xlsx") + CountDownLatch latch = new CountDownLatch(data.size()) + for (List 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() + } +}