|
@@ -8,11 +8,9 @@ import com.gyee.alarm.model.auto.ProBasicEquipmentPoint;
|
|
import com.gyee.alarm.model.auto.ProBasicPowerstationPoint;
|
|
import com.gyee.alarm.model.auto.ProBasicPowerstationPoint;
|
|
import com.gyee.alarm.model.vo.AlarmCustomTag;
|
|
import com.gyee.alarm.model.vo.AlarmCustomTag;
|
|
import com.gyee.alarm.model.vo.AlarmTag;
|
|
import com.gyee.alarm.model.vo.AlarmTag;
|
|
-import com.gyee.alarm.task.thread.AlarmThread;
|
|
|
|
-import com.gyee.alarm.task.thread.ReadWpDataThread;
|
|
|
|
-import com.gyee.alarm.task.thread.ReadWsDataThread;
|
|
|
|
-import com.gyee.alarm.task.thread.ReadWtDataThread;
|
|
|
|
|
|
+import com.gyee.alarm.task.thread.*;
|
|
import com.gyee.alarm.util.realtimesource.IEdosUtil;
|
|
import com.gyee.alarm.util.realtimesource.IEdosUtil;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -22,12 +20,12 @@ import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.concurrent.Executor;
|
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
+import java.util.concurrent.*;
|
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
-
|
|
|
|
|
|
+@Slf4j
|
|
public class AlarmCustomService {
|
|
public class AlarmCustomService {
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
private Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
@@ -51,174 +49,170 @@ public class AlarmCustomService {
|
|
@Resource
|
|
@Resource
|
|
private IAlarmService alarmService;
|
|
private IAlarmService alarmService;
|
|
|
|
|
|
- private List<AlarmCustomTag> alarmTags=new ArrayList<>();
|
|
|
|
|
|
+ private List<AlarmCustomTag> alarmTags = new ArrayList<>();
|
|
@Resource
|
|
@Resource
|
|
private Executor executor;
|
|
private Executor executor;
|
|
|
|
|
|
- private StringBuilder str=new StringBuilder();
|
|
|
|
/**
|
|
/**
|
|
* 初始化
|
|
* 初始化
|
|
*/
|
|
*/
|
|
public void init() {
|
|
public void init() {
|
|
|
|
|
|
- alarmTags =alarmService.findTagsByCt();
|
|
|
|
|
|
+ alarmTags = alarmService.findTagsByCt();
|
|
}
|
|
}
|
|
|
|
|
|
public void taskJobs(boolean runStarted) throws InterruptedException {
|
|
public void taskJobs(boolean runStarted) throws InterruptedException {
|
|
- readTaskJobs(runStarted);
|
|
|
|
-// Thread.sleep(interval);
|
|
|
|
- calTaskJobs(runStarted);
|
|
|
|
|
|
+
|
|
|
|
+ while (runStarted) {
|
|
|
|
+
|
|
|
|
+ readTaskJobs(runStarted);
|
|
|
|
+
|
|
|
|
+ Thread.sleep((interval * 500));
|
|
|
|
+
|
|
|
|
+ calTaskJobs(runStarted);
|
|
|
|
+
|
|
|
|
+ Thread.sleep((interval * 500));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 读取测点数据,缓存到内存
|
|
* 读取测点数据,缓存到内存
|
|
*/
|
|
*/
|
|
- public void readTaskJobs(boolean runStarted) {
|
|
|
|
|
|
+ public synchronized void readTaskJobs(boolean runStarted) throws InterruptedException {
|
|
|
|
|
|
|
|
+ List<ProBasicEquipmentPoint> wtPointList = CacheContext.wtPointList;// 设备测点集合
|
|
|
|
|
|
- while (runStarted)
|
|
|
|
- {
|
|
|
|
|
|
+ List<ProBasicPowerstationPoint> wsPointList = CacheContext.wsPointList; //升压站测点集合
|
|
|
|
|
|
- int wtlen = 1;
|
|
|
|
|
|
+ //读取设备测点
|
|
|
|
+ List<ProBasicEquipmentPoint> wtpols = new ArrayList<>();
|
|
|
|
|
|
- List<ProBasicEquipmentPoint> wtPointList = CacheContext.wtPointList;// 设备测点集合
|
|
|
|
- List<ProBasicPowerstationPoint> wpPointList =CacheContext.wpPointList; //场站测点集合
|
|
|
|
- List<ProBasicPowerstationPoint> wsPointList =CacheContext.wsPointList; //升压站测点集合
|
|
|
|
|
|
+ int wtlistNumber = wtPointList.size() / readCount;
|
|
|
|
+ int wslistNumber = wsPointList.size() / readCount;
|
|
|
|
|
|
- //读取设备测点
|
|
|
|
- List<ProBasicEquipmentPoint> wtpols=new ArrayList<>();
|
|
|
|
|
|
|
|
- int listNumber=wtPointList.size()/readCount;
|
|
|
|
|
|
+ int number = 0;
|
|
|
|
+ if (wtPointList.size() % wtlistNumber == 0) {
|
|
|
|
+ number = readCount;
|
|
|
|
+ } else {
|
|
|
|
+ number = readCount + 1;
|
|
|
|
+ }
|
|
|
|
|
|
- for(int i=0;i<wtPointList.size();i++)
|
|
|
|
- {
|
|
|
|
- wtpols.add(wtPointList.get(i));
|
|
|
|
- if(i!=0 && i%listNumber==0)
|
|
|
|
- {
|
|
|
|
- str.setLength(0);
|
|
|
|
- str.append("设备读取线程号:").append(wtlen);
|
|
|
|
- new Thread(new ReadWtDataThread(executor, edosUtil, readRows, wtpols,interval,str)).start();
|
|
|
|
- wtpols=new ArrayList<>();
|
|
|
|
- wtlen++;
|
|
|
|
|
|
+ if (wsPointList.size() % wslistNumber == 0) {
|
|
|
|
+ number = number+readCount;
|
|
|
|
+ } else {
|
|
|
|
+ number = number+readCount + 1;
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ CountDownLatch countDownLatch = new CountDownLatch(number);
|
|
|
|
|
|
- if(!wtpols.isEmpty())
|
|
|
|
- {
|
|
|
|
- str.setLength(0);
|
|
|
|
- str.append("设备读取线程号:").append(wtlen);
|
|
|
|
- new Thread(new ReadWtDataThread(executor, edosUtil, readRows, wtpols,interval,str)).start();
|
|
|
|
- listNumber++;
|
|
|
|
- }
|
|
|
|
|
|
+ int time=0;
|
|
|
|
+ StringBuilder str = new StringBuilder();
|
|
|
|
+ str.append("设备读取总数:").append(alarmTags.size()).append(",线程数:").append(number).append(",分块大小:").append(wtlistNumber+wslistNumber);
|
|
|
|
+ log.info(String.valueOf(str));
|
|
|
|
|
|
- StringBuilder str=new StringBuilder();
|
|
|
|
- str.append("设备读取总数:").append(alarmTags.size()).append(",线程数:").append(taskCount).append(",分块大小:").append(listNumber);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-// System.out.println(str.toString());
|
|
|
|
-// //读取场站测点
|
|
|
|
-// int wplen = 1;
|
|
|
|
-// List<ProBasicPowerstationPoint> wppols=new ArrayList<>();
|
|
|
|
-// listNumber=wpPointList.size()/readCount;
|
|
|
|
-// for(int i=0;i<wpPointList.size();i++)
|
|
|
|
-// {
|
|
|
|
-// wppols.add(wpPointList.get(i));
|
|
|
|
-// if(i!=0 && i%listNumber==0)
|
|
|
|
-// {
|
|
|
|
-// str.setLength(0);
|
|
|
|
-// str.append("场站读取线程号:").append(wplen);
|
|
|
|
-// new Thread(new ReadWpDataThread(executor, edosUtil, readRows, wppols,interval,str)).start();
|
|
|
|
-// wppols=new ArrayList<>();
|
|
|
|
-// wplen++;
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// if(!wppols.isEmpty())
|
|
|
|
-// {
|
|
|
|
-// str.setLength(0);
|
|
|
|
-// str.append("场站读取线程号:").append(wplen);
|
|
|
|
-// new Thread(new ReadWpDataThread(executor, edosUtil, readRows, wppols,interval,str)).start();
|
|
|
|
-// listNumber++;
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// str=new StringBuilder();
|
|
|
|
-// str.append("场站读取总数:").append(alarmTags.size()).append(",线程数:").append(taskCount).append(",分块大小:").append(listNumber);
|
|
|
|
-//
|
|
|
|
-// System.out.println(str.toString());
|
|
|
|
-
|
|
|
|
- str.setLength(0);
|
|
|
|
- //读取升压站测点
|
|
|
|
- int wslen = 1;
|
|
|
|
- List<ProBasicPowerstationPoint> wspols=new ArrayList<>();
|
|
|
|
- for(int i=0;i<wsPointList.size();i++)
|
|
|
|
- {
|
|
|
|
- wspols.add(wsPointList.get(i));
|
|
|
|
- if(i!=0 && i%readCount==0)
|
|
|
|
- {
|
|
|
|
- str.setLength(0);
|
|
|
|
- str.append("总数:").append(wspols.size()).append(",线程数:").append(readCount).append(",分块大小:").append(wslen);
|
|
|
|
|
|
+ for (int i = 0; i < wtPointList.size(); i++) {
|
|
|
|
+ wtpols.add(wtPointList.get(i));
|
|
|
|
+ if (i != 0 && (i+1) % wtlistNumber == 0) {
|
|
|
|
|
|
- new Thread(new ReadWsDataThread(executor, edosUtil, readRows, wspols,interval,str)).start();
|
|
|
|
- wspols=new ArrayList<>();
|
|
|
|
- wslen++;
|
|
|
|
|
|
+ time++;
|
|
|
|
+ str.setLength(0);
|
|
|
|
+ str.append("数据读取").append(time).append("线程");
|
|
|
|
+ new Thread(new ReadWtDataThread(executor, edosUtil, readRows, wtpols, interval, str, countDownLatch)).start();
|
|
|
|
+ wtpols = new ArrayList<>();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- if(!wspols.isEmpty())
|
|
|
|
- {
|
|
|
|
- str.setLength(0);
|
|
|
|
- str.append("总数:").append(wspols.size()).append(",线程数:").append(readCount).append(",分块大小:").append(wslen);
|
|
|
|
|
|
+ if (!wtpols.isEmpty()) {
|
|
|
|
|
|
- new Thread(new ReadWsDataThread(executor, edosUtil, readRows, wspols,interval,str)).start();
|
|
|
|
|
|
+ time++;
|
|
|
|
+ str.setLength(0);
|
|
|
|
+ str.append("数据读取").append(time).append("线程");
|
|
|
|
+ new Thread(new ReadWtDataThread(executor, edosUtil, readRows, wtpols, interval, str, countDownLatch)).start();
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- Thread.sleep((interval * 1000));
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+/***************************************************************************************************************************/
|
|
|
|
|
|
|
|
+ //读取升压站测点
|
|
|
|
|
|
- public void calTaskJobs(boolean runStarted) {
|
|
|
|
|
|
+ List<ProBasicPowerstationPoint> wspols = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < wsPointList.size(); i++) {
|
|
|
|
+ wspols.add(wsPointList.get(i));
|
|
|
|
+ if (i != 0 && (i+1) % wslistNumber == 0) {
|
|
|
|
+ time++;
|
|
|
|
+ str.setLength(0);
|
|
|
|
+ str.append("数据读取").append(time).append("线程");
|
|
|
|
+ new Thread(new ReadWsDataThread(executor, edosUtil, readRows, wspols, interval, str, countDownLatch)).start();
|
|
|
|
+ wspols = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ if (!wspols.isEmpty()) {
|
|
|
|
+ time++;
|
|
|
|
+ str.setLength(0);
|
|
|
|
+ str.append("数据读取").append(time).append("线程");
|
|
|
|
+ new Thread(new ReadWsDataThread(executor, edosUtil, readRows, wspols, interval, str, countDownLatch)).start();
|
|
|
|
|
|
- while(runStarted)
|
|
|
|
- {
|
|
|
|
- int len = 1;
|
|
|
|
|
|
+ }
|
|
|
|
+ countDownLatch.await();
|
|
|
|
+ log.info("数据读取完成!");
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep((interval * 500));
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
- List<AlarmCustomTag> alarmls=new ArrayList<>();
|
|
|
|
|
|
|
|
- for(int i=0;i<alarmTags.size();i++)
|
|
|
|
- {
|
|
|
|
|
|
+ public synchronized void calTaskJobs(boolean runStarted) throws InterruptedException {
|
|
|
|
+
|
|
|
|
+ List<AlarmCustomTag> alarmls = new ArrayList<>();
|
|
|
|
+ int number = 0;
|
|
|
|
+ int listNumber = alarmTags.size() / taskCount;
|
|
|
|
+ if (alarmTags.size() % listNumber == 0) {
|
|
|
|
+ number = taskCount;
|
|
|
|
+ } else {
|
|
|
|
+ number = taskCount+1;
|
|
|
|
+ }
|
|
|
|
+ StringBuilder str = new StringBuilder();
|
|
|
|
+ str.append("自定义分析总数:").append(alarmTags.size()).append(",线程数:").append(number).append(",分块大小:").append(listNumber);
|
|
|
|
+ log.info(String.valueOf(str));
|
|
|
|
+ CountDownLatch countDownLatch = new CountDownLatch(number);
|
|
|
|
+
|
|
|
|
+ int time=0;
|
|
|
|
+ for (int i = 0; i < alarmTags.size(); i++) {
|
|
alarmls.add(alarmTags.get(i));
|
|
alarmls.add(alarmTags.get(i));
|
|
- if(i!=0 && i%taskCount==0)
|
|
|
|
- {
|
|
|
|
|
|
+ if (i != 0 && (i+1) % listNumber == 0) {
|
|
|
|
+
|
|
|
|
+ time++;
|
|
str.setLength(0);
|
|
str.setLength(0);
|
|
- str.append("总数:").append(alarmTags.size()).append(",线程数:").append(taskCount).append(",分块大小:").append(len);
|
|
|
|
|
|
+ str.append("自定义分析").append(time).append("线程");
|
|
|
|
+ new Thread(new AlarmThread(executor, alarmService, alarmls,interval,str,readRows,countDownLatch)).start();
|
|
|
|
+ alarmls = new ArrayList<>();
|
|
|
|
|
|
- new Thread(new AlarmThread(executor, alarmService, alarmls,interval,str,readRows)).start();
|
|
|
|
- alarmls=new ArrayList<>();
|
|
|
|
- len++;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if(!alarmls.isEmpty())
|
|
|
|
- {
|
|
|
|
- str.setLength(0);
|
|
|
|
- str.append("总数:").append(alarmTags.size()).append(",线程数:").append(taskCount).append(",分块大小:").append(len);
|
|
|
|
|
|
+ if (!alarmls.isEmpty()) {
|
|
|
|
|
|
- new Thread(new AlarmThread(executor, alarmService, alarmls,interval,str,readRows)).start();
|
|
|
|
|
|
+ time++;
|
|
|
|
+ str.setLength(0);
|
|
|
|
+ str.append("自定义分析").append(time).append("线程");
|
|
|
|
+ new Thread(new AlarmThread(executor, alarmService, alarmls,interval,str,readRows,countDownLatch)).start();
|
|
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- try {
|
|
|
|
- Thread.sleep((interval * 1000));
|
|
|
|
- } catch (InterruptedException e) {
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
|
+ countDownLatch.await();
|
|
|
|
+ log.info("自定义分析完成!");
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep((interval * 500));
|
|
|
|
+ } catch (InterruptedException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+//
|
|
|
|
+// }
|
|
}
|
|
}
|