Ver Fonte

Merge remote-tracking branch 'origin/master'

yang há 3 anos atrás
pai
commit
c3135877a7

+ 31 - 0
huimv-farm-receiver/src/main/java/com/huimv/receiver/farm/controller/AlarmController.java

@@ -0,0 +1,31 @@
+package com.huimv.receiver.farm.controller;
+
+import com.huimv.receiver.farm.service.IAlarm;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@CrossOrigin
+@RestController
+@Slf4j
+@RequestMapping(value = "/receiver/alarm")
+public class AlarmController {
+    @Autowired
+    private IAlarm iAlarm;
+
+    //发送环境警报信息
+    @RequestMapping(value = "/environ/putEnvironAlarm",method = RequestMethod.POST)
+    public void putEnvironAlarm(@RequestParam(value = "data",required = true) String alarmInfo){
+        System.out.println(">>>>>>>>>>>>>>> 接收"+alarmInfo);
+        //处理环境警报
+        iAlarm.handleEnvironAlarm(alarmInfo);
+    }
+}

+ 137 - 0
huimv-farm-receiver/src/main/java/com/huimv/receiver/farm/dao/entity/BaseWarningInfoEntity.java

@@ -0,0 +1,137 @@
+package com.huimv.receiver.farm.dao.entity;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.sql.Timestamp;
+
+@Entity
+@Table(name = "base_warning_info")
+public class BaseWarningInfoEntity implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id", nullable = false)
+    private Integer id;
+
+    @Column(name = "farm_id")
+    private Integer farmId;
+
+    @Column(name = "level")
+    private Integer level;
+
+    @Column(name = "msg")
+    private String msg;
+
+    @Column(name = "level_name")
+    private String levelName;
+
+    @Column(name = "warning_name")
+    private String warningName;
+
+    @Column(name = "warning_time")
+    private Timestamp warningTime;
+
+    @Column(name = "upload_time")
+    private Timestamp uploadTime;
+
+    /**
+     * 警报类型
+     */
+    @Column(name = "alarm_type")
+    private Integer alarmType;
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setFarmId(Integer farmId) {
+        this.farmId = farmId;
+    }
+
+    public Integer getFarmId() {
+        return farmId;
+    }
+
+    public void setLevel(Integer level) {
+        this.level = level;
+    }
+
+    public Integer getLevel() {
+        return level;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setLevelName(String levelName) {
+        this.levelName = levelName;
+    }
+
+    public String getLevelName() {
+        return levelName;
+    }
+
+    public void setWarningName(String warningName) {
+        this.warningName = warningName;
+    }
+
+    public String getWarningName() {
+        return warningName;
+    }
+
+    public void setWarningTime(Timestamp warningTime) {
+        this.warningTime = warningTime;
+    }
+
+    public Timestamp getWarningTime() {
+        return warningTime;
+    }
+
+    public void setUploadTime(Timestamp uploadTime) {
+        this.uploadTime = uploadTime;
+    }
+
+    public Timestamp getUploadTime() {
+        return uploadTime;
+    }
+
+    /**
+     * 警报类型
+     */
+    public void setAlarmType(Integer alarmType) {
+        this.alarmType = alarmType;
+    }
+
+    /**
+     * 警报类型
+     */
+    public Integer getAlarmType() {
+        return alarmType;
+    }
+
+    @Override
+    public String toString() {
+        return "BaseWarningInfoEntity{" +
+                "id=" + id + '\'' +
+                "farmId=" + farmId + '\'' +
+                "level=" + level + '\'' +
+                "msg=" + msg + '\'' +
+                "levelName=" + levelName + '\'' +
+                "warningName=" + warningName + '\'' +
+                "warningTime=" + warningTime + '\'' +
+                "uploadTime=" + uploadTime + '\'' +
+                "alarmType=" + alarmType + '\'' +
+                '}';
+    }
+}

+ 9 - 0
huimv-farm-receiver/src/main/java/com/huimv/receiver/farm/dao/repo/BaseWarningInfoRepo.java

