Forráskód Böngészése

Merge branch 'master' of http://124.70.58.209:3000/ytrd-project-management/GeoHazardMonitor

gao.qiang 2 éve
szülő
commit
70ce2daad5

+ 2 - 2
.idea/compiler.xml

@@ -7,10 +7,10 @@
         <sourceOutputDir name="target/generated-sources/annotations" />
         <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
         <outputRelativeToContentRoot value="true" />
-        <module name="hazard-admin" />
         <module name="hazard-sdk" />
-        <module name="base-admin" />
         <module name="business-service" />
+        <module name="hazard-admin" />
+        <module name="base-admin" />
       </profile>
     </annotationProcessing>
     <bytecodeTargetLevel>

+ 12 - 12
.idea/jarRepositories.xml

@@ -1,16 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="RemoteRepositoriesConfiguration">
-    <remote-repository>
-      <option name="id" value="central" />
-      <option name="name" value="Central Repository" />
-      <option name="url" value="https://maven.aliyun.com/repository/public" />
-    </remote-repository>
-    <remote-repository>
-      <option name="id" value="central" />
-      <option name="name" value="Central Repository" />
-      <option name="url" value="https://repo.maven.apache.org/maven2" />
-    </remote-repository>
     <remote-repository>
       <option name="id" value="public" />
       <option name="name" value="aliyun nexus" />
@@ -18,8 +8,8 @@
     </remote-repository>
     <remote-repository>
       <option name="id" value="central" />
-      <option name="name" value="Maven Central repository" />
-      <option name="url" value="https://repo1.maven.org/maven2" />
+      <option name="name" value="Central Repository" />
+      <option name="url" value="https://repo.maven.apache.org/maven2" />
     </remote-repository>
     <remote-repository>
       <option name="id" value="central" />
@@ -36,6 +26,11 @@
       <option name="name" value="Central Repository" />
       <option name="url" value="http://maven.aliyun.com/nexus/content/repositories/central/" />
     </remote-repository>
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
     <remote-repository>
       <option name="id" value="custom_group" />
       <option name="name" value="Nexus Repository" />
@@ -46,5 +41,10 @@
       <option name="name" value="JBoss Community repository" />
       <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
     </remote-repository>
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Central Repository" />
+      <option name="url" value="https://maven.aliyun.com/repository/public" />
+    </remote-repository>
   </component>
 </project>

+ 3 - 2
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -385,7 +385,7 @@ public class BaseCameraManagementController extends BaseController {
         return new AjaxResult(200, "ok", CameraUtil.getPlayFlv(cameraCode, one.getChannel()));
     }
 
