Bladeren bron

添加异步多线程调度功能

shilin 4 maanden geleden
bovenliggende
commit
3c02b2c09c

+ 2 - 0
alarm-custom/src/main/java/com/gyee/alarm/AlarmCustom.java

@@ -3,9 +3,11 @@ package com.gyee.alarm;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableAsync;
 
 
 @SpringBootApplication
+@EnableAsync
 @MapperScan("com.gyee.alarm.mapper")
 public class AlarmCustom {
     public static void main(String[] args) throws Exception {

+ 7 - 3
alarm-custom/src/main/java/com/gyee/alarm/CalculateServer.java

@@ -1,6 +1,7 @@
 package com.gyee.alarm;
 
 
+import com.gyee.alarm.service.AlarmCustomAsyncService;
 import com.gyee.alarm.service.AlarmCustomService;
 
 import org.springframework.stereotype.Component;
@@ -11,8 +12,11 @@ import javax.annotation.Resource;
 @Component
 public class CalculateServer {
 
+//    @Resource
+//    AlarmCustomService alarmCustomService;
+
     @Resource
-    AlarmCustomService alarmCustomService;
+    AlarmCustomAsyncService alarmCustomAsyncService;
     private boolean serverStarted = false;
 
     private boolean runStarted = false;
@@ -25,9 +29,9 @@ public class CalculateServer {
             //GlobalVar.config = configProperties;
             log.warn("自定义报警计算服务启动...... ");
             log.info("开始加载配置及测点数据......");
-            alarmCustomService.init();
+            alarmCustomAsyncService.init();
             runStarted = true;
-            alarmCustomService.taskJobs(runStarted);
+            alarmCustomAsyncService.taskJobs(runStarted);
             serverStarted = true;
         } catch (Exception ex) {
             serverStarted = false;

+ 273 - 0
alarm-custom/src/main/java/com/gyee/alarm/service/AlarmCustomAsyncService.java

@@ -0,0 +1,273 @@
+package com.gyee.alarm.service;
+
+
+import com.gyee.alarm.feigns.IAlarmService;
+import com.gyee.alarm.init.CacheContext;
+import com.gyee.alarm.model.auto.ProBasicEquipmentPoint;
+import com.gyee.alarm.model.vo.AlarmCustomTag;
+import com.gyee.alarm.service.auto.IAlarmTsService;
+import com.gyee.alarm.task.thread.AlarmThread;
+import com.gyee.alarm.task.thread.ReadWtDataThread;
+import com.gyee.alarm.util.realtimesource.IEdosUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.*;
+
+
+@Service
+@Slf4j
+public class AlarmCustomAsyncService {
+
+    private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Value("${task-count}")
+    private Integer taskCount;
+
+    @Value("${interval}")
+    private Integer interval;
+
+    @Value("${read-count}")
+    private Integer readCount;
+
+    @Value("${read-rows}")
+    private Integer readRows;
+
+    @Value("${alarmType}")
+    private String alarmType;
+    @Resource
+    private IEdosUtil edosUtil;
+    @Resource
+    private IAlarmService alarmService;
+
+    private List<AlarmCustomTag> alarmTags = new CopyOnWriteArrayList<>();
+
+
+    @Resource
+    private IAlarmTsService alarmTsService;
+    @Resource
+    private CustomAsyncService customAsyncService;
+
+    /**
+     * 初始化
+     */
+    public void init() {
+
+        alarmTags = alarmService.findTagsByCt();
+    }
+
+    public void taskJobs(boolean runStarted) throws Exception {
+
+        while (runStarted) {
+
+            readTaskJobs(runStarted);
+
+            Thread.sleep((interval * 1000));
+
+            calTaskJobs(runStarted);
+
+            Thread.sleep((interval * 1000));
+        }
+    }
+
+
+    /**
+     * 读取测点数据,缓存到内存
+     */
+    public  void readTaskJobs(boolean runStarted) throws Exception {
+
+        List<ProBasicEquipmentPoint> wtPointList = CacheContext.wtPointList;// 设备测点集合
+
+        List<ProBasicEquipmentPoint> fdPointList =new ArrayList<>();
+        List<ProBasicEquipmentPoint> gdPointList =new ArrayList<>();
+        if(!wtPointList.isEmpty())
+        {
+            for(ProBasicEquipmentPoint tag:wtPointList)
+            {
+                if(tag.getNemCode().startsWith("GF"))
+                {
+                    gdPointList.add(tag);
+                }else
+                {
+                    fdPointList.add(tag);
+                }
+            }
+        }
+
+//        List<ProBasicPowerstationPoint> wsPointList = CacheContext.wsPointList; //升压站测点集合
+
+        //读取设备测点
+        List<ProBasicEquipmentPoint> wtpols = new ArrayList<>();
+
+        int wtlistNumber = fdPointList.size() / readCount;
+//        int wslistNumber = wsPointList.size() / readCount;
+
+            if (fdPointList.size() % readCount != 0) {
+                wtlistNumber=wtlistNumber+1;
+            }
+
+//            if (wsPointList.size() % readCount != 0) {
+//                wslistNumber =  wslistNumber+1;
+//            }
+        List<CompletableFuture<String>> futures = new ArrayList<>();
+
+
+
+
+        int time = 0;
+        StringBuilder str = new StringBuilder();
+        str.append("设备读取总数:").append(fdPointList.size()).append(",线程数:").append(wtlistNumber ).append(",分块大小:").append(readCount);
+        log.info(String.valueOf(str));
+
+        for (int i = 0; i < fdPointList.size(); i++) {
+            wtpols.add(fdPointList.get(i));
+            if (i != 0 && (i) % readCount == 0) {
+
+                time++;
+                str.setLength(0);
+                str.append("数据读取").append(time).append("线程");
+                futures.add( customAsyncService.readCall( edosUtil, readRows, wtpols,String.valueOf(str)));
+                wtpols = new ArrayList<>();
+            }
+        }
+
+        if (!wtpols.isEmpty()) {
+
+            time++;
+            str.setLength(0);
+            str.append("数据读取").append(time).append("线程");
+            futures.add( customAsyncService.readCall( edosUtil, readRows, wtpols,String.valueOf(str)));
+        }
+
+
+
+/***************************************************************************************************************************/
+
+        //读取设备测点
+        wtpols = new ArrayList<>();
+
+        wtlistNumber = gdPointList.size() / readCount;
+//        int wslistNumber = wsPointList.size() / readCount;
+
+        if (gdPointList.size() % readCount != 0) {
+            wtlistNumber=wtlistNumber+1;
+        }
+
+//            if (wsPointList.size() % readCount != 0) {
+//                wslistNumber =  wslistNumber+1;
+//            }
+
+
+        time = 0;
+        str = new StringBuilder();
+        str.append("设备读取总数:").append(fdPointList.size()).append(",线程数:").append(wtlistNumber ).append(",分块大小:").append(readCount);
+        log.info(String.valueOf(str));
+
+        for (int i = 0; i < gdPointList.size(); i++) {
+            wtpols.add(gdPointList.get(i));
+            if (i != 0 && (i) % readCount == 0) {
+
+                time++;
+                str.setLength(0);
+                str.append("数据读取").append(time).append("线程");
+                futures.add( customAsyncService.readCall( edosUtil, readRows, wtpols,String.valueOf(str)));
+                wtpols = new ArrayList<>();
+            }
+        }
+
+        if (!wtpols.isEmpty()) {
+
+            time++;
+            str.setLength(0);
+            str.append("数据读取").append(time).append("线程");
+            futures.add( customAsyncService.readCall( edosUtil, readRows, wtpols,String.valueOf(str)));
+        }
+/***************************************************************************************************************************/
+
+        //读取升压站测点
+
+//        List<ProBasicPowerstationPoint> wspols = new ArrayList<>();
+//        for (int i = 0; i < wsPointList.size(); i++) {
+//            wspols.add(wsPointList.get(i));
+//            if (i != 0 && (i) % readCount == 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();
+//
+//        }
+        // 等待所有任务完成
+        CompletableFuture[] futuresArray = futures.toArray(new CompletableFuture[0]);
+        CompletableFuture.allOf(futuresArray).join();
+        log.info("数据读取完成!");
+
+
+
+    }
+
+
+    public  void calTaskJobs(boolean runStarted) throws Exception {
+
+
+        List<CompletableFuture<String>> futures = new ArrayList<>();
+
+        List<AlarmCustomTag> alarmls = new ArrayList<>();
+//            int number = 0;
+        int listNumber = alarmTags.size() / taskCount;
+
+            if (alarmTags.size() % taskCount == 0) {
+                listNumber = listNumber+1;
+            }
+        StringBuilder str = new StringBuilder();
+        str.append("自定义分析总数:").append(alarmTags.size()).append(",线程数:").append(listNumber).append(",分块大小:").append(taskCount);
+        log.info(String.valueOf(str));
+
+
+        int time = 0;
+        for (int i = 0; i < alarmTags.size(); i++) {
+            alarmls.add(alarmTags.get(i));
+            if (i != 0 && (i) % taskCount == 0) {
+
+                time++;
+                str.setLength(0);
+                str.append("自定义分析").append(time).append("线程");
+
+                futures.add( customAsyncService.checkCall(alarmService, alarmls,  str, readRows,  alarmTsService));
+                alarmls = new ArrayList<>();
+
+            }
+        }
+
+        if (!alarmls.isEmpty()) {
+
+            time++;
+            str.setLength(0);
+            str.append("自定义分析").append(time).append("线程");
+            futures.add( customAsyncService.checkCall(alarmService, alarmls,  str, readRows,  alarmTsService));
+
+        }
+
+        CompletableFuture[] futuresArray = futures.toArray(new CompletableFuture[0]);
+        CompletableFuture.allOf(futuresArray).join();
+
+        log.info("自定义分析完成!");
+
+    }
+//
+//    }
+}

+ 279 - 0
alarm-custom/src/main/java/com/gyee/alarm/service/CustomAsyncService.java

@@ -0,0 +1,279 @@
+package com.gyee.alarm.service;
+
+
+import com.gyee.alarm.feigns.IAlarmService;
+import com.gyee.alarm.init.CacheContext;
+import com.gyee.alarm.model.auto.ProBasicEquipmentPoint;
+import com.gyee.alarm.model.vo.*;
+import com.gyee.alarm.rule.AlarmFunction;
+import com.gyee.alarm.rule.expression.AlarmExpression;
+import com.gyee.alarm.rule.expression.Analyzer;
+import com.gyee.alarm.service.auto.IAlarmTsService;
+import com.gyee.alarm.task.thread.AlarmThread;
+import com.gyee.alarm.task.thread.ReadWtDataThread;
+import com.gyee.alarm.util.realtimesource.IEdosUtil;
+import com.gyee.common.model.PointData;
+import com.gyee.common.model.StringUtils;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.concurrent.*;
+
+
+@Service
+@Slf4j
+public class CustomAsyncService {
+
+    private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+
+    @Resource
+    private Executor executor;
+
+
+    @Resource
+    private IAlarmTsService alarmTsService;
+
+
+    @SneakyThrows
+    @Async("taskExecutor")
+    public CompletableFuture<String> readCall(IEdosUtil edosUtil, Integer readRows, List<ProBasicEquipmentPoint> pointList,String str) throws Exception {
+
+        Integer result = 1;
+
+        try {
+
+            List<String>  ls=new ArrayList<>();
+            List<PointData> values=new ArrayList<>();
+
+            int times=0;
+            for(ProBasicEquipmentPoint vo:pointList)
+            {
+                ls.add(vo.getNemCode());
+                times++;
+                if(times==readRows)
+                {
+                    List<PointData> templs=edosUtil.getRealData(ls);
+                    values.addAll(templs);
+                    ls=new ArrayList<>();
+                    times=0;
+                }
+            }
+            if(!ls.isEmpty())
+            {
+                List<PointData> templs=edosUtil.getRealData(ls);
+                values.addAll(templs);
+            }
+
+            if(values.size() == pointList.size())
+            {
+
+                for(int i=0;i<pointList.size();i++)
+                {
+                    ProBasicEquipmentPoint point=pointList.get(i);
+                    PointData value=values.get(i);
+                    if(CacheContext.wtDataValueMap.containsKey(point.getWindturbineId()))
+                    {
+                        Map<String, PointData> map=CacheContext.wtDataValueMap.get(point.getWindturbineId());
+                        map.put(point.getUniformCode(),value);
+                    }else
+                    {
+                        Map<String, PointData> map=new HashMap<>();
+
+                        map.put(point.getUniformCode(),value);
+                        CacheContext.wtDataValueMap.put(point.getWindturbineId(),map);
+                    }
+                }
+            }
+
+
+
+        } catch (Exception e) {
+
+            e.printStackTrace();
+            result=0;
+        }
+
+
+        return CompletableFuture.completedFuture(str+"Task completed");
+
+    }
+
+
+
+    @SneakyThrows
+    @Async("taskExecutor")
+    public CompletableFuture<String>  checkCall(IAlarmService alarmService, List<AlarmCustomTag> alarmVoList,
+                                     StringBuilder str, Integer readRows, IAlarmTsService alarmTsService) throws Exception {
+
+        Integer result = 1;
+
+        try {
+
+
+
+            List<AlarmTag> saveAlarmTags =   new CopyOnWriteArrayList<>();
+            List<AlarmTag> updateAlarmTags  = new CopyOnWriteArrayList<>();
+
+
+            StringBuilder sb = new StringBuilder();
+
+
+            List<AlarmSimpleVo> alarmls = new CopyOnWriteArrayList<>();
+            int times = 0;
+            for (AlarmCustomTag alarm : alarmVoList) {
+
+                sb.append("'").append(alarm.getId().toLowerCase()).append("',");
+                times++;
+                if (times == readRows) {
+                    String ids =  sb.substring(0, sb.length() - 1);
+                    List<AlarmSimpleVo>  templs=new ArrayList<>();
+                    templs =  alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.CT.getCode(), ids);
+                    alarmls.addAll(templs);
+                    sb.setLength(0);
+                    times = 0;
+                }
+            }
+            if (sb.length()>0) {
+
+                String ids =  sb.substring(0, sb.length() - 1);
+                List<AlarmSimpleVo>  templs=new ArrayList<>();
+                templs =  alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.CT.getCode(), ids);
+                alarmls.addAll(templs);
+            }
+
+            Map<String, AlarmSimpleVo> map = new ConcurrentHashMap<>();
+
+
+            if (!alarmls.isEmpty()) {
+                for (AlarmSimpleVo vo : alarmls) {
+                    map.put(vo.getTbName().toLowerCase(), vo);
+                }
+            }
+
+
+            for (AlarmCustomTag vo : alarmVoList) {
+
+                checkRule(saveAlarmTags, updateAlarmTags, vo,map);
+
+            }
+
+            if (!saveAlarmTags.isEmpty()) {
+                alarmService.saveAlarm(saveAlarmTags);
+            }
+
+            if (!updateAlarmTags.isEmpty()) {
+                alarmService.updateAlarm(updateAlarmTags);
+            }
+
+
+
+            logger.info(str+ "新增报警数量:" + saveAlarmTags.size());
+            logger.info(str+ "结束报警数量:" + updateAlarmTags.size());
+        } catch (Exception e) {
+
+            e.printStackTrace();
+
+        }
+
+
+        return CompletableFuture.completedFuture(str+"Task completed");
+
+    }
+
+    private  void checkRule(List<AlarmTag> saveAlarmTags, List<AlarmTag> updateAlarmTags, AlarmCustomTag ar,Map<String, AlarmSimpleVo> map) {
+
+
+        try {
+
+            AlarmExpression alarmExpression = Analyzer.getAlarmExpression(ar.getTagId());
+
+            AlarmFunction alarmFunction = null;
+
+            if (ar.getDevicetype().equals(DeviceTypeValue.WT.getCode())) {
+                alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.WT, ar.getDeviceid());
+
+
+            }else if (ar.getDevicetype().equals(DeviceTypeValue.IN.getCode())) {
+                alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.IN, ar.getDeviceid());
+
+
+            } else if (ar.getDevicetype().equals(DeviceTypeValue.BT.getCode())) {
+                alarmFunction = new AlarmFunction(alarmExpression, DeviceTypeValue.BT, ar.getStationid());
+            }
+
+            try {
+
+                Object obj = alarmFunction.explain();
+
+                if (obj instanceof Boolean) {
+
+
+                    boolean endStatus = true;
+
+                    if(map.containsKey(ar.getId().toLowerCase()))
+                    {
+                        AlarmSimpleVo vo=map.get(ar.getId().toLowerCase());
+
+                        if(StringUtils.notEmp(vo.getEndts()))
+                        {
+                            endStatus=true;
+                        }else
+                        {
+                            endStatus=false;
+                        }
+                    }else
+                    {
+                        endStatus = true;
+                    }
+                    if (true == (boolean) obj) {
+
+                        if(endStatus)
+                        {
+                            AlarmTag po = new AlarmTag();
+                            po.setId(ar.getId());
+                            po.setTs(new Date().getTime());
+                            po.setEndts(null);
+                            po.setVal(1.0);
+                            po.setOval(1.0);
+                            po.setTimeLong(0.0);
+
+                            saveAlarmTags.add(po);
+                        }
+
+                    } else {
+
+                        if(!endStatus)
+                        {
+                            AlarmTag po = new AlarmTag();
+                            po.setId(ar.getId());
+                            po.setTs(new Date().getTime());
+                            po.setEndts(new Date().getTime());
+                            po.setVal(0.0);
+                            po.setOval(0.0);
+                            po.setTimeLong(0.0);
+
+                            updateAlarmTags.add(po);
+                        }
+
+                    }
+                } else {
+                    // System.out.print(obj.toString());
+                }
+            } catch (Exception ex) {
+                // ex.printStackTrace();
+                logger.error("自定义报警规则执行时出错!" + alarmFunction.getThingId() + "--" + ar.getTagId() + "----" + ex.getMessage());
+            }
+
+        } catch (Exception ex) {
+            logger.error("生成自定义报警规则失败!规则id:" + ar.getId());
+        }
+    }
+}

