|
@@ -4,7 +4,9 @@ import cn.hutool.http.HttpRequest;
|
|
|
import com.aidex.common.exception.SysException;
|
|
|
import com.aidex.common.utils.StringUtils;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.alibaba.fastjson2.TypeReference;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -13,113 +15,113 @@ import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Component
|
|
|
-public class GpsRequest<T> {
|
|
|
+public class GpsRequest {
|
|
|
|
|
|
@Autowired
|
|
|
private GeneratorGspApi generatorGspApi;
|
|
|
|
|
|
|
|
|
- public List<T> postArray(Map<String,Object> params, Integer timeOut){
|
|
|
+ public JSONArray postArray(Map<String,Object> params, Integer timeOut){
|
|
|
JSONObject res = postRequest(params,timeOut);
|
|
|
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);
|
|
|
+ return res.getJSONArray("data");
|
|
|
}
|
|
|
throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
- public List<T> postArray(Map<String,Object> params){
|
|
|
+ public JSONArray postArray(Map<String,Object> params){
|
|
|
JSONObject res = postRequest(params,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);
|
|
|
+ return res.getJSONArray("data");
|
|
|
}
|
|
|
throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
- public T post(Map<String,Object> params, Integer timeOut){
|
|
|
+ public JSONObject post(Map<String,Object> params, Integer timeOut){
|
|
|
JSONObject res = postRequest(params,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);
|
|
|
+ return res.getJSONObject("data");
|
|
|
}
|
|
|
throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
- public T post(Map<String,Object> params){
|
|
|
+ public JSONObject post(Map<String,Object> params){
|
|
|
JSONObject res = postRequest(params,1000);
|
|
|
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);
|
|
|
+ return res.getJSONObject("data");
|
|
|
}
|
|
|
throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
- public List<T> getArray(Map<String,Object> params, Integer timeOut){
|
|
|
+ public JSONArray getArray(Map<String,Object> params, Integer timeOut){
|
|
|
JSONObject res = postRequest(params,timeOut);
|
|
|
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);
|
|
|
+ return res.getJSONArray("data");
|
|
|
}
|
|
|
throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
- public List<T> getArray(Map<String,Object> params){
|
|
|
+ public JSONArray getArray(Map<String,Object> params){
|
|
|
JSONObject res = postRequest(params,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);
|
|
|
+ return res.getJSONArray("data");
|
|
|
}
|
|
|
throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
- public T get(Map<String,Object> params, Integer timeOut){
|
|
|
+ public JSONObject get(Map<String,Object> params, Integer timeOut){
|
|
|
JSONObject res = postRequest(params,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);
|
|
|
+ return res.getJSONObject("data");
|
|
|
}
|
|
|
throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
- public T get(Map<String,Object> params){
|
|
|
+ public JSONObject get(Map<String,Object> params){
|
|
|
JSONObject res = postRequest(params,1000);
|
|
|
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);
|
|
|
+ return res.getJSONObject("data");
|
|
|
}
|
|
|
throw new SysException(code,"GPS数据获取错误:"+msg);
|
|
|
|