@@ -0,0 +1,9 @@
+package com.huimv.receiver.farm.dao.repo;
+
+import com.huimv.receiver.farm.dao.entity.BaseWarningInfoEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface BaseWarningInfoRepo extends JpaRepository<BaseWarningInfoEntity, Integer>, JpaSpecificationExecutor<BaseWarningInfoEntity> {
+
+}

+ 5 - 0
huimv-farm-receiver/src/main/java/com/huimv/receiver/farm/service/IAlarm.java

@@ -0,0 +1,5 @@
+package com.huimv.receiver.farm.service;
+
+public interface IAlarm {
+    void handleEnvironAlarm(String alarmInfo);
+}

+ 45 - 0
huimv-farm-receiver/src/main/java/com/huimv/receiver/farm/service/impl/AlarmImpl.java

@@ -0,0 +1,45 @@
+package com.huimv.receiver.farm.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.receiver.farm.dao.entity.BaseWarningInfoEntity;
+import com.huimv.receiver.farm.dao.repo.BaseWarningInfoRepo;
+import com.huimv.receiver.farm.service.IAlarm;
+import com.huimv.receiver.utils.DateUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.sql.Timestamp;
+import java.util.Date;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Service
+public class AlarmImpl implements IAlarm {
+    @Autowired
+    private BaseWarningInfoRepo warningInfoRepo;
+    @Autowired
+    private DateUtil dateUtil;
+
+    @Override
+    public void handleEnvironAlarm(String alarmInfo){
+        JSONObject alarmJo = JSON.parseObject(alarmInfo);
+        BaseWarningInfoEntity warningInfoEntity  = new BaseWarningInfoEntity();
+        warningInfoEntity.setFarmId(alarmJo.getInteger("farmId"));
+        warningInfoEntity.setAlarmType(alarmJo.getInteger("alarmType"));
+        warningInfoEntity.setMsg(alarmJo.getString("info"));
+        warningInfoEntity.setLevel(alarmJo.getInteger("level"));
+        warningInfoEntity.setLevelName(alarmJo.getString("levelName"));
+        warningInfoEntity.setWarningName(alarmJo.getString("warningName"));
+        warningInfoEntity.setWarningTime(new Timestamp(alarmJo.getLong("alarmTime")));
+        warningInfoEntity.setUploadTime(new Timestamp(new Date().getTime()));
+        //
+        warningInfoRepo.saveAndFlush(warningInfoEntity);
+    }
+}

+ 17 - 4
huimv-farm-video/pom.xml

@@ -19,9 +19,6 @@
         <version>1.0.8</version>
         <version>1.0.8</version>
     </dependency>
     </dependency>
 
 
-
-
-
         <dependency>
         <dependency>
             <groupId>org.apache.httpcomponents</groupId>
             <groupId>org.apache.httpcomponents</groupId>
             <artifactId>httpclient</artifactId>
             <artifactId>httpclient</artifactId>
@@ -50,7 +47,23 @@
             <artifactId>commons-io</artifactId>
             <artifactId>commons-io</artifactId>
             <version>2.8.0</version>
             <version>2.8.0</version>
         </dependency>
         </dependency>
-
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>3.3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+            <version>0.9.1</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.json-lib</groupId>
+            <artifactId>json-lib</artifactId>
+            <version>2.2.3</version>
+            <classifier>jdk15</classifier>
+            <!-- jdk版本 -->
+        </dependency>
     </dependencies>
     </dependencies>
 
 
 
 

+ 35 - 5
huimv-farm-video/src/main/java/com/huimv/video/dhicc/controller/ClientController/ClientAllEventController.java

@@ -2,6 +2,7 @@ package com.huimv.video.dhicc.controller.ClientController;
 
 
 
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.dahuatech.hutool.http.HttpRequest;
 import com.dahuatech.hutool.http.Method;
 import com.dahuatech.hutool.http.Method;
 import com.dahuatech.icc.exception.ClientException;
 import com.dahuatech.icc.exception.ClientException;
 import com.dahuatech.icc.oauth.http.DefaultClient;
 import com.dahuatech.icc.oauth.http.DefaultClient;
@@ -11,13 +12,13 @@ import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
 import com.huimv.common.utils.StringUtilsWork;
 import com.huimv.common.utils.StringUtilsWork;
 import com.huimv.video.dhicc.icc.CommonConstant;
 import com.huimv.video.dhicc.icc.CommonConstant;
 import com.huimv.video.dhicc.result.R;
 import com.huimv.video.dhicc.result.R;
