Browse Source

视频联动

hanfucheng 2 weeks ago
parent
commit
69f14b6c1f

+ 2 - 0
src/main/java/com/sooka/sponest/monitor/base/service/impl/BaseService.java

@@ -61,6 +61,8 @@ public class BaseService {
     public String videoDownloadUrlLinux;
     @Value("${sooka.dahua_dss_server.video_download_url_win:}")
     public String videoDownloadUrlWin;
+    @Value("${sooka.dahua_dss_server.version_linkage:}")
+    public String versionLinkage;
 
 
     @Value("${sooka.haikang_video_server.loginIp:}")

+ 8 - 0
src/main/java/com/sooka/sponest/monitor/camera/mapper/CentermonitorTCameraMapper.java

@@ -371,5 +371,13 @@ public interface CentermonitorTCameraMapper {
 
     CentermonitorTCamera selectCameraInfoByChannelCode(@Param("channelCode") String channelCode);
 
+    /*
+    * 按摄像头编码查询通道编号
+    *
+    * @author 韩福成
+    * @date 2025/8/20 上午10:22
+    */
+    List<String> getCreamList(List<String> list);
+
 }
 

+ 18 - 5
src/main/java/com/sooka/sponest/monitor/dahua/controller/DahuaController.java

@@ -129,11 +129,11 @@ public class DahuaController {
      * @param list
      * @return
      */
-    @Log(title = "大华", businessType = BusinessType.OTHER)
-    @RequestMapping(value = "/rotation",method = GET)
-    public AjaxResult rotation(Double lng, Double lat, @RequestParam("list") List<String> list) {
-        return dahuaService.rotation(lng,lat,list);
-    }
+//    @Log(title = "大华", businessType = BusinessType.OTHER)
+//    @RequestMapping(value = "/rotation",method = GET)
+//    public AjaxResult rotation(Double lng, Double lat, @RequestParam("list") List<String> list) {
+//        return dahuaService.rotation(lng,lat,list);
+//    }
 
     /**
      * 摄像头获取回放
@@ -281,4 +281,17 @@ public class DahuaController {
         }
         return sb.toString();
     }
+
+    /*
+    *  联动调转摄像头指向
+    *
+    * @author 韩福成
+    * @date 2025/8/19 上午9:23
+    */
+    @Log(title = "大华联动调转摄像头指向", businessType = BusinessType.OTHER)
+    @GetMapping(value = "/rotation")
+    public AjaxResult rotation(Double lng, Double lat, @RequestParam("list") List<String> list) {
+        return dahuaService.cameraSteering(lng,lat,list);
+    }
+
 }

+ 8 - 0
src/main/java/com/sooka/sponest/monitor/dahua/service/DahuaService.java

@@ -106,4 +106,12 @@ public interface DahuaService {
     boolean isWindows();
 
     String secondsToFormat(Long seconds);
+
+    /*
+    * 大华联动调转摄像头指向
+    *
+    * @author 韩福成
+    * @date 2025/8/19 上午9:26
+    */
+    AjaxResult cameraSteering(Double lng, Double lat, List<String> list);
 }

+ 34 - 3
src/main/java/com/sooka/sponest/monitor/dahua/service/impl/DahuaServiceImpl.java

@@ -378,7 +378,7 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
             pr.getHttpRequest().header("Authorization", "bearer " + token);
             prBody = pr.execute();
             log.info("----结束执行----{}------返回报文:{}", "获取大华摄像头的预置点", prBody);
-            return AjaxResult.success("操作成功", JSONUtil.parseObj(prBody));
+            return AjaxResult.success("操作成功", JSON.parseObject(prBody));
         } catch (Exception ex) {
             ex.printStackTrace();
             JSONObject jsonObject = JSONUtil.parseObj(prBody);
@@ -408,10 +408,10 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
                     .header("User-Id", "1");
             prBody = pr.execute();
             log.info("----结束执行----{}------返回报文:{}", "预置点控制(添加/删除/定位)", prBody);
-            return AjaxResult.success("操作成功", JSONUtils.parse(prBody));
+            return AjaxResult.success("操作成功", JSON.parseObject(prBody));
         } catch (Exception ex) {
             ex.printStackTrace();
-            return AjaxResult.error("操作失败", JSONUtils.parse(prBody));
+            return AjaxResult.error("操作失败", JSON.parseObject(prBody));
         }
     }
 
@@ -774,5 +774,36 @@ public class DahuaServiceImpl extends BaseService implements DahuaService {
         return System.getProperty("os.name");
     }
 
+    /*
+    * 大华联动调转摄像头指向
+    *
+    * @author 韩福成
+    * @date 2025/8/19 上午9:26
+    */
+    public AjaxResult cameraSteering(Double lng, Double lat, List<String> list) {
+        List<String> creamList = centermonitorTCameraMapper.getCreamList(list);
+        if (CollectionUtils.isEmpty(creamList)) {
+            return AjaxResult.error("未找到对应的摄像头编码");
+        }
+        String ROTATION_URL = host + "/evo-apigw/evo-gmcommon/" + versionLinkage + "/watchtower/calPTAngleAndSitPosition";
+        String token = getToken();
+        for (String channelNum : creamList) {
+
+            String urlWithParams = ROTATION_URL + "?lng=" + lng + "&lat=" + lat + "&channelCode=" + channelNum;
+            log.info("----开始执行----{}------请求参数:{}", "调转摄像头指向", JSONUtil.toJsonStr(urlWithParams));
+            String prBody = null;
+            try {
+                IccHttpHttpRequest pr = new IccHttpHttpRequest(urlWithParams, Method.GET);
+                pr.getHttpRequest().header("Authorization", "bearer " + token);
+                prBody = pr.execute();
+                log.info("----结束执行----{}------返回报文:{}", "调转摄像头指向", prBody);
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                JSONObject jsonObject = JSONUtil.parseObj(prBody);
+                log.error("通道 {} 请求异常: {}", channelNum, jsonObject.get("errMsg").toString());
+            }
+        }
+        return AjaxResult.success();
+    }
 
 }

+ 8 - 0
src/main/resources/mapper/monitor/camera/CentermonitorTCameraMapper.xml

@@ -1645,4 +1645,12 @@
         WHERE ctc.channel_code = #{channelCode} limit 1
     </select>
 
+    <select id="getCreamList" resultType="java.lang.String">
+        SELECT channel_num FROM centermonitor_t_camera
+        WHERE camera_code IN
+        <foreach collection="list" item="code" open="(" separator="," close=")">
+            #{code}
+        </foreach>
+    </select>
+
 </mapper>