|
@@ -20,11 +20,14 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.http.HttpEntity;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -70,26 +73,30 @@ public class ZhbdJob implements JobHandler {
|
|
|
|
|
|
// 1. 设置请求头
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
- headers.setContentType(MediaType.APPLICATION_JSON); // 表单类型
|
|
|
+// headers.setContentType(MediaType.APPLICATION_JSON); // 表单类型
|
|
|
// 或者设置为 JSON 类型:headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
headers.add("Authorization", finalZhbdtoken); // 添加自定义头信息
|
|
|
+// headers.addHeader("User-Agent", "Apifox/1.0.0 (https://apifox.com)")
|
|
|
+ headers.add("Content-Type", "application/json");
|
|
|
+ headers.add("Accept", "*/*");
|
|
|
+ headers.add("Host", "zhbdgps.cn");
|
|
|
+ headers.add("Connection", "keep-alive");
|
|
|
|
|
|
// 2. 设置请求体参数
|
|
|
// 方式一:表单参数(对应 MediaType.APPLICATION_FORM_URLENCODED)
|
|
|
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
|
|
- params.add("car_ids", carIds);
|
|
|
+
|
|
|
+ params.add("car_ids", "8203,"+carIds+",8203");
|
|
|
// 3. 组合请求头和请求体
|
|
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(params, headers);
|
|
|
- JSONObject entries = restTemplate.postForObject(LOCATION_URL, requestEntity, JSONObject.class);
|
|
|
+ String result = restTemplate.postForObject(LOCATION_URL, requestEntity, String.class);
|
|
|
+ JSONObject entries = JSON.parseObject(result,JSONObject.class);
|
|
|
if (Objects.nonNull(entries)&&entries.get("code") != null&&Integer.parseInt(String.valueOf(entries.get("code")))==200) {
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(entries.get("data").toString());
|
|
|
if (Objects.nonNull(jsonObject)) {
|
|
|
List<Map> maps = JSON.parseArray(jsonObject.get("data").toString(), Map.class);
|
|
|
for (Map<String,Object> location : maps) {
|
|
|
String vehicleId = String.valueOf(location.get("vehicle_id"));
|
|
|
- if ("8203".equals(vehicleId)) {
|
|
|
- System.out.println("33333333333333333333333333333333"+location.get("vehicle_name"));
|
|
|
- }
|
|
|
zhbdList.stream().filter(e -> vehicleId.equals(e.getCarId())).findFirst().ifPresent(e -> {
|
|
|
TDLogDO logDO = new TDLogDO();
|
|
|
List<DeviceLogDO> list = new ArrayList<>();
|