Commit c76556a2 by yanHeng

[修改] 轨迹获取

parent dc907b22
......@@ -60,7 +60,7 @@ public class IotPlatformUtils {
/**
* 历史轨迹URL
*/
private static final String HISTORY_URL = GPS_WU_LING_DOMAIN_API +"/api/v1/gateways/%1$s/metrics";
private static final String HISTORY_URL = GPS_WU_LING_DOMAIN_API +"api/v1/gateways/%1$s/metrics";
//跟踪url
......@@ -184,7 +184,7 @@ public class IotPlatformUtils {
}
String accessToken = postStr.getString("access_token");
if (accessToken != null) {
RedisUtils.getInstance().set(getGpsWuLingTokenRedisKey(CLIET_ID, CLIENT_SECRET),accessToken,postStr.getInt("expires_in")-3);
RedisUtils.getInstance().set(getGpsWuLingTokenRedisKey(CLIET_ID, CLIENT_SECRET),accessToken,postStr.getInt("expires_in")-30);
map.put("status", 0);
map.put("data", accessToken);
return map;
......@@ -246,4 +246,28 @@ public class IotPlatformUtils {
}
return datas;
}
public static String findGatewayId(String deviceNumber, String token) {
if(token==null || "".equals(token)){
return "token为空";
}
if("".equals(deviceNumber)){
return "设备序列号为空";
}
String param = "serialNumber=" + deviceNumber;
//根据设备序号 查询网关id
String findGatewayId = HttpSendUtil.sendGet(FIND_GATEWAY_ID_URL,param ,token);
JSONObject findStr = new JSONObject(findGatewayId);
int findCode = findStr.getInt("code");
String id = "";
if (20000==(findCode)) {
id = findStr.get("data").toString();
}else{
id = findStr.get("message").toString();
}
if("".equals(id)){
return null;
}
return id;
}
}
......@@ -4,6 +4,7 @@ package com.xyst.dinas.camera.web;
import com.beecode.bcp.type.KObject;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.beecode.inz.common.util.IotPlatformUtils;
import com.beecode.util.StringUtils;
import com.xyst.dinas.biz.service.SandMiningAreaService;
import com.xyst.dinas.biz.service.ShipInfoService;
import com.xyst.dinas.camera.entity.RegionalCompanyWatershedCameraTree;
......@@ -107,5 +108,15 @@ public class WatershedCameraPlayController {
}
}
@GetMapping("/findGatewayId")
public ResponseObj findGatewayId(@RequestParam(name = "deviceNumber") String deviceNumber, @RequestParam(name = "token") String token) throws Exception{
String gatewayId = IotPlatformUtils.findGatewayId(deviceNumber,token);
boolean numeric = StringUtils.isNumeric(gatewayId);
if("".equals(gatewayId) || !numeric){
return ResponseObj.error(500,"查询失败",gatewayId);
}
return ResponseObj.response(200,"查询成功", gatewayId );
}
}
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