+import com.huimv.video.dhicc.service.IClientAllEventService;
 import com.huimv.video.dhicc.service.ISysTelecomEventService;
 import com.huimv.video.dhicc.service.ISysTelecomEventService;
 import net.sf.json.JSONObject;
 import net.sf.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
+import javax.servlet.http.HttpServletRequest;
 import java.text.ParseException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Calendar;
@@ -29,10 +30,11 @@ import java.util.Map;
 @RestController
 @RestController
 @RequestMapping("/client/event")
 @RequestMapping("/client/event")
 public class ClientAllEventController {
 public class ClientAllEventController {
-
-
     @Autowired
     @Autowired
     private ISysTelecomEventService sysTelecomEventService;
     private ISysTelecomEventService sysTelecomEventService;
+    @Autowired
+    private IClientAllEventService iClientAllEventService;
+
     //所有的事件接口
     //所有的事件接口
     @RequestMapping("/ListAllEvent")
     @RequestMapping("/ListAllEvent")
     public R SiZhuList(@RequestBody Map<String, Object> params1) throws ClientException, ParseException {
     public R SiZhuList(@RequestBody Map<String, Object> params1) throws ClientException, ParseException {
@@ -115,5 +117,33 @@ public class ClientAllEventController {
         JSONObject jsonObject = JSONObject.fromObject(JSONObject.fromObject(iClient.doAction(generalRequest, generalRequest.getResponseClass()).getResult()).get("data"));
         JSONObject jsonObject = JSONObject.fromObject(JSONObject.fromObject(iClient.doAction(generalRequest, generalRequest.getResponseClass()).getResult()).get("data"));
         return jsonObject.get("value").toString();
         return jsonObject.get("value").toString();
     }
     }
+
+    /**
+     * @Method      : getEventBySort
+     * @Description : 分类查看事件
+     * @Params      : [farmId, sort, startDateText, endDateText, pageNum, pageSize, request]
+     * @Return      : com.huimv.video.dhicc.result.R
+     * 
+     * @Author      : ZhuoNing
+     * @Date        : 2021/12/24       
+     * @Time        : 13:34
+     */
+    @RequestMapping(value = "/listEventBySort",method = RequestMethod.GET)
+    public R getEventBySort(@RequestParam(value = "farmId",required = true) Integer farmId,@RequestParam(value = "sort",required = true) Integer sort,
+                            @RequestParam(value = "alarmStartDateString",required = true) String startDateText,@RequestParam(value = "alarmEndDateString",required = true) String endDateText,
+                            @RequestParam(value = "pageNum",required = true) Integer pageNum,@RequestParam(value = "pageSize",required = true) Integer pageSize, HttpServletRequest request) throws ClientException {
+        //牧场id
+        if(farmId != 1){
+            return  R.ok("当前牧场无数据。").put("data",null);
+        }
+        //事件分类
+        if(sort == null){
+            return  R.ok("请选择事件分类。").put("data",null);
+        }
+        //
+        return iClientAllEventService.getEventBySort(farmId,sort,startDateText,endDateText,pageNum,pageSize,request);
+    }
+    
+
 }
 }
 
 

+ 12 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/service/IClientAllEventService.java

@@ -0,0 +1,12 @@
+package com.huimv.video.dhicc.service;
+
+import com.dahuatech.icc.exception.ClientException;
+import com.dahuatech.icc.oauth.model.v202010.GeneralResponse;
+import com.huimv.video.dhicc.result.R;
+
+import javax.servlet.http.HttpServletRequest;
+
+public interface IClientAllEventService {
+    //
+    R getEventBySort(Integer farmId, Integer sort, String startDateText, String endDateText, Integer pageNum, Integer pageSize, HttpServletRequest request) throws ClientException;
+}

+ 465 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/service/impl/ClientAllEventServiceImpl.java

@@ -0,0 +1,465 @@
+package com.huimv.video.dhicc.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+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.service.IClientAllEventService;
+import com.huimv.video.dhicc.util.GetResponse;
+import lombok.extern.slf4j.Slf4j;
+import net.sf.json.JSONObject;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@Service
+@Slf4j
+public class ClientAllEventServiceImpl implements IClientAllEventService {
+
+    @Override
+    public R getEventBySort(Integer farmId, Integer sort,String startDateText, String endDateText, Integer pageNum, Integer pageSize,HttpServletRequest request) throws ClientException {
+        Map paramsMap = new HashMap();
+        paramsMap.put("farmId",farmId);
+        paramsMap.put("pageNum",pageNum);
+        paramsMap.put("pageSize",pageSize);
+        //
+        switch (sort) {
+            case 1:
+                //大门事件
+                paramsMap.put("alarmStartDateString",startDateText);
+                paramsMap.put("alarmEndDateString",endDateText);
+                log.info("大门事件输入参数>>"+paramsMap.toString());
+                return getGateEvent(paramsMap);
+            case 2:
+                //洗消事件
+                paramsMap.put("alarmStartDateString",startDateText);
+                paramsMap.put("alarmEndDateString",endDateText);
+                log.info("洗消事件输入参数>>"+paramsMap.toString());
+                return getWashEvent(paramsMap);
+            case 3:
+                //死猪通道事件
+                paramsMap.put("alarmStartDateString",startDateText);
+                paramsMap.put("alarmEndDateString",endDateText);
+                log.info("死猪通道事件输入参数>>"+paramsMap.toString());
+                return getDeadPigChannel(paramsMap);
+            case 4:
+                //熏蒸事件
+                paramsMap.put("alarmStartDateString",startDateText);
+                paramsMap.put("alarmEndDateString",endDateText);
+                log.info("熏蒸事件输入参数>>"+paramsMap.toString());
+                return getFumigateChannel(paramsMap);
+            case 5:
+                //卖猪事件
+                paramsMap.put("alarmStartDateString",startDateText);
+                paramsMap.put("alarmEndDateString",endDateText);
+                log.info("卖猪事件输入参数>>"+paramsMap.toString());
+                return getSellPigsChannel(paramsMap);
+            case 6:
+                //人员门禁事件
+//                paramsMap.put("startSwingTime",startDateText);
+//                paramsMap.put("endSwingTime",endDateText);
+//                paramsMap.put("openType",61);
+                log.info("人员门禁事件输入参数>>"+paramsMap.toString());
+                return getEntranceGuard(paramsMap);
+            default:
+                //车辆闸机事件
+                log.info("车辆闸机事件输入参数>>"+paramsMap.toString());
+                return getCarAutoGate(request,paramsMap);
+        }
+    }
+
+    //大门事件
+    private R getGateEvent(Map<String, Object> paramsMap) throws ClientException {
+        //绑定大门通道
+        String[] doorChannel = CommonConstant.DoorChannle;
+        return R.ok("请求成功").put("data", getEventList(paramsMap, doorChannel)).put("total", CountTimes(paramsMap, doorChannel)).put("isVideo",true);
+    }
+
+    //洗消事件
+    private R getWashEvent(Map<String, Object> paramsMap) throws ClientException {
+        //绑定大门通道
+        String[] washChannel = CommonConstant.XixiaoChannle;
+        return R.ok("请求成功").put("data", getEventList(paramsMap, washChannel)).put("total", CountTimes(paramsMap, washChannel)).put("isVideo",true);
+    }
+
+    //死猪事件
+    private R getDeadPigChannel(Map<String, Object> paramsMap) throws ClientException {
+        String[] deadPigChannel = CommonConstant.SIZhuChannle;
+        return R.ok("请求成功").put("data", getEventList(paramsMap, deadPigChannel)).put("total", CountTimes(paramsMap, deadPigChannel)).put("isVideo",true);
+    }
+
+    //熏蒸事件
+    private R getFumigateChannel(Map paramsMap) throws ClientException {
+        //绑定熏蒸通道
+        String[] fumigateChannel = CommonConstant.XunZhengChannle;
+        return R.ok("请求成功").put("data", getEventList(paramsMap, fumigateChannel)).put("total", CountTimes(paramsMap, fumigateChannel)).put("isVideo",true);
+    }
+
+    //卖猪事件
+    private R getSellPigsChannel(Map paramsMap) throws ClientException {
+        //卖猪通道
+        String[] sellPigsChannel = CommonConstant.MaiZhuChannle;
+        return R.ok("请求成功").put("data", getEventList(paramsMap, sellPigsChannel)).put("total", CountTimes(paramsMap, sellPigsChannel)).put("isVideo",true);
+    }
+
+    //人员门禁事件
+    private R getEntranceGuard(Map<String, Object> paramsMap) throws ClientException {
+//        String total = SendMassageGetPagePersonAlarm(paramsMap.get("alarmStartDateString").toString(),paramsMap.get("alarmEndDateString").toString());
+//        if(total == null){
+//            total = "0";
+//        }
+        //
+//        return R.ok("请求成功").put("data", getAccidentRecord(paramsMap)).put("total", Integer.parseInt(total)).put("isVideo",false);
+//        getAccidentRecord(paramsMap);
+
+
+        return getAccidentRecord(paramsMap).put("isVideo",false);
+    }
+
+    //解析总页码
+    private Integer parseTotal(String totalText) {
+        totalText = totalText.substring(totalText.indexOf("data"),totalText.length());
+        totalText = totalText.substring(totalText.indexOf(":")+1,totalText.indexOf("}"));
+        return Integer.parseInt(totalText);
+    }
+
+    //车辆闸机事件
+    private R getCarAutoGate(HttpServletRequest request, Map<String, Object> paramsMap) throws ClientException {
+        Integer  farmId= (int) paramsMap.get("farmId");
+        GeneralResponse grObj = getCarRecord(request,farmId);
+        com.alibaba.fastjson.JSONObject grJo = JSON.parseObject(com.alibaba.fastjson.JSONObject.toJSONString(grObj));
+        com.alibaba.fastjson.JSONObject resultJo = grJo.getJSONObject("result");
+        com.alibaba.fastjson.JSONObject dataJo = resultJo.getJSONObject("data");
+        String totalRowsText = dataJo.getString("totalRows");
+        resultJo.put("total",Integer.parseInt(totalRowsText));
+        return R.ok("请求成功").put("data", grObj).put("total",Integer.parseInt(totalRowsText)).put("isVideo",false);
+    }
+
+    private R getCarAutoGate_old1(HttpServletRequest request, Map<String, Object> paramsMap) throws ClientException {
+        Integer  farmId= (int) paramsMap.get("farmId");
+        JSONObject carJo = JSONObject.fromObject(getCarRecord(request,farmId));
+        String resultText = carJo.getString("result");
+        String dataText = JSON.parseObject(resultText).getString("data");
+        String totalRowsText = JSON.parseObject(dataText).getString("totalRows");
+        //
+        return R.ok("请求成功").put("data", resultText).put("total",Integer.parseInt(totalRowsText)).put("isVideo",false);
+    }
+
+    //查询车辆通行记录 by Yangdi
+    public GeneralResponse getCarRecord(HttpServletRequest request  , @RequestParam(name = "farmId") Integer farmId  ) throws ClientException {
+        if(farmId!=1){
+            //返回为空数据
+            return  new GeneralResponse() ;
+        }
+        System.out.println(request.getRequestURL()   );
+        System.out.println(request.getQueryString());
+        String queryString = request.getQueryString();
+        String URL = "/evo-apigw/ipms/carcapture/find/conditions?";  //获取事件URL    post请求
+        IClient iClient = new DefaultClient();
+        System.out.println("开始执行");
+        String newUrl = URL + queryString;
+        System.out.println(newUrl);
+        //这种已经在配置文件里面安排了账号ip以及密码    现在变了
+        GeneralRequest generalRequest = new GeneralRequest(newUrl, Method.GET);
+        GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
+        System.out.println("执行结束");
+        return generalResponse;
+    }
+
+    //返回所有的事件 的集合  包括死猪和洗消和大门 --分页参数 by Yangdi
+    public GeneralResponse getEventList(Map<String, Object> params1, String[] nodeCodeListIn) 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.AllChannle;
+        params.put("nodeCodeList", nodeCodeListIn);
+        // String URL = "/evo-apigw/evo-event/1.2.0/alarm-record/page"; //获取事件URL    post请求
+        String URL = "/evo-apigw/evo-event/1.2.0/alarm-record/page";  //获取事件URL    post请求
+        IClient iClient = new DefaultClient();
+        String NewUrl = URL;
+        //这种已经在配置文件里面安排了账号ip以及密码
+        GeneralRequest generalRequest = new GeneralRequest(NewUrl, Method.POST);
+        System.out.println(NewUrl);
+        generalRequest.header("Content-Type", " application/json");
+        generalRequest.body(JSON.toJSONString(params));
+        GeneralResponse generalResponse = iClient.doAction(generalRequest, generalRequest.getResponseClass());
+        return generalResponse;
+    }
+
+    //计算次数 by Yangdi
+    public String CountTimes(Map<String, Object> params1, String[] nodeCodeListIn) 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("alarmType", 303);
+        params.put("dbType", 0);
+        params.put("deviceCategory", 1);
+//        String[] nodeCodeList = CommonConstant.AllChannle;
+        params.put("nodeCodeList", nodeCodeListIn);
+        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();
+    }
+
+    //刷脸失败记录 by Yangdi
+    public R getAccidentRecord(Map<String, Object> params1 ) throws ClientException {
+        System.out.println("## params1>>"+params1);
+        Integer farmId= (int) params1.get("farmId");
+        if(farmId!=1){
+            //返回为空数据
+            return  null;
+        }
+        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);
+        if (!StringUtilsWork.isNotEmpty( (String) params1.get("startSwingTime"))){
+            params1.put("startSwingTime",formatA);
+            params1.put("endSwingTime",formatD);
+        }
+        params1.put("containDomain","1");
+        params1.put("openResult",0); //刷脸失败
+        String URL = "/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combined?";
+        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();
+
+        return  R.ok("请求成功").put("data", generalResponse ).put("total",  getResponse.SendMassageGetPagePersonAlarm((String) params1.get("startSwingTime"),(String) params1.get("endSwingTime")));
+    }
+
+    //查询人员违规记录 by Yangdi
+    public GeneralResponse getAccidentRecord1(Map<String, Object> params ) throws ClientException {
+        Integer  farmId= (int) params.get("farmId");
+        if(farmId!=1){
+            //返回为空数据
+            return  new GeneralResponse() ;
+        }
+        String URL = "/evo-apigw/evo-accesscontrol/1.0.0/card/accessControl/swingCardRecord/bycondition/combined";  //获取事件URL    post请求
+        IClient iClient = new DefaultClient();
+        System.out.println("开始执行");
+        //这种已经在配置文件里面安排了账号ip以及密码
+        GeneralRequest generalRequest = new GeneralRequest(URL, Method.POST);
+        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("执行结束");
+        return generalResponse;
+    }
+
+    /**
+     *  //查人员通过过去几个小时的接口---异常通过次数接口
+     * @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);
+        System.out.println("内部参数>>"+params);
+        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");
+        System.out.println("## 内部打印结果>>"+data);
+        return data.toString();
+    }
+
+    //人员通道查询总页数 by Yangdi
+//    @RequestMapping("/get_person_record_totalpage")
+//    public GeneralResponse get_person_record_totalpage( @RequestBody Map<String, Object> params ) throws ClientException {
+//        Integer  farmId= (int) params.get("farmId");
+//        if(farmId!=1){
+//            //返回为空数据
+//            return  new GeneralResponse() ;
+//        }
+//        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("执行结束");
+//        return generalResponse;
+//    }
+
+    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,0);
+        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);
+
+        System.out.println("########### formatA>>"+formatA);
+        System.out.println("########### formatD>>"+formatD);
+
+        params1.put("pageNum",1);
+        params1.put("pageSize",20);
+        params1.put("startSwingTime",formatA);
+        params1.put("endSwingTime",formatD);
+//        params1.put("startSwingTime","2021-12-24 00:00:00");
+//        params1.put("endSwingTime","2021-12-24 23:59:59");
+
+        params1.put("containDomain","1");
+        params1.put("openResult",0); //刷脸失败
+        String URL = "/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());
+//        System.out.println("## generalResponse>>"+generalResponse.toString());
+        JSONObject jsonObject = JSONObject.fromObject(generalResponse.getResult());
+//        System.out.println("## getResult>>"+generalResponse.getResult());
+        GetResponse getResponse = new GetResponse();
+
+        System.out.println("total>>"+getResponse.SendMassageGetPagePersonAlarm((String) params1.get("startSwingTime"),(String) params1.get("endSwingTime")));
+        System.out.println(jsonObject.toString());
+//        System.out.println("## 1>>"+JSON.toJSONString(generalResponse.getResult()));
+//        JSON.parseObject(JSON.toJSONString(generalResponse.getResult()));
+//        com.alibaba.fastjson.JSONObject resultJo = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.toJSON(generalResponse.getResult());
+//        System.out.println("## resultJo>>"+resultJo);
+        com.alibaba.fastjson.JSONObject grObj = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.toJSON(generalResponse);
+        System.out.println("grObj>>"+grObj);
+        com.alibaba.fastjson.JSONObject resultJo = grObj.getJSONObject("result");
+        System.out.println("resultJo>>"+resultJo);
+        com.alibaba.fastjson.JSONObject dataJo = resultJo.getJSONObject("data");
+        System.out.println("dataJo>>"+dataJo);
+        JSONArray pageDataJa = dataJo.getJSONArray("pageData");
+        System.out.println("pageDataJa>>"+pageDataJa);
+        System.out.println("pageDataJa.size>>"+pageDataJa.size());
+
+
+
+    }
+}

+ 0 - 1
huimv-farm-video/src/main/java/com/huimv/video/dhicc/timmer/SysTelcomEnentTimmer.java

@@ -153,6 +153,5 @@ public class SysTelcomEnentTimmer {
                     }
                     }
                }
                }
            }
            }
-
        }
        }
 }
 }

+ 3 - 6
huimv-farm-video/src/main/resources/application-prod2.yml

@@ -5,9 +5,9 @@ spring:
     name: pigfarm-local-device
     name: pigfarm-local-device
   #------DataSource-----
   #------DataSource-----
   datasource:
   datasource:
-    url: jdbc:mysql://115.238.57.190:3309/huimv-farm-center?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://47.96.4.54:10052/huimv-farm-center?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&serverTimezone=Asia/Shanghai
     username: root
     username: root
-    password: root
+    password: hm123456789
     driver-class-name: com.mysql.cj.jdbc.Driver
     driver-class-name: com.mysql.cj.jdbc.Driver
   jpa:
   jpa:
     hibernate:
     hibernate:
@@ -31,7 +31,4 @@ spring:
   # 线程池 - 最大线程数 20
   # 线程池 - 最大线程数 20
   #pool-max: 30
   #pool-max: 30
   # 线程队列容量 10
   # 线程队列容量 10
-  #pool-queue-init: 10
-#mybatis-plus:
-#  configuration:
-#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+  #pool-queue-init: 10

+ 34 - 0
huimv-farm-video/src/test/java/com/huimv/video/dhicc/service/ClientAllEventServiceImplTest.java

@@ -0,0 +1,34 @@
+package com.huimv.video.dhicc.service;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+/**
+ * @Project : huimv.shiwan
+ * @Package : com.huimv.biosafety.uface.controller
+ * @Description : TODO
+ * @Version : 1.0
+ * @Author : ZhuoNing
+ * @Create : 2020-12-25
+ **/
+@SpringBootTest
+public class ClientAllEventServiceImplTest {
+
+    @Test
+    public void testPasrse(){
+        String text = "IccResponse{result='{\"success\":true,\"code\":\"0\",\"errMsg\":\"success\",\"data\":104}', requestId='null', code='0', success=true, errMsg='success'}";
+        System.out.println("text 1>>"+text);
+        text = text.substring(text.indexOf("data"),text.length());
+//        System.out.println("text 2>>"+text);
+        text = text.substring(text.indexOf(":")+1,text.indexOf("}"));
+        System.out.println("text 3>>"+text);
+//        text = text.substring(0,text.length()-1);
+//        System.out.println("text 3>>"+text);
+
+//        JSONObject dataJo = JSON.parseObject(text);
+//        System.out.println("dataJo>>"+dataJo);
+
+    }
+}