Bläddra i källkod

截图修改路径

wyyay 7 månader sedan
förälder
incheckning
5e8e491a7d

+ 12 - 0
business-service/src/main/java/com/ozs/service/entity/vo/BaseCameraVO.java

@@ -1,5 +1,7 @@
 package com.ozs.service.entity.vo;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.ozs.common.annotation.Excel;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
@@ -30,6 +32,16 @@ public class BaseCameraVO implements Serializable{
      */
     private String channel;
 
+    /**
+     *线路名称
+     */
+    private String railwayName;
+
+    /**
+     * 监控相机安装里程位置
+     */
+    private String installMiles;
+
     /**
      * 下次执行时间
      */

+ 9 - 2
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/CaptureStreamListener.java

@@ -19,6 +19,8 @@ import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.time.LocalDate;
+import java.util.Calendar;
 
 @Component
 @Slf4j
@@ -66,7 +68,8 @@ public class CaptureStreamListener implements StreamListener<String, ObjectRecor
             Dict dataDict = JSONUtil.toBean(value, Dict.class);
 
             String cameraCode = dataDict.getStr("cameraCode");
-
+            String railwayName = dataDict.getStr("railwayName");
+            String installMiles = dataDict.getStr("installMiles");
             Boolean isAlarm = dataDict.getBool("isAlarm");
             String camera_type_hash = isAlarm ? ShotPictureTaskExecutors.CAMERA_ALARM_HASH : ShotPictureTaskExecutors.CAMERA_NORMAL_HASH;
 
@@ -84,9 +87,13 @@ public class CaptureStreamListener implements StreamListener<String, ObjectRecor
             }
             String ymd = DateTime.now().toString("yyyy-MM-dd");
             DateTime now = DateTime.now();
+            StringBuilder fileName = new StringBuilder(cameraCode);
+            fileName.append("-");
+            fileName.append(DateTime.now().toString("yyyyMMddHHmmss"));
+            String filePath = railwayName+"/"+installMiles+"/"+ LocalDate.now().getYear() +"/"+ LocalDate.now().getMonthValue() + "/" +fileName + ".jpeg";
             // 超过时间则进行抓拍
             if (now.isAfterOrEquals(nextExecuteTime) && nextExecuteTime.between(now, DateUnit.MINUTE) < 2) {
-                genPictureTaskService.getNormalPicture(cameraCode, dataDict.getStr("channel"), dataDict.getStr("address"), ymd);
+                genPictureTaskService.getNormalPicture(cameraCode, dataDict.getStr("channel"),filePath,dataDict.getStr("address"));
             }
             // 通过RedisTemplate手动确认消息
             stringRedisTemplate.opsForStream().acknowledge(RedisPushService.STREAM_KEY, RedisPushService.STREAM_CONSUMER_GROUP_KEY, recordId.getValue());

+ 3 - 3
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/GenPictureTaskService.java

