瀏覽代碼

截图优化

wyyay 10 月之前
父節點
當前提交
3404ff3ecb

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

@@ -6,6 +6,7 @@ import com.ozs.system.service.ISysDictDataService;
 import com.ozs.system.service.ISysDictTypeService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.EnableAsync;
@@ -32,6 +33,8 @@ public class ShotPictureExecutors {
     private ISysDictTypeService iSysDictTypeService;
     @Autowired
     private TaskService taskService; //任务
+    @Value("${shot.storeAddress}")
+    private String storeAddress;
 
     /**
      * 处理非预警摄像头截图
@@ -44,11 +47,19 @@ public class ShotPictureExecutors {
             dataList = iSysDictTypeService.selectDictDataByType("shot_switch");
             DictUtils.setDictCache("shot_switch",dataList);
         }
-        //boolean shotSwitch = Boolean.parseBoolean(dictDataService.selectDictLabel("shot_switch", String.valueOf(0)));
+        List<SysDictData> addressDataList = DictUtils.getDictCache("shot_address");
+        if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
+            addressDataList = iSysDictTypeService.selectDictDataByType("shot_address");
+            DictUtils.setDictCache("shot_address",addressDataList);
+        }
+        String address = addressDataList.get(0).getDictLabel();
         try {
             if(!CollectionUtils.isEmpty(dataList) && Objects.nonNull(dataList.get(0))){
                 if (Boolean.parseBoolean(dataList.get(0).getDictLabel())) {
-                    taskService.getNormalPicture();
+                    if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
+                        address = storeAddress;
+                    }
+                    taskService.getNormalPicture(address);
                 }
             }
         } catch (Exception e) {
@@ -68,10 +79,19 @@ public class ShotPictureExecutors {
             dataList = iSysDictTypeService.selectDictDataByType("shot_switch");
             DictUtils.setDictCache("shot_switch",dataList);
         }
+        List<SysDictData> addressDataList = DictUtils.getDictCache("shot_address");
+        if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
+            addressDataList = iSysDictTypeService.selectDictDataByType("shot_address");
+            DictUtils.setDictCache("shot_address",addressDataList);
+        }
+        String address = addressDataList.get(0).getDictLabel();
         try {
             if(!CollectionUtils.isEmpty(dataList) && Objects.nonNull(dataList.get(0))){
                 if (Boolean.parseBoolean(dataList.get(0).getDictLabel())) {
-                    taskService.getAlarmPicture();
+                    if(CollectionUtils.isEmpty(addressDataList) || Objects.isNull(addressDataList.get(0))){
+                        address = storeAddress;
+                    }
+                    taskService.getAlarmPicture(address);
                 }
             }
         } catch (Exception e) {

+ 6 - 6
hazard-admin/src/main/java/com/ozs/web/controller/shotschedule/TaskService.java

@@ -51,7 +51,7 @@ public class TaskService {
     @Value("${shot.urlAddress}")
     private String urlAddress;
 
-    public void getNormalPicture() {
+    public void getNormalPicture(String address) {
         List<BaseCameraManagement> list = msgAlarmService.getBaseCameraManagements();
         if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
             list.forEach(l -> {
@@ -61,15 +61,15 @@ public class TaskService {
                         System.out.println(urlAddress + l.getCameraCode() + "/" + l.getChannel());
                         log.info("请求url======" + urlAddress + l.getCameraCode() + "/" + l.getChannel());
                         URL url = new URL(urlAddress + l.getCameraCode() + "/" + l.getChannel());
-                        String root = dictDataService.selectDictLabel("shot_address", String.valueOf(0));
                         String dateString = format.format(new Date());
-                        String fileName = root + "/" + "normal" + "/" + dateString + "/" + uuid + ".jpeg";
+                        String fileName = address + "/" + "normal" + "/" + dateString + "/" + uuid + ".jpeg";
                         log.info("fileName======" + fileName);
                         executorService.submit(new Runnable() {
                             @Override
                             public void run() {
                                 log.info("调用图片生成服务开始");
                                 try {
+                                    System.out.println("fileName"+fileName+"正常图片开始截图时间"+new Date());
                                     cameraCaptureService.getCapture(url, fileName);
                                 } catch (IOException e) {
                                     e.printStackTrace();
@@ -86,7 +86,7 @@ public class TaskService {
         }
     }
 
-    public void getAlarmPicture() {
+    public void getAlarmPicture(String address) {
         List<BaseCameraManagement> msgAlarmList = msgAlarmService.getBaseCameraManagementsByLockedMsgAlarms(2);
         if(!CollectionUtils.isEmpty(msgAlarmList) && Objects.nonNull(msgAlarmList.get(0))){
             msgAlarmList.forEach(l -> {
@@ -99,9 +99,8 @@ public class TaskService {
                         System.out.println(urlAddress+l.getCameraCode()+"/"+baseCameraManagement.getChannel());
                         log.info("请求url======"+urlAddress+l.getCameraCode()+"/"+baseCameraManagement.getChannel());
                         URL url = new URL(urlAddress+l.getCameraCode()+"/"+baseCameraManagement.getChannel());
-                        String root = dictDataService.selectDictLabel("shot_address", String.valueOf(0));
                         String dateString = format.format(new Date());
-                        String fileName = root + "/" + "alarm" + "/" + dateString + "/" + uuid + ".jpeg";
+                        String fileName = address + "/" + "alarm" + "/" + dateString + "/" + uuid + ".jpeg";
                         log.info("fileName======"+fileName);
                         alarmExecutorService.submit(new Runnable() {
                             @Override
@@ -124,4 +123,5 @@ public class TaskService {
         }
     }
 
+
 }

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

@@ -162,3 +162,4 @@ mqtt:
 
 shot:
   urlAddress: http://10.161.12.50:9080/snap/
+  storeAddress: camera_picture