|
@@ -26,7 +26,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
-import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -37,6 +37,8 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class TaskService {
|
|
|
+ private static ExecutorService executorService = Executors.newFixedThreadPool(50);
|
|
|
+ private static ExecutorService alarmExecutorService = Executors.newFixedThreadPool(10);
|
|
|
@Resource
|
|
|
BaseCameraManagementService baseCameraManagementService;
|
|
|
@Resource
|
|
@@ -48,11 +50,9 @@ public class TaskService {
|
|
|
private static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
@Value("${shot.urlAddress}")
|
|
|
private String urlAddress;
|
|
|
- @Resource
|
|
|
- MinioUtils minioUtils;
|
|
|
|
|
|
public void getNormalPicture() {
|
|
|
- List<BaseCameraManagement> list = msgAlarmService.getBaseCameraManagementsByLockedMsgAlarms(1);
|
|
|
+ List<BaseCameraManagement> list = msgAlarmService.getBaseCameraManagements();
|
|
|
if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
|
|
|
list.forEach(l -> {
|
|
|
String uuid = IdUtils.fastSimpleUUID();
|
|
@@ -65,16 +65,31 @@ public class TaskService {
|
|
|
String dateString = format.format(new Date());
|
|
|
String fileName = root + "/" + "normal" + "/" + dateString + "/" + uuid + ".jpeg";
|
|
|
log.info("fileName======" + fileName);
|
|
|
- log.info("调用图片生成服务开始");
|
|
|
- cameraCaptureService.getCapture(url,fileName);
|
|
|
- log.info("调用图片生成服务结束");
|
|
|
- } catch (MalformedURLException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } catch (IOException e) {
|
|
|
+ executorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ log.info("调用图片生成服务开始");
|
|
|
+ try {
|
|
|
+ cameraCaptureService.getCapture(url, fileName);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("调用图片生成服务结束");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Throwable e) {
|
|
|
e.printStackTrace();
|
|
|
+ log.error(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ try {
|
|
|
+ if(executorService.awaitTermination(60,TimeUnit.SECONDS)){
|
|
|
+ executorService.shutdown();
|
|
|
+ }
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -93,17 +108,33 @@ public class TaskService {
|
|
|
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 = root + "/" + "alarm" + "/" + dateString + "/" + uuid + ".jpeg";
|
|
|
log.info("fileName======"+fileName);
|
|
|
- log.info("报警摄像头截图开始");
|
|
|
- cameraCaptureService.getCapture(url,fileName);
|
|
|
- log.info("报警摄像头截图结束");
|
|
|
+ alarmExecutorService.submit(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ log.info("报警摄像头截图开始");
|
|
|
+ try {
|
|
|
+ cameraCaptureService.getCapture(url, fileName);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("报警摄像头截图结束");
|
|
|
+ }
|
|
|
+ });
|
|
|
} catch (Throwable e) {
|
|
|
e.printStackTrace();
|
|
|
log.error(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ try {
|
|
|
+ if(alarmExecutorService.awaitTermination(30,TimeUnit.SECONDS)){
|
|
|
+ executorService.shutdown();
|
|
|
+ }
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|