Commit a01c5680 by 陶光胜

门店经纬度

parent be8ad127
......@@ -67,6 +67,9 @@ public class StoreInfoDTO implements Serializable {
* 纬度
*/
private String latitude;
private List<Double> location;
/**
* 距离
*/
......@@ -461,4 +464,12 @@ public class StoreInfoDTO implements Serializable {
public void setC10(String c10) {
this.c10 = c10;
}
public List<Double> getLocation() {
return location;
}
public void setLocation(List<Double> location) {
this.location = location;
}
}
......@@ -33,6 +33,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.geo.GeoUtils;
import org.redisson.api.RKeys;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -384,6 +385,12 @@ public class StoreApiServiceImpl implements StoreApiService {
List<StoreDTO> result = new ArrayList<>();
for(int i=0; i<list.size(); i++){
StoreDTO storeDTO = JSON.toJavaObject(list.get(i), StoreDTO.class);
if(StringUtils.isNotBlank(storeSearchDTO.getLatitude()) && StringUtils.isNotBlank(storeSearchDTO.getLongitude()) &&
CollectionUtils.isNotEmpty(storeDTO.getLocation())){
double v = GeoUtils.arcDistance(Double.valueOf(storeSearchDTO.getLatitude()), Double.valueOf(storeSearchDTO.getLongitude()),
Double.valueOf(storeDTO.getLocation().get(1)), storeDTO.getLocation().get(0));
storeDTO.setDistance(v);
}
result.add(storeDTO);
}
page.setResult(result);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment