Browse Source

修正升压站报警异常

shilin 1 year ago
parent
commit
774726fb0e

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

@@ -117,10 +117,10 @@ public class AlarmTag {
         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(); // 十进制报警数

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

@@ -168,7 +168,8 @@ public class AlarmScannerService {
                 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);
+//                countDownLatch.await(30, TimeUnit.SECONDS);
+                countDownLatch.await();
             } else {
 
 
@@ -198,8 +199,8 @@ public class AlarmScannerService {
                 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);
+                countDownLatch.await();
             }
 
 

+ 10 - 48
alarm-scanner/src/main/java/com/gyee/alarm/task/thread/AlarmThreadPool.java

@@ -83,54 +83,6 @@ public class AlarmThreadPool implements Callable<String>, Serializable {
             values.addAll(templs);
         }
 
-//        StringBuilder sb = new StringBuilder();
-//
-//
-//        List<AlarmSimpleVo> alarmls = new CopyOnWriteArrayList<>();
-//        times = new AtomicInteger(0);
-//        for (AlarmTag alarm : alarmVoList) {
-//
-//            sb.append("'").append(alarm.getId().toLowerCase()).append("',");
-//            times.getAndAdd(1);
-//            if (times.get() == 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);
-//                }
-//                alarmls.addAll(templs);
-//                sb.setLength(0);
-//                times.set(0);
-//            }
-//        }
-//
-//        if (sb.length() > 0) {
-//
-//            String ids = sb.substring(0, sb.length() - 1);
-//            List<AlarmSimpleVo> templs = new CopyOnWriteArrayList<>();
-//            if (alarmVoList.get(0).getAlarmType().equals(AlarmTypeValue.BT.getCode())) {
-//                templs = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.BT.getCode(), ids);
-//            } else if (alarmVoList.get(0).getAlarmType().equals(AlarmTypeValue.WT.getCode())) {
-//                templs = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.WT.getCode(), ids);
-//            } else if (alarmVoList.get(0).getAlarmType().equals(AlarmTypeValue.IN.getCode())) {
-//                templs = alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.WT.getCode(), ids);
-//            }
-//            alarmls.addAll(templs);
-//        }
-//
-//        Map<String, AlarmSimpleVo> map = new HashMap<>();
-//
-//
-//        if (!alarmls.isEmpty()) {
-//            for (AlarmSimpleVo vo : alarmls) {
-//                map.put(vo.getTbName().toLowerCase(), vo);
-//            }
-//        }
-
 //				System.out.println(values.size()+"____"+ alarmVoList.size());
         int alarmNumber = 0;
         if (values.size() == alarmVoList.size()) {
@@ -249,9 +201,19 @@ public class AlarmThreadPool implements Callable<String>, Serializable {
                     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);
                     }
 

+ 4 - 4
alarm-service/src/main/java/com/gyee/alarm/service/AlarmBtService.java

@@ -312,7 +312,7 @@ public class AlarmBtService {
 //                        vo.setUpdateTime(in.getLastUpdateTime());
 //                    }
                     templs.add(vo);
-                    if (templs.size() == 100) {
+                    if (templs.size() == 900) {
                         proEconAlarmInfoService.saveBatch(templs);
                         templs = new ArrayList<>();
                     }
@@ -356,7 +356,7 @@ public class AlarmBtService {
                     }
                 }
 
-                Thread.sleep(300);
+                Thread.sleep(pushinterval.intValue());
 
 
             }
@@ -533,7 +533,7 @@ public class AlarmBtService {
 //                        vo.setUpdateTime(in.getLastUpdateTime());
 //                    }
                     templs.add(vo);
-                    if (templs.size() == 100) {
+                    if (templs.size() == 900) {
                         proEconAlarmInfoService.saveBatch(templs);
                         templs = new ArrayList<>();
                     }
@@ -577,7 +577,7 @@ public class AlarmBtService {
                     }
                 }
 
-                Thread.sleep(300);
+                Thread.sleep(pushinterval.intValue());
             }
         }
 

+ 8 - 6
alarm-service/src/main/java/com/gyee/alarm/service/AlarmCtService.java

