Commit 71ebceb0 authored by chenzhao's avatar chenzhao

Merge remote-tracking branch 'origin/developer' into developer

parents 8a3393fd 94d18836
......@@ -2,7 +2,9 @@ package com.yeejoin.amos.boot.module.jxiop.biz.listener;
import java.text.ParseException;
import java.util.Date;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
......@@ -76,33 +78,57 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
redisUtils.set(JXIOP_ANALYSE_TIME, format);
System.out.println(format);
final Date timeF = time;
ExecutorService excutorService = Executors.newFixedThreadPool(10);
int taskCount = 2;
final CountDownLatch latch = new CountDownLatch(taskCount);
excutorService.submit(() -> {
CompletableFuture<String> fan=CompletableFuture.supplyAsync(()->{
commonServiceImpl.healthWarningMinuteByFan(timeF);
System.out.println("风电任务完成..");
latch.countDown();
String fanResult = "风电任务完成..";
System.out.println(fanResult);
return fanResult;
});
excutorService.submit(() -> {
CompletableFuture<String> pv=CompletableFuture.supplyAsync(()->{
commonServiceImpl.healthWarningMinuteByPv(timeF);
System.out.println("光伏任务完成..");
latch.countDown();
String pvResult = "光伏任务完成..";
System.out.println(pvResult);
return pvResult;
});
try {
System.out.println("等待所有任务完成..");
latch.await();
System.out.println("所有任务完成");
} catch (InterruptedException e) {
String fanResult = fan.get();
String pvResult = pv.get();
// 区域 全域最后统一生成
tdengineTimeService.insertMomentDataAll(format);
} catch (InterruptedException | ExecutionException e) {
System.out.println("任务执行异常");
e.printStackTrace();
Thread.currentThread().interrupt();
}
// 结束线程池
excutorService.shutdown();
//
// ExecutorService excutorService = Executors.newFixedThreadPool(10);
// int taskCount = 2;
// final CountDownLatch latch = new CountDownLatch(taskCount);
// excutorService.submit(() -> {
// commonServiceImpl.healthWarningMinuteByFan(timeF);
// System.out.println("风电任务完成..");
// latch.countDown();
// });
// excutorService.submit(() -> {
// commonServiceImpl.healthWarningMinuteByPv(timeF);
// System.out.println("光伏任务完成..");
// latch.countDown();
// });
//
// try {
// System.out.println("等待所有任务完成..");
// latch.await();
// System.out.println("所有任务完成");
// } catch (InterruptedException e) {
// System.out.println("任务执行异常");
// e.printStackTrace();
// Thread.currentThread().interrupt();
// }
// // 结束线程池
// excutorService.shutdown();
// 区域 全域最后统一生成
tdengineTimeService.insertMomentDataAll(format);
// tdengineTimeService.insertMomentDataAll(format);
// // 开始异步计算光伏的健康指数算法
// new Thread(() -> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment