优化搜索
This commit is contained in:
+8
-7
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject
|
|||||||
import com.fangjia.script.lixue.util.DBUtils
|
import com.fangjia.script.lixue.util.DBUtils
|
||||||
import com.fangjia.script.statistics.poi.AmapPoi
|
import com.fangjia.script.statistics.poi.AmapPoi
|
||||||
import com.fangjia.script.statistics.poi.AmapPoiDetail
|
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.GaoDeUtils
|
||||||
import com.fangjia.script.temp.shenjian.util.HttpUtils
|
import com.fangjia.script.temp.shenjian.util.HttpUtils
|
||||||
import com.fangjia.script.temp.shenjian.util.SeaweedUtils
|
import com.fangjia.script.temp.shenjian.util.SeaweedUtils
|
||||||
@@ -81,13 +82,13 @@ class SeaweedPoiDetail {
|
|||||||
pois = GaoDeUtils.searchPoi(city, name, region, typecodes)
|
pois = GaoDeUtils.searchPoi(city, name, region, typecodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AmapPoiDetail> detailList = new ArrayList<>()
|
List<AmapPoiDetail> detailList = CommonDtoUtils.transformListV(AmapPoiDetail.class, pois);
|
||||||
for (AmapPoi amapPoi : pois) {
|
// for (AmapPoi amapPoi : pois) {
|
||||||
List<AmapPoiDetail> amapPoiList = GaoDeUtils.getAmapDetailById(amapPoi.getId());
|
// List<AmapPoiDetail> amapPoiList = GaoDeUtils.getAmapDetailById(amapPoi.getId());
|
||||||
if (CollectionUtils.isNotEmpty(amapPoiList)) {
|
// if (CollectionUtils.isNotEmpty(amapPoiList)) {
|
||||||
detailList.addAll(amapPoiList)
|
// detailList.addAll(amapPoiList)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (CollectionUtils.isNotEmpty(detailList)) {
|
if (CollectionUtils.isNotEmpty(detailList)) {
|
||||||
String jsonStr = JSONObject.toJSONString(detailList)
|
String jsonStr = JSONObject.toJSONString(detailList)
|
||||||
HttpUtils.postForJson(URL, jsonStr)
|
HttpUtils.postForJson(URL, jsonStr)
|
||||||
|
|||||||
+40
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user