|
@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -45,6 +46,8 @@ public class AlarmScannerService {
|
|
|
@Resource
|
|
|
private IAlarmTsService alarmTsService;
|
|
|
private List<AlarmTag> alarmTags=new CopyOnWriteArrayList<>();
|
|
|
+
|
|
|
+ private List<AlarmTag> alarmInTags=new CopyOnWriteArrayList<>();
|
|
|
@Resource
|
|
|
@Qualifier(value = "taskExecutor")
|
|
|
private Executor executor;
|
|
@@ -63,27 +66,44 @@ public class AlarmScannerService {
|
|
|
switch (alarmType){
|
|
|
case "wt_alarms":
|
|
|
alarmTags =alarmService.findTagsByWt(runWindpowerstation);
|
|
|
- history();
|
|
|
+ history(alarmTags);
|
|
|
break;
|
|
|
case "bt_alarms":
|
|
|
- alarmTags =alarmService.findTagsByBt();
|
|
|
- history();
|
|
|
+ List<AlarmTag> templs =alarmService.findTagsByBt();
|
|
|
+
|
|
|
+ if(!templs.isEmpty())
|
|
|
+ {
|
|
|
+ for(AlarmTag tag:templs)
|
|
|
+ {
|
|
|
+ if(StringUtils.notEmp(tag.getTagId()) )
|
|
|
+ {
|
|
|
+ if(tag.getTagId().startsWith("FD"))
|
|
|
+ {
|
|
|
+ alarmTags.add(tag);
|
|
|
+ }else if(tag.getTagId().startsWith("GF"))
|
|
|
+ {
|
|
|
+ alarmInTags.add(tag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ history(templs);
|
|
|
break;
|
|
|
case "in_alarms":
|
|
|
alarmTags =alarmService.findTagsByIn();
|
|
|
- history();
|
|
|
+ history(alarmTags);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void history() {
|
|
|
+ public void history(List<AlarmTag> tags) {
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
List<AlarmSimpleVo> alarmvols = new CopyOnWriteArrayList<>();
|
|
|
AtomicInteger times = new AtomicInteger(0);
|
|
|
- for (AlarmTag alarm : alarmTags) {
|
|
|
+ for (AlarmTag alarm : tags) {
|
|
|
|
|
|
sb.append("'").append(alarm.getId().toLowerCase()).append("',");
|
|
|
times.getAndAdd(1);
|
|
@@ -136,39 +156,54 @@ public class AlarmScannerService {
|
|
|
/**
|
|
|
* 分配任务
|
|
|
*/
|
|
|
- public void taskJobs(boolean start) throws InterruptedException {
|
|
|
+ public synchronized void taskJobs(boolean start) throws InterruptedException {
|
|
|
|
|
|
|
|
|
while (start) {
|
|
|
- int len = 1;
|
|
|
|
|
|
- List<AlarmTag> alarmls = new CopyOnWriteArrayList<>();
|
|
|
+ if (alarmType.equals("bt_alarms")) {
|
|
|
|
|
|
- int listNumber = alarmTags.size() / taskCount;
|
|
|
- int number = 0;
|
|
|
- if (alarmTags.size() % taskCount != 0) {
|
|
|
- listNumber = listNumber + 1;
|
|
|
- }
|
|
|
- CountDownLatch countDownLatch = new CountDownLatch(listNumber);
|
|
|
-
|
|
|
- StringBuilder str = new StringBuilder();
|
|
|
- str.append("总数:").append(alarmTags.size()).append(",线程数:").append(listNumber).append(",分块大小:").append(taskCount);
|
|
|
- log.info(String.valueOf(str));
|
|
|
- for (int i = 0; i < alarmTags.size(); i++) {
|
|
|
- alarmls.add(alarmTags.get(i));
|
|
|
- if (i != 0 && (i) % taskCount == 0) {
|
|
|
- new Thread(new AlarmThread(executor, edosUtil, alarmService, alarmls, interval, String.valueOf(len), readRows, alarmType,countDownLatch,alarmTsService,historymap)).start();
|
|
|
- alarmls = new CopyOnWriteArrayList<>();
|
|
|
- len++;
|
|
|
+ CountDownLatch countDownLatch = new CountDownLatch(2);
|
|
|
+
|
|
|
+ new Thread(new AlarmThread(executor, edosUtil, alarmService, alarmTags, interval, String.valueOf(1), readRows, alarmType, countDownLatch, alarmTsService, historymap)).start();
|
|
|
+ new Thread(new AlarmThread(executor, edosUtil, alarmService, alarmInTags, interval, String.valueOf(2), readRows, alarmType, countDownLatch, alarmTsService, historymap)).start();
|
|
|
+
|
|
|
+ countDownLatch.await(30, TimeUnit.SECONDS);
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+ int len = 1;
|
|
|
+
|
|
|
+ List<AlarmTag> alarmls = new ArrayList<>();
|
|
|
+
|
|
|
+ int listNumber = alarmTags.size() / taskCount;
|
|
|
+ int number = 0;
|
|
|
+ if (alarmTags.size() % taskCount != 0) {
|
|
|
+ listNumber = listNumber + 1;
|
|
|
+ }
|
|
|
+ CountDownLatch countDownLatch = new CountDownLatch(listNumber);
|
|
|
+
|
|
|
+ StringBuilder str = new StringBuilder();
|
|
|
+ str.append("总数:").append(alarmTags.size()).append(",线程数:").append(listNumber).append(",分块大小:").append(taskCount);
|
|
|
+ log.info(String.valueOf(str));
|
|
|
+ for (int i = 0; i < alarmTags.size(); i++) {
|
|
|
+ alarmls.add(alarmTags.get(i));
|
|
|
+ if (i != 0 && (i) % taskCount == 0) {
|
|
|
+ new Thread(new AlarmThread(executor, edosUtil, alarmService, alarmls, interval, String.valueOf(len), readRows, alarmType, countDownLatch, alarmTsService, historymap)).start();
|
|
|
+ alarmls = new ArrayList<>();
|
|
|
+ len++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!alarmls.isEmpty()) {
|
|
|
+ new Thread(new AlarmThread(executor, edosUtil, alarmService, alarmls, interval, String.valueOf(len), readRows, alarmType, countDownLatch, alarmTsService, historymap)).start();
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if (!alarmls.isEmpty()) {
|
|
|
- new Thread(new AlarmThread(executor, edosUtil, alarmService, alarmls, interval, String.valueOf(len), readRows, alarmType,countDownLatch,alarmTsService,historymap)).start();
|
|
|
+ countDownLatch.await(30, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
|
|
|
- countDownLatch.await(30, TimeUnit.SECONDS);
|
|
|
+
|
|
|
log.info("报警排查完成!");
|
|
|
|
|
|
|