|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
package com.zilber.boot.module.vehicle.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ArrayUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
|
import com.zilber.boot.exception.ServiceException; |
|
|
|
|
import com.zilber.boot.module.vehicle.constant.Constant; |
|
|
|
@ -14,16 +13,13 @@ import com.zilber.boot.utils.StringUtils; |
|
|
|
|
import com.zilber.boot.utils.page.PageUtils; |
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.net.HttpURLConnection; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
import java.util.function.Predicate; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
import static com.zilber.boot.module.vehicle.util.http.HttpUtils.sendGet; |
|
|
|
@ -67,38 +63,38 @@ public class TourRunServiceImpl |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public PageUtils list(DevicePR pr) { |
|
|
|
|
String token = token(); |
|
|
|
|
|
|
|
|
|
Map<String, String> paramMap = paramMap(Method.LIST.getCode()); |
|
|
|
|
|
|
|
|
|
// 私有参数
|
|
|
|
|
paramMap.put("access_token", token); |
|
|
|
|
paramMap.put("target", properties.getTourRunAccount()); |
|
|
|
|
// 计算签名
|
|
|
|
|
String sign = ""; |
|
|
|
|
try { |
|
|
|
|
sign = SignUtils.signTopRequest(paramMap, properties.getAppSecret(), Constant.MD5); |
|
|
|
|
paramMap.put("sign", sign); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
//调用com/zilber/boot/module/vehicle/util/http/HttpUtils方法
|
|
|
|
|
JSONObject jsonObject = sendPost(properties.getOpenapiUrl(), headerMap(), paramMap); |
|
|
|
|
//初始化列表
|
|
|
|
|
// List<JSONObject> resultList = null;
|
|
|
|
|
// if ( jsonObject != null) {
|
|
|
|
|
// if ( !jsonObject.get("code").toString().equals("0"))
|
|
|
|
|
// {
|
|
|
|
|
// throw new ServiceException(jsonObject.get("message").toString());
|
|
|
|
|
// }
|
|
|
|
|
// resultList = jsonObject.getList("result", JSONObject.class);
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// throw new ServiceException("列表获取失败");
|
|
|
|
|
// String token = token();
|
|
|
|
|
//
|
|
|
|
|
// Map<String, String> paramMap = paramMap(Method.LIST.getCode());
|
|
|
|
|
//
|
|
|
|
|
// // 私有参数
|
|
|
|
|
// paramMap.put("access_token", token);
|
|
|
|
|
// paramMap.put("target", properties.getTourRunAccount());
|
|
|
|
|
// // 计算签名
|
|
|
|
|
// String sign = "";
|
|
|
|
|
// try {
|
|
|
|
|
// sign = SignUtils.signTopRequest(paramMap, properties.getAppSecret(), Constant.MD5);
|
|
|
|
|
// paramMap.put("sign", sign);
|
|
|
|
|
// } catch (IOException e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
List<JSONObject> resultList = handleResult(jsonObject, JSONObject.class, "获取列表失败"); |
|
|
|
|
if (CollectionUtils.isNotEmpty(resultList)) |
|
|
|
|
{ |
|
|
|
|
// //调用com/zilber/boot/module/vehicle/util/http/HttpUtils方法
|
|
|
|
|
// JSONObject jsonObject = sendPost(properties.getOpenapiUrl(), headerMap(), paramMap);
|
|
|
|
|
// //初始化列表
|
|
|
|
|
//// List<JSONObject> resultList = null;
|
|
|
|
|
//// if ( jsonObject != null) {
|
|
|
|
|
//// if ( !jsonObject.get("code").toString().equals("0"))
|
|
|
|
|
//// {
|
|
|
|
|
//// throw new ServiceException(jsonObject.get("message").toString());
|
|
|
|
|
//// }
|
|
|
|
|
//// resultList = jsonObject.getList("result", JSONObject.class);
|
|
|
|
|
//// }
|
|
|
|
|
//// else {
|
|
|
|
|
//// throw new ServiceException("列表获取失败");
|
|
|
|
|
//// }
|
|
|
|
|
// List<JSONObject> resultList = handleResult(jsonObject, JSONObject.class, "获取列表失败");
|
|
|
|
|
List<JSONObject> resultList = resultList(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(resultList)) { |
|
|
|
|
List<JSONObject> handledList = resultList.stream() |
|
|
|
|
.filter(jo -> jo.get("mcTypeUseScope").toString().equals(pr.getScope())) |
|
|
|
|
.sorted((o1, o2) -> StringUtils.compare(o1.get("imei").toString(), o2.get("imei").toString())) |
|
|
|
@ -116,6 +112,31 @@ public class TourRunServiceImpl |
|
|
|
|
return new PageUtils(new ArrayList<>(), 0, pr.getPageSize(), pr.getPageNo()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<String, Integer> stat() { |
|
|
|
|
Map<String, Integer> resultMap = new HashMap<>(2); |
|
|
|
|
List<JSONObject> resultList = resultList(); |
|
|
|
|
if (CollectionUtils.isNotEmpty(resultList)) { |
|
|
|
|
Map<String, List<JSONObject>> scopeMap |
|
|
|
|
= resultList.stream() |
|
|
|
|
.collect(Collectors.groupingBy(jo -> jo.get("mcTypeUseScope").toString())); |
|
|
|
|
for (String scope: Constant.SCOPES) { |
|
|
|
|
List<JSONObject> jsonObjects = scopeMap.get(scope); |
|
|
|
|
if ( CollectionUtils.isNotEmpty(jsonObjects)) { |
|
|
|
|
resultMap.put(scope, jsonObjects.size()); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
resultMap.put(scope, 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return resultMap; |
|
|
|
|
} |
|
|
|
|
for (String scope: Constant.SCOPES) { |
|
|
|
|
resultMap.put(scope, 0); |
|
|
|
|
} |
|
|
|
|
return resultMap; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//https://openh5.aichezaixian.com/?token=XXX&imei=AAA&appKey=BBB&activeTab=CCC
|
|
|
|
|
@Override |
|
|
|
|
public String h5(String tabType, String imei) { |
|
|
|
@ -201,6 +222,39 @@ public class TourRunServiceImpl |
|
|
|
|
return paramMap; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<JSONObject> resultList() { |
|
|
|
|
String token = token(); |
|
|
|
|
|
|
|
|
|
Map<String, String> paramMap = paramMap(Method.LIST.getCode()); |
|
|
|
|
|
|
|
|
|
// 私有参数
|
|
|
|
|
paramMap.put("access_token", token); |
|
|
|
|
paramMap.put("target", properties.getTourRunAccount()); |
|
|
|
|
// 计算签名
|
|
|
|
|
String sign = ""; |
|
|
|
|
try { |
|
|
|
|
sign = SignUtils.signTopRequest(paramMap, properties.getAppSecret(), Constant.MD5); |
|
|
|
|
paramMap.put("sign", sign); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
//调用com/zilber/boot/module/vehicle/util/http/HttpUtils方法
|
|
|
|
|
JSONObject jsonObject = sendPost(properties.getOpenapiUrl(), headerMap(), paramMap); |
|
|
|
|
//初始化列表
|
|
|
|
|
// List<JSONObject> resultList = null;
|
|
|
|
|
// if ( jsonObject != null) {
|
|
|
|
|
// if ( !jsonObject.get("code").toString().equals("0"))
|
|
|
|
|
// {
|
|
|
|
|
// throw new ServiceException(jsonObject.get("message").toString());
|
|
|
|
|
// }
|
|
|
|
|
// resultList = jsonObject.getList("result", JSONObject.class);
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// throw new ServiceException("列表获取失败");
|
|
|
|
|
// }
|
|
|
|
|
return handleResult(jsonObject, JSONObject.class, "获取列表失败"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理接收到的返回结果(列表) |
|
|
|
|
* @param result 返回结果 |
|
|
|
|