GetResponse.java 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. package com.huimv.video.dhicc.util;
  2. import com.alibaba.fastjson.JSON;
  3. import com.dahuatech.hutool.http.Method;
  4. import com.dahuatech.icc.exception.ClientException;
  5. import com.dahuatech.icc.oauth.http.DefaultClient;
  6. import com.dahuatech.icc.oauth.http.IClient;
  7. import com.dahuatech.icc.oauth.model.v202010.GeneralRequest;
  8. import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
  9. import com.huimv.common.utils.StringUtilsWork;
  10. import com.huimv.video.dhicc.icc.CommonConstant;
  11. import com.huimv.video.dhicc.result.R;
  12. import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
  13. import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
  14. import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo03;
  15. import com.huimv.video.dhicc.test.request.ClientCarListRequestSg;
  16. import com.huimv.video.dhicc.test.request.ClientSendMassageXixiaoPersonRequestSg;
  17. import jdk.nashorn.internal.ir.IfNode;
  18. import net.sf.json.JSONObject;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.stereotype.Component;
  21. import org.springframework.web.bind.annotation.RequestBody;
  22. import org.springframework.web.bind.annotation.RequestMapping;
  23. import java.text.SimpleDateFormat;
  24. import java.util.Calendar;
  25. import java.util.Date;
  26. import java.util.HashMap;
  27. import java.util.Map;
  28. public class GetResponse {
  29. /**
  30. * //查车辆通行数量的接口**不分进出
  31. *
  32. * @param begin 开始时间
  33. * @param end 结束时间
  34. * @return
  35. * @throws ClientException
  36. */
  37. public String SendMassageGetPage(String begin, String end) throws ClientException {
  38. //条件只有开始结束时间 有问题 这个是条数 有统计条数的专门接口
  39. //时间参数这里之前让前端传了 我这里只做转发 现在自己加上去
  40. String URL = "/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combinedCount?systime="; //获取事件URL post请求
  41. IClient iClient = new DefaultClient();
  42. String timestamp = String.valueOf((new Date()).getTime());
  43. Long aLong = Long.valueOf(timestamp);
  44. String NewUrl = URL + aLong;
  45. //这种已经在配置文件里面安排了账号ip以及密码
  46. GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
  47. generalRequest.header("Content-Type", " application/json");
  48. //设置时间参数
  49. Map<String, Object> params = new HashMap<>();
  50. params.put("startSwingTime", begin);
  51. params.put("endSwingTime", end);
  52. params.put("openType", "61");//刷脸开门
  53. //里面是
  54. generalRequest.body(JSON.toJSONString(params));
  55. //发起请求处理应答
  56. GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
  57. Object data = JSONObject.fromObject(generalResponse.getResult()).get("data");
  58. return data.toString();
  59. }
  60. /**
  61. * //查车辆通行数量的接口**出去记录
  62. *
  63. * @param begin 开始时间
  64. * @param end 结束时间
  65. * @return
  66. * @throws ClientException
  67. */
  68. public String SendMassageCarOut(String begin, String end) throws ClientException {
  69. String param = "queryTimeBegin=" + begin + "&queryTimeEnd=" + end + "&carDirect=9";
  70. String Url = "/evo-apigw/ipms/carcapture/find/conditions?";
  71. IClient iClient = new DefaultClient();
  72. System.out.println("开始执行");
  73. String newUrl = Url + param;
  74. GeneralRequest generalRequest = new GeneralRequest(newUrl, Method.GET);
  75. GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
  76. System.out.println("执行结束");
  77. JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
  78. Object data = jsonObject.get("data");
  79. JSONObject bject = JSONObject.fromObject(data);
  80. Object data1 = bject.get("totalRows"); //打印 2390
  81. return data1.toString();
  82. }
  83. /**
  84. * //查车辆通行数量的接口**进入的记录----车辆闸机
  85. *
  86. * @param begin 开始时间
  87. * @param end 结束时间
  88. * @return
  89. * @throws ClientException
  90. */
  91. public String SendMassageCarIn(String begin, String end) throws ClientException {
  92. String param = "queryTimeBegin=" + begin + "&queryTimeEnd=" + end + "&carDirect=8";
  93. String Url = "/evo-apigw/ipms/carcapture/find/conditions?";
  94. IClient iClient = new DefaultClient();
  95. System.out.println("开始执行");
  96. String newUrl = Url + param;
  97. System.out.println(newUrl);
  98. GeneralRequest generalRequest = new GeneralRequest(newUrl, Method.GET);
  99. GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
  100. System.out.println("执行结束");
  101. JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
  102. Object data = jsonObject.get("data");
  103. JSONObject bject = JSONObject.fromObject(data);
  104. Object data1 = bject.get("totalRows"); //打印 2390
  105. return data1.toString();
  106. }
  107. /**
  108. * //查人员通过过去几个小时的接口---正常通过次数
  109. *
  110. * @param begin 开始时间
  111. * @param end 结束时间
  112. * @return
  113. * @throws ClientException
  114. */
  115. public String SendMassageGetPagePerson(String begin, String end) throws ClientException {
  116. Map<String, Object> params = new HashMap<>();
  117. params.put("startSwingTime", begin);
  118. params.put("endSwingTime", end);
  119. params.put("openType", 61);
  120. String URL = "/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combinedCount?systime="; //获取事件URL post请求
  121. IClient iClient = new DefaultClient();
  122. String timestamp = String.valueOf((new Date()).getTime());
  123. Long aLong = Long.valueOf(timestamp);
  124. String NewUrl = URL + aLong;
  125. System.out.println("开始执行");
  126. //这种已经在配置文件里面安排了账号ip以及密码
  127. GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
  128. System.out.println(NewUrl);
  129. generalRequest.header("Content-Type", " application/json");
  130. System.out.println(JSON.toJSONString(params));
  131. //里面是
  132. generalRequest.body(JSON.toJSONString(params));
  133. //发起请求处理应答
  134. GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
  135. System.out.println("执行结束");
  136. JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
  137. Object data = jsonObject.get("data");
  138. return data.toString();
  139. }
  140. /**
  141. * //查人员通过过去几个小时的接口---异常通过次数接口
  142. *
  143. * @param begin 开始时间
  144. * @param end 结束时间
  145. * @return
  146. * @throws ClientException
  147. */
  148. public String SendMassageGetPagePersonAlarm(String begin, String end) throws ClientException {
  149. Map<String, Object> params = new HashMap<>();
  150. params.put("startSwingTime", begin);
  151. params.put("endSwingTime", end);
  152. params.put("containDomain", "1");
  153. params.put("openResult", 0);
  154. String URL = "/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combinedCount?systime="; //获取事件URL post请求
  155. IClient iClient = new DefaultClient();
  156. String timestamp = String.valueOf((new Date()).getTime());
  157. Long aLong = Long.valueOf(timestamp);
  158. String NewUrl = URL + aLong;
  159. System.out.println("开始执行");
  160. //这种已经在配置文件里面安排了账号ip以及密码
  161. GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
  162. System.out.println(NewUrl);
  163. generalRequest.header("Content-Type", " application/json");
  164. System.out.println(JSON.toJSONString(params));
  165. //里面是
  166. generalRequest.body(JSON.toJSONString(params));
  167. //发起请求处理应答
  168. GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
  169. System.out.println("执行结束");
  170. JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
  171. Object data = jsonObject.get("data");
  172. return data.toString();
  173. }
  174. /* public static void main(String[] args) throws ClientException {
  175. Map<String, Object> params1 = new HashMap<>();
  176. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  177. Calendar c = Calendar.getInstance();
  178. Date date = new Date();
  179. c.setTime(date);
  180. c.set(Calendar.HOUR_OF_DAY, 0);
  181. c.set(Calendar.MINUTE, 0);
  182. c.set(Calendar.SECOND, 0);
  183. //调整天数
  184. c.add(Calendar.DATE, -1);
  185. Date A = c.getTime();
  186. String formatA = format.format(A);
  187. c.set(Calendar.HOUR, +24);
  188. Date d = c.getTime();
  189. String formatD = format.format(d);
  190. System.out.println(formatA + formatD);
  191. params1.put("pageNum", 1);
  192. params1.put("pageSize", 20);
  193. params1.put("startSwingTime", formatA);
  194. params1.put("endSwingTime", formatD);
  195. params1.put("containDomain", "1");
  196. params1.put("openResult", 0); //刷脸失败
  197. String URL = "http://36.26.62.70:80/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combined?systime=";
  198. IClient iClient = new DefaultClient();
  199. GeneralRequest generalRequest = new GeneralRequest(URL + Long.valueOf(String.valueOf((new Date()).getTime())), Method.POST);
  200. generalRequest.header("Content-Type", " application/json");
  201. generalRequest.body(JSON.toJSONString(params1));
  202. GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
  203. JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
  204. GetResponse getResponse = new GetResponse();
  205. System.out.println(jsonObject.toString() + getResponse.SendMassageGetPagePersonAlarm((String) params1.get("startSwingTime"), (String) params1.get("endSwingTime")));
  206. }*/
  207. /**
  208. * //查洗消 ---时间次数的接口-----
  209. *
  210. * @param begin 开始时间
  211. * @param end 结束时间
  212. * @return
  213. * @throws ClientException
  214. */
  215. public String SendMassageXixiaoPerson(String begin, String end,Integer farmId,OauthConfigBaseInfo oauthConfigBaseInfo) throws ClientException {
  216. String res = "";
  217. if(farmId ==1){
  218. ClientSendMassageXixiaoPersonRequestSg requestSg = new ClientSendMassageXixiaoPersonRequestSg(oauthConfigBaseInfo);
  219. requestSg.setAlarmStartDateString(begin);
  220. requestSg.setAlarmEndDateString(end);
  221. requestSg.setAlarmType(303);
  222. requestSg.setDbType(0);
  223. requestSg.setDeviceCategory(1);
  224. requestSg.setNodeCodeList(CommonConstant.XixiaoChannle);
  225. System.out.println(requestSg);
  226. res = requestSg.doAction();
  227. JSONObject jsonObject = JSONObject.fromObject(res);
  228. Object data = jsonObject.get("data");
  229. JSONObject jsonObject1 = JSONObject.fromObject(data);
  230. System.out.println(jsonObject1);
  231. return jsonObject1.get("value").toString();
  232. }
  233. return null;
  234. }
  235. /**
  236. * //查大门 ---时间次数的接口-----
  237. *
  238. * @param begin 开始时间
  239. * @param end 结束时间
  240. * @return
  241. * @throws ClientException
  242. */
  243. public String SendMassageGateCount(String begin, String end) throws ClientException {
  244. Map<String, Object> params = new HashMap<>();
  245. params.put("alarmStartDateString", begin);
  246. params.put("alarmEndDateString", end);
  247. params.put("alarmType", 303);
  248. params.put("dbType", 0);
  249. params.put("deviceCategory", 1);
  250. params.put("nodeCodeList", CommonConstant.DoorChannle);
  251. String URL = "/evo-apigw/evo-event/1.0.0/alarm-record/count-num"; //获取事件URL post请求
  252. IClient iClient = new DefaultClient();
  253. String NewUrl = URL;
  254. System.out.println("开始执行");
  255. //这种已经在配置文件里面安排了账号ip以及密码
  256. GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
  257. System.out.println(NewUrl);
  258. generalRequest.header("Content-Type", " application/json");
  259. System.out.println(JSON.toJSONString(params));
  260. //里面是
  261. generalRequest.body(JSON.toJSONString(params));
  262. //发起请求处理应答
  263. GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
  264. System.out.println("执行结束");
  265. JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
  266. Object data = jsonObject.get("data");
  267. JSONObject jsonObject1 = JSONObject.fromObject(data);
  268. System.out.println(jsonObject1);
  269. return jsonObject1.get("value").toString();
  270. }
  271. /**
  272. * //查死猪 ---时间次数的接口-----
  273. *
  274. * @param begin 开始时间
  275. * @param end 结束时间
  276. * @return
  277. * @throws ClientException
  278. */
  279. public String SendCountSiZhu(String begin, String end) throws ClientException {
  280. Map<String, Object> params = new HashMap<>();
  281. params.put("alarmStartDateString", begin);
  282. params.put("alarmEndDateString", end);
  283. params.put("alarmType", 303);
  284. params.put("dbType", 0);
  285. params.put("deviceCategory", 1);
  286. //死猪通道
  287. String[] nodeCodeList = CommonConstant.SIZhuChannle;
  288. params.put("nodeCodeList", nodeCodeList);
  289. String URL = "/evo-apigw/evo-event/1.0.0/alarm-record/count-num"; //获取事件URL post请求
  290. IClient iClient = new DefaultClient();
  291. String NewUrl = URL;
  292. System.out.println("开始执行");
  293. //这种已经在配置文件里面安排了账号ip以及密码
  294. GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
  295. System.out.println(NewUrl);
  296. generalRequest.header("Content-Type", " application/json");
  297. System.out.println(JSON.toJSONString(params));
  298. //里面是
  299. generalRequest.body(JSON.toJSONString(params));
  300. //发起请求处理应答
  301. GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
  302. System.out.println("执行结束");
  303. JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
  304. Object data = jsonObject.get("data");
  305. JSONObject jsonObject1 = JSONObject.fromObject(data);
  306. System.out.println(jsonObject1);
  307. return jsonObject1.get("value").toString();
  308. }
  309. /**
  310. * //查洗消死猪事件的时间-----次数的接口-----
  311. *
  312. * @param begin 开始时间
  313. * @param end 结束时间
  314. * @return
  315. * @throws ClientException
  316. */
  317. public String SendMassageSiZhuRecord(String begin, String end) throws ClientException {
  318. Map<String, Object> params = new HashMap<>();
  319. params.put("alarmStartDateString", begin);
  320. params.put("alarmEndDateString", end);
  321. params.put("alarmType", 303);
  322. params.put("dbType", 0);
  323. params.put("deviceCategory", 1);
  324. //死猪的通道
  325. String[] nodeCodeList = CommonConstant.SIZhuChannle;
  326. params.put("nodeCodeList", nodeCodeList);
  327. String URL = "/evo-apigw/evo-event/1.0.0/alarm-record/count-num"; //获取事件URL post请求
  328. IClient iClient = new DefaultClient();
  329. String NewUrl = URL;
  330. System.out.println("开始执行");
  331. //这种已经在配置文件里面安排了账号ip以及密码
  332. GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
  333. System.out.println(NewUrl);
  334. generalRequest.header("Content-Type", " application/json");
  335. System.out.println(JSON.toJSONString(params));
  336. //里面是
  337. generalRequest.body(JSON.toJSONString(params));
  338. //发起请求处理应答
  339. GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
  340. System.out.println("执行结束");
  341. JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
  342. Object data = jsonObject.get("data");
  343. JSONObject jsonObject1 = JSONObject.fromObject(data);
  344. System.out.println(jsonObject1);
  345. return jsonObject1.get("value").toString();
  346. }
  347. public Object SendMassagePost(String param, String Url, String chooseMethod) throws ClientException {
  348. IClient iClient = new DefaultClient();
  349. System.out.println("开始执行");
  350. String newUrl = Url + param;
  351. //这种已经在配置文件里面安排了账号ip以及密码 现在变了
  352. GeneralRequest generalRequest = new GeneralRequest(newUrl, Method.POST);
  353. GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
  354. System.out.println("执行结束");
  355. return R.ok("请求成功").put("token", generalResponse);
  356. }
  357. }