Browse Source

添加deviceCode、deviceProtocolType、deviceLoginType字段

bihs 1 tuần trước cách đây
mục cha
commit
d0f2dc6e4e

+ 42 - 1
src/main/java/com/sooka/sponest/monitor/camera/domain/CentermonitorTRecorderAlarm.java

@@ -18,7 +18,7 @@ public class CentermonitorTRecorderAlarm extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
     /**
-     * 摄像头编码
+     * 摄像头编码(通道编码)
      */
     private String cameraCode;
 
@@ -66,6 +66,20 @@ public class CentermonitorTRecorderAlarm extends BaseEntity {
      */
     private String deviceSn;
 
+    /**
+     * 设备编码
+     */
+    private String deviceCode;
+
+    /**
+     * 接入协议
+     */
+    private String deviceProtocolType;
+
+    /**
+     * 设备登录类型
+     */
+    private String deviceLoginType;
 
 
     public void setCameraCode(String cameraCode) {
@@ -141,6 +155,30 @@ public class CentermonitorTRecorderAlarm extends BaseEntity {
         this.deviceSn = deviceSn;
     }
 
+    public String getDeviceCode() {
+        return deviceCode;
+    }
+
+    public void setDeviceCode(String deviceCode) {
+        this.deviceCode = deviceCode;
+    }
+
+    public String getDeviceProtocolType() {
+        return deviceProtocolType;
+    }
+
+    public void setDeviceProtocolType(String deviceProtocolType) {
+        this.deviceProtocolType = deviceProtocolType;
+    }
+
+    public String getDeviceLoginType() {
+        return deviceLoginType;
+    }
+
+    public void setDeviceLoginType(String deviceLoginType) {
+        this.deviceLoginType = deviceLoginType;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@@ -153,6 +191,9 @@ public class CentermonitorTRecorderAlarm extends BaseEntity {
                 .append("deptIds", getDeptIds())
                 .append("deptNames", getDeptNames())
                 .append("deviceSn", getDeviceSn())
+                .append("deviceCode", getDeviceCode())
+                .append("deviceProtocolType", getDeviceProtocolType())
+                .append("deviceLoginType", getDeviceLoginType())
                 .toString();
     }
 }

+ 6 - 85
src/main/java/com/sooka/sponest/monitor/dahua/controller/EquipmentStatusTaskController.java

@@ -23,24 +23,14 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
-import java.io.IOException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
@@ -79,15 +69,10 @@ public class EquipmentStatusTaskController {
     private String userName;
     @Value("${sooka.dahua_interface_server.userPwd}")
     private String userPwd;
-    //获取回放URI接口ip、port、url
-    @Value("${sooka.dahua_interface_server.baseUrl}")
-    private String baseUrl;
 //    private String loginIp = "10.53.0.35";
 //    private String loginPort = "7901";
 //    private String userName = "system";
 //    private String userPwd = "Admin123";
-//    //获取回放URI接口ip、port、url
-//    private String baseUrl = "http://10.53.0.35:7901/videoService/playback/uri";
     //按组织获取设备详细信息
     public static final String ACTION = "/videoService/devicesManager/devicesInfo";
     private List<String> orgCodes = Arrays.asList("11033445593778368", "11248668755298496");
@@ -177,12 +162,12 @@ public class EquipmentStatusTaskController {
                 }
             } else {
                 //向执法中心推送设备状态
-                R result = remoteLawenforcementBaseService.deviceOpenOrClose(arr);
-                if (result.getCode() != 200) {
-                    log.info("向执法中心推送设备状态失败:{}", result.getMsg());
-                }
-                //更新执法仪在离线状态
-                centermonitorTCameraMapper.updateBatchLawEnforcementInstrumentState(arr);
+//                R result = remoteLawenforcementBaseService.deviceOpenOrClose(arr);
+//                if (result.getCode() != 200) {
+//                    log.info("向执法中心推送设备状态失败:{}", result.getMsg());
+//                }
+//                //更新执法仪在离线状态
+//                centermonitorTCameraMapper.updateBatchLawEnforcementInstrumentState(arr);
                 //误操作开机,导致设备状态非正常使用,进行告警处理
                 saveOrUpdateRecorderStatus(arr);
             }
@@ -292,68 +277,4 @@ public class EquipmentStatusTaskController {
     }
 
 
-    @RequestMapping(value = "/getAlarmVideoByChannelCodeAndAlarmTime/{deviceSn}/{alarmTime}", method = GET)
-    public void test(@PathVariable("deviceSn") String deviceSn, @PathVariable("alarmTime") String alarmTime) {
-        R<?> result = null;
-        try {
-            result = HttpTestUtils.getToken(loginIp, Integer.parseInt(loginPort), userName, userPwd);
-        } catch (Exception e) {
-            log.info("获取token失败,请检查配置信息:{}", JSONObject.parseObject(result.getMsg()));
-        }
-        String token = result.getData().toString();
-        // 定义输入格式
-        DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-        // 解析为 LocalDateTime(无时区信息)
-        LocalDateTime localDateTime = LocalDateTime.parse(alarmTime, inputFormatter);
-//        String deviceSn = "34020000001329000701";
-        String beginTime = DateTimeConversion(localDateTime);
-        // 加 10 分钟
-        LocalDateTime plus10Minutes = localDateTime.plusMinutes(10);
-//        String beginTime = "20250626T015000Z";
-//        String endTime = "20250626T020000Z";
-        String endTime = DateTimeConversion(plus10Minutes);
-        String location = "cloud";
-        String scheme = "RTSP";
-        String response = getVideoRecords(deviceSn, beginTime, endTime, location, scheme, token);
-        System.out.println(response);
-    }
-
-    public String getVideoRecords(String deviceSn, String beginTime,
-                                  String endTime, String location, String scheme,
-                                  String token) {
-        // 构建请求URL
-        String url = String.format("%s?channelCode=%s&scheme=%s&beginTime=%s&endTime=%s&location=%s",
-                baseUrl, deviceSn, scheme, beginTime, endTime, location);
-        // 创建HTTP客户端
-        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
-            // 创建GET请求
-            HttpGet httpGet = new HttpGet(url);
-            // 添加请求头
-            httpGet.addHeader("X-Subject-Token", token);
-            httpGet.addHeader("Accept", "application/json"); // 根据实际情况设置
-            // 执行请求
-            HttpResponse response = httpClient.execute(httpGet);
-            // 检查响应状态
-            int statusCode = response.getStatusLine().getStatusCode();
-            if (statusCode != 200) {
-                log.error("HTTP request failed with code: " + statusCode);
-            }
-            // 获取响应内容
-            return EntityUtils.toString(response.getEntity());
-        } catch (IOException e) {
-            log.error("HTTP request failed with exception: " + e.getMessage());
-            return null;
-        }
-    }
-
-    private String DateTimeConversion(LocalDateTime dateTime) {
-        // 转换为东八区时间(假设原始时间是东八区)
-        ZonedDateTime beijingTime = dateTime.atZone(ZoneId.of("Asia/Shanghai"));
-        // 转换为 UTC 时间(减 8 小时)
-        ZonedDateTime utcTime = beijingTime.withZoneSameInstant(ZoneId.of("UTC"));
-        // 定义输出格式(ISO 8601 格式)
-        DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyyMMdd'T'HHmmss'Z'");
-        return utcTime.format(outputFormatter);
-    }
-
 }