@@ -561,7 +561,7 @@ public class AlarmCtService {
 //                        vo.setUpdateTime(in.getLastUpdateTime());
 //                    }
                     templs.add(vo);
-                    if (templs.size() == 100) {
+                    if (templs.size() == 900) {
                         proEconAlarmInfoService.saveBatch(templs);
                         templs = new ArrayList<>();
                     }
@@ -610,11 +610,11 @@ public class AlarmCtService {
 
                     }
                 }
-                Thread.sleep(300);
-            }
-
 
+            }
 
+//            Thread.sleep(300);
+            Thread.sleep(pushinterval.intValue());
         }
 
     }
@@ -796,7 +796,7 @@ public class AlarmCtService {
 //                            vo.setUpdateTime(in.getLastUpdateTime());
 //                        }
                         templs.add(vo);
-                        if (templs.size() == 100) {
+                        if (templs.size() == 900) {
                             proEconAlarmInfoService.saveBatch(templs);
                             templs = new ArrayList<>();
                         }
@@ -843,9 +843,11 @@ public class AlarmCtService {
                             }
                         }
 
-                        Thread.sleep(300);
+
                     }
                 }
+                //            Thread.sleep(300);
+                Thread.sleep(pushinterval.intValue());
             }
         }
     }

+ 6 - 4
alarm-service/src/main/java/com/gyee/alarm/service/AlarmInService.java

@@ -358,7 +358,7 @@ public class AlarmInService {
 //                        vo.setUpdateTime(in.getLastUpdateTime());
 //                    }
                     templs.add(vo);
-                    if (templs.size() == 500) {
+                    if (templs.size() == 900) {
                         proEconAlarmInfoService.saveBatch(templs);
                         templs = new ArrayList<>();
                     }
@@ -404,7 +404,8 @@ public class AlarmInService {
                     }
                 }
 
-                Thread.sleep(300);
+                //            Thread.sleep(300);
+                Thread.sleep(pushinterval.intValue());
 
             }
 
@@ -576,7 +577,7 @@ public class AlarmInService {
 //                        vo.setUpdateTime(in.getLastUpdateTime());
 //                    }
                     templs.add(vo);
-                    if (templs.size() == 500) {
+                    if (templs.size() == 900) {
                         proEconAlarmInfoService.saveBatch(templs);
                         templs = new ArrayList<>();
                     }
@@ -623,7 +624,8 @@ public class AlarmInService {
 
                     }
 
-                    Thread.sleep(300);
+                    //            Thread.sleep(300);
+                    Thread.sleep(pushinterval.intValue());
                 }
 
 

+ 6 - 4
alarm-service/src/main/java/com/gyee/alarm/service/AlarmWtService.java

@@ -404,7 +404,7 @@ public class AlarmWtService {
 //                        vo.setUpdateTime(in.getLastUpdateTime());
 //                    }
                     templs.add(vo);
-                    if (templs.size() == 500) {
+                    if (templs.size() == 900) {
                         proEconAlarmInfoService.saveBatch(templs);
                         templs = new ArrayList<>();
                     }
@@ -449,7 +449,8 @@ public class AlarmWtService {
                         pushDataSevice.pushWtData(alarm);
                     }
                 }
-                Thread.sleep(300);
+                //            Thread.sleep(300);
+                Thread.sleep(pushinterval.intValue());
             }
         }
     }
@@ -615,7 +616,7 @@ public class AlarmWtService {
 //                        vo.setUpdateTime(in.getLastUpdateTime());
 //                    }
                     templs.add(vo);
-                    if (templs.size() == 500) {
+                    if (templs.size() == 900) {
                         proEconAlarmInfoService.saveBatch(templs);
                         templs = new ArrayList<>();
                     }
@@ -660,7 +661,8 @@ public class AlarmWtService {
                         pushDataSevice.pushWtData(alarm);
                     }
 
-                    Thread.sleep(300);
+                    //            Thread.sleep(300);
+                    Thread.sleep(pushinterval.intValue());
                 }
             }
         }