-    @ApiOperation("播放回放")
+    @ApiOperation("播放回放-废弃")
     @PostMapping("/api/invite")
     public AjaxResult apiInvite(@Validated @RequestBody BaseCameraResVo vo) {
         LambdaQueryWrapper<BaseCameraManagement> lw = new LambdaQueryWrapper<BaseCameraManagement>();
@@ -394,7 +394,8 @@ public class BaseCameraManagementController extends BaseController {
         if (ObjectUtils.isEmpty(one)) {
             throw new BaseException("相机编号【" + vo.getCameraCode() + "】不存在");
         }
-        return success(CameraUtil.historyPlayList(one.getChannel(), vo.getStartTime(), vo.getEntTime(), caneraConfig.getMappingUrl()));
+        // CameraUtil.historyPlayList(one.getChannel(), vo.getStartTime(), vo.getEntTime(), caneraConfig.getMappingUrl())
+        return success();
     }
 
     @ApiOperation("播放回放")

+ 22 - 0
hazard-admin/src/main/java/com/ozs/web/controller/system/SysLoginController.java

@@ -60,6 +60,28 @@ public class SysLoginController {
         return ajax;
     }
 
+    /**
+     * 登录方法
+     *
+     * @param loginBody 登录信息
+     * @return 结果
+     */
+    @PostMapping("/loginApp")
+    public AjaxResult loginApp(@RequestBody LoginBody loginBody) {
+        AjaxResult ajax = AjaxResult.success();
+        // 生成令牌
+        String token = loginService.loginApp(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
+                loginBody.getUuid());
+        ajax.put(Constants.TOKEN, token);
+        LoginUser loginedUser = tokenService.getLoginedUserByToken(token);
+        if (loginedUser != null) {
+            ajax.put("userId", loginedUser.getUserId());
+            ajax.put("username", loginedUser.getUsername());
+            ajax.put("avatar", loginedUser.getUser() != null ? loginedUser.getUser().getAvatar() : "");
+        }
+        return ajax;
+    }
+
     /**
      * 获取用户信息
      *

+ 5 - 11
hazard-admin/src/main/java/com/ozs/web/core/config/CaneraConfig.java

@@ -8,17 +8,12 @@ import org.springframework.context.annotation.Configuration;
 @Data
 public class CaneraConfig {
 
-    /**
-     * 视频服务器访问路径
-     */
-    @Value("${base.url:http://47.106.159.135:8554}")
-    private String url;
-
     /**
      * 视频服务器访问路径
      */
     @Value("${base.historyUrl:http://47.106.159.135/streams}")
     private String historyUrl;
+
     /**
      * ffmpeg.exe路径
      * "D:\\Java\\operSources\\ffmpeg-4.3.1\\bin\\ffmpeg.exe"
@@ -27,13 +22,12 @@ public class CaneraConfig {
     private String ffmpegPath;
 
 
-    @Value("${base.mappingUrl:http://47.106.159.135/}")
-    private String mappingUrl;
-
     @Value("${base.filePath:/opt/streams/}")
     private String filePath;
 
-    @Value("${base.flvPath:/opt/streams/record/flv/hazard/}")
-    private String flvPath;
+
+    @Value("${base.webUrl:http://47.106.159.135/streams}")
+    private String webUrl;
+
 
 }

+ 29 - 167
hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

@@ -4,18 +4,15 @@ package com.ozs.web.core.util;
 import com.alibaba.fastjson2.JSON;
 import com.ozs.common.config.BaseConfig;
 import com.ozs.common.constant.Constants;
-import com.ozs.common.core.domain.AjaxResult;
 import com.ozs.common.exception.base.BaseException;
 import com.ozs.common.utils.DateUtils;
 import com.ozs.common.utils.http.HttpUtils;
 import com.ozs.web.core.config.CaneraConfig;
-import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
-import org.springframework.web.bind.annotation.GetMapping;
 
 import javax.annotation.PostConstruct;
 import java.io.*;
@@ -32,12 +29,10 @@ import java.util.stream.Collectors;
 @Slf4j
 public class CameraUtil {
 
-    private static String url;
     private static String historyUrl;
     private static String ffmpegPath;
-    private static String mappingUrl;
-    private static String flvPath;
     private static String filePath;
+    private static String webUrl;
 
     @Autowired
     private CaneraConfig caneraConfig;
@@ -53,7 +48,6 @@ public class CameraUtil {
      */
     public static String historyPlay(List<String> fromVideoFileList, String ph) {
         // 视频服务映射路径
-//        String NewfilePath = flvPath + ph;
         String NewfilePath = BaseConfig.getProfile() + "/" + ph;
         log.info("NewfilePath:{}", NewfilePath);
         log.info("fromVideoFileList:{}", fromVideoFileList);
@@ -68,10 +62,7 @@ public class CameraUtil {
                 e.printStackTrace();
             }
         }).start();
-        // windows可以 linux不行
-//        convetor(fromVideoFileList, NewfilePath);
         return Constants.RESOURCE_PREFIX + "/" + ph;
-//        return mappingUrl + "record/flv/hazard/" + ph;
     }
 
     /**
@@ -82,7 +73,7 @@ public class CameraUtil {
      * @return
      */
     public static String getPlayFlv(String cameraCode, String channel) {
-        return historyUrl + "/hdl/" + channel + "/" + cameraCode + ".flv";
+        return webUrl + "/hdl/" + channel + "/" + cameraCode + ".flv";
     }
 
     /**
@@ -106,24 +97,17 @@ public class CameraUtil {
         return historyUrl + "/api/record/flv/stop?id=" + taskId;
     }
 
+
     /**
-     * 实时播放
+     * 历史回放流(获取)
      *
-     * @param cameraCode
-     * @param channel
+     * @param channel 相机通道
+     * @param startTm 开始时间
+     * @param endTm   结束时间
      * @return
      */
