|
@@ -1,114 +1,114 @@
|
|
|
-package com.huimv.video.dhicc.controller.ClientController;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.dahuatech.hutool.http.Method;
|
|
|
-import com.dahuatech.icc.exception.ClientException;
|
|
|
-import com.dahuatech.icc.oauth.http.DefaultClient;
|
|
|
-import com.dahuatech.icc.oauth.http.IClient;
|
|
|
-import com.dahuatech.icc.oauth.model.v202010.GeneralRequest;
|
|
|
-import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
|
|
|
-import com.huimv.common.utils.StringUtilsWork;
|
|
|
-import com.huimv.video.dhicc.icc.CommonConstant;
|
|
|
-import com.huimv.video.dhicc.result.R;
|
|
|
-import net.sf.json.JSONObject;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-
|
|
|
-//其实可以整合到一起去了
|
|
|
-@RestController
|
|
|
-@RequestMapping("/event")
|
|
|
-public class ClientWeiQiangController {
|
|
|
-
|
|
|
- //所有的事件接口
|
|
|
- @RequestMapping("/weiQiang")
|
|
|
- public R SiZhuList(@RequestBody Map<String, Object> params1) throws ClientException, ParseException {
|
|
|
- Integer farmId = (int) params1.get("farmId");
|
|
|
- if (farmId != 1) {
|
|
|
- return R.ok("当前牧场无设备").put("data", null);
|
|
|
- }
|
|
|
- return R.ok("请求成功").put("data", getEventList(params1)).put("total", CountTimes(params1));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //围墙事件
|
|
|
- public GeneralResponse getEventList(Map<String, Object> params1) throws ClientException {
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- Calendar c = Calendar.getInstance();
|
|
|
- Date date = new Date();
|
|
|
- c.setTime(date);
|
|
|
- c.set(Calendar.HOUR, 0);
|
|
|
- c.set(Calendar.MINUTE, 0);
|
|
|
- c.set(Calendar.SECOND, 0);
|
|
|
- Date A = c.getTime();
|
|
|
- String formatA = format.format(A);
|
|
|
- c.set(Calendar.HOUR, +24);
|
|
|
- Date d = c.getTime();
|
|
|
- String formatD = format.format(d);
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("alarmStartDateString", formatA);
|
|
|
- params.put("alarmEndDateString", formatD);
|
|
|
- if (StringUtilsWork.isNotEmpty((String) params1.get("alarmStartDateString"))) {
|
|
|
- params.put("alarmStartDateString", (String) params1.get("alarmStartDateString"));
|
|
|
- params.put("alarmEndDateString", (String) params1.get("alarmEndDateString"));
|
|
|
- }
|
|
|
- params.put("pageNum", (Integer) params1.get("pageNum"));
|
|
|
- params.put("pageSize", (Integer) params1.get("pageSize"));
|
|
|
- params.put("alarmType", 303);
|
|
|
- params.put("dbType", 0);
|
|
|
- params.put("deviceCategory", 1);
|
|
|
- String[] nodeCodeList = CommonConstant.EggWeiQiang;
|
|
|
- params.put("nodeCodeList", nodeCodeList);
|
|
|
- String URL = "/evo-apigw/evo-event/1.2.0/alarm-record/page"; //获取事件URL post请求
|
|
|
- IClient iClient = new DefaultClient();
|
|
|
- GeneralRequest generalRequest = new GeneralRequest(URL, Method.POST);
|
|
|
- generalRequest.header("Content-Type", " application/json");
|
|
|
- generalRequest.body(JSON.toJSONString(params));
|
|
|
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
|
|
|
- return generalResponse;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public String CountTimes(Map<String, Object> params1) throws ClientException {
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- Calendar c = Calendar.getInstance();
|
|
|
- Date date = new Date();
|
|
|
- c.setTime(date);
|
|
|
- c.set(Calendar.HOUR, 0);
|
|
|
- c.set(Calendar.MINUTE, 0);
|
|
|
- c.set(Calendar.SECOND, 0);
|
|
|
- Date A = c.getTime();
|
|
|
- String formatA = format.format(A);
|
|
|
- c.set(Calendar.HOUR, +24);
|
|
|
- Date d = c.getTime();
|
|
|
- String formatD = format.format(d);
|
|
|
- Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("alarmStartDateString", formatA);
|
|
|
- params.put("alarmEndDateString", formatD);
|
|
|
- if (StringUtilsWork.isNotEmpty((String) params1.get("alarmStartDateString"))) {
|
|
|
- params.put("alarmStartDateString", params1.get("alarmStartDateString"));
|
|
|
- params.put("alarmEndDateString", params1.get("alarmEndDateString"));
|
|
|
- }
|
|
|
- params.put("alarmType", 303);
|
|
|
- params.put("dbType", 0);
|
|
|
- params.put("deviceCategory", 1);
|
|
|
- String[] nodeCodeList = CommonConstant.EggWeiQiang;
|
|
|
- params.put("nodeCodeList", nodeCodeList);
|
|
|
- String URL = "/evo-apigw/evo-event/1.0.0/alarm-record/count-num"; //获取事件URL post请求
|
|
|
- IClient iClient = new DefaultClient();
|
|
|
- GeneralRequest generalRequest = new GeneralRequest(URL, Method.POST);
|
|
|
- generalRequest.header("Content-Type", " application/json");
|
|
|
- generalRequest.body(JSON.toJSONString(params));
|
|
|
- JSONObject jsonObject = JSONObject.fromObject(JSONObject.fromObject(iClient.doAction(generalRequest, generalRequest.getResponseClass()).getResult()).get("data"));
|
|
|
- return jsonObject.get("value").toString();
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
+//package com.huimv.video.dhicc.controller.ClientController;
|
|
|
+//
|
|
|
+//import com.alibaba.fastjson.JSON;
|
|
|
+//import com.dahuatech.hutool.http.Method;
|
|
|
+//import com.dahuatech.icc.exception.ClientException;
|
|
|
+//import com.dahuatech.icc.oauth.http.DefaultClient;
|
|
|
+//import com.dahuatech.icc.oauth.http.IClient;
|
|
|
+//import com.dahuatech.icc.oauth.model.v202010.GeneralRequest;
|
|
|
+//import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
|
|
|
+//import com.huimv.common.utils.StringUtilsWork;
|
|
|
+//import com.huimv.video.dhicc.icc.CommonConstant;
|
|
|
+//import com.huimv.video.dhicc.result.R;
|
|
|
+//import net.sf.json.JSONObject;
|
|
|
+//import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+//import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+//import org.springframework.web.bind.annotation.RestController;
|
|
|
+//
|
|
|
+//import java.text.ParseException;
|
|
|
+//import java.text.SimpleDateFormat;
|
|
|
+//import java.util.Calendar;
|
|
|
+//import java.util.Date;
|
|
|
+//import java.util.HashMap;
|
|
|
+//import java.util.Map;
|
|
|
+//
|
|
|
+//
|
|
|
+////其实可以整合到一起去了
|
|
|
+//@RestController
|
|
|
+//@RequestMapping("/event")
|
|
|
+//public class ClientWeiQiangController {
|
|
|
+//
|
|
|
+// //所有的事件接口
|
|
|
+// @RequestMapping("/weiQiang")
|
|
|
+// public R SiZhuList(@RequestBody Map<String, Object> params1) throws ClientException, ParseException {
|
|
|
+// Integer farmId = (int) params1.get("farmId");
|
|
|
+// if (farmId != 1) {
|
|
|
+// return R.ok("当前牧场无设备").put("data", null);
|
|
|
+// }
|
|
|
+// return R.ok("请求成功").put("data", getEventList(params1)).put("total", CountTimes(params1));
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// //围墙事件
|
|
|
+// public GeneralResponse getEventList(Map<String, Object> params1) throws ClientException {
|
|
|
+// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+// Calendar c = Calendar.getInstance();
|
|
|
+// Date date = new Date();
|
|
|
+// c.setTime(date);
|
|
|
+// c.set(Calendar.HOUR, 0);
|
|
|
+// c.set(Calendar.MINUTE, 0);
|
|
|
+// c.set(Calendar.SECOND, 0);
|
|
|
+// Date A = c.getTime();
|
|
|
+// String formatA = format.format(A);
|
|
|
+// c.set(Calendar.HOUR, +24);
|
|
|
+// Date d = c.getTime();
|
|
|
+// String formatD = format.format(d);
|
|
|
+// Map<String, Object> params = new HashMap<>();
|
|
|
+// params.put("alarmStartDateString", formatA);
|
|
|
+// params.put("alarmEndDateString", formatD);
|
|
|
+// if (StringUtilsWork.isNotEmpty((String) params1.get("alarmStartDateString"))) {
|
|
|
+// params.put("alarmStartDateString", (String) params1.get("alarmStartDateString"));
|
|
|
+// params.put("alarmEndDateString", (String) params1.get("alarmEndDateString"));
|
|
|
+// }
|
|
|
+// params.put("pageNum", (Integer) params1.get("pageNum"));
|
|
|
+// params.put("pageSize", (Integer) params1.get("pageSize"));
|
|
|
+// params.put("alarmType", 303);
|
|
|
+// params.put("dbType", 0);
|
|
|
+// params.put("deviceCategory", 1);
|
|
|
+// String[] nodeCodeList = CommonConstant.W;
|
|
|
+// params.put("nodeCodeList", nodeCodeList);
|
|
|
+// String URL = "/evo-apigw/evo-event/1.2.0/alarm-record/page"; //获取事件URL post请求
|
|
|
+// IClient iClient = new DefaultClient();
|
|
|
+// GeneralRequest generalRequest = new GeneralRequest(URL, Method.POST);
|
|
|
+// generalRequest.header("Content-Type", " application/json");
|
|
|
+// generalRequest.body(JSON.toJSONString(params));
|
|
|
+// GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
|
|
|
+// return generalResponse;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// public String CountTimes(Map<String, Object> params1) throws ClientException {
|
|
|
+// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+// Calendar c = Calendar.getInstance();
|
|
|
+// Date date = new Date();
|
|
|
+// c.setTime(date);
|
|
|
+// c.set(Calendar.HOUR, 0);
|
|
|
+// c.set(Calendar.MINUTE, 0);
|
|
|
+// c.set(Calendar.SECOND, 0);
|
|
|
+// Date A = c.getTime();
|
|
|
+// String formatA = format.format(A);
|
|
|
+// c.set(Calendar.HOUR, +24);
|
|
|
+// Date d = c.getTime();
|
|
|
+// String formatD = format.format(d);
|
|
|
+// Map<String, Object> params = new HashMap<>();
|
|
|
+// params.put("alarmStartDateString", formatA);
|
|
|
+// params.put("alarmEndDateString", formatD);
|
|
|
+// if (StringUtilsWork.isNotEmpty((String) params1.get("alarmStartDateString"))) {
|
|
|
+// params.put("alarmStartDateString", params1.get("alarmStartDateString"));
|
|
|
+// params.put("alarmEndDateString", params1.get("alarmEndDateString"));
|
|
|
+// }
|
|
|
+// params.put("alarmType", 303);
|
|
|
+// params.put("dbType", 0);
|
|
|
+// params.put("deviceCategory", 1);
|
|
|
+// String[] nodeCodeList = CommonConstant.EggWeiQiang;
|
|
|
+// params.put("nodeCodeList", nodeCodeList);
|
|
|
+// String URL = "/evo-apigw/evo-event/1.0.0/alarm-record/count-num"; //获取事件URL post请求
|
|
|
+// IClient iClient = new DefaultClient();
|
|
|
+// GeneralRequest generalRequest = new GeneralRequest(URL, Method.POST);
|
|
|
+// generalRequest.header("Content-Type", " application/json");
|
|
|
+// generalRequest.body(JSON.toJSONString(params));
|
|
|
+// JSONObject jsonObject = JSONObject.fromObject(JSONObject.fromObject(iClient.doAction(generalRequest, generalRequest.getResponseClass()).getResult()).get("data"));
|
|
|
+// return jsonObject.get("value").toString();
|
|
|
+// }
|
|
|
+//}
|
|
|
+//
|