Ver código fonte

直播管理

bihuisong 4 meses atrás
pai
commit
536bbf1232

+ 48 - 38
qmjszx-admin/src/main/resources/templates/system/hik/hik.html

@@ -63,41 +63,51 @@
     </style>
 </head>
 <body>
-<div id="app">
-    <a-locale-provider :locale="zh_CN">
-        <a-row>
-            <a-col :span="24" :md="12">
-                <a-affix :offset-top="8">
-                    <div id="player"></div>
-                </a-affix>
-                <!--                <a-form-item>-->
-                <!--                    <a-button @click="wholeFullScreen" v-show="!isMoveDevice">整体全屏</a-button>-->
-                <!--                </a-form-item>-->
-            </a-col>
-            <a-col :span="24" :md="12">
-                <div class="actions">
-                    <a-form :label-col="labelCol" :wrapper-col="wrapperCol" v-show="tabActive !== 'log'">
-                        <a-form-item>
-                            <a-row>
-                                <a-col :span="8">
-                                    <a-button id="btn-realplay" @click="realplay">开始预览</a-button>
-                                    <a-button id="btn-realplay-stop" @click="stopPlay">停止预览</a-button>
-                                </a-col>
-                            </a-row>
-                        </a-form-item>
-                        <a-form-item>
-                            <a-row>
-                                <a-col :span="8">
-                                    <a-button id="btn-sound-open" @click="openSound">开启声音</a-button>
-                                    <a-button id="btn-sound-close" @click="closeSound">关闭声音</a-button>
-                                </a-col>
-                            </a-row>
-                        </a-form-item>
-                    </a-form>
-                </div>
-            </a-col>
-        </a-row>
-    </a-locale-provider>
+<div>
+    <div class="col-sm-12 search-collapse">
+        <form id="formId">
+            <div class="select-list">
+                <ul>
+                    <li>
+                        <input type="hidden" name="cameraIndexCode" id="cameraIndexCode" th:value="${cameraIndexCode}"/>
+                    </li>
+                </ul>
+            </div>
+        </form>
+    </div>
+    <div id="app">
+        <a-locale-provider :locale="zh_CN">
+            <a-row>
+                <a-col :span="24" :md="12">
+                    <a-affix :offset-top="8">
+                        <div id="player"></div>
+                    </a-affix>
+                </a-col>
+                <a-col :span="24" :md="12">
+                    <div class="actions">
+                        <a-form :label-col="labelCol" :wrapper-col="wrapperCol" v-show="tabActive !== 'log'">
+                            <a-form-item>
+                                <a-row>
+                                    <a-col :span="8">
+                                        <a-button id="btn-realplay" @click="realplay">开始预览</a-button>
+                                        <a-button id="btn-realplay-stop" @click="stopPlay">停止预览</a-button>
+                                    </a-col>
+                                </a-row>
+                            </a-form-item>
+                            <a-form-item>
+                                <a-row>
+                                    <a-col :span="8">
+                                        <a-button id="btn-sound-open" @click="openSound">开启声音</a-button>
+                                        <a-button id="btn-sound-close" @click="closeSound">关闭声音</a-button>
+                                    </a-col>
+                                </a-row>
+                            </a-form-item>
+                        </a-form>
+                    </div>
+                </a-col>
+            </a-row>
+        </a-locale-provider>
+    </div>
 </div>
 <template id="play-log">
     <div></div>
@@ -128,11 +138,10 @@
     function getCameraPreviewURL() {
         // alert(prefix+"ctx")
         $.ajax({
-            url: ('' + prefix).split("undefined")[0] + "/system/hik/getCameraPreviewURL",
+            url: ('' + prefix).split("undefined")[0] + "/system/hik/getCameraPreviewURL/" + cameraIndexCode.defaultValue,
             type: "GET",
             success: function (res) {
-                console.log("222222222222", res)
-                let initUrl = res.data[1];
+                let initUrl = res.data;
                 initPage(initUrl)
             },
             error: function (err) {
@@ -308,6 +317,7 @@
                 this.$el.style.setProperty('display', 'block')
                 this.init()
                 this.createPlayer()
+                this.realplay()
             }
         })
     }

+ 14 - 19
qmjszx-business/src/main/java/beilv/hik/controller/HiKController.java

@@ -4,27 +4,29 @@ package beilv.hik.controller;
 import beilv.common.core.controller.BaseController;
 import beilv.common.core.domain.AjaxResult;
 import beilv.hik.controller.utils.GetCameraPreviewURL;
-import beilv.hik.controller.utils.GetCameras;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
-import org.springframework.util.CollectionUtils;
+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.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
 
 
 @Controller
 @RequestMapping("/system/hik")
-public class HiKController extends BaseController  {
+public class HiKController extends BaseController {
 
     private String prefix = "system/hik";
 
-    @GetMapping()
-    public String hik() {
+    @GetMapping("/{cameraIndexCode}")
+    public String hik(@PathVariable("cameraIndexCode") String cameraIndexCode, ModelMap mmap) throws IOException {
+        mmap.put("cameraIndexCode", cameraIndexCode);
         return prefix + "/hik";
     }
 
@@ -38,17 +40,10 @@ public class HiKController extends BaseController  {
     /**
      * 获取直播流地址
      */
-    @GetMapping("/getCameraPreviewURL")
+    @GetMapping("/getCameraPreviewURL/{cameraIndexCode}")
     @ResponseBody
-    public AjaxResult getCameraPreviewURL() {
-        List<String> urlList = new ArrayList<>();
-        List<Map<String, Object>> cameras = GetCameras.getCameras(host, appKey, appSecret);
-        if (!CollectionUtils.isEmpty(cameras)) {
-            for (Map<String, Object> map : cameras) {
-                String url = GetCameraPreviewURL.getCameraPreviewURL(host, appKey, appSecret, map.get("cameraIndexCode").toString());
-                urlList.add(url);
-            }
-        }
-        return AjaxResult.success(urlList);
+    public AjaxResult getCameraPreviewURL(@PathVariable("cameraIndexCode") String cameraIndexCode) {
+        String cameraPreviewURL = GetCameraPreviewURL.getCameraPreviewURL(host, appKey, appSecret, cameraIndexCode);
+        return AjaxResult.success("操作成功", cameraPreviewURL);
     }
 }

+ 3 - 0
qmjszx-framework/src/main/java/beilv/framework/config/ShiroConfig.java

@@ -271,6 +271,9 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ruoyi.png**", "anon");
         filterChainDefinitionMap.put("/html/**", "anon");
         filterChainDefinitionMap.put("/css/**", "anon");
+        filterChainDefinitionMap.put("/hik/**", "anon");
+        // 小程序直播不需要拦截的访问
+        filterChainDefinitionMap.put("/system/hik/**", "anon");
         filterChainDefinitionMap.put("/docs/**", "anon");
         filterChainDefinitionMap.put("/fonts/**", "anon");
         filterChainDefinitionMap.put("/img/**", "anon");