|
|
@@ -40,6 +40,8 @@ public class ZHBDUtil {
|
|
|
private static final String TOKEN_URL = "https://zhbdgps.cn/video/webapi/user/login";
|
|
|
// 日报表明细
|
|
|
private static final String LOCATION_URL = "https://zhbdgps.cn/video/webapi/report/fuel/daily/detail";
|
|
|
+ // 日报表统计
|
|
|
+ private static final String DAILY_FUEL_STATISTICS_URL = "https://zhbdgps.cn/video/webapi/report/fuel/daily/statistics";
|
|
|
// 查询位置(车牌号)
|
|
|
private static final String GET_LOCATION_USE_PLATES_URL = "https://zhbdgps.cn/video/webapi/location/get-location-use-plates";
|
|
|
private static final String parameter = "lng,lat,today_distance,distance,todayoil,totaloil,online,oil1,oil2,oil3,oil4,vehicle_name";
|
|
|
@@ -57,7 +59,8 @@ public class ZHBDUtil {
|
|
|
*/
|
|
|
public Map<Integer, IotDeviceCarFuelVO> carFuels(String carIds, String startDate, String endDate) throws Exception {
|
|
|
String zhbdtoken = redisTemplate.opsForValue().get("zhbdtoken");
|
|
|
- if (StrUtil.isBlank(zhbdtoken)) {
|
|
|
+ String clientId = redisTemplate.opsForValue().get("zhdbClientId");
|
|
|
+ if (StrUtil.isBlank(zhbdtoken) || StrUtil.isBlank(clientId)) {
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
map.put("id", ID);
|
|
|
map.put("secret", SECRET);
|
|
|
@@ -65,12 +68,15 @@ public class ZHBDUtil {
|
|
|
if (Objects.nonNull(entries)&&entries.get("code") != null&&Integer.parseInt(String.valueOf(entries.get("code")))==200) {
|
|
|
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(entries.get("data")));
|
|
|
zhbdtoken = jsonObject.get("token").toString();
|
|
|
+ // 缓存 client_id
|
|
|
+ clientId = jsonObject.get("client_id").toString();
|
|
|
redisTemplate.opsForValue().set("zhbdtoken", zhbdtoken, 80000, TimeUnit.SECONDS);
|
|
|
+ redisTemplate.opsForValue().set("zhdbClientId", clientId, 80000, TimeUnit.SECONDS);
|
|
|
}
|
|
|
}
|
|
|
// 构建请求JSON
|
|
|
Map<String, Object> requestMap = new HashMap<>();
|
|
|
- requestMap.put("client_ids", ID);
|
|
|
+ requestMap.put("client_ids", clientId);
|
|
|
requestMap.put("vehicle_ids", carIds);
|
|
|
requestMap.put("begin_time", startDate);
|
|
|
requestMap.put("end_time", endDate);
|
|
|
@@ -80,7 +86,7 @@ public class ZHBDUtil {
|
|
|
Map<Integer, IotDeviceCarFuelVO> carOilFuelPair = new HashMap<>();
|
|
|
if (StrUtil.isNotBlank(zhbdtoken)) {
|
|
|
try {
|
|
|
- String jsonResponse = sendPostRequest(requestMap, zhbdtoken, LOCATION_URL);
|
|
|
+ String jsonResponse = sendPostRequest(requestMap, zhbdtoken, DAILY_FUEL_STATISTICS_URL);
|
|
|
ApiOilResponse response = parseResponse(jsonResponse);
|
|
|
if (response != null && response.code == 200) {
|
|
|
List<Map<String, Object>> details = response.data.pageList;
|
|
|
@@ -90,11 +96,11 @@ public class ZHBDUtil {
|
|
|
Integer carId = Integer.valueOf(detail.get("vehicle_id").toString());
|
|
|
Double oil = Double.valueOf(detail.get("oil").toString());
|
|
|
String vehicleName = String.valueOf(detail.get("vehicle_name"));
|
|
|
- String createtime = String.valueOf(detail.get("createtime"));
|
|
|
+ // String createtime = String.valueOf(detail.get("createtime"));
|
|
|
carFuel.setVehicleId(carId);
|
|
|
carFuel.setVehicleName(vehicleName);
|
|
|
carFuel.setOil(oil);
|
|
|
- carFuel.setCreatetime(createtime);
|
|
|
+ // carFuel.setCreatetime(createtime);
|
|
|
carOilFuelPair.put(carId, carFuel);
|
|
|
}
|
|
|
}
|