liukangdong
2025-03-11 89ae52af69bc71691f284a133f83f99a33ebca57
Merge branch 'master' of http://139.186.142.91:10010/r/productDev/dmvisit
已修改1个文件
16 ■■■■■ 文件已修改
server/visits/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKCarOpenService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/visits/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKCarOpenService.java
@@ -16,6 +16,7 @@
    import com.doumee.core.utils.DateUtil;
    import com.google.common.collect.Maps;
    import org.apache.commons.lang3.StringUtils;
    import org.apache.http.client.config.RequestConfig;
    import org.apache.http.client.methods.CloseableHttpResponse;
    import org.apache.http.client.methods.HttpGet;
    import org.apache.http.impl.client.CloseableHttpClient;
@@ -52,7 +53,6 @@
    public static String sign(String accessSecret, TreeMap<String, String> params, HttpMethod method) throws Exception {
        String stringToSign = getStringToSign(params, method);
        System.out.println("StringToSign = [" + stringToSign + "]");
        javax.crypto.Mac mac = javax.crypto.Mac.getInstance("HmacSHA1");
        mac.init(new javax.crypto.spec.SecretKeySpec(accessSecret.getBytes(DEFAULT_CHARSET), "HmacSHA1"));
        byte[] signData = mac.doFinal(stringToSign.getBytes(DEFAULT_CHARSET));
@@ -158,6 +158,7 @@
        Collections.sort(list, (o1, o2) -> {
            return (int) (o2.getTimeStamp() - o1.getTimeStamp()); //按时间倒序
        });
        System.out.println(JSONObject.toJSONString(list));
        return list;
    }
@@ -172,6 +173,8 @@
    public static String sendRequest(String url,TreeMap<String, String> map){
        try {
            map.put("random", System.currentTimeMillis()+"");
            StringBuilder sortQueryStringTmp = new StringBuilder();
            for(Map.Entry<String, String> entry : map.entrySet()){
                sortQueryStringTmp
@@ -183,13 +186,19 @@
            //与下方的HttpGet对应,采用的是HttpMethod.GET
            String sign = sign(ACCESS_SECRET + "&", map, HttpMethod.GET);
            url += "?Signature=" + specialUrlEncode(sign) + sortQueryStringTmp.toString();
            RequestConfig requestConfig = RequestConfig.custom()
                    .setSocketTimeout(5000)  // 设置读取超时时间(单位:毫秒)
                    .setConnectTimeout(5000) // 设置连接超时时间(单位:毫秒)
                    .build();
            CloseableHttpClient httpClient = HttpClientBuilder.create().build();
            //与上方的HttpMethod.GET对应,使用HttpGet
            HttpGet httpDelete = new HttpGet(url);
            httpDelete.setConfig(requestConfig);
            CloseableHttpResponse response = httpClient.execute(httpDelete);
            return  EntityUtils.toString(response.getEntity());
        }catch (Exception e){
            e.printStackTrace();
            System.err.println(url);
        }
        return null;
@@ -224,6 +233,7 @@
        return  null;
    }
    public static  CarsGpsResponse   getLatestGpsInfo(String deviceCode)   {
        try {
        String url = BASE_URL + "gps/latest/";
        TreeMap<String, String> BASE_PARAMS = getBaseParams();
        BASE_PARAMS.put("deviceCode", deviceCode);//设备型号秘钥
@@ -234,6 +244,10 @@
        if(result!=null && Constants.equalsInteger(result.getStatus(),0)){
            return  result.getData();
        }
        }catch (Exception e){
            e.printStackTrace();
        }
        return  null;
    }
    public static   Map<String,Integer>   getDeviceStatusList(List<String> code)   {