|
@@ -2,6 +2,7 @@ package com.aidex.common.gps.common;
|
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
import cn.hutool.http.HttpRequest;
|
|
import com.aidex.common.exception.SysException;
|
|
import com.aidex.common.exception.SysException;
|
|
|
|
+import com.aidex.common.utils.StringUtils;
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -18,8 +19,8 @@ public class GpsRequest<T> {
|
|
private GeneratorGspApi generatorGspApi;
|
|
private GeneratorGspApi generatorGspApi;
|
|
|
|
|
|
|
|
|
|
- public List<T> postArray(Map<String,Object> params, JSONObject body, Integer timeOut){
|
|
|
|
- JSONObject res = postRequest(params,body,timeOut);
|
|
|
|
|
|
+ public List<T> postArray(Map<String,Object> params, Integer timeOut){
|
|
|
|
+ JSONObject res = postRequest(params,timeOut);
|
|
Boolean status = res.getBoolean("success");
|
|
Boolean status = res.getBoolean("success");
|
|
Integer code = res.getInteger("errorCode");
|
|
Integer code = res.getInteger("errorCode");
|
|
String msg = res.getString("errorDescribe");
|
|
String msg = res.getString("errorDescribe");
|
|
@@ -27,25 +28,12 @@ public class GpsRequest<T> {
|
|
if(status){
|
|
if(status){
|
|
return (ArrayList<T>) JSONObject.parseObject(res.getString("data"),List.class);
|
|
return (ArrayList<T>) JSONObject.parseObject(res.getString("data"),List.class);
|
|
}
|
|
}
|
|
- throw new SysException(code,msg);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public List<T> postArray(Map<String,Object> params, JSONObject body){
|
|
|
|
- JSONObject res = postRequest(params,body,1000);
|
|
|
|
- Boolean status = res.getBoolean("success");
|
|
|
|
- Integer code = res.getInteger("errorCode");
|
|
|
|
- String msg = res.getString("errorDescribe");
|
|
|
|
-
|
|
|
|
- if(status){
|
|
|
|
- return (ArrayList<T>) JSONObject.parseObject(res.getString("data"),List.class);
|
|
|
|
- }
|
|
|
|
- throw new SysException(code,msg);
|
|
|
|
|
|
+ throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public List<T> postArray(Map<String,Object> params){
|
|
public List<T> postArray(Map<String,Object> params){
|
|
- JSONObject res = postRequest(params,null,1000);
|
|
|
|
|
|
+ JSONObject res = postRequest(params,1000);
|
|
Boolean status = res.getBoolean("success");
|
|
Boolean status = res.getBoolean("success");
|
|
Integer code = res.getInteger("errorCode");
|
|
Integer code = res.getInteger("errorCode");
|
|
String msg = res.getString("errorDescribe");
|
|
String msg = res.getString("errorDescribe");
|
|
@@ -53,26 +41,13 @@ public class GpsRequest<T> {
|
|
if(status){
|
|
if(status){
|
|
return (ArrayList<T>) JSONObject.parseObject(res.getString("data"),List.class);
|
|
return (ArrayList<T>) JSONObject.parseObject(res.getString("data"),List.class);
|
|
}
|
|
}
|
|
- throw new SysException(code,msg);
|
|
|
|
|
|
+ throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public T post(Map<String,Object> params, JSONObject body, Integer timeOut){
|
|
|
|
- JSONObject res = postRequest(params,body,timeOut);
|
|
|
|
- Boolean status = res.getBoolean("success");
|
|
|
|
- Integer code = res.getInteger("errorCode");
|
|
|
|
- String msg = res.getString("errorDescribe");
|
|
|
|
-
|
|
|
|
- if(status){
|
|
|
|
- return (T) JSONObject.parseObject(res.getString("data"), Map.class);
|
|
|
|
- }
|
|
|
|
- throw new SysException(code,msg);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public T post(Map<String,Object> params, JSONObject body){
|
|
|
|
- JSONObject res = postRequest(params,body,1000);
|
|
|
|
|
|
+ public T post(Map<String,Object> params, Integer timeOut){
|
|
|
|
+ JSONObject res = postRequest(params,timeOut);
|
|
Boolean status = res.getBoolean("success");
|
|
Boolean status = res.getBoolean("success");
|
|
Integer code = res.getInteger("errorCode");
|
|
Integer code = res.getInteger("errorCode");
|
|
String msg = res.getString("errorDescribe");
|
|
String msg = res.getString("errorDescribe");
|
|
@@ -80,12 +55,12 @@ public class GpsRequest<T> {
|
|
if(status){
|
|
if(status){
|
|
return (T) JSONObject.parseObject(res.getString("data"), Map.class);
|
|
return (T) JSONObject.parseObject(res.getString("data"), Map.class);
|
|
}
|
|
}
|
|
- throw new SysException(code,msg);
|
|
|
|
|
|
+ throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public T post(Map<String,Object> params){
|
|
public T post(Map<String,Object> params){
|
|
- JSONObject res = postRequest(params,null,1000);
|
|
|
|
|
|
+ JSONObject res = postRequest(params,1000);
|
|
Boolean status = res.getBoolean("success");
|
|
Boolean status = res.getBoolean("success");
|
|
Integer code = res.getInteger("errorCode");
|
|
Integer code = res.getInteger("errorCode");
|
|
String msg = res.getString("errorDescribe");
|
|
String msg = res.getString("errorDescribe");
|
|
@@ -93,12 +68,12 @@ public class GpsRequest<T> {
|
|
if(status){
|
|
if(status){
|
|
return (T) JSONObject.parseObject(res.getString("data"), Map.class);
|
|
return (T) JSONObject.parseObject(res.getString("data"), Map.class);
|
|
}
|
|
}
|
|
- throw new SysException(code,msg);
|
|
|
|
|
|
+ throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- public List<T> getArray(Map<String,Object> params, JSONObject body, Integer timeOut){
|
|
|
|
- JSONObject res = postRequest(params,body,timeOut);
|
|
|
|
|
|
+ public List<T> getArray(Map<String,Object> params, Integer timeOut){
|
|
|
|
+ JSONObject res = postRequest(params,timeOut);
|
|
Boolean status = res.getBoolean("success");
|
|
Boolean status = res.getBoolean("success");
|
|
Integer code = res.getInteger("errorCode");
|
|
Integer code = res.getInteger("errorCode");
|
|
String msg = res.getString("errorDescribe");
|
|
String msg = res.getString("errorDescribe");
|
|
@@ -106,25 +81,12 @@ public class GpsRequest<T> {
|
|
if(status){
|
|
if(status){
|
|
return (ArrayList<T>) JSONObject.parseObject(res.getString("data"),List.class);
|
|
return (ArrayList<T>) JSONObject.parseObject(res.getString("data"),List.class);
|
|
}
|
|
}
|
|
- throw new SysException(code,msg);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public List<T> getArray(Map<String,Object> params, JSONObject body){
|
|
|
|
- JSONObject res = postRequest(params,body,1000);
|
|
|
|
- Boolean status = res.getBoolean("success");
|
|
|
|
- Integer code = res.getInteger("errorCode");
|
|
|
|
- String msg = res.getString("errorDescribe");
|
|
|
|
-
|
|
|
|
- if(status){
|
|
|
|
- return (ArrayList<T>) JSONObject.parseObject(res.getString("data"),List.class);
|
|
|
|
- }
|
|
|
|
- throw new SysException(code,msg);
|
|
|
|
|
|
+ throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public List<T> getArray(Map<String,Object> params){
|
|
public List<T> getArray(Map<String,Object> params){
|
|
- JSONObject res = postRequest(params,null,1000);
|
|
|
|
|
|
+ JSONObject res = postRequest(params,1000);
|
|
Boolean status = res.getBoolean("success");
|
|
Boolean status = res.getBoolean("success");
|
|
Integer code = res.getInteger("errorCode");
|
|
Integer code = res.getInteger("errorCode");
|
|
String msg = res.getString("errorDescribe");
|
|
String msg = res.getString("errorDescribe");
|
|
@@ -132,26 +94,13 @@ public class GpsRequest<T> {
|
|
if(status){
|
|
if(status){
|
|
return (ArrayList<T>) JSONObject.parseObject(res.getString("data"),List.class);
|
|
return (ArrayList<T>) JSONObject.parseObject(res.getString("data"),List.class);
|
|
}
|
|
}
|
|
- throw new SysException(code,msg);
|
|
|
|
|
|
+ throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public T get(Map<String,Object> params, JSONObject body, Integer timeOut){
|
|
|
|
- JSONObject res = postRequest(params,body,timeOut);
|
|
|
|
- Boolean status = res.getBoolean("success");
|
|
|
|
- Integer code = res.getInteger("errorCode");
|
|
|
|
- String msg = res.getString("errorDescribe");
|
|
|
|
-
|
|
|
|
- if(status){
|
|
|
|
- return (T) JSONObject.parseObject(res.getString("data"), Map.class);
|
|
|
|
- }
|
|
|
|
- throw new SysException(code,msg);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public T get(Map<String,Object> params, JSONObject body){
|
|
|
|
- JSONObject res = postRequest(params,body,1000);
|
|
|
|
|
|
+ public T get(Map<String,Object> params, Integer timeOut){
|
|
|
|
+ JSONObject res = postRequest(params,timeOut);
|
|
Boolean status = res.getBoolean("success");
|
|
Boolean status = res.getBoolean("success");
|
|
Integer code = res.getInteger("errorCode");
|
|
Integer code = res.getInteger("errorCode");
|
|
String msg = res.getString("errorDescribe");
|
|
String msg = res.getString("errorDescribe");
|
|
@@ -159,12 +108,12 @@ public class GpsRequest<T> {
|
|
if(status){
|
|
if(status){
|
|
return (T) JSONObject.parseObject(res.getString("data"), Map.class);
|
|
return (T) JSONObject.parseObject(res.getString("data"), Map.class);
|
|
}
|
|
}
|
|
- throw new SysException(code,msg);
|
|
|
|
|
|
+ throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public T get(Map<String,Object> params){
|
|
public T get(Map<String,Object> params){
|
|
- JSONObject res = postRequest(params,null,1000);
|
|
|
|
|
|
+ JSONObject res = postRequest(params,1000);
|
|
Boolean status = res.getBoolean("success");
|
|
Boolean status = res.getBoolean("success");
|
|
Integer code = res.getInteger("errorCode");
|
|
Integer code = res.getInteger("errorCode");
|
|
String msg = res.getString("errorDescribe");
|
|
String msg = res.getString("errorDescribe");
|
|
@@ -172,19 +121,19 @@ public class GpsRequest<T> {
|
|
if(status){
|
|
if(status){
|
|
return (T) JSONObject.parseObject(res.getString("data"), Map.class);
|
|
return (T) JSONObject.parseObject(res.getString("data"), Map.class);
|
|
}
|
|
}
|
|
- throw new SysException(code,msg);
|
|
|
|
|
|
+ throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- private JSONObject postRequest(Map<String,Object> params, JSONObject body, Integer timeOut){
|
|
|
|
|
|
+ private JSONObject postRequest(Map<String,Object> params, Integer timeOut){
|
|
String api = generatorGspApi.GeneratorApi();
|
|
String api = generatorGspApi.GeneratorApi();
|
|
- String res = HttpRequest.post(api).form(params).body(body.toString()).timeout(timeOut).execute().body();
|
|
|
|
|
|
+ String res = HttpRequest.post(api).form(params).timeout(timeOut).execute().body();
|
|
return JSON.parseObject(res);
|
|
return JSON.parseObject(res);
|
|
}
|
|
}
|
|
|
|
|
|
- private JSONObject getRequest(Map<String,Object> params, JSONObject body, Integer timeOut){
|
|
|
|
|
|
+ private JSONObject getRequest(Map<String,Object> params, Integer timeOut){
|
|
String api = generatorGspApi.GeneratorApi();
|
|
String api = generatorGspApi.GeneratorApi();
|
|
- String res = HttpRequest.get(api).form(params).body(body.toString()).timeout(timeOut).execute().body();
|
|
|
|
|
|
+ String res = HttpRequest.get(api).form(params).timeout(timeOut).execute().body();
|
|
return JSON.parseObject(res);
|
|
return JSON.parseObject(res);
|
|
}
|
|
}
|
|
}
|
|
}
|