优化搜索

This commit is contained in:
Jian Shen
2022-05-25 19:42:57 +08:00
parent 299e9e81a0
commit 082f7fff20
2 changed files with 48 additions and 7 deletions
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject
import com.fangjia.script.lixue.util.DBUtils
import com.fangjia.script.statistics.poi.AmapPoi
import com.fangjia.script.statistics.poi.AmapPoiDetail
import com.fangjia.script.temp.shenjian.util.CommonDtoUtils
import com.fangjia.script.temp.shenjian.util.GaoDeUtils
import com.fangjia.script.temp.shenjian.util.HttpUtils
import com.fangjia.script.temp.shenjian.util.SeaweedUtils
@@ -81,13 +82,13 @@ class SeaweedPoiDetail {
pois = GaoDeUtils.searchPoi(city, name, region, typecodes)
}
List<AmapPoiDetail> detailList = new ArrayList<>()
for (AmapPoi amapPoi : pois) {
List<AmapPoiDetail> amapPoiList = GaoDeUtils.getAmapDetailById(amapPoi.getId());
if (CollectionUtils.isNotEmpty(amapPoiList)) {
detailList.addAll(amapPoiList)
}
}
List<AmapPoiDetail> detailList = CommonDtoUtils.transformListV(AmapPoiDetail.class, pois);
// for (AmapPoi amapPoi : pois) {
// List<AmapPoiDetail> amapPoiList = GaoDeUtils.getAmapDetailById(amapPoi.getId());
// if (CollectionUtils.isNotEmpty(amapPoiList)) {
// detailList.addAll(amapPoiList)
// }
// }
if (CollectionUtils.isNotEmpty(detailList)) {
String jsonStr = JSONObject.toJSONString(detailList)
HttpUtils.postForJson(URL, jsonStr)
@@ -0,0 +1,40 @@
package com.fangjia.script.temp.shenjian.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
/**
* 通用实体与DTO互相转换工具类
*
* @author shenjian
* @date 2021/06/16
*/
public class CommonDtoUtils {
public static <T> T transformV(Class<T> targetClass, Object source) {
if (source == null) {
return null;
} else {
try {
String jsonSource = JSON.toJSONString(source);
return JSONObject.parseObject(jsonSource, targetClass);
} catch (Exception var3) {
throw var3;
}
}
}
public static <T> List<T> transformListV(Class<T> targetClass, List<?> listSource) {
if (listSource == null) {
return null;
} else {
try {
String jsonSource = JSON.toJSONString(listSource);
return JSONArray.parseArray(jsonSource, targetClass);
} catch (Exception var3) {
throw var3;
}
}
}
}