Bladeren bron

ie摄像头播放内置

18686652964 3 jaren geleden
bovenliggende
commit
14bf764279

+ 31 - 5
mybusiness/src/main/java/com/business/slfh/manager/cameramanager/controller/TResCameraController.java

@@ -1,5 +1,6 @@
 package com.business.slfh.manager.cameramanager.controller;
 
+import java.io.IOException;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
@@ -10,6 +11,7 @@ import java.util.stream.Collectors;
 
 import com.business.slfh.manager.cameramanager.domain.TResCamera;
 import com.business.slfh.manager.cameramanager.service.ITResCameraService;
+import com.business.slfh.tools.BrowserUtil;
 import com.business.slfh.tools.UUID_Tools;
 import com.business.slfh.visualization.event.service.Visualization_Event_Service;
 import com.sooka.common.annotation.Log;
@@ -24,11 +26,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.ModelMap;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 
@@ -158,6 +156,34 @@ public class TResCameraController extends BaseController
     }
 
     /**
+     * 单个摄像头使用IE预览
+     */
+    @GetMapping("/onePreviewByIE/{id}")
+    @ResponseBody
+    public AjaxResult onePreviewByIE(@PathVariable("id") String id) {
+
+        if (StringUtils.isEmpty(id)) {
+            return AjaxResult.error("启动摄像头失败,丢失唯一标识!");
+        }
+
+        TResCamera tResCamera = tResCameraService.selectTResCameraById(id);
+        if (tResCamera == null) {
+            return AjaxResult.error("启动摄像头失败,该摄像头不存在!");
+        }
+
+        String ip = tResCamera.getHikIp();
+        String port = tResCamera.getHikPort();
+        String username = tResCamera.getHikUsername();
+        String password = tResCamera.getHikPassword();
+
+        String url = "http://218.27.1.154:9090/camera2/cn/demo.html?camera_id="+ip+","+port+","+username+","+password+",8000";
+
+        System.out.println(url);
+
+        return BrowserUtil.open_ie(url);
+    }
+
+    /**
      * 单个摄像头预览
      * 历史
      */

+ 31 - 0
mybusiness/src/main/java/com/business/slfh/tools/BrowserUtil.java

@@ -0,0 +1,31 @@
+package com.business.slfh.tools;
+
+import com.alibaba.fastjson.JSONObject;
+import com.sooka.common.core.domain.AjaxResult;
+
+import java.io.IOException;
+
+/********************
+ * yanhongliang
+ * 11:24-04-07 11:24
+ *********************/
+
+public class BrowserUtil {
+
+    public static String IE = "C:\\Program Files\\Internet Explorer\\iexplore.exe";
+
+    public static AjaxResult open_ie(String url){
+        return openBrowser(url, IE);
+    }
+
+    public static AjaxResult openBrowser(String url, String browser){
+        try {
+            Runtime.getRuntime().exec(new String[] {browser, url });
+            return AjaxResult.success();
+        } catch (IOException e) {
+            e.printStackTrace();
+            return AjaxResult.error("启动失败浏览器失败:"+url);
+        }
+    }
+
+}

+ 22 - 15
mybusiness/src/main/resources/templates/business/manager/cameramanager/onePreviewOld.html

@@ -22,8 +22,8 @@
 <div class="wrapper wrapper-content fadeInRight" style="height: inherit;">
     <div class="row" style="height: auto;">
         <div class="col-sm-12" style="height: inherit;">
-            <a href="javascript:void (0)" onclick="openOnePreview()">体验新版</a>
-            <a href="javascript:void (0)" onclick="goPlugIn()">启动插件版</a>
+            <a href="javascript:void (0)" onclick="openOnePreview()">体验新版</a>
+            <a href="javascript:void (0)" onclick="goPlugIn()">启动插件版</a>
         </div>
     </div>
     <div class="row" style="height: inherit;">
@@ -311,19 +311,26 @@
     });
 
     function goPlugIn() {
-        var jIp = [[${ip}]];
-        var jPort = [[${port}]];
-        var jUsername = [[${username}]];
-        var jPassword = [[${password}]];
-        var jDeviceport = [[${deviceport}]];
-        $.post("/business/manager/cameramanager/getRoleMenu",function(e){
-            var url = 'http://localhost:8899/camera_id='+jIp+","+jPort+","+jUsername+","+jPassword+","+jDeviceport;
-            if(e == 0){
-                url+=",no_controll";
-            }
-            console.log(url);
-        $.post(url);
-        });
+        // var jIp = [[${ip}]];
+        // var jPort = [[${port}]];
+        // var jUsername = [[${username}]];
+        // var jPassword = [[${password}]];
+        // var jDeviceport = [[${deviceport}]];
+        // $.post("/business/manager/cameramanager/getRoleMenu",function(e){
+            // var url = 'http://localhost:8899/camera_id='+jIp+","+jPort+","+jUsername+","+jPassword+","+jDeviceport;
+            // if(e == 0){
+            //     url+=",no_controll";
+            // }
+            console.log(cId);
+            $.get("/business/manager/cameramanager/onePreviewByIE/"+cId, function (e) {
+                console.log(e);
+                // if (e.code !== 0) {
+                //     $.modal.alertError(e.msg);
+                // } else {
+                //     $.modal.alertError(e.msg);
+                // }
+            });
+        // });
     }
 
 </script>