123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391 |
- package com.huimv.video.dhicc.util;
- 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 com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
- import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
- import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo03;
- import com.huimv.video.dhicc.test.request.ClientCarListRequestSg;
- import com.huimv.video.dhicc.test.request.ClientSendMassageXixiaoPersonRequestSg;
- import jdk.nashorn.internal.ir.IfNode;
- import net.sf.json.JSONObject;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Map;
- public class GetResponse {
- /**
- * //查车辆通行数量的接口**不分进出
- *
- * @param begin 开始时间
- * @param end 结束时间
- * @return
- * @throws ClientException
- */
- public String SendMassageGetPage(String begin, String end) throws ClientException {
- //条件只有开始结束时间 有问题 这个是条数 有统计条数的专门接口
- //时间参数这里之前让前端传了 我这里只做转发 现在自己加上去
- String URL = "/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combinedCount?systime="; //获取事件URL post请求
- IClient iClient = new DefaultClient();
- String timestamp = String.valueOf((new Date()).getTime());
- Long aLong = Long.valueOf(timestamp);
- String NewUrl = URL + aLong;
- //这种已经在配置文件里面安排了账号ip以及密码
- GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
- generalRequest.header("Content-Type", " application/json");
- //设置时间参数
- Map<String, Object> params = new HashMap<>();
- params.put("startSwingTime", begin);
- params.put("endSwingTime", end);
- params.put("openType", "61");//刷脸开门
- //里面是
- generalRequest.body(JSON.toJSONString(params));
- //发起请求处理应答
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
- Object data = JSONObject.fromObject(generalResponse.getResult()).get("data");
- return data.toString();
- }
- /**
- * //查车辆通行数量的接口**出去记录
- *
- * @param begin 开始时间
- * @param end 结束时间
- * @return
- * @throws ClientException
- */
- public String SendMassageCarOut(String begin, String end) throws ClientException {
- String param = "queryTimeBegin=" + begin + "&queryTimeEnd=" + end + "&carDirect=9";
- String Url = "/evo-apigw/ipms/carcapture/find/conditions?";
- IClient iClient = new DefaultClient();
- System.out.println("开始执行");
- String newUrl = Url + param;
- GeneralRequest generalRequest = new GeneralRequest(newUrl, Method.GET);
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
- System.out.println("执行结束");
- JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
- Object data = jsonObject.get("data");
- JSONObject bject = JSONObject.fromObject(data);
- Object data1 = bject.get("totalRows"); //打印 2390
- return data1.toString();
- }
- /**
- * //查车辆通行数量的接口**进入的记录----车辆闸机
- *
- * @param begin 开始时间
- * @param end 结束时间
- * @return
- * @throws ClientException
- */
- public String SendMassageCarIn(String begin, String end) throws ClientException {
- String param = "queryTimeBegin=" + begin + "&queryTimeEnd=" + end + "&carDirect=8";
- String Url = "/evo-apigw/ipms/carcapture/find/conditions?";
- IClient iClient = new DefaultClient();
- System.out.println("开始执行");
- String newUrl = Url + param;
- System.out.println(newUrl);
- GeneralRequest generalRequest = new GeneralRequest(newUrl, Method.GET);
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
- System.out.println("执行结束");
- JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
- Object data = jsonObject.get("data");
- JSONObject bject = JSONObject.fromObject(data);
- Object data1 = bject.get("totalRows"); //打印 2390
- return data1.toString();
- }
- /**
- * //查人员通过过去几个小时的接口---正常通过次数
- *
- * @param begin 开始时间
- * @param end 结束时间
- * @return
- * @throws ClientException
- */
- public String SendMassageGetPagePerson(String begin, String end) throws ClientException {
- Map<String, Object> params = new HashMap<>();
- params.put("startSwingTime", begin);
- params.put("endSwingTime", end);
- params.put("openType", 61);
- String URL = "/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combinedCount?systime="; //获取事件URL post请求
- IClient iClient = new DefaultClient();
- String timestamp = String.valueOf((new Date()).getTime());
- Long aLong = Long.valueOf(timestamp);
- String NewUrl = URL + aLong;
- System.out.println("开始执行");
- //这种已经在配置文件里面安排了账号ip以及密码
- GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
- System.out.println(NewUrl);
- generalRequest.header("Content-Type", " application/json");
- System.out.println(JSON.toJSONString(params));
- //里面是
- generalRequest.body(JSON.toJSONString(params));
- //发起请求处理应答
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
- System.out.println("执行结束");
- JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
- Object data = jsonObject.get("data");
- return data.toString();
- }
- /**
- * //查人员通过过去几个小时的接口---异常通过次数接口
- *
- * @param begin 开始时间
- * @param end 结束时间
- * @return
- * @throws ClientException
- */
- public String SendMassageGetPagePersonAlarm(String begin, String end) throws ClientException {
- Map<String, Object> params = new HashMap<>();
- params.put("startSwingTime", begin);
- params.put("endSwingTime", end);
- params.put("containDomain", "1");
- params.put("openResult", 0);
- String URL = "/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combinedCount?systime="; //获取事件URL post请求
- IClient iClient = new DefaultClient();
- String timestamp = String.valueOf((new Date()).getTime());
- Long aLong = Long.valueOf(timestamp);
- String NewUrl = URL + aLong;
- System.out.println("开始执行");
- //这种已经在配置文件里面安排了账号ip以及密码
- GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
- System.out.println(NewUrl);
- generalRequest.header("Content-Type", " application/json");
- System.out.println(JSON.toJSONString(params));
- //里面是
- generalRequest.body(JSON.toJSONString(params));
- //发起请求处理应答
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
- System.out.println("执行结束");
- JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
- Object data = jsonObject.get("data");
- return data.toString();
- }
- /* public static void main(String[] args) throws ClientException {
- Map<String, Object> params1 = new HashMap<>();
- 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_OF_DAY, 0);
- c.set(Calendar.MINUTE, 0);
- c.set(Calendar.SECOND, 0);
- //调整天数
- c.add(Calendar.DATE, -1);
- Date A = c.getTime();
- String formatA = format.format(A);
- c.set(Calendar.HOUR, +24);
- Date d = c.getTime();
- String formatD = format.format(d);
- System.out.println(formatA + formatD);
- params1.put("pageNum", 1);
- params1.put("pageSize", 20);
- params1.put("startSwingTime", formatA);
- params1.put("endSwingTime", formatD);
- params1.put("containDomain", "1");
- params1.put("openResult", 0); //刷脸失败
- String URL = "http://36.26.62.70:80/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combined?systime=";
- IClient iClient = new DefaultClient();
- GeneralRequest generalRequest = new GeneralRequest(URL + Long.valueOf(String.valueOf((new Date()).getTime())), Method.POST);
- generalRequest.header("Content-Type", " application/json");
- generalRequest.body(JSON.toJSONString(params1));
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
- JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
- GetResponse getResponse = new GetResponse();
- System.out.println(jsonObject.toString() + getResponse.SendMassageGetPagePersonAlarm((String) params1.get("startSwingTime"), (String) params1.get("endSwingTime")));
- }*/
- /**
- * //查洗消 ---时间次数的接口-----
- *
- * @param begin 开始时间
- * @param end 结束时间
- * @return
- * @throws ClientException
- */
- public String SendMassageXixiaoPerson(String begin, String end,Integer farmId,OauthConfigBaseInfo oauthConfigBaseInfo) throws ClientException {
- String res = "";
- if(farmId ==1){
- ClientSendMassageXixiaoPersonRequestSg requestSg = new ClientSendMassageXixiaoPersonRequestSg(oauthConfigBaseInfo);
- requestSg.setAlarmStartDateString(begin);
- requestSg.setAlarmEndDateString(end);
- requestSg.setAlarmType(303);
- requestSg.setDbType(0);
- requestSg.setDeviceCategory(1);
- requestSg.setNodeCodeList(CommonConstant.XixiaoChannle);
- System.out.println(requestSg);
- res = requestSg.doAction();
- JSONObject jsonObject = JSONObject.fromObject(res);
- Object data = jsonObject.get("data");
- JSONObject jsonObject1 = JSONObject.fromObject(data);
- System.out.println(jsonObject1);
- return jsonObject1.get("value").toString();
- }
- return null;
- }
- /**
- * //查大门 ---时间次数的接口-----
- *
- * @param begin 开始时间
- * @param end 结束时间
- * @return
- * @throws ClientException
- */
- public String SendMassageGateCount(String begin, String end) throws ClientException {
- Map<String, Object> params = new HashMap<>();
- params.put("alarmStartDateString", begin);
- params.put("alarmEndDateString", end);
- params.put("alarmType", 303);
- params.put("dbType", 0);
- params.put("deviceCategory", 1);
- params.put("nodeCodeList", CommonConstant.DoorChannle);
- String URL = "/evo-apigw/evo-event/1.0.0/alarm-record/count-num"; //获取事件URL post请求
- IClient iClient = new DefaultClient();
- String NewUrl = URL;
- System.out.println("开始执行");
- //这种已经在配置文件里面安排了账号ip以及密码
- GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
- System.out.println(NewUrl);
- generalRequest.header("Content-Type", " application/json");
- System.out.println(JSON.toJSONString(params));
- //里面是
- generalRequest.body(JSON.toJSONString(params));
- //发起请求处理应答
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
- System.out.println("执行结束");
- JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
- Object data = jsonObject.get("data");
- JSONObject jsonObject1 = JSONObject.fromObject(data);
- System.out.println(jsonObject1);
- return jsonObject1.get("value").toString();
- }
- /**
- * //查死猪 ---时间次数的接口-----
- *
- * @param begin 开始时间
- * @param end 结束时间
- * @return
- * @throws ClientException
- */
- public String SendCountSiZhu(String begin, String end) throws ClientException {
- Map<String, Object> params = new HashMap<>();
- params.put("alarmStartDateString", begin);
- params.put("alarmEndDateString", end);
- params.put("alarmType", 303);
- params.put("dbType", 0);
- params.put("deviceCategory", 1);
- //死猪通道
- String[] nodeCodeList = CommonConstant.SIZhuChannle;
- params.put("nodeCodeList", nodeCodeList);
- String URL = "/evo-apigw/evo-event/1.0.0/alarm-record/count-num"; //获取事件URL post请求
- IClient iClient = new DefaultClient();
- String NewUrl = URL;
- System.out.println("开始执行");
- //这种已经在配置文件里面安排了账号ip以及密码
- GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
- System.out.println(NewUrl);
- generalRequest.header("Content-Type", " application/json");
- System.out.println(JSON.toJSONString(params));
- //里面是
- generalRequest.body(JSON.toJSONString(params));
- //发起请求处理应答
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
- System.out.println("执行结束");
- JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
- Object data = jsonObject.get("data");
- JSONObject jsonObject1 = JSONObject.fromObject(data);
- System.out.println(jsonObject1);
- return jsonObject1.get("value").toString();
- }
- /**
- * //查洗消死猪事件的时间-----次数的接口-----
- *
- * @param begin 开始时间
- * @param end 结束时间
- * @return
- * @throws ClientException
- */
- public String SendMassageSiZhuRecord(String begin, String end) throws ClientException {
- Map<String, Object> params = new HashMap<>();
- params.put("alarmStartDateString", begin);
- params.put("alarmEndDateString", end);
- params.put("alarmType", 303);
- params.put("dbType", 0);
- params.put("deviceCategory", 1);
- //死猪的通道
- String[] nodeCodeList = CommonConstant.SIZhuChannle;
- params.put("nodeCodeList", nodeCodeList);
- String URL = "/evo-apigw/evo-event/1.0.0/alarm-record/count-num"; //获取事件URL post请求
- IClient iClient = new DefaultClient();
- String NewUrl = URL;
- System.out.println("开始执行");
- //这种已经在配置文件里面安排了账号ip以及密码
- GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
- System.out.println(NewUrl);
- generalRequest.header("Content-Type", " application/json");
- System.out.println(JSON.toJSONString(params));
- //里面是
- generalRequest.body(JSON.toJSONString(params));
- //发起请求处理应答
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
- System.out.println("执行结束");
- JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
- Object data = jsonObject.get("data");
- JSONObject jsonObject1 = JSONObject.fromObject(data);
- System.out.println(jsonObject1);
- return jsonObject1.get("value").toString();
- }
- public Object SendMassagePost(String param, String Url, String chooseMethod) throws ClientException {
- IClient iClient = new DefaultClient();
- System.out.println("开始执行");
- String newUrl = Url + param;
- //这种已经在配置文件里面安排了账号ip以及密码 现在变了
- GeneralRequest generalRequest = new GeneralRequest(newUrl, Method.POST);
- GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
- System.out.println("执行结束");
- return R.ok("请求成功").put("token", generalResponse);
- }
- }
|