Browse Source

相机修改

hexiao 2 years ago
parent
commit
b9778103e6

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

@@ -31,10 +31,8 @@ import com.ozs.web.core.config.CaneraConfig;
 import com.ozs.web.core.util.CameraUtil;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.http.MediaType;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
@@ -384,7 +382,11 @@ public class BaseCameraManagementController extends BaseController {
         if (ObjectUtils.isEmpty(one)) {
             throw new BaseException("相机编号【" + vo.getCameraCode() + "】不存在");
         }
-        return new AjaxResult(200, "ok", CameraUtil.historyPlayListStr(one.getChannel(), vo.getStartTime(), vo.getEntTime()));
+        String path = CameraUtil.historyPlayListStr(one.getChannel(), vo.getStartTime(), vo.getEntTime());
+        if (org.apache.commons.lang3.StringUtils.isBlank(path)) {
+            throw new BaseException("当前相机无视频录像");
+        }
+        return new AjaxResult(200, "ok", serverConfig + path);
 //        return success(CameraUtil.historyPlayList(one.getChannel(), vo.getStartTime(), vo.getEntTime()));
     }
 

+ 11 - 2
hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

@@ -3,6 +3,7 @@ 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;
@@ -36,6 +37,7 @@ public class CameraUtil {
     private static String mappingUrl;
     private static String flvPath;
     private static String filePath;
+
     @Autowired
     private CaneraConfig caneraConfig;
 
@@ -50,9 +52,13 @@ public class CameraUtil {
      */
     public static String historyPlay(List<String> fromVideoFileList, String ph) {
         // 视频服务映射路径
-        String NewfilePath = flvPath + ph;
+//        String NewfilePath = flvPath + ph;
+        String NewfilePath = BaseConfig.getProfile() + ph;
         log.info("NewfilePath:{}", NewfilePath);
         log.info("fromVideoFileList:{}", fromVideoFileList);
+        if (ObjectUtils.isEmpty(fromVideoFileList) || fromVideoFileList.size() <= 0) {
+            throw new BaseException("当前相机无视频录像");
+        }
         new Thread(() -> {
             try {
                 myConvetor(fromVideoFileList, NewfilePath);
@@ -63,7 +69,8 @@ public class CameraUtil {
         }).start();
         // windows可以 linux不行
 //        convetor(fromVideoFileList, NewfilePath);
-        return mappingUrl + "record/flv/hazard/" + ph;
+        return Constants.RESOURCE_PREFIX + ph;
+//        return mappingUrl + "record/flv/hazard/" + ph;
     }
 
     /**
@@ -126,6 +133,8 @@ public class CameraUtil {
                 log.error(e.getMessage());
                 e.printStackTrace();
             }
+        } else {
+            throw new BaseException("当前相机无视频录像");
         }
         return null;
     }