+ 3 - 0
src/main/java/com/sooka/sponest/monitor/dahua/utils/DeviceMonitorManager.java

@@ -146,6 +146,9 @@ public class DeviceMonitorManager {
             saveVo.setDeptIds(ObjectUtils.isEmpty(map.get("deptIds")) ? null : map.get("deptIds").toString());
             saveVo.setDeptNames(ObjectUtils.isEmpty(map.get("deptNames")) ? null : map.get("deptNames").toString());
             saveVo.setDeviceSn(ObjectUtils.isEmpty(map.get("deviceSn")) ? null : map.get("deviceSn").toString());
+            saveVo.setDeviceCode(ObjectUtils.isEmpty(map.get("deviceCode")) ? null : map.get("deviceCode").toString());
+            saveVo.setDeviceProtocolType(ObjectUtils.isEmpty(map.get("deviceProtocolType")) ? null : map.get("deviceProtocolType").toString());
+            saveVo.setDeviceLoginType(ObjectUtils.isEmpty(map.get("deviceLoginType")) ? null : map.get("deviceLoginType").toString());
 //            log.info("设备编码:{}摄像头编码:{}时间:{}执行报警操作.", deviceCode, map.get("channelCode").toString(), onlineTime);
             centermonitorTRecorderAlarmMapper.insertCentermonitorTRecorderAlarm(saveVo);
 //        System.out.println("设备编码:" + deviceCode + "摄像头编码:" + map.get("channelCode").toString() + "执行报警操作.");

+ 3 - 0
src/main/resources/mapper/monitor/camera/CentermonitorTCamerachannelMapper.xml

@@ -9,6 +9,9 @@
             channel_name channelName,
             channel_code channelCode,
             device_sn deviceSn,
+            tc.device_code deviceCode,
+            tc.device_protocol_type deviceProtocolType,
+            tc.device_login_type deviceLoginType,
             GROUP_CONCAT(ta.map_dept_id) deptIds,
             GROUP_CONCAT(ta.map_dept_name) deptNames
         FROM

+ 3 - 2
src/main/resources/mapper/monitor/camera/CentermonitorTRecorderAlarmMapper.xml

@@ -13,9 +13,10 @@
     <insert id="insertCentermonitorTRecorderAlarm" parameterType="CentermonitorTRecorderAlarm">
         INSERT INTO centermonitor_t_recorder_alarm (camera_code, camera_name, alarm_name, alarm_time,
                                                     record_id, status,
-                                                    dept_ids, dept_names, device_sn)
+                                                    dept_ids, dept_names, device_sn, device_code, device_protocol_type,
+                                                    device_login_type)
         VALUES (#{cameraCode}, #{cameraName}, #{alarmName}, #{alarmTime}, #{recordId}, #{status},
-                #{deptIds}, #{deptNames}, #{deviceSn})
+                #{deptIds}, #{deptNames}, #{deviceSn}, #{deviceCode}, #{deviceProtocolType}, #{deviceLoginType})
     </insert>
 
     <select id="selectRecorderAlarm" resultType="java.lang.Integer">