-    public static String play(String cameraCode, String channel) {
-        if (StringUtils.isBlank(cameraCode) || StringUtils.isBlank(channel)) {
-            return null;
-        }
-        String param = "id=" + cameraCode + "&channel=" + channel;
-        return HttpUtils.sendGet(url + "/gb28181/api/records", param);
-    }
-
-
     public static String historyPlayListStr(String channel, Date startTm, Date endTm) {
-        List<String> list = historyPlayList(channel, startTm, endTm, filePath);
+        List<String> list = filterPlayList(channel, startTm, endTm, filePath);
         String ph = "flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date())
                 + "/" + channel + "/"
                 + UUID.randomUUID().toString() + ".flv";
@@ -141,7 +125,16 @@ public class CameraUtil {
     }
 
 
-    public static List<String> historyPlayList(String channel, Date startTm, Date endTm, String mappingUrl) {
+    /**
+     * 过滤符合条件的视频
+     *
+     * @param channel
+     * @param startTm
+     * @param endTm
+     * @param mappingUrl
+     * @return
+     */
+    public static List<String> filterPlayList(String channel, Date startTm, Date endTm, String mappingUrl) {
         if (StringUtils.isBlank(channel)
                 || ObjectUtils.isEmpty(startTm)
                 || ObjectUtils.isEmpty(endTm)) {
@@ -209,133 +202,11 @@ public class CameraUtil {
     }
 
     /**
-     * * 参数:
-     * **List<String> fromVideoFileList 需要合并的多视频url地址以List存放**
-     * **String ffmpeg 此处是ffmpeg 配置地址,可写死如“E:/ffmpeg/bin/ffmpeg.exe”**
-     * **String NewfilePath 合并后的视频存放地址,如:E:/mergevideo.mp4***
+     * 合并视频(转化文件)
+     * @param fromVideoFileList 视频路径
+     * @param newfilePath 生产新的视频文件路径
+     * @throws IOException
      */
-    public static void convetor(List<String> fromVideoFileList,
-                                String newfilePath) throws IOException {
-        File file = new File(newfilePath);
-        if (!file.getParentFile().exists()) {
-            file.getParentFile().mkdirs();
-            log.info("创建文件夹:{}", file.getParentFile().getPath());
-        }
-        log.info("newfilePath:{}", newfilePath);
-        Runtime.getRuntime().exec("chmod 777 " + file.getParentFile().getPath());
-        List<String> voidTS = new ArrayList<>();
-        Process process = null;
-        ProcessBuilder builder = null;
-        List<String> command = null;
-        String substr = fromVideoFileList.get(0).substring(0, fromVideoFileList.get(0).lastIndexOf("/"));
-        log.info("substr:{}", substr);
-        Runtime.getRuntime().exec("chmod 777 " + substr);
-        // 转化为临时文件 .ts  放入到 voidTS里面
-        for (int i = 0; i < fromVideoFileList.size(); i++) {
-            String fromVideoFile = fromVideoFileList.get(i);
-            File file1 = new File(fromVideoFile);
-            if (file1.exists()) {
-                log.info("文件存在:{}", fromVideoFile);
-                command = new ArrayList<String>();
-                command.add(ffmpegPath);
-                command.add("-y");
-                command.add("-i");
-                command.add(fromVideoFile);
-                command.add("-vcodec");
-                command.add("copy");
-                command.add("-bsf:v");
-                command.add("h264_mp4toannexb");
-                command.add("-f");
-                command.add("mpegts");
-                command.add(fromVideoFile.substring(0,
-                        fromVideoFile.lastIndexOf(".")) + ".ts");
-                builder = new ProcessBuilder(command);
-                voidTS.add(fromVideoFile.substring(0,
-                        fromVideoFile.lastIndexOf(".")) + ".ts");
-                try {
-                    process = builder.start();
-                    InputStream errorStream = process
-                            .getErrorStream();
-                    InputStreamReader inputStreamReader = new InputStreamReader(
-                            errorStream);
-                    BufferedReader br = new BufferedReader(
-                            inputStreamReader);
-                    String line = "";
-                    StringBuffer sb = new StringBuffer();
-                    while ((line = br.readLine()) != null) {
-                        sb.append(line);
-                    }
-                    String regexDuration = "Duration: (.*?), start: (.*?), bitrate: (\\d*) kb\\/s";
-                    Pattern pattern = Pattern
-                            .compile(regexDuration);
-                    Matcher m = pattern.matcher(sb.toString());
-                    System.out.println(sb.toString());
-                    br.close();
-                    inputStreamReader.close();
-                    errorStream.close();
-                } catch (IOException e) {
-                    log.error(e.getMessage());
-                    e.printStackTrace();
-                }
-            } else {
-                log.info("文件不存在:{}", fromVideoFile);
-            }
-        }
-        for (String voidT : voidTS) {
-            Runtime.getRuntime().exec("chmod 777 " + voidT);
-        }
-        log.info("ffmpegPath:{}", ffmpegPath);
-        List<String> dos = new ArrayList<>();
-        StringBuffer tsPath = new StringBuffer();
-        tsPath.append(ffmpegPath);
-        tsPath.append(" -i ");
-        tsPath.append("concat:");
-        log.info("voidTS:{}", voidTS);
-        for (int t = 0; t < voidTS.size(); t++) {
-            if (t != voidTS.size() - 1) {
-                tsPath.append(voidTS.get(t) + "|");
-            } else {
-                tsPath.append(voidTS.get(t));
-            }
-        }
-        tsPath.append(" -vcodec ");
-        tsPath.append(" copy ");
-        tsPath.append(" -bsf:a ");
-        tsPath.append(" aac_adtstoasc ");
-        tsPath.append(" -movflags ");
-        tsPath.append(" +faststart ");
-        tsPath.append(newfilePath);
-        log.info("执行的命令:{}", tsPath.toString());
-        Process pr = Runtime.getRuntime().exec(
-                tsPath.toString());
-        process.getInputStream();
-        pr.getOutputStream().close();
-        pr.getInputStream().close();
-        pr.getErrorStream().close();
-        try {
-            int i = pr.waitFor();
-            System.out.println("********");
-            log.info("********");
-            System.out.println(i);
-            log.info(i + "");
-            log.info("********");
-            System.out.println("********");
-        } catch (InterruptedException e) {
-            log.error(e.getMessage());
-            e.printStackTrace();
-        } finally {
-            pr.destroy();
-        }
-
-        //删除生成的ts文件
-//        for (String filePath : voidTS) {
-//            File filet = new File(filePath);
-//            filet.delete();
-//            pr.destroy();
-//        }
-    }
-
-
     public static void myConvetor(List<String> fromVideoFileList,
                                   String newfilePath) throws IOException {
         /*
@@ -435,30 +306,21 @@ public class CameraUtil {
         String s = HttpUtils.sendGet("http://47.106.159.135/streams" + "/api/record/flv/list", param);
     }
 
-    //工具类
-
-    public static void queryRecords(String cameraCode, String channel, Date startTm, Date endTm) {
-        if (StringUtils.isBlank(cameraCode)
-                || StringUtils.isBlank(channel)
-                || ObjectUtils.isEmpty(startTm)
-                || ObjectUtils.isEmpty(endTm)) {
-            throw new BaseException("参数为空");
-        }
-        String param = "id=" + cameraCode + "&channel=" + channel + "&startTime=" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, startTm) + "&endTm=" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, endTm);
-        String s = HttpUtils.sendGet(historyUrl + "/api/gb28181/query/records", param);
-        System.out.println(s);
-    }
 
     @PostConstruct
     public void init() {
-        url = caneraConfig.getUrl();
-        mappingUrl = caneraConfig.getMappingUrl();
         historyUrl = caneraConfig.getHistoryUrl();
         ffmpegPath = caneraConfig.getFfmpegPath();
-        flvPath = caneraConfig.getFlvPath();
         filePath = caneraConfig.getFilePath();
+        webUrl = caneraConfig.getWebUrl();
     }
 
+    /**
+     * 定时任务参数flv文件
+     *
+     * @throws IOException
+     * @throws InterruptedException
+     */
     public void deleteFlv() throws IOException, InterruptedException {
         SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
         Date date = new Date();

+ 3 - 3
hazard-admin/src/main/resources/application.yml

@@ -15,11 +15,11 @@ base:
   addressEnabled: false
   # 验证码类型 math 数组计算 char 字符验证
   captchaType: math
-  #  path: http://47.106.159.135:8554
-  path: http://47.106.159.135:8554
+  # 摄像头配置
   ffmpegPath: /usr/local/ffmpeg/bin/ffmpeg
-  mappingUrl: http://47.106.159.135/
   filePath: /opt/streams/
+  historyUrl: http://127.0.0.1:9080
+  webUrl: http://124.70.58.209:9080
 
 # 开发环境配置
 server: