|
@@ -47,10 +47,11 @@ public class DeviceController extends BaseController{
|
|
|
|
|
|
@Autowired
|
|
|
ZnylYjzcxxServiceImpl znylYjzcxxService;
|
|
|
-// public static void main(String args[]) throws Exception {
|
|
|
+ public static void main(String args[]) throws Exception {
|
|
|
// getToken("18946560909","123456");
|
|
|
// getAlarmEventLsit("866756510181548","20220419","20220519");
|
|
|
-// }
|
|
|
+// deviceSearch();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
// 推送数据格式
|
|
@@ -218,4 +219,52 @@ public class DeviceController extends BaseController{
|
|
|
return AjaxResult.success("暂无数据");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @GetMapping("/getAlarmEventLsit")
|
|
|
+ public static AjaxResult deviceSearch() throws Exception {
|
|
|
+ String url = "http://www.bignbiot.com/api/device/search";
|
|
|
+// {
|
|
|
+// "CompanyLimit": 0, //0:包含下级单位;1:仅本单位 (默认是0)
|
|
|
+// "PageIndex": 1, //查询页号
|
|
|
+// "PageSize": "20",//查询也大小
|
|
|
+// }
|
|
|
+ JSONObject query = new JSONObject();
|
|
|
+ query.put("CompanyLimit",0);
|
|
|
+ query.put("PageIndex",1);
|
|
|
+ query.put("PageSize",20);
|
|
|
+ String token = getToken("18946560909","123456");
|
|
|
+ String Authorization = "Bearer "+token;
|
|
|
+ CloseableHttpClient httpClient = null;
|
|
|
+ HttpResponse response = null;
|
|
|
+ httpClient = HttpClientBuilder.create().build();
|
|
|
+ // 构造请求的URL,具体参考文档中心->使能平台API文档中的请求地址和访问路径
|
|
|
+ URIBuilder uriBuilder = new URIBuilder();
|
|
|
+ uriBuilder.setScheme("http");
|
|
|
+ uriBuilder.setHost("www.bignbiot.com");
|
|
|
+ uriBuilder.setPath("/api/device/search");
|
|
|
+ HttpPost httpPost = new HttpPost(uriBuilder.build());//构造post请求
|
|
|
+ // head中添加公共参数
|
|
|
+ // 内容类型
|
|
|
+ httpPost.addHeader("Content-Type", "application/json; charset=utf-8");
|
|
|
+ httpPost.addHeader("Authorization",Authorization);
|
|
|
+ //请求添加body部分
|
|
|
+ httpPost.setEntity(new StringEntity(JSONObject.toJSONString(query),"utf-8"));
|
|
|
+ try {
|
|
|
+ // 发送请求
|
|
|
+ response = httpClient.execute(httpPost);
|
|
|
+ JSONObject obj = JSONObject.parseObject(new String(EntityUtils.toByteArray(response.getEntity())));
|
|
|
+ System.out.println("==========="+obj.toString());
|
|
|
+ httpClient.close();
|
|
|
+ // "Status": 200
|
|
|
+ if (null != obj.get("Status") && obj.get("Status").toString().equals("200")){
|
|
|
+ return AjaxResult.success(obj.get("Data"));
|
|
|
+ }
|
|
|
+ } catch (ClientProtocolException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return AjaxResult.error("查询失败");
|
|
|
+ }
|
|
|
+
|
|
|
}
|