Browse Source

截图定时修改存放路径

wyyay 7 tháng trước cách đây
mục cha
commit
13ff81377c

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

@@ -85,15 +85,16 @@ public class CaptureStreamListener implements StreamListener<String, ObjectRecor
             if (StringUtils.isNotBlank(dataDict.getStr("nextExecuteTime"))) {
                 nextExecuteTime = DateTime.of(dataDict.getStr("nextExecuteTime"), "yyyy-MM-dd HH:mm:ss");
             }
-            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";
+            String isNormalPath = "normal";
+            if(isAlarm) isNormalPath="alarm";
+            String filePath = dataDict.getStr("address")+"/"+isNormalPath+"/"+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"),filePath,dataDict.getStr("address"));
+                genPictureTaskService.getNormalPicture(cameraCode, dataDict.getStr("channel"),filePath);
             }
             // 通过RedisTemplate手动确认消息
             stringRedisTemplate.opsForStream().acknowledge(RedisPushService.STREAM_KEY, RedisPushService.STREAM_CONSUMER_GROUP_KEY, recordId.getValue());

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

@@ -30,7 +30,7 @@ public class GenPictureTaskService {
     @Value("${shot.urlAddress}")
     private String urlAddress;
 
-    public boolean getNormalPicture(String cameraCode, String channel,String filePath,String address) {
+    public boolean getNormalPicture(String cameraCode, String channel,String filePath) {
         long start = System.currentTimeMillis();
         if (!ObjectUtils.isEmpty(cameraCode)) {
             try {
@@ -38,12 +38,11 @@ public class GenPictureTaskService {
 //                    log.debug("请求url======" + urlAddress + cameraCode + "/" + channel);
 //                }
                 URL url = new URL(urlAddress + cameraCode + "/" + channel);
-                String fileName = address + "/" + "normal" + "/" +filePath;
-                System.out.println("fileName:"+fileName);
+                System.out.println("fileName:"+filePath);
 //                if (log.isDebugEnabled()) {
 //                    log.debug("正常摄像头截图开始, url: " + url + ", fileName: " + fileName);
 //                }
-                boolean capture = cameraCaptureService.getCapture(url, cameraCode, fileName);
+                boolean capture = cameraCaptureService.getCapture(url, cameraCode, filePath);
 //                if (log.isDebugEnabled()) {
 //                    log.debug("正常摄像头截图结束, url: " + url + (capture ? "" : ", 出现错误") + ", 共计耗时: " + ((System.currentTimeMillis() - start) / 1000) + "s");
 //                }