|
@@ -13,14 +13,20 @@ import com.aoyang.tms.feign.result.TmsMongoDoc;
|
|
|
import com.aoyang.tms.service.*;
|
|
import com.aoyang.tms.service.*;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
|
|
+import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
|
|
+import org.apache.http.client.methods.HttpGet;
|
|
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
|
|
+import org.apache.http.impl.client.HttpClientBuilder;
|
|
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.data.domain.Sort;
|
|
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;
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
@@ -261,7 +267,7 @@ public class CommonServiceImpl implements CommonService {
|
|
|
return location;
|
|
return location;
|
|
|
}
|
|
}
|
|
|
Criteria criteria = Criteria.where("clientId").is(truckSimCard.getClientId());
|
|
Criteria criteria = Criteria.where("clientId").is(truckSimCard.getClientId());
|
|
|
- criteria.andOperator(Criteria.where("dateTime").gt(date));
|
|
|
|
|
|
|
+ criteria.andOperator(Criteria.where("createTime").gt(date));
|
|
|
Query query = new Query(criteria);
|
|
Query query = new Query(criteria);
|
|
|
query.with(new Sort(Sort.Direction.ASC, "dateTime"));
|
|
query.with(new Sort(Sort.Direction.ASC, "dateTime"));
|
|
|
TmsMongoDoc tmsMongoDoc = mongoTemplate.findOne(query, TmsMongoDoc.class);
|
|
TmsMongoDoc tmsMongoDoc = mongoTemplate.findOne(query, TmsMongoDoc.class);
|
|
@@ -289,8 +295,8 @@ public class CommonServiceImpl implements CommonService {
|
|
|
return Collections.EMPTY_LIST;
|
|
return Collections.EMPTY_LIST;
|
|
|
}
|
|
}
|
|
|
Criteria criteria = Criteria.where("clientId").is(truckSimCard.getClientId());
|
|
Criteria criteria = Criteria.where("clientId").is(truckSimCard.getClientId());
|
|
|
- criteria.andOperator(Criteria.where("dateTime").gt(startDate));
|
|
|
|
|
- criteria.andOperator(Criteria.where("dateTime").lt(endDate));
|
|
|
|
|
|
|
+ criteria.andOperator(Criteria.where("createTime").gt(startDate));
|
|
|
|
|
+ criteria.andOperator(Criteria.where("createTime").lt(endDate));
|
|
|
Query query = new Query(criteria);
|
|
Query query = new Query(criteria);
|
|
|
List<TmsMongoDoc> tmsMongoDocs = mongoTemplate.find(query, TmsMongoDoc.class);
|
|
List<TmsMongoDoc> tmsMongoDocs = mongoTemplate.find(query, TmsMongoDoc.class);
|
|
|
List<String> result = new ArrayList<>();
|
|
List<String> result = new ArrayList<>();
|
|
@@ -300,6 +306,7 @@ public class CommonServiceImpl implements CommonService {
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
public String longitudeToAddress(float lat, float lng) {
|
|
public String longitudeToAddress(float lat, float lng) {
|
|
|
//拼接请求路径
|
|
//拼接请求路径
|
|
|
String url = BAIDUMAP_URL + "&ak=" + BAIDUMAP_AK + "&location=" + lat + "," + lng;
|
|
String url = BAIDUMAP_URL + "&ak=" + BAIDUMAP_AK + "&location=" + lat + "," + lng;
|
|
@@ -311,35 +318,35 @@ public class CommonServiceImpl implements CommonService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static String doGet(String url) {
|
|
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();
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ //创建一个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;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|