소스 검색

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

gao.qiang 2 년 전
부모
커밋
9be0e389d4

+ 31 - 28
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/MsgAlarmController.java

@@ -169,13 +169,13 @@ public class MsgAlarmController extends BaseController {
     public AjaxResult selectMsgAlarm(@RequestBody MsgAlarmVo msgAlarmVo) {
         msgAlarmVo = (MsgAlarmVo) dataScoreUtil.setDataScore(getUserId(), msgAlarmVo);
         if (!ObjectUtils.isEmpty(msgAlarmVo.getAlarmMile())) {
-                msgAlarmVo.setAlarmMile(msgAlarmVo.getAlarmMile() * 1000);
+            msgAlarmVo.setAlarmMile(msgAlarmVo.getAlarmMile() * 1000);
         }
         if (!ObjectUtils.isEmpty(msgAlarmVo.getBeginMile())) {
-                msgAlarmVo.setBeginMile(msgAlarmVo.getBeginMile() * 1000);
+            msgAlarmVo.setBeginMile(msgAlarmVo.getBeginMile() * 1000);
         }
         if (!ObjectUtils.isEmpty(msgAlarmVo.getEndMile())) {
-                msgAlarmVo.setEndMile(msgAlarmVo.getEndMile() * 1000);
+            msgAlarmVo.setEndMile(msgAlarmVo.getEndMile() * 1000);
         }
         IPage<MsgAlarm> page = msgAlarmService.queryPage(msgAlarmVo);
         page.setTotal(page.getTotal());
@@ -222,7 +222,7 @@ public class MsgAlarmController extends BaseController {
         }
         return AjaxResult.success(page);
     }
-    
+
     /**
      * 导出报警消息
      *
@@ -317,6 +317,9 @@ public class MsgAlarmController extends BaseController {
             msgAlarmResp.setBeginMile(endMile);
             String mile = AppendUtils.stringAppend(baseCameraManagement.getInstallMile());
             msgAlarmResp.setAlarmMile(mile);
+            if (!ObjectUtils.isEmpty(msgAlarm.getReleasedType())) {
+                msgAlarmResp.setReleasedTypeName(msgAlarmResp.getReleasedType() == 1 ? "真实报警" : "误报警");
+            }
             msgAlarmResp.setInstallLongitude(baseCameraManagement.getInstallLongitude() + "," + baseCameraManagement.getInstallLatitude());
             return AjaxResult.success(msgAlarmResp);
         } else {
@@ -373,8 +376,8 @@ public class MsgAlarmController extends BaseController {
     @ApiOperation("根据报警信息ID解除报警")
     @Log(title = "报警信息管理", businessType = BusinessType.UPDATE)
     public AjaxResult updateIsLock(@RequestParam(value = "id") Long id,
-                                   @RequestParam(value = "releasedType",required = false) Integer releasedType,
-                                   @RequestParam(value = "releasedReason",required = false) String releasedReason) {
+                                   @RequestParam(value = "releasedType", required = false) Integer releasedType,
+                                   @RequestParam(value = "releasedReason", required = false) String releasedReason) {
         MsgAlarm msgAlarm = msgAlarmService.getById(id);
         msgAlarm.setIsLock(1);
         msgAlarm.setUpdateBy(getUserId());
@@ -509,30 +512,30 @@ public class MsgAlarmController extends BaseController {
         }
 
         List<Integer> list1 = new ArrayList<>();
-            if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
-                list.forEach(l -> {
-                    list1.add(l.getMonthsta());
-                });
-            }
-            AlarmStatisticMonthDto dto;
-            for (int i = 0; i < numbs.size(); i++) {
-                if (!list1.contains(numbs.get(i))) {
-                    dto = new AlarmStatisticMonthDto();
-                    dto.setMonthsta(numbs.get(i));
-                    dto.setFrequency(0);
-                    list.add(dto);
-                }
+        if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
+            list.forEach(l -> {
+                list1.add(l.getMonthsta());
+            });
+        }
+        AlarmStatisticMonthDto dto;
+        for (int i = 0; i < numbs.size(); i++) {
+            if (!list1.contains(numbs.get(i))) {
+                dto = new AlarmStatisticMonthDto();
+                dto.setMonthsta(numbs.get(i));
+                dto.setFrequency(0);
+                list.add(dto);
             }
-            if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
-                Collections.sort(list, new Comparator<AlarmStatisticMonthDto>() {
-                    @Override
-                    public int compare(AlarmStatisticMonthDto o1, AlarmStatisticMonthDto o2) {
+        }
+        if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
+            Collections.sort(list, new Comparator<AlarmStatisticMonthDto>() {
+                @Override
+                public int compare(AlarmStatisticMonthDto o1, AlarmStatisticMonthDto o2) {
 
-                        return o1.getMonthsta().compareTo(o2.getMonthsta());
-                    }
-                });
-            }
-            return AjaxResult.success(list);
+                    return o1.getMonthsta().compareTo(o2.getMonthsta());
+                }
+            });
+        }
+        return AjaxResult.success(list);
     }
 
 

+ 32 - 3
hazard-admin/src/main/java/com/ozs/web/controller/app/GeoHazardMineController.java

@@ -7,10 +7,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ozs.common.core.controller.BaseController;
 import com.ozs.common.core.domain.AjaxResult;
 
+import com.ozs.common.core.domain.entity.SysUser;
+import com.ozs.common.core.domain.model.LoginUser;
 import com.ozs.common.utils.ImgUtil;
 import com.ozs.common.utils.MinioUtils;
+import com.ozs.common.utils.SecurityUtils;
 import com.ozs.common.utils.StringUtils;
 import com.ozs.common.utils.uuid.IdUtils;
+import com.ozs.framework.web.service.TokenService;
 import com.ozs.service.entity.BaseCameraManagement;
 import com.ozs.service.entity.BaseRailwayManagement;
 import com.ozs.service.entity.MsgAlarm;
@@ -46,6 +50,11 @@ import java.util.UUID;
 @RequestMapping("/app/mine")
 @Slf4j
 public class GeoHazardMineController extends BaseController {
+    public static final String PW_PATTERN = "^(?![A-Za-z0-9]+$)(?![a-z0-9\\W]+$)(?![A-Za-z\\W]+$)(?![A-Z0-9\\W]+$)[a-zA-Z0-9\\W]{8,20}$";
+    @Autowired
+    private ISysUserService userService;
+    @Autowired
+    private TokenService tokenService;
     @Value("${file.avatarUrl:#{null}}")
     private String avatarURL;
     @Value("${file.filreUrl:#{null}}")
@@ -98,9 +107,29 @@ public class GeoHazardMineController extends BaseController {
      */
     @RequestMapping(value = "/updatePassword", method = RequestMethod.POST)
     @ApiOperation("app修改密码")
-    public AjaxResult updatePassword(@RequestParam("userId") String userId, @RequestParam("newPwd") String newPwd) {
-        sysUserService.updatePassword(userId, newPwd);
-        return AjaxResult.success();
+    public AjaxResult updatePassword(@RequestBody SysUser user) {
+//        sysUserService.updatePassword(userId, newPwd);
+//        return AjaxResult.success();
+        LoginUser loginUser = getLoginUser();
+        if (!SecurityUtils.matchesPassword(user.getPassword(), loginUser.getPassword())) {
+            return error("修改密码失败,旧密码错误");
+        }
+        boolean matches = user.getNewPassword().matches(PW_PATTERN);
+        if (!matches) {
+            return error("您的密码太简单!需要包含大小英文、数字、特殊字符、并且长度8-20");
+        }
+        if (SecurityUtils.matchesPassword(user.getNewPassword(), loginUser.getPassword())) {
+            return error("新密码不能与旧密码相同");
+        }
+        user.setPassword(SecurityUtils.encryptPassword(user.getNewPassword()));
+        user.setUpdateBy(getUsername());
+        if (userService.resetPwd(user) > 0) {
+            // 更新缓存用户密码
+            loginUser.getUser().setPassword(SecurityUtils.encryptPassword(user.getNewPassword()));
+            tokenService.setLoginUser(loginUser);
+            return success();
+        }
+        return error("修改密码异常,请联系管理员");
     }
 
     /**

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

@@ -8,11 +8,6 @@ import org.springframework.context.annotation.Configuration;
 @Data
 public class CaneraConfig {
 
-    /**
-     * 视频服务器访问路径
-     */
-    @Value("${base.historyUrl:http://47.106.159.135/streams}")
-    private String historyUrl;
 
     /**
      * ffmpeg.exe路径
@@ -21,7 +16,6 @@ public class CaneraConfig {
     @Value("${base.ffmpegPath:C:\\Users\\Administrator.DESKTOP-0NUUTMM\\Downloads\\ffmpeg-5.1.2-essentials_build\\ffmpeg-5.1.2-essentials_build\\bin\\ffmpeg.exe}")
     private String ffmpegPath;
 
-
     @Value("${base.filePath:/opt/streams/}")
     private String filePath;
 
@@ -31,7 +25,6 @@ public class CaneraConfig {
     @Value("${base.transcribeFilePath:/opt/streams/record/flv}")
     private String transcribeFilePath;
 
-
     @Value("${base.webUrl:http://47.106.159.135/streams}")
     private String webUrl;
 
@@ -39,8 +32,4 @@ public class CaneraConfig {
     private String bakUrl;
 
 
-    @Value("${base.recordUrl:http://124.70.58.209:18832}")
-    private String recordUrl;
-
-
 }

+ 62 - 66
hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

@@ -10,6 +10,7 @@ import com.ozs.common.core.redis.RedisCache;
 import com.ozs.common.exception.base.BaseException;
 import com.ozs.common.utils.DateUtils;
 import com.ozs.common.utils.http.HttpUtils;
+import com.ozs.framework.config.ServerConfig;
 import com.ozs.service.entity.BaseCameraManagement;
 import com.ozs.service.service.BaseCameraManagementService;
 import com.ozs.system.mapper.SysDictDataMapper;
@@ -19,8 +20,6 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
 
@@ -33,8 +32,6 @@ import java.util.*;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 /**
@@ -47,8 +44,7 @@ import java.util.stream.Collectors;
 public class CameraUtil {
 
     private static final ExecutorService executor = Executors.newFixedThreadPool(20);
-    private static String historyUrl;
-    private static String recordUrl;
+
     private static String ffmpegPath;
     private static String filePath;
     private static String transcribeFilePath;
@@ -56,19 +52,33 @@ public class CameraUtil {
     private static String bakUrl;
     private static CmdCameraUtil cUtil;
     private static RedisCache rc;
+    private static ServerConfig sc;
 
     public final static String mvkey = "WAIT_MERGE_VIDEO_ALARM_ID";
+
+    public final static String tsFilekey = "mergeVideoTsFile";
+
+    // 相机配置
     @Autowired
     private CaneraConfig caneraConfig;
 
+    // 命令工具
     @Autowired
     private CmdCameraUtil cmdCameraUtil;
 
+    // 字典
     @Autowired
     private SysDictDataMapper dictDataMapper;
 
+    // redis
     @Autowired
     private RedisCache redisCache;
+
+    // redis
+    @Autowired
+    private ServerConfig serverConfig;
+
+
     @Resource
     BaseCameraManagementService baseCameraManagementService;
 
@@ -93,15 +103,6 @@ public class CameraUtil {
             @Override
             public void run() {
                 try {
-//                    Map<String, String> map = myConvetor(fromVideoFileList, NewfilePath, uuid);
-//                    if (!ObjectUtils.isEmpty(map)) {
-//                        cUtil.cmd(map.get("cmd"));
-//                        //删除生成的ts文件
-//                        File file1 = new File(map.get("path"));
-//                        if (file1.exists()) {
-//                            file1.delete();
-//                        }
-//                    }
                     txConvetor(fromVideoFileList, NewfilePath, uuid);
                 } catch (IOException e) {
                     log.error(e.getMessage());
@@ -146,7 +147,7 @@ public class CameraUtil {
      * @return
      */
     public static String startRecording(String cameraCode, String channel) {
-        return historyUrl + "/api/record/flv/start?streamPath=" + channel + "/" + cameraCode;
+        return webUrl + "/api/record/flv/start?streamPath=" + channel + "/" + cameraCode;
     }
 
     /**
@@ -156,7 +157,7 @@ public class CameraUtil {
      * @return
      */
     public static String endRecording(String taskId) {
-        return historyUrl + "/api/record/flv/stop?id=" + taskId;
+        return webUrl + "/api/record/flv/stop?id=" + taskId;
     }
 
 
@@ -211,7 +212,7 @@ public class CameraUtil {
         String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, endTm);
 
         String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
-        String s = HttpUtils.sendGet(historyUrl + "/api/record/flv/list", param);
+        String s = HttpUtils.sendGet(webUrl + "/api/record/flv/list", param);
         // 视频拼接
         if (!StringUtils.isBlank(s) || "null".equals(s)) {
             List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
@@ -412,15 +413,13 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
         }
 
         if (fileTs.size() > 0) {
-            Map<String, Object> mergeVideoTsFile = rc.getCacheMap("mergeVideoTsFile");
+            Map<String, Object> mergeVideoTsFile = rc.getCacheMap(tsFilekey);
             if (ObjectUtils.isEmpty(mergeVideoTsFile)) {
                 mergeVideoTsFile = new HashMap<>();
             }
-            Map<Date, List<String>> objectObjectHashMap = new HashMap<>();
-            objectObjectHashMap.put(new Date(), fileTs);
-            mergeVideoTsFile.put(newfilePath, objectObjectHashMap);
-            rc.deleteObject("mergeVideoTsFile");
-            rc.setCacheMap("mergeVideoTsFile", mergeVideoTsFile);
+            mergeVideoTsFile.put(new Date().getTime() + "", fileTs);
+            rc.deleteObject(tsFilekey);
+            rc.setCacheMap(tsFilekey, mergeVideoTsFile);
 
             sm.append("-c copy " + newfilePath);
             log.info("合并命令:{}", sm.toString());
@@ -436,7 +435,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
     }
 
     public static List<Map<String, Object>> getRecordList(String channel, Date startTm, Date endTm) {
-        return filterRecordList(channel, startTm, endTm, filePath, recordUrl + "/");
+        return filterRecordList(channel, startTm, endTm, filePath, sc.getUrl() + "/profile/");
     }
 
     /**
@@ -670,25 +669,11 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
         }
     }
 
-    @PostConstruct
-    public void init() {
-        historyUrl = caneraConfig.getHistoryUrl();
-        ffmpegPath = caneraConfig.getFfmpegPath();
-        filePath = caneraConfig.getFilePath();
-        transcribeFilePath = caneraConfig.getTranscribeFilePath();
-        webUrl = caneraConfig.getWebUrl();
-        bakUrl = caneraConfig.getBakUrl();
-        recordUrl = caneraConfig.getRecordUrl();
-        cUtil = cmdCameraUtil;
-        rc = redisCache;
-    }
-
-
     public static List<Map<String, Object>> filterRecordList(String channel,
                                                              Date startTm,
                                                              Date endTm,
                                                              String mappingUrl,
-                                                             String webUrl) {
+                                                             String wUrl) {
         List<Map<String, Object>> rmaps = new ArrayList<>();
 
         if (StringUtils.isBlank(channel)
@@ -702,7 +687,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
         String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, endTm);
 
         String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
-        String s = HttpUtils.sendGet(historyUrl + "/api/record/flv/list", param);
+        String s = HttpUtils.sendGet(webUrl + "/api/record/flv/list", param);
         // 视频拼接
         if (!StringUtils.isBlank(s) || "null".equals(s)) {
             List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
@@ -730,7 +715,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
                         Date edate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s4);
                         mo.put("startTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, sdate));
                         mo.put("entTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, edate));
-                        mo.put("url", webUrl + path.toString());
+                        mo.put("url", wUrl + path.toString());
                         mo.put("path", mappingUrl + path.toString());
                         mo.put("fileName", substring);
                         mo.put("size", size);
@@ -771,6 +756,18 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
         return null;
     }
 
+    @PostConstruct
+    public void init() {
+        ffmpegPath = caneraConfig.getFfmpegPath();
+        filePath = caneraConfig.getFilePath();
+        transcribeFilePath = caneraConfig.getTranscribeFilePath();
+        webUrl = caneraConfig.getWebUrl();
+        bakUrl = caneraConfig.getBakUrl();
+        cUtil = cmdCameraUtil;
+        rc = redisCache;
+        sc = serverConfig;
+    }
+
 
     /**
      * 定时合成视频
@@ -779,9 +776,11 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
         Date date = new Date();
         Calendar calendar = new GregorianCalendar();
         Map<String, Object> alarmIdMap = redisCache.getCacheMap(mvkey);
+        List<String> dl = new ArrayList<>();
         log.info("WAIT_MERGE_VIDEO_ALARM_ID:{}", alarmIdMap);
         if (!ObjectUtils.isEmpty(alarmIdMap)) {
             Set<String> alarmIds = alarmIdMap.keySet();
+            log.info("mergeVideo方法:alarmIds:{}", alarmIds);
             if (!ObjectUtils.isEmpty(alarmIds) && alarmIds.size() > 0) {
                 for (String alarmId : alarmIds) {
                     Object oTime = alarmIdMap.get(alarmId);
@@ -799,12 +798,17 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
 
                             redisCache.setCacheObject("STREAMING_ALARM_VIDEO:" + alarmId, url);
                             redisCache.expire("STREAMING_ALARM_VIDEO:" + alarmId, 365L, TimeUnit.DAYS);
-                            alarmIdMap.remove(alarmId);
+                            dl.add(alarmId);
                         }
                     }
                 }
             }
         }
+        if (dl.size() > 0) {
+            for (String s : dl) {
+                alarmIdMap.remove(s);
+            }
+        }
         log.info("删除后的alarmIdMap:{}", alarmIdMap);
         redisCache.deleteObject(mvkey);
         redisCache.setCacheMap(mvkey, alarmIdMap);
@@ -814,35 +818,26 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
 
     public void deleteTsFile() {
         Date date = new Date();
-        Set<String> keys = new HashSet<>();
+        List<String> keys = new ArrayList<>();
         Calendar calendar = new GregorianCalendar();
         Map<String, Object> mergeVideoTsFile = redisCache.getCacheMap("mergeVideoTsFile");
         if (!ObjectUtils.isEmpty(mergeVideoTsFile) && mergeVideoTsFile.size() > 0) {
             mergeVideoTsFile.keySet().forEach(s -> {
                 Object o = mergeVideoTsFile.get(s);
-                if (!ObjectUtils.isEmpty(o)) {
-                    Map<Date, List<String>> m = (Map<Date, List<String>>) o;
-                    if (!ObjectUtils.isEmpty(m) && m.size() > 0) {
-                        m.keySet().forEach(md -> {
-                            Date fileTime = (Date) md;
-                            // 判断当前时间是否超过报警时间 20分钟
-                            calendar.setTime(fileTime);
-                            calendar.add(calendar.MINUTE, 10); //把日期往后增加一天,整数  往后推,负数往前移动
-                            fileTime = calendar.getTime(); //这个时间就是日期往后推一天的结果
-                            if (date.compareTo(fileTime) > 0) {
-                                List<String> list = m.get(md);
-                                for (String s1 : list) {
-                                    File ft = new File(s1);
-                                    if (ft.exists()) {
-                                        ft.delete();
-                                    }
-                                }
-                                //
-                                m.remove(md);
-                                keys.add(s);
-                            }
-                        });
+                Date fileTime = new Date(Long.parseLong(s));
+                calendar.setTime(fileTime);
+                calendar.add(calendar.MINUTE, 10); //把日期往后增加10分钟,整数  往后推,负数往前移动
+                fileTime = calendar.getTime(); //这个时间就是日期往后推一天的结果
+                if (date.compareTo(fileTime) > 0) {
+                    List<String> list = (List<String>) o;
+                    for (String s1 : list) {
+                        File ft = new File(s1);
+                        if (ft.exists()) {
+                            ft.delete();
+                        }
                     }
+                    //
+                    keys.add(s);
                 }
             });
             // 删除key
@@ -852,6 +847,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
                 }
             }
         }
+        log.info("mergeVideoTsFile:{}", mergeVideoTsFile);
         redisCache.deleteObject("mergeVideoTsFile");
         redisCache.setCacheMap("mergeVideoTsFile", mergeVideoTsFile);
     }

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

@@ -18,11 +18,8 @@ base:
   # 摄像头配置
   ffmpegPath: /usr/local/ffmpeg/bin/ffmpeg
   filePath: /opt/streams/
-  historyUrl: http://124.70.58.209:18891
-  #  webUrl: http://124.70.58.209:18819
   webUrl: http://124.70.58.209:18812
   bakUrl: http://124.70.58.209:18891
-  recordUrl: http://124.70.58.209:18832
   defaultPassword: yn5aq5Mt.106.tky
   imgUrl: http://124.71.171.71:18801/picbucket