Quellcode durchsuchen

截图定时优化

wyyay vor 1 Jahr
Ursprung
Commit
3706a1bf4a

+ 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;
@@ -34,6 +35,8 @@ public class ShotPictureExecutors {
     private ISysDictTypeService iSysDictTypeService;
     @Autowired
     private TaskService taskService; //任务
+    @Value("${shot.storeAddress}")
+    private String storeAddress;
 
     /**
      * 处理非预警摄像头截图
@@ -46,11 +49,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) {
@@ -70,10 +81,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) {

+ 4 - 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,9 +61,8 @@ 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
@@ -87,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 -> {
@@ -100,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

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

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