@@ -30,8 +30,7 @@ public class GenPictureTaskService {
     @Value("${shot.urlAddress}")
     private String urlAddress;
 
-    public boolean getNormalPicture(String cameraCode, String channel, String address, String ymd) {
-        String uuid = IdUtils.fastSimpleUUID();
+    public boolean getNormalPicture(String cameraCode, String channel,String filePath,String address) {
         long start = System.currentTimeMillis();
         if (!ObjectUtils.isEmpty(cameraCode)) {
             try {
@@ -39,7 +38,8 @@ public class GenPictureTaskService {
 //                    log.debug("请求url======" + urlAddress + cameraCode + "/" + channel);
 //                }
                 URL url = new URL(urlAddress + cameraCode + "/" + channel);
-                String fileName = address + "/" + "normal" + "/" + ymd + "/" + uuid + ".jpeg";
+                String fileName = address + "/" + "normal" + "/" +filePath;
+                System.out.println("fileName:"+fileName);
 //                if (log.isDebugEnabled()) {
 //                    log.debug("正常摄像头截图开始, url: " + url + ", fileName: " + fileName);
 //                }

+ 17 - 1
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/ShotPictureTaskExecutors.java

@@ -7,11 +7,14 @@ import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ozs.common.core.domain.entity.SysDictData;
 import com.ozs.common.core.redis.RedisCache;
+import com.ozs.common.utils.AppendUtils;
 import com.ozs.common.utils.DictUtils;
 import com.ozs.service.entity.BaseCameraManagement;
+import com.ozs.service.entity.BaseRailwayManagement;
 import com.ozs.service.entity.MsgAlarm;
 import com.ozs.service.entity.vo.BaseCameraVO;
 import com.ozs.service.mapper.BaseCameraManagementMapper;
+import com.ozs.service.mapper.BaseRailwayManagementMapper;
 import com.ozs.service.mapper.MsgAlarmMapper;
 import com.ozs.service.service.RedisService;
 import com.ozs.system.service.ISysDictTypeService;
@@ -70,6 +73,9 @@ public class ShotPictureTaskExecutors {
 
     @Resource
     private BaseCameraManagementMapper baseCameraManagementMapper;
+
+    @Resource
+    private BaseRailwayManagementMapper baseRailwayManagementMapper;
     @Autowired
     RedisCache redisCache;
 
@@ -99,10 +105,14 @@ public class ShotPictureTaskExecutors {
                     .stream().map(f -> f.getCameraCode()).distinct().collect(Collectors.toList());
             try {
                 QueryWrapper<BaseCameraManagement> queryWrapper = new QueryWrapper<>();
-                queryWrapper.select("distinct camera_code, channel");
+                queryWrapper.select("distinct camera_code, channel,railway_code,install_mile");
                 // 获取数据库中最新摄像头相关内容
                 List<BaseCameraManagement> dbAlarms = baseCameraManagementMapper.selectList(queryWrapper).stream().collect(Collectors.toList());
+                List<BaseRailwayManagement> dbRailways = baseRailwayManagementMapper.selectList(null);
                 if (!CollectionUtils.isEmpty(dbAlarms)) {
+                    for(BaseRailwayManagement dbRailway:dbRailways){
+                        redisCache.setCacheObject(dbRailway.getRailwayCode(),dbRailway.getRailwayName());
+                    }
                     Set<Object> hashAlarmKeys = redisService.redisTemplate.opsForHash().keys(CAMERA_ALARM_HASH);
                     Set<Object> hashNormalKeys = redisService.redisTemplate.opsForHash().keys(CAMERA_NORMAL_HASH);
                     // 数据库中存在的数据, 但是缓存中不存在, 则进行补全
@@ -110,6 +120,8 @@ public class ShotPictureTaskExecutors {
                         BaseCameraVO  vo = new BaseCameraVO();
                         vo.setCameraCode(dbAlarm.getCameraCode());
                         vo.setChannel(dbAlarm.getChannel());
+                        vo.setInstallMiles(AppendUtils.stringAppend(dbAlarm.getInstallMile()));
+                        vo.setRailwayName(redisCache.getCacheObject(dbAlarm.getRailwayCode()));
                         vo.setNextExecuteTime(DateTime.now().toString("yyyy-MM-dd HH:mm:ss"));
                         if (lockedMsgAlarmCameraCodes.contains(vo.getCameraCode()) && !hashAlarmKeys.contains(vo.getCameraCode())) {
                             vo.setIsAlarm(true);
@@ -192,6 +204,8 @@ public class ShotPictureTaskExecutors {
                     dict.put("cameraCode", item.getCameraCode());
                     dict.put("channel", item.getChannel());
                     dict.put("address", finalAddress);
+                    dict.put("railwayName", item.getRailwayName());
+                    dict.put("installMiles", item.getInstallMiles());
                     dict.put("isAlarm", false);
                     dict.put("nextExecuteTime", item.getNextExecuteTime());
                     redisPushService.pushMsg(JSONUtil.toJsonStr(dict));
@@ -215,6 +229,8 @@ public class ShotPictureTaskExecutors {
                     dict.put("cameraCode", item.getCameraCode());
                     dict.put("channel", item.getChannel());
                     dict.put("address", finalAddress);
+                    dict.put("railwayName", item.getRailwayName());
+                    dict.put("installMiles", item.getInstallMiles());
                     dict.put("isAlarm", true);
                     dict.put("nextExecuteTime", item.getNextExecuteTime());
                     redisPushService.pushMsg(JSONUtil.toJsonStr(dict));