|
@@ -3,9 +3,15 @@ package com.ozs.web.controller.shotschedule;
|
|
|
import com.ozs.system.service.ISysDictDataService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
+import java.util.UUID;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -15,11 +21,13 @@ import java.util.concurrent.TimeUnit;
|
|
|
* @subject
|
|
|
* @creat 2023/5/6
|
|
|
*/
|
|
|
-@Component
|
|
|
+@Configuration
|
|
|
+@EnableScheduling
|
|
|
+@EnableAsync
|
|
|
@Slf4j
|
|
|
public class ShotExecutors {
|
|
|
|
|
|
- private static ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
|
|
|
+ // private static ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
|
|
|
@Autowired
|
|
|
private ISysDictDataService dictDataService;
|
|
|
@Autowired
|
|
@@ -27,16 +35,37 @@ public class ShotExecutors {
|
|
|
@Autowired
|
|
|
private TaskAlarmService taskAlarmService;//定时任务-报警摄像头
|
|
|
|
|
|
- @PostConstruct
|
|
|
- public void init() {
|
|
|
- try{
|
|
|
- boolean shotSwitch = Boolean.parseBoolean(dictDataService.selectDictLabel("shot_switch", String.valueOf(0)));
|
|
|
- if(shotSwitch){
|
|
|
- scheduledExecutorService.scheduleAtFixedRate(taskNormalService, 0, 500, TimeUnit.MILLISECONDS);
|
|
|
- scheduledExecutorService.scheduleAtFixedRate(taskAlarmService, 0, 200, TimeUnit.MILLISECONDS);
|
|
|
+ /**
|
|
|
+ * 处理非预警摄像头截图
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ @Scheduled(fixedRate = 500)
|
|
|
+ public void handleNormalPicture() {
|
|
|
+ boolean shotSwitch = Boolean.parseBoolean(dictDataService.selectDictLabel("shot_switch", String.valueOf(0)));
|
|
|
+ try {
|
|
|
+ if (shotSwitch) {
|
|
|
+ taskNormalService.getNormalPicture();
|
|
|
}
|
|
|
- }catch (Throwable throwable){
|
|
|
- log.error(throwable.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.getMessage();
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理预警摄像头截图
|
|
|
+ */
|
|
|
+ @Async
|
|
|
+ @Scheduled(fixedRate = 200)
|
|
|
+ public void handleAlarmPicture() {
|
|
|
+ boolean shotSwitch = Boolean.parseBoolean(dictDataService.selectDictLabel("shot_switch", String.valueOf(0)));
|
|
|
+ try {
|
|
|
+ if (shotSwitch) {
|
|
|
+ taskAlarmService.getAlarmPicture();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.getMessage();
|
|
|
+ log.error(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|