Commit f48c12fa authored by zhouzihao's avatar zhouzihao

dev-查询车轨迹点的接口

parent e27fa15c
......@@ -51,7 +51,8 @@ public class Tmp {
case1 = new DayReportDecorator(case1);
// 查询车轨迹接口
case1 = new CarLocusPageDecorator(case1);
// 查询车轨迹点 接口
case1 = new CarLocausPointListDecorator(case1);
case1 = new CarInfoDecorator(case1);
case1 = new CarDetectDecorator(case1);
case1 = new CarStatusDecorator(case1);
......
package com.vandyo.sentry.core.cases;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.vandyo.sentry.core.dto.ErrStatus;
import com.vandyo.sentry.core.dto.Res;
import com.vandyo.sentry.core.tools.Signature;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
* 查询车轨迹点的接口
*/
public class CarLocausPointListDecorator extends CaseDecorator{
private static final String CarLocausPointListUrl = "/car/api/locus/points/list";
public CarLocausPointListDecorator(Case aCase) {
super(aCase);
}
@Override
public Res<Map<String, String>> check() {
Res<Map<String, String>> oldRes = super.check();
if (oldRes.getSuccess()) {
Map<String, String> carMap = oldRes.getData();
Res<Map<String, String>> newRes = new Res<>();
newRes.setSId(oldRes.getSId());
newRes.setUId(oldRes.getUId());
if (Objects.isNull(carMap) || !carMap.containsKey("cid") || !carMap.containsKey("traceid")) {
newRes.setIgnore(true);
newRes.setStatus(ErrStatus.ErrUnexpected);
newRes.setSuccess(false);
} else {
String cid = carMap.get("cid");
Map<String, String> paramMap = new HashMap<>();
paramMap.put("cid", cid);
paramMap.put("uid", oldRes.getUId());
paramMap.put("traceid",carMap.get("traceid"));
paramMap.put("start",carMap.get("sti"));
paramMap.put("end",carMap.get("eti"));
// paramMap.put("start", String.valueOf(System.currentTimeMillis() / 1000 - 24 * 60 * 60));
// paramMap.put("end",String.valueOf(System.currentTimeMillis()/1000));
try {
HttpResponse response = HttpRequest.get(
Signature.host + CarLocausPointListUrl + "?"
+ Signature.getUrlParamsByMap(Signature.sign(paramMap, oldRes.getSId()))
).execute();
if (response.isOk()) {
JSONObject jsonObject = JSONUtil.parseObj(response.body());
// JSONArray list = jsonObject.getJSONArray("result");
// if (list.size() > 0) {
// JSONObject result = list.getJSONObject(0);
// carMap.put("traceid",result.getStr("traceid"));
// }
newRes.setData(carMap);
newRes.setSuccess(true);
} else {
newRes.setKey(CarLocausPointListUrl);
newRes.setStatus(Signature.matchStatus(response.getStatus()));
newRes.setSuccess(false);
}
} catch (Exception e) {
newRes.setKey(CarLocausPointListUrl);
newRes.setStatus(ErrStatus.ErrUnknown);
newRes.setSuccess(false);
}
}
return newRes;
} else {
oldRes.setIgnore(true);
return oldRes;
}
}
}
......@@ -55,6 +55,8 @@ public class CarLocusPageDecorator extends CaseDecorator {
if (list.size() > 0) {
JSONObject result = list.getJSONObject(0);
carMap.put("traceid",result.getStr("traceid"));
carMap.put("sti",result.getStr("sti"));
carMap.put("eti",result.getStr("eti"));
}
newRes.setData(carMap);
newRes.setSuccess(true);
......
......@@ -15,6 +15,7 @@ checkmeta:
"[/user/info/get]": 获取用户信息
"[/car/api/reprt/reportDay/get]": 车日报
"[/car/api/locus/list/page]": 轨迹查询接口
"[/car/api/locus/points/list]": 车辆轨迹点接口
test: 测试接口
timeMap:
"[/car/my_car/info]": 6
......@@ -25,6 +26,7 @@ checkmeta:
"[/user/info/get]": 6
"[/car/api/reprt/reportDay/get]": 6
"[/car/api/locus/list/page]": 6
"[/car/api/locus/points/list]": 6
test: 2
emailList[0]: "1042181618@qq.com"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment