|
@@ -17,6 +17,7 @@ import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -54,6 +55,10 @@ public class CommonServiceImpl implements CommonService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private WorkCycleService workCycleService;
|
|
private WorkCycleService workCycleService;
|
|
|
|
|
|
|
|
|
|
+ final static String BAIDUMAP_AK = "Zvd6FzmertUwjhZih5Zfq0D8uTUhvqsH";
|
|
|
|
|
+
|
|
|
|
|
+ final static String BAIDUMAP_URL = "http://api.map.baidu.com/reverse_geocoding/v3/?output=json&coordtype=BD09&pois=1";
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Org findOrg(Long orgId) {
|
|
public Org findOrg(Long orgId) {
|
|
|
Org orgParam = new Org();
|
|
Org orgParam = new Org();
|
|
@@ -273,6 +278,10 @@ public class CommonServiceImpl implements CommonService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<String> getLocationtrip(Long truckId, LocalDateTime startDate, LocalDateTime endDate) {
|
|
public List<String> getLocationtrip(Long truckId, LocalDateTime startDate, LocalDateTime endDate) {
|
|
|
|
|
+ if (startDate == null || endDate == null) {
|
|
|
|
|
+ log.error("getLocationtrip 查询时间错误");
|
|
|
|
|
+ return Collections.EMPTY_LIST;
|
|
|
|
|
+ }
|
|
|
QueryWrapper<TruckSimCard> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<TruckSimCard> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("truck_id", truckId);
|
|
queryWrapper.eq("truck_id", truckId);
|
|
|
TruckSimCard truckSimCard = truckSimCardService.getOne(queryWrapper);
|
|
TruckSimCard truckSimCard = truckSimCardService.getOne(queryWrapper);
|
|
@@ -291,4 +300,47 @@ public class CommonServiceImpl implements CommonService {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String longitudeToAddress(float lat, float lng) {
|
|
|
|
|
+ //拼接请求路径
|
|
|
|
|
+ String url = BAIDUMAP_URL + "&ak=" + BAIDUMAP_AK + "&location=" + lat + "," + lng;
|
|
|
|
|
+ log.info("请求url:" + url);
|
|
|
|
|
+ String res = doGet(url);
|
|
|
|
|
+ String Addresslocation= JSON.parseObject(res).getJSONObject("result").getString("formatted_address");
|
|
|
|
|
+ System.out.println(Addresslocation);
|
|
|
|
|
+ return Addresslocation;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static String doGet(String url) {
|
|
|
|
|
+// //创建一个Http客户端
|
|
|
|
|
+// CloseableHttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
|
|
+// //创建一个get请求
|
|
|
|
|
+// HttpGet httpGet = new HttpGet(url);
|
|
|
|
|
+// //响应模型
|
|
|
|
|
+// CloseableHttpResponse response = null;
|
|
|
|
|
+// try {
|
|
|
|
|
+// //由客户端发送get请求
|
|
|
|
|
+// response = httpClient.execute(httpGet);
|
|
|
|
|
+// //从响应模型中获取响应实体
|
|
|
|
|
+// HttpEntity responseEntity = response.getEntity();
|
|
|
|
|
+// if (responseEntity != null) {
|
|
|
|
|
+// return EntityUtils.toString(responseEntity);
|
|
|
|
|
+// }
|
|
|
|
|
+// } catch (IOException e) {
|
|
|
|
|
+// e.printStackTrace();
|
|
|
|
|
+// } finally {
|
|
|
|
|
+// try {
|
|
|
|
|
+// if (httpClient != null) {
|
|
|
|
|
+// httpClient.close();
|
|
|
|
|
+// }
|
|
|
|
|
+// if (response != null) {
|
|
|
|
|
+// response.close();
|
|
|
|
|
+// }
|
|
|
|
|
+// } catch (IOException e) {
|
|
|
|
|
+// e.printStackTrace();
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|