+ 0 - 1
alarm-custom/src/main/java/com/gyee/alarm/task/thread/ReadWtDataThreadPoolPool.java

@@ -99,7 +99,6 @@ public class ReadWtDataThreadPoolPool implements Callable<Integer>, Serializable
 							CacheContext.wtDataValueMap.put(point.getWindturbineId(),map);
 						}
 					}
-
 				}
 
 //				try {

+ 2 - 0
alarm-scanner/src/main/java/com/gyee/alarm/AlarmScannerMain.java

@@ -3,11 +3,13 @@ package com.gyee.alarm;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
 
 @SpringBootApplication
 @EnableScheduling
+@EnableAsync
 @MapperScan("com.gyee.alarm.mapper")
 public class AlarmScannerMain {
     public static void main(String[] args) throws Exception {

+ 7 - 3
alarm-scanner/src/main/java/com/gyee/alarm/CalculateServer.java

@@ -2,6 +2,7 @@ package com.gyee.alarm;
 
 
 import com.gyee.alarm.init.CacheContext;
+import com.gyee.alarm.service.AlarmScannerAsyncService;
 import com.gyee.alarm.service.AlarmScannerService;
 
 import org.springframework.beans.factory.annotation.Value;
@@ -14,8 +15,11 @@ import java.util.concurrent.CountDownLatch;
 @Component
 public class CalculateServer {
 
+//    @Resource
+//    AlarmScannerService alarmScannerService;
+
     @Resource
-    AlarmScannerService alarmScannerService;
+    AlarmScannerAsyncService alarmScannerAsyncService;
     @Value("${interval}")
     private Integer interval;
     @Value("${task-count}")
@@ -32,10 +36,10 @@ public class CalculateServer {
             //GlobalVar.config = configProperties;
             log.warn("警计算服务启动...... ");
             log.info("开始加载配置及测点数据......");
-            alarmScannerService.init();
+            alarmScannerAsyncService.init();
 
             runStarted=true;
-            alarmScannerService.taskJobs(runStarted);
+            alarmScannerAsyncService.taskJobs(runStarted);
             serverStarted = true;
         } catch (Exception ex) {
             serverStarted = false;

+ 1 - 1
alarm-scanner/src/main/java/com/gyee/alarm/config/ThreadPoolTaskConfig.java

@@ -52,7 +52,7 @@ public class ThreadPoolTaskConfig {
     }
 
 
-    @Bean
+    @Bean("taskExecutor")
     public ThreadPoolTaskExecutor taskExecutor() {
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         executor.setCorePoolSize(corePoolSize);

+ 29 - 7
alarm-scanner/src/main/java/com/gyee/alarm/model/vo/AlarmTag.java

@@ -104,7 +104,7 @@ public class AlarmTag {
      */
     public synchronized Boolean updateAndCheck(PointData pointData) {
 
-        if(alarmType.equals(AlarmTypeValue.BT.getCode()))
+        if(alarmType.equals(AlarmTypeValue.BT.getCode()) && StringUtils.notEmp(wpId) && wpId.contains("_SBS"))
         {
             if(pointData.getPointValueInDouble()<1)
             {
@@ -115,7 +115,7 @@ public class AlarmTag {
             }
         }
 
-        if(null ==oval)
+        if(null == oval)
         {
             oval=pointData.getPointValueInDouble();
             return false;
@@ -125,15 +125,28 @@ public class AlarmTag {
         if (pointData.getPointValueInDouble() == oval.doubleValue()) {
             return false;
         }
+
+        if (StringUtils.empty(pointData.getPointTime())) {
+            return false;
+        }
+
+        if (pointData.getPointTime().intValue()==0) {
+            return false;
+        }
+        if(StringUtils.notEmp(wpId) && wpId.contains("_SBS"))
+        {
+            log.info("判定相等报警tagId_"+tagId+"_wpId_"+wpId+"_ts_"+ts+"_val_"+oval.doubleValue());
+        }
         ts = pointData.getPointTime();
         oval = pointData.getPointValueInDouble();
         endts= pointData.getPointTime();
         val=0.0;
 
-//        if(StringUtils.notEmp(wpId) && wpId.contains("_SBS"))
-//        {
-//            log.info("tagId_"+tagId+"_wpId_"+wpId+"_ts_"+ts+"_val_"+pointData.getPointValueInDouble());
-//        }
+
+        if(StringUtils.notEmp(wpId) && wpId.contains("_SBS"))
+        {
+            log.info("报警发生tagId_"+tagId+"_wpId_"+wpId+"_ts_"+ts+"_val_"+pointData.getPointValueInDouble());
+        }
         if(StringUtils.notEmp(uniformCode) && uniformCode.startsWith("BI")){
 
             int decimal = oval.intValue(); // 十进制报警数
@@ -192,7 +205,16 @@ public class AlarmTag {
 
     public synchronized Boolean updateAndCheckNoInfo(PointData pointData) {
 
-
+        if(alarmType.equals(AlarmTypeValue.BT.getCode()))
+        {
+            if(pointData.getPointValueInDouble()<1)
+            {
+                pointData.setPointValueInDouble(0.0);
+            }else
+            {
+                pointData.setPointValueInDouble(1.0);
+            }
+        }
         ts = pointData.getPointTime();
         oval = pointData.getPointValueInDouble();
         endts= pointData.getPointTime();

+ 227 - 0
alarm-scanner/src/main/java/com/gyee/alarm/service/AlarmScannerAsyncService.java

@@ -0,0 +1,227 @@
+package com.gyee.alarm.service;
+
+
+import com.gyee.alarm.controller.feigns.IAlarmService;
+import com.gyee.alarm.model.vo.AlarmSimpleVo;
+import com.gyee.alarm.model.vo.AlarmSuperTalbeType;
+import com.gyee.alarm.model.vo.AlarmTag;
+import com.gyee.alarm.model.vo.AlarmTypeValue;
+import com.gyee.alarm.service.auto.IAlarmTsService;
+import com.gyee.alarm.task.thread.AlarmThread;
+import com.gyee.alarm.util.StringUtils;
+import com.gyee.alarm.util.realtimesource.IEdosUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.*;
+
+
+@Service
+@Slf4j
+public class AlarmScannerAsyncService {
+
+    @Value("${task-count}")
+    private Integer taskCount;
+
+    @Value("${interval}")
+    private Integer interval;
+
+    @Value("${alarmType}")
+    private String alarmType;
+    @Value("${read-rows}")
+    private Integer readRows;
+    @Resource
+    private IEdosUtil edosUtil;
+    @Resource
+    private IAlarmService alarmService;
+    @Resource
+    private  IAlarmTsService alarmTsService;
+    private List<AlarmTag>  alarmTags=new CopyOnWriteArrayList<>();
+
+    private List<AlarmTag>  alarmInTags=new CopyOnWriteArrayList<>();
+    @Resource
+    private AsyncService asyncService;
+    @Value("${runWindpowerstation}")
+    private String runWindpowerstation;
+
+
+    private Map<String, Integer> historymap;
+    /**
+     * 初始化
+     */
+    public void init() {
+//#WT("wt_alarms", "设备报警超级表"),
+//#BT("bt_alarms", "升压站报警超级表"),
+//#IN("in_alarms", "逆变器报警超级表"),
+        switch (alarmType){
+            case "wt_alarms":
+                alarmTags =alarmService.findTagsByWt(runWindpowerstation);
+                history(alarmTags);
+                break;
+            case "bt_alarms":
+                List<AlarmTag>  templs =alarmService.findTagsByBt();
+
+                if(!templs.isEmpty())
+                {
+                    for(AlarmTag tag:templs)
+                    {
+                        if(StringUtils.notEmp(tag.getTagId()) )
+                        {
+                            if(tag.getTagId().startsWith("GF"))
+                            {
+//                                tag.setVal(-10000.0);
+//                                tag.setOval(-10000.0);
+                                alarmInTags.add(tag);
+                            }else
+                            {
+                                alarmTags.add(tag);
+                            }
+                        }
+                    }
+                }
+                history(templs);
+                break;
+            case "in_alarms":
+                alarmTags =alarmService.findTagsByIn();
+                history(alarmTags);
+                break;
+        }
+    }
+
+    public void history(List<AlarmTag> tags) {
+
+        StringBuilder sb = new StringBuilder();
+
+
+        List<AlarmSimpleVo> alarmvols = new CopyOnWriteArrayList<>();
+        int times = 0;
+        for (AlarmTag alarm : tags) {
+
+            sb.append("'").append(alarm.getId().toLowerCase()).append("',");
+            times++;
+            if (times  == 1000) {
+                String ids = sb.substring(0, sb.length() - 1);
+                List<AlarmSimpleVo> templs = new CopyOnWriteArrayList<>();
+                if (alarm.getAlarmType().equals(AlarmTypeValue.BT.getCode())) {
+                    templs = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.BT.getCode(), ids);
+                } else if (alarm.getAlarmType().equals(AlarmTypeValue.WT.getCode())) {
+                    templs = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.WT.getCode(), ids);
+                } else if (alarm.getAlarmType().equals(AlarmTypeValue.IN.getCode())) {
+                    templs = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.WT.getCode(), ids);
+                }
+                alarmvols.addAll(templs);
+                sb.setLength(0);
+                times=0;
+            }
+        }
+
+        if (sb.length() > 0) {
+
+            String ids = sb.substring(0, sb.length() - 1);
+            List<AlarmSimpleVo> templs = new CopyOnWriteArrayList<>();
+            if (alarmTags.get(0).getAlarmType().equals(AlarmTypeValue.BT.getCode())) {
+                templs = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.BT.getCode(), ids);
+            } else if (alarmTags.get(0).getAlarmType().equals(AlarmTypeValue.WT.getCode())) {
+                templs = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.WT.getCode(), ids);
+            } else if (alarmTags.get(0).getAlarmType().equals(AlarmTypeValue.IN.getCode())) {
+                templs = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.WT.getCode(), ids);
+            }
+            alarmvols.addAll(templs);
+        }
+
+       historymap= new ConcurrentHashMap<>();
+
+
+        if (!alarmvols.isEmpty()) {
+            for (AlarmSimpleVo vo : alarmvols) {
+                if(StringUtils.empty(vo.getEndts()))
+                {
+                    historymap.put(vo.getTbName().toLowerCase(), 0);
+                }else
+                {
+                    historymap.put(vo.getTbName().toLowerCase(), 1);
+                }
+
+            }
+        }
+    }
+    /**
+     * 分配任务
+     */
+    public  void taskJobs(boolean start) throws Exception {
+
+
+        while (start) {
+
+            if (alarmType.equals("bt_alarms")) {
+
+                List<CompletableFuture<String>> futures = new ArrayList<>();
+
+                futures.add(  asyncService.asyncService(alarmTags,readRows,edosUtil, historymap,
+                        alarmType,  alarmService,1));
+
+                futures.add(  asyncService.asyncService(alarmInTags,readRows,edosUtil, historymap,
+                        alarmType,  alarmService,2));
+
+                // 等待所有任务完成
+                CompletableFuture[] futuresArray = futures.toArray(new CompletableFuture[0]);
+                CompletableFuture.allOf(futuresArray).join();
+
+
+            } else {
+
+                List<CompletableFuture<String>> futures = new ArrayList<>();
+                int len = 1;
+
+                List<AlarmTag> alarmls = new ArrayList<>();
+
+                int listNumber = alarmTags.size() / taskCount;
+                int number = 0;
+                if (alarmTags.size() % taskCount != 0) {
+                    listNumber = listNumber + 1;
+                }
+
+
+                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) {
+
+                        futures.add(asyncService.asyncService(alarmls,readRows,edosUtil, historymap,
+                                alarmType,  alarmService,len));
+                        alarmls = new ArrayList<>();
+                        len++;
+                    }
+                }
+
+                if (!alarmls.isEmpty()) {
+
+                    futures.add(  asyncService.asyncService(alarmls,readRows,edosUtil, historymap,
+                            alarmType,  alarmService,len));
+                }
+
+
+                // 等待所有任务完成
+                CompletableFuture[] futuresArray = futures.toArray(new CompletableFuture[0]);
+                CompletableFuture.allOf(futuresArray).join();
+
+            }
+
+
+
+            log.info("报警排查完成!");
+
+
+        }
+    }
+
+
+}

+ 2 - 2
alarm-scanner/src/main/java/com/gyee/alarm/service/AlarmScannerService.java

@@ -79,8 +79,8 @@ public class AlarmScannerService {
                         {
                             if(tag.getTagId().startsWith("GF"))
                             {
-                                tag.setVal(-10000.0);
-                                tag.setOval(-10000.0);
+//                                tag.setVal(-10000.0);
+//                                tag.setOval(-10000.0);
                                 alarmInTags.add(tag);
                             }else
                             {

+ 223 - 0
alarm-scanner/src/main/java/com/gyee/alarm/service/AsyncService.java

@@ -0,0 +1,223 @@
+package com.gyee.alarm.service;
+
+
+import com.gyee.alarm.controller.feigns.IAlarmService;
+import com.gyee.alarm.model.vo.AlarmSimpleVo;
+import com.gyee.alarm.model.vo.AlarmSuperTalbeType;
+import com.gyee.alarm.model.vo.AlarmTag;
+import com.gyee.alarm.model.vo.AlarmTypeValue;
+import com.gyee.alarm.service.auto.IAlarmTsService;
+import com.gyee.alarm.task.thread.AlarmThread;
+import com.gyee.alarm.util.StringUtils;
+import com.gyee.alarm.util.realtimesource.IEdosUtil;
+import com.gyee.common.model.PointData;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.*;
+
+
+@Service
+@Slf4j
+public class AsyncService {
+
+    private Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @SneakyThrows
+    @Async("taskExecutor")
+    public CompletableFuture<String>  asyncService(
+            List<AlarmTag> alarmVoList,Integer readRows,IEdosUtil edosUtil,Map<String, Integer> historymap,
+    String alarmType, IAlarmService alarmService,int len) throws Exception {
+
+
+
+
+//			while (true)
+//			{
+        List<String> ls = new ArrayList<>();
+        List<PointData> values = new ArrayList<>();
+
+
+        int times = 0;
+
+        for (AlarmTag vo : alarmVoList) {
+
+            ls.add(vo.getTagId());
+            times++;
+            if (times == readRows) {
+                List<PointData> templs = edosUtil.getRealData(ls);
+                values.addAll(templs);
+                ls = new ArrayList<>();
+                times=0;
+            }
+        }
+
+        if (!ls.isEmpty()) {
+            List<PointData> templs = edosUtil.getRealData(ls);
+            values.addAll(templs);
+        }
+
+
+//				System.out.println(values.size()+"____"+ alarmVoList.size());
+        int alarmNumber = 0;
+        if (values.size() == alarmVoList.size()) {
+            List<AlarmTag> saveAlarmTags = new ArrayList<>();
+
+            List<AlarmTag> updateAlarmTags = new ArrayList<>();
+
+            for (int i = 0; i < alarmVoList.size(); i++) {
+
+                AlarmTag vo = alarmVoList.get(i);
+
+//                    if(vo.getTagId().equals("FD-DJY-YuanDong.140623F0221MDQ02GS006DB0111SW09RAW00"))
+//                    {
+//                        System.out.println("");
+//                    }
+
+                PointData value = values.get(i);
+
+//                    if (vo.getTagId().equals("FD-PYZK-Taizhong1.140728F0111MDY01GS002DB0111SW01RAW00")) {
+//                        System.out.println("");
+//                    }
+                if (vo.updateAndCheck(value)) {
+                    if (vo.getVal() == 1) {
+                        AlarmTag po = new AlarmTag();
+
+                        po.setId(vo.getId());
+                        po.setTs(vo.getTs());
+//                        po.setEndts(po.getEndts());
+                        po.setVal(vo.getVal());
+                        po.setOval(vo.getOval());
+                        po.setTriggerType(vo.getTriggerType());
+                        po.setTagId(vo.getTagId());
+                        po.setRank(vo.getRank());
+                        po.setTimeLong(0.0);
+                        saveAlarmTags.add(po);
+                        alarmNumber++;
+
+                        historymap.put(vo.getId().toLowerCase(),0);
+
+
+                    } else if (vo.getVal() == 2) {
+
+                        if (historymap.containsKey(vo.getId().toLowerCase())) {
+                            //有结束时间,创建新的报警
+                            if (historymap.get(vo.getId().toLowerCase()) == 0) {
+                                //没有有结束时间,结束报警
+                                AlarmTag po = new AlarmTag();
+
+                                po.setId(vo.getId());
+                                po.setTs(vo.getTs());
+                                po.setEndts(vo.getEndts());
+                                po.setVal(vo.getVal());
+                                po.setOval(vo.getOval());
+                                po.setTriggerType(vo.getTriggerType());
+                                po.setTagId(vo.getTagId());
+                                po.setRank(vo.getRank());
+                                po.setTimeLong(0.0);
+                                updateAlarmTags.add(po);
+                                historymap.put(vo.getId().toLowerCase(),1);
+                            }
+                        }
+
+                    } else {
+                        AlarmTag po = new AlarmTag();
+
+                        po.setId(vo.getId());
+                        po.setTs(vo.getTs());
+                        po.setEndts(vo.getEndts());
+                        po.setVal(vo.getVal());
+                        po.setOval(vo.getOval());
+                        po.setTriggerType(vo.getTriggerType());
+                        po.setTagId(vo.getTagId());
+                        po.setRank(vo.getRank());
+                        po.setTimeLong(0.0);
+                        updateAlarmTags.add(po);
+                        alarmNumber++;
+                        historymap.put(vo.getId().toLowerCase(),1);
+                    }
+                }
+//                else  if (!historymap.containsKey(vo.getId().toLowerCase())) {
+//                    if (vo.updateAndCheckNoInfo(value)) {
+//                        if (vo.getVal() == 1) {
+//                            AlarmTag po = new AlarmTag();
+//
+//                            po.setId(vo.getId());
+//                            po.setTs(vo.getTs());
+//                            po.setEndts(po.getEndts());
+//                            po.setVal(vo.getVal());
+//                            po.setOval(vo.getOval());
+//                            po.setTriggerType(vo.getTriggerType());
+//                            po.setTagId(vo.getTagId());
+//                            po.setRank(vo.getRank());
+//                            po.setTimeLong(0.0);
+//                            saveAlarmTags.add(po);
+//                            alarmNumber++;
+//                            historymap.put(vo.getId().toLowerCase(),0);
+//                        }
+//                    }
+//                }
+            }
+
+            switch (alarmType) {
+                case "in_alarms":
+                    if (!saveAlarmTags.isEmpty()) {
+                        alarmService.saveInTags(saveAlarmTags);
+                    }
+                    if (!updateAlarmTags.isEmpty()) {
+                        alarmService.updateInTags(updateAlarmTags);
+                    }
+                    break;
+                case "wt_alarms":
+                    if (!saveAlarmTags.isEmpty()) {
+                        alarmService.saveWtTags(saveAlarmTags);
+                    }
+                    if (!updateAlarmTags.isEmpty()) {
+                        alarmService.updateWtTags(updateAlarmTags);
+                    }
+                    break;
+                case "bt_alarms":
+                    if (!saveAlarmTags.isEmpty()) {
+
+//                        for(AlarmTag tag:saveAlarmTags)
+//                        {
+//                            logger.info("tagId_"+tag.getTagId()+"_wpId_"+tag.getWpId()+"_ts_"+tag.getTs()+"_val_"+tag.getVal());
+//                        }
+
+                        alarmService.saveBtTags(saveAlarmTags);
+                    }
+                    if (!updateAlarmTags.isEmpty()) {
+//                        for(AlarmTag tag:updateAlarmTags)
+//                        {
+//                            logger.info("tagId_"+tag.getTagId()+"_wpId_"+tag.getWpId()+"_ts_"+tag.getTs()+"_val_"+tag.getVal());
+//                        }
+                        alarmService.updateBtTags(updateAlarmTags);
+                    }
+
+                    break;
+
+            }
+
+
+            logger.info(len+ "开始报警数量:" + saveAlarmTags.size());
+            logger.info(len+"结束报警数量:" + updateAlarmTags.size());
+        }
+
+        Thread.sleep(1000);
+
+
+        return CompletableFuture.completedFuture(len+"Task completed");
+    }
+
+
+}

+ 32 - 28
alarm-scanner/src/main/java/com/gyee/alarm/task/thread/AlarmThreadPool.java

@@ -83,6 +83,7 @@ public class AlarmThreadPool implements Callable<String>, Serializable {
             values.addAll(templs);
         }
 
+        
 //				System.out.println(values.size()+"____"+ alarmVoList.size());
         int alarmNumber = 0;
         if (values.size() == alarmVoList.size()) {
@@ -158,28 +159,30 @@ public class AlarmThreadPool implements Callable<String>, Serializable {
                         po.setRank(vo.getRank());
                         po.setTimeLong(0.0);
                         updateAlarmTags.add(po);
+                        alarmNumber++;
                         historymap.put(vo.getId().toLowerCase(),1);
                     }
-                } else  if (!historymap.containsKey(vo.getId().toLowerCase())) {
-                    if (vo.updateAndCheckNoInfo(value)) {
-                        if (vo.getVal() == 1) {
-                            AlarmTag po = new AlarmTag();
-
-                            po.setId(vo.getId());
-                            po.setTs(vo.getTs());
-                            po.setEndts(po.getEndts());
-                            po.setVal(vo.getVal());
-                            po.setOval(vo.getOval());
-                            po.setTriggerType(vo.getTriggerType());
-                            po.setTagId(vo.getTagId());
-                            po.setRank(vo.getRank());
-                            po.setTimeLong(0.0);
-                            saveAlarmTags.add(po);
-                            alarmNumber++;
-                            historymap.put(vo.getId().toLowerCase(),0);
-                        }
-                    }
                 }
+//                else  if (!historymap.containsKey(vo.getId().toLowerCase())) {
+//                    if (vo.updateAndCheckNoInfo(value)) {
+//                        if (vo.getVal() == 1) {
+//                            AlarmTag po = new AlarmTag();
+//
+//                            po.setId(vo.getId());
+//                            po.setTs(vo.getTs());
+//                            po.setEndts(po.getEndts());
+//                            po.setVal(vo.getVal());
+//                            po.setOval(vo.getOval());
+//                            po.setTriggerType(vo.getTriggerType());
+//                            po.setTagId(vo.getTagId());
+//                            po.setRank(vo.getRank());
+//                            po.setTimeLong(0.0);
+//                            saveAlarmTags.add(po);
+//                            alarmNumber++;
+//                            historymap.put(vo.getId().toLowerCase(),0);
+//                        }
+//                    }
+//                }
             }
 
             switch (alarmType) {
@@ -202,18 +205,18 @@ public class AlarmThreadPool implements Callable<String>, Serializable {
                 case "bt_alarms":
                     if (!saveAlarmTags.isEmpty()) {
 
-                        for(AlarmTag tag:saveAlarmTags)
-                        {
-                            logger.info("tagId_"+tag.getTagId()+"_wpId_"+tag.getWpId()+"_ts_"+tag.getTs()+"_val_"+tag.getVal());
-                        }
+//                        for(AlarmTag tag:saveAlarmTags)
+//                        {
+//                            logger.info("tagId_"+tag.getTagId()+"_wpId_"+tag.getWpId()+"_ts_"+tag.getTs()+"_val_"+tag.getVal());
+//                        }
 
                         alarmService.saveBtTags(saveAlarmTags);
                     }
                     if (!updateAlarmTags.isEmpty()) {
-                        for(AlarmTag tag:updateAlarmTags)
-                        {
-                            logger.info("tagId_"+tag.getTagId()+"_wpId_"+tag.getWpId()+"_ts_"+tag.getTs()+"_val_"+tag.getVal());
-                        }
+//                        for(AlarmTag tag:updateAlarmTags)
+//                        {
+//                            logger.info("tagId_"+tag.getTagId()+"_wpId_"+tag.getWpId()+"_ts_"+tag.getTs()+"_val_"+tag.getVal());
+//                        }
                         alarmService.updateBtTags(updateAlarmTags);
                     }
 
@@ -222,7 +225,8 @@ public class AlarmThreadPool implements Callable<String>, Serializable {
             }
 
 
-            logger.info(String.valueOf(threadPoolTaskData) + "报警数量:" + alarmNumber);
+            logger.info(String.valueOf(threadPoolTaskData) + "开始报警数量:" + saveAlarmTags.size());
+            logger.info(String.valueOf(threadPoolTaskData) + "结束报警数量:" + updateAlarmTags.size());
         }
 
         try {

+ 30 - 24
alarm-service/src/main/java/com/gyee/alarm/init/CacheContext.java

@@ -625,31 +625,7 @@ public class CacheContext implements CommandLineRunner {
 //            }
 //        }
 
-        List<ProEconAlarmRule> customls =proEconAlarmRuleService.list().stream().filter(i -> i.getEnable()).collect(Collectors.toList());
-
-        List<ProEconAlarmRule> wtCustomls=new ArrayList<>();
-        List<ProEconAlarmRule> inCustomls=new ArrayList<>();
-        List<ProEconAlarmRule> btCustomls=new ArrayList<>();
-        if(!customls.isEmpty())
-        {
-            for(ProEconAlarmRule vo: customls)
-            {
-                if(vo.getCategory().equals(AlarmCustomType.WT.getCode()))
-                {
-                    wtCustomls.add(vo);
-                }else  if(vo.getCategory().equals(AlarmCustomType.IN.getCode()))
-                {
-                    inCustomls.add(vo);
-                }else  if(vo.getCategory().equals(AlarmCustomType.Bt.getCode()))
-                {
-                    btCustomls.add(vo);
-                }
 
-            }
-        }
-        alarmRulesMap.put(AlarmCustomType.Bt.getCode(),btCustomls);
-        alarmRulesMap.put(AlarmCustomType.WT.getCode(),wtCustomls);
-        alarmRulesMap.put(AlarmCustomType.IN.getCode(),inCustomls);
 
 
         List<ProEconAlarmConfiguration> templs = proEconAlarmConfigurationService.list().stream().filter(i -> i.getEnable()).collect(Collectors.toList());
@@ -731,6 +707,36 @@ public class CacheContext implements CommandLineRunner {
                 alarmBtMap.put(vo.getTbName().toUpperCase(),vo);
             }
         }
+
+        //从pg数据库获取自定义报警配置信息
+        List<ProEconAlarmRule> customls =proEconAlarmRuleService.list().stream().filter(i -> i.getEnable()).collect(Collectors.toList());
+
+        List<ProEconAlarmRule> wtCustomls=new ArrayList<>();
+        List<ProEconAlarmRule> inCustomls=new ArrayList<>();
+        List<ProEconAlarmRule> btCustomls=new ArrayList<>();
+
+        //对自定义报警进行分类
+        if(!customls.isEmpty())
+        {
+            for(ProEconAlarmRule vo: customls)
+            {
+                if(vo.getCategory().equals(AlarmCustomType.WT.getCode()))
+                {
+                    wtCustomls.add(vo);
+                }else  if(vo.getCategory().equals(AlarmCustomType.IN.getCode()))
+                {
+                    inCustomls.add(vo);
+                }else  if(vo.getCategory().equals(AlarmCustomType.Bt.getCode()))
+                {
+                    btCustomls.add(vo);
+                }
+
+            }
+        }
+
+        alarmRulesMap.put(AlarmCustomType.Bt.getCode(),btCustomls);
+        alarmRulesMap.put(AlarmCustomType.WT.getCode(),wtCustomls);
+        alarmRulesMap.put(AlarmCustomType.IN.getCode(),inCustomls);
         //自定义报警初始化标签
         alarmCtList=alarmCtService.initalAlarmVo();
         if(!alarmCtList.isEmpty())

+ 3 - 2
alarm-service/src/main/java/com/gyee/alarm/service/AlarmCtService.java

@@ -56,7 +56,7 @@ public class AlarmCtService {
 
 
         List<AlarmVo> alarmVoList = CacheContext.alarmCtList;
-        List<AlarmTag> alarmTags = new ArrayList<>();
+//        List<AlarmTag> alarmTags = new ArrayList<>();
 
 
 
@@ -127,7 +127,7 @@ public class AlarmCtService {
     private void wtCustomAlarm(List<AlarmVo> alarmVoList, Map<String, List<ProEconAlarmRule>> alarmRulesMap) {
 
         Map<String, List<ProEconAlarmRule>> armap = new HashMap<>();
-
+        //将多有的自定义报警通过场站编号和型号进行分类
         if (alarmRulesMap.containsKey(DeviceTypeValue.WT.getCode())) {
             List<ProEconAlarmRule> arls = alarmRulesMap.get(DeviceTypeValue.WT.getCode());
             if (!arls.isEmpty()) {
@@ -145,6 +145,7 @@ public class AlarmCtService {
                 }
             }
         }
+        //将pg数据库中配置的自定义报警信息转化为报警对象,方便进行自定义报警的判定功能
         for (ProBasicEquipment wt : CacheContext.wtls) {
             StringBuilder sb = new StringBuilder();
             sb.append(wt.getWindpowerstationId() + wt.getModelId());