银联测试

This commit is contained in:
沈健
2021-09-14 14:46:14 +08:00
parent 6b06ee211e
commit f9a60cfa95
5 changed files with 163 additions and 44 deletions
+31 -28
View File
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.fangjia</groupId>
<artifactId>fangjia-script</artifactId>
@@ -62,7 +62,7 @@
</resources>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
@@ -141,11 +141,11 @@
<artifactId>activemq-pool</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>cn.emay</groupId>
<artifactId>emayclient</artifactId>
<version>4.3</version>
</dependency>
<dependency>
<groupId>cn.emay</groupId>
<artifactId>emayclient</artifactId>
<version>4.3</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
@@ -366,20 +366,20 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<!-- <version>3.17</version>-->
<version>3.10-FINAL</version>
<version>3.17</version>
<!-- <version>3.10-FINAL</version>-->
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<!-- <version>3.17</version>-->
<version>3.10-FINAL</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
<version>3.17</version>
<!-- <version>3.10-FINAL</version>-->
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>
@@ -478,18 +478,21 @@
<artifactId>aliyun-java-sdk-address-purification</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.eclipsesource.j2v8</groupId>
<artifactId>j2v8_win32_x86_64</artifactId>
<version>4.6.0</version>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.msgpack</groupId>
<artifactId>msgpack</artifactId>
<version>0.6.12</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>elastic.co</id>
<url>https://artifacts.elastic.co/maven</url>
</repository>
</repositories>
</project>
@@ -152,7 +152,7 @@ class SeaweedAroundPoi extends BaseBatch {
conn136.insert(newObj)
}
static def listAllType() {
public static def listAllType() {
StringBuilder ret = new StringBuilder()
for (def val : KEYWORDS_MAP.values()) {
ret.append(val).append("|")
@@ -161,22 +161,24 @@ class SeaweedAroundPoi extends BaseBatch {
return result.substring(0, result.length() - 1)
}
public static final Map<String,String> KEYWORDS_MAP = new HashMap<String, String>(){{
// put("地铁", "150500");
// put("公交", "1507");
// put("医院", "090100|090101|090200|090202|090203|090204|090205|090206|090207|090208|090209|090210|090211");
// put("写字楼", "120201");
// put("学校","141200|141201|141202|141203|141204");
// put("银行","1601|1603");
// put("大型超市","0604");
// put("商场","0601");
// put("餐饮","0501|0502|0503|0504");
// put("旅游景点","110000");
// put("图书馆","140500");
put("政府机关","130100|130101|130102|130103|130104|130105|130106|130107");
put("丧葬设施", "071900|071901|071902|071903")
public static final Map<String, String> KEYWORDS_MAP = new HashMap<String, String>() {
{
put("地铁", "150500");
put("公交", "1507");
put("医院", "090100|090101|090200|090202|090203|090204|090205|090206|090207|090208|090209|090210|090211");
put("写字楼", "120201");
put("学校", "141200|141201|141202|141203|141204");
put("银行", "1601|1603");
put("大型超市", "0604");
put("商场", "0601");
put("餐饮", "0501|0502|0503|0504");
put("旅游景点", "110000");
put("图书馆", "140500");
put("政府机关", "130100|130101|130102|130103|130104|130105|130106|130107");
put("丧葬设施", "071900|071901|071902|071903")
}};
}
};
@Override
void process(Object args) {
@@ -0,0 +1,69 @@
package com.fangjia.script.temp.shenjian.poi
import com.alibaba.excel.EasyExcel
import com.alibaba.fastjson.JSONObject
import com.fangjia.script.statistics.poi.AmapPoi
import com.fangjia.script.temp.shenjian.util.ExcelUtils
import com.fangjia.script.temp.shenjian.util.GaoDeUtils
import com.fangjia.script.temp.shenjian.util.HttpUtils
import joptsimple.internal.Strings
import org.apache.commons.collections.CollectionUtils
/**
* 银联小区经纬度与周边配套
*/
class YinlianLngLatAndAround {
static final def URL = "http://192.168.0.19:38080/FangJiaDataService/saveAmapPoi"
static void main(String[] args) {
this.getAround()
}
public static void getAround() {
List<List<String>> datas = ExcelUtils.read("D:\\数据\\银联\\测试样本.xlsx")
for (List<String> data : datas) {
if ("城市".equals(data.get(0))) {
continue;
}
if (data.size() == 7) {
String city = data.get(0)
double lng = Double.valueOf(data.get(5))
double lat = Double.valueOf(data.get(6))
HttpUtils.postForJson()
List<AmapPoi> pois = GaoDeUtils.searchNearDtoByPoi(city, SeaweedAroundPoi.listAllType(), lng, lat, 3000, "")
if (CollectionUtils.isNotEmpty(pois)) {
// String jsonStr = JSONObject.toJSONString(pois)
// HttpUtils.postForJson(URL, jsonStr)
List<String> infos = new ArrayList<>()
for (AmapPoi amapPoi : pois) {
infos.add(amapPoi.getName())
}
data.add(Strings.join(infos, ","))
}
}
}
def headArr = ["城市","区域","小区名","面积","估值","周边3公里配套", "经度", "纬度"]
def head = ExcelUtils.formatHead(headArr)
EasyExcel.write("D:\\数据\\银联\\测试样本-估值&小区配套3公里(银联测试)结果.xlsx").head(head).sheet("Sheet1").doWrite(datas);
}
public void getLocation() {
List<List<String>> datas = ExcelUtils.read("D:\\数据\\银联\\测试样本.xlsx")
for (List<String> data : datas) {
String city = data.get(0)
String region = data.get(1)
String name = data.get(2)
String address = city + region + name
List<Double> lngLat = GaoDeUtils.getLngLat(city, address, region, name, "")
if (CollectionUtils.isNotEmpty(lngLat)) {
data.add(lngLat.get(0))
data.add(lngLat.get(1))
}
}
def headArr = ["城市","区域","小区名","面积","估值","周边3公里配套", "经度", "纬度"]
def head = ExcelUtils.formatHead(headArr)
EasyExcel.write("D:\\数据\\银联\\测试样本-估值&小区配套3公里(银联测试)结果.xlsx").head(head).sheet("Sheet1").doWrite(datas);
}
}
@@ -17,6 +17,15 @@ import java.util.concurrent.ConcurrentHashMap
*/
class ExcelUtils {
static List<List<String>> formatHead(def headArr) {
List<List<String>> head = new ArrayList<>()
for (String name: headArr) {
List<String> temp = new ArrayList<>()
temp.add(name)
head.add(temp)
}
return head;
}
static List<List<String>> read(String filePath) {
SimpleExcelListener listener = new SimpleExcelListener(filePath);
@@ -2,6 +2,7 @@ package com.fangjia.script.temp.shenjian.util
import com.alibaba.fastjson.JSONArray
import com.alibaba.fastjson.JSONObject
import com.fangjia.core.util.CosineSimilarAlgorithm
import com.fangjia.core.util.DataUtil
import com.fangjia.core.util.HttpRequest
import com.fangjia.script.common.DataHandleUtils
@@ -167,6 +168,41 @@ class GaoDeUtils {
return result
}
/**
* 查找最可能的地址经纬度
*
* @param city
* @param address
* @param region
* @param typecodes,如130106|130105|130104
* @return
*/
static List<Double> getLngLat(def city, def address, def region, def name, def typecodes) {
List<AmapPoi> amapPoi = GaoDeUtils.searchPoi(city, address, region, typecodes)
if (amapPoi && amapPoi.size() > 0) {
def poi = amapPoi[0]
double similarity = CosineSimilarAlgorithm.getSimilarity(poi.name, name)
if (similarity < 0.7) {
amapPoi = GaoDeUtils.searchPoi(city, address, region, "")
}
poi = amapPoi[0]
String[] locations = poi.location.split(",")
def lng = Double.valueOf(locations[0])
def lat = Double.valueOf(locations[1])
return Arrays.asList(lng, lat)
} else {
amapPoi = GaoDeUtils.searchPoi(city, address, region, "")
if (amapPoi && amapPoi.size() > 0) {
def poi = amapPoi[0]
String[] locations = poi.location.split(",")
def lng = Double.valueOf(locations[0])
def lat = Double.valueOf(locations[1])
return Arrays.asList(lng, lat)
}
}
return Collections.emptyList();
}
/**
* 查找关键字经纬度
*/