Bladeren bron

计算服务修改

shilin 1 jaar geleden
bovenliggende
commit
f223aa3004
93 gewijzigde bestanden met toevoegingen van 4691 en 3530 verwijderingen
  1. 5 4
      realtime/generationXK-service/pom.xml
  2. 34 0
      realtime/generationXK-service/src/main/java/com/gyee/generation/GenerationMain.java
  3. 2 2
      realtime/generationXK-service/src/main/java/com/gyee/generation/config/XxlJobConfig.java
  4. 58 23
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo1Service.java
  5. 49 25
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo2Service.java
  6. 56 26
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo3Service.java
  7. 59 23
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo4Service.java
  8. 48 20
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo5Service.java
  9. 48 23
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfoDayTopService.java
  10. 0 1952
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/PowerCurveFittingByTimeNewService.java
  11. 59 27
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindturbineGoodnessService.java
  12. 25 13
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WpwindDayInfoService.java
  13. 61 28
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WtAlysisDayService.java
  14. 26 13
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/WtwindDayInfoService.java
  15. 72 72
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/initalcache/CacheService.java
  16. 6 3
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/realtimelibrary/CycleCalculationService.java
  17. 491 14
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/realtimelibrary/RealtimeService.java
  18. 4 3
      realtime/generationXK-service/src/main/java/com/gyee/generation/service/realtimelibrary/StatusService.java
  19. 31 1
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/SaticScheduleCALTask.java
  20. 37 160
      realtime/generationXK-service/src/main/java/com/gyee/generation/task/thread/EquipmentInfo1ThreadPool.java
  21. 91 48
      realtime/generationXK-service/src/main/resources/application-dev.yml
  22. 1 1
      realtime/generationXK-service/src/main/resources/application-jn.yml
  23. 5 3
      realtime/generationXK-service/src/test/java/com/gyee/generation/RealTest.java
  24. 272 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlarmTsMapper.java
  25. 0 45
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlarmcountMapper.java
  26. 0 24
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlarmsnapMapper.java
  27. 0 29
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/Alertrule2Mapper.java
  28. 0 25
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlertrulefailureMapper.java
  29. 0 24
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlertrulefailuresubMapper.java
  30. 0 16
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlertrulesubMapper.java
  31. 41 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProBasicFeatureStatMapper.java
  32. 68 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconAlarmConfigurationMapper.java
  33. 41 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconAlarmRuleFailureMapper.java
  34. 17 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconAlarmTypeMapper.java
  35. 16 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/AlarmTs.java
  36. 0 42
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alarmcount.java
  37. 0 113
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alarmsnap.java
  38. 0 80
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alertrule2.java
  39. 0 50
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alertrulefailure.java
  40. 0 38
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alertrulefailuresub.java
  41. 0 46
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alertrulesub.java
  42. 91 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProBasicFeatureStat.java
  43. 157 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmConfiguration.java
  44. 135 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmRule.java
  45. 84 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmRuleFailure.java
  46. 52 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmType.java
  47. 21 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmConfigurationVo.java
  48. 52 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmCustomTag.java
  49. 53 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmCustomType.java
  50. 24 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmRuleVo.java
  51. 19 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmSimpleVo.java
  52. 31 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmStatVo.java
  53. 54 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmSuperTalbeType.java
  54. 119 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmTag.java
  55. 54 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmTime.java
  56. 17 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmTsVo.java
  57. 54 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmType.java
  58. 56 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmTypeValue.java
  59. 68 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmVo.java
  60. 54 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/DeviceTypeValue.java
  61. 294 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmCtService.java
  62. 570 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmHistoryService.java
  63. 132 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmInService.java
  64. 144 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmWtService.java
  65. 0 80
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmcountsService.java
  66. 0 35
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmsnapsService.java
  67. 0 44
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/Alertrule2sService.java
  68. 0 35
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlertrulefailuresubsService.java
  69. 60 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlarmTsService.java
  70. 0 25
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlarmcountService.java
  71. 0 21
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlarmsnapService.java
  72. 0 22
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlertrule2Service.java
  73. 0 20
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlertrulefailureService.java
  74. 0 19
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlertrulefailuresubService.java
  75. 0 16
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlertrulesubService.java
  76. 21 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProBasicFeatureStatService.java
  77. 24 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconAlarmConfigurationService.java
  78. 17 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconAlarmRuleFailureService.java
  79. 16 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconAlarmRuleService.java
  80. 17 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconAlarmTypeService.java
  81. 172 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlarmTsServiceImpl.java
  82. 0 44
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlarmcountServiceImpl.java
  83. 0 33
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlarmsnapServiceImpl.java
  84. 0 36
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/Alertrule2ServiceImpl.java
  85. 0 33
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlertrulefailureServiceImpl.java
  86. 0 31
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlertrulefailuresubServiceImpl.java
  87. 0 20
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlertrulesubServiceImpl.java
  88. 40 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProBasicFeatureStatServiceImpl.java
  89. 42 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconAlarmConfigurationServiceImpl.java
  90. 21 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconAlarmRuleFailureServiceImpl.java
  91. 21 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconAlarmRuleServiceImpl.java
  92. 21 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconAlarmTypeServiceImpl.java
  93. 161 0
      realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/util/SnowflakeGenerator.java

+ 5 - 4
realtime/generationXK-service/pom.xml

@@ -32,10 +32,7 @@
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-data-redis</artifactId>
-        </dependency>
+
         <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
@@ -52,6 +49,10 @@
             <scope>compile</scope>
         </dependency>
         <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.springframework.data</groupId>
             <artifactId>spring-data-redis</artifactId>
         </dependency>

+ 34 - 0
realtime/generationXK-service/src/main/java/com/gyee/generation/GenerationMain.java

@@ -16,6 +16,40 @@ public class GenerationMain {
     public static void main(String[] args) throws Exception {
         SpringApplication.run(GenerationMain.class, args);
 
+//
+//        Calendar c = Calendar.getInstance();
+//        Date begin = null;
+//        Date end = null;
+//        c.set(Calendar.DAY_OF_MONTH, 27);
+//
+//        c.setTime(DateUtils.truncate(c.getTime()));
+//
+//        begin = new Date();
+//        System.out.println("设备指标记录调度程序执行开始!。。。。。。");
+//        for (int i = 0; i < 3; i++) {
+//
+//
+//            System.out.println(DateUtils.format(c.getTime(), "yyyy-MM-dd HH:mm:ss").toString());
+//
+//            WindturbineGoodnessService windturbineGoodnessService = SpringUtils.getBean("windturbineGoodnessService");
+//            WpwindDayInfoService wpwindDayInfoService = SpringUtils.getBean("wpwindDayInfoService");
+//            WtwindDayInfoService wtwindDayInfoService = SpringUtils.getBean("wtwindDayInfoService");
+//            InputOrOutPutService inputOrOutPutService = SpringUtils.getBean("inputOrOutPutService");
+//
+//            windturbineGoodnessService.calWindturbineGoodness(c.getTime());
+//            wpwindDayInfoService.calWpwindDayInfo(c.getTime());
+//            wtwindDayInfoService.calWtwindDayInfo(c.getTime());
+//            inputOrOutPutService.inputOrOutput(c.getTime());
+//
+//            c.add(Calendar.DAY_OF_MONTH, 1);
+//
+//            System.out.println("完成一次!。。。。。。");
+//        }
+//
+//        end = new Date();
+//        System.out.println("执行用时" + DateUtils.secondsDiff(begin, end) + "秒");
+//        System.out.println("设备指标记录调度程序执行结束!。。。。。。");
+
 
         System.out.println("完成");
     }

+ 2 - 2
realtime/generationXK-service/src/main/java/com/gyee/generation/config/XxlJobConfig.java

@@ -20,8 +20,8 @@ import org.springframework.core.env.Environment;
 @Configuration
 //@PropertySource("classpath:xxl-job-executor.properties")
 //@PropertySource("classpath:xxl-job-executor2.properties")
-//@PropertySource("classpath:xxl-job-executor3.properties")
-@PropertySource("classpath:xxl-job-executor4.properties")
+@PropertySource("classpath:xxl-job-executor3.properties")
+//@PropertySource("classpath:xxl-job-executor4.properties")
 //@PropertySource("classpath:xxl-job-executorWPLY.properties")
 //@PropertySource("classpath:xxl-job-executorRG.properties")
 //@PropertySource("classpath:xxl-job-executorJN.properties")

+ 58 - 23
realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo1Service.java

@@ -46,29 +46,29 @@ public class EquipmentInfo1Service {
 
         Date begin= DateUtils.truncate(c.getTime());
 
-        QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("record_date",recordDate);
-        //判断是否有重复记录,先删除重复记录
-        List<String> idls = proEconEquipmentInfoDay1Service.list(queryWrapper).stream()
-                .map(ProEconEquipmentInfoDay1::getId)
-                .collect(Collectors.toList());
-
-        List<String> tempids=new ArrayList<>();
-
-        for(int i=0;i<idls.size();i++)
-        {
-            tempids.add(idls.get(i));
-            if(tempids.size()==100)
-            {
-                proEconEquipmentInfoDay1Service.removeByIds(tempids);
-                tempids=new ArrayList<>();
-            }
-        }
-
-        if(!tempids.isEmpty())
-        {
-            proEconEquipmentInfoDay1Service.removeByIds(tempids);
-        }
+//        QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("record_date",recordDate);
+//        //判断是否有重复记录,先删除重复记录
+//        List<String> idls = proEconEquipmentInfoDay1Service.list(queryWrapper).stream()
+//                .map(ProEconEquipmentInfoDay1::getId)
+//                .collect(Collectors.toList());
+//
+//        List<String> tempids=new ArrayList<>();
+//
+//        for(int i=0;i<idls.size();i++)
+//        {
+//            tempids.add(idls.get(i));
+//            if(tempids.size()==100)
+//            {
+//                proEconEquipmentInfoDay1Service.removeByIds(tempids);
+//                tempids=new ArrayList<>();
+//            }
+//        }
+//
+//        if(!tempids.isEmpty())
+//        {
+//            proEconEquipmentInfoDay1Service.removeByIds(tempids);
+//        }
 
         Map<String,ProEconEquipmentInfoDay1> pep1map=new HashMap<>();
         Calendar cl=Calendar.getInstance();
@@ -138,6 +138,41 @@ public class EquipmentInfo1Service {
         }
         latch.await();
 
+
+        c=Calendar.getInstance();
+        c.setTime(recordDate);
+
+        c.set(Calendar.HOUR_OF_DAY, 23);
+        c.set(Calendar.MINUTE, 59);
+        c.set(Calendar.SECOND, 59);
+        end=c.getTime();
+
+        begin= DateUtils.truncate(c.getTime());
+
+        QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("record_date",recordDate);
+        //判断是否有重复记录,先删除重复记录
+        List<String> idls = proEconEquipmentInfoDay1Service.list(queryWrapper).stream()
+                .map(ProEconEquipmentInfoDay1::getId)
+                .collect(Collectors.toList());
+
+        List<String> tempids=new ArrayList<>();
+
+        for(int i=0;i<idls.size();i++)
+        {
+            tempids.add(idls.get(i));
+            if(tempids.size()==100)
+            {
+                proEconEquipmentInfoDay1Service.removeByIds(tempids);
+                tempids=new ArrayList<>();
+            }
+        }
+
+        if(!tempids.isEmpty())
+        {
+            proEconEquipmentInfoDay1Service.removeByIds(tempids);
+        }
+
         List<ProEconEquipmentInfoDay1> templs=new ArrayList<>();
         for(ProEconEquipmentInfoDay1 vo:dayls)
         {

+ 49 - 25
realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo2Service.java

@@ -46,34 +46,28 @@ public class EquipmentInfo2Service {
 
         Date begin= DateUtils.truncate(c.getTime());
 
-        //判断是否有重复记录,先删除重复记录
-        QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("record_date",recordDate);
-        List<String> idls = proEconEquipmentInfoDay2Service.list(queryWrapper).stream().map(ProEconEquipmentInfoDay2::getId)
-                .collect(Collectors.toList());
-
-//        if (idls.size() > 0) {
+//        //判断是否有重复记录,先删除重复记录
+//        QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("record_date",recordDate);
+//        List<String> idls = proEconEquipmentInfoDay2Service.list(queryWrapper).stream().map(ProEconEquipmentInfoDay2::getId)
+//                .collect(Collectors.toList());
 //
-//            proEconEquipmentInfoDay2Service.removeByIds(idls);
+//        List<String> tempids=new ArrayList<>();
 //
+//        for(int i=0;i<idls.size();i++)
+//        {
+//            tempids.add(idls.get(i));
+//            if(tempids.size()==100)
+//            {
+//                proEconEquipmentInfoDay2Service.removeByIds(tempids);
+//                tempids=new ArrayList<>();
+//            }
+//        }
+//
+//        if(!tempids.isEmpty())
+//        {
+//            proEconEquipmentInfoDay2Service.removeByIds(tempids);
 //        }
-
-        List<String> tempids=new ArrayList<>();
-
-        for(int i=0;i<idls.size();i++)
-        {
-            tempids.add(idls.get(i));
-            if(tempids.size()==100)
-            {
-                proEconEquipmentInfoDay2Service.removeByIds(tempids);
-                tempids=new ArrayList<>();
-            }
-        }
-
-        if(!tempids.isEmpty())
-        {
-            proEconEquipmentInfoDay2Service.removeByIds(tempids);
-        }
 
         Map<String, ProEconEquipmentInfoDay2> pep2map=new HashMap<>();
         Calendar cl=Calendar.getInstance();
@@ -145,6 +139,36 @@ public class EquipmentInfo2Service {
         }
         latch.await();
 
+
+
+        c=Calendar.getInstance();
+        c.setTime(recordDate);
+
+
+        //判断是否有重复记录,先删除重复记录
+        QueryWrapper<ProEconEquipmentInfoDay2> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("record_date",recordDate);
+        List<String> idls = proEconEquipmentInfoDay2Service.list(queryWrapper).stream().map(ProEconEquipmentInfoDay2::getId)
+                .collect(Collectors.toList());
+
+        List<String> tempids=new ArrayList<>();
+
+        for(int i=0;i<idls.size();i++)
+        {
+            tempids.add(idls.get(i));
+            if(tempids.size()==100)
+            {
+                proEconEquipmentInfoDay2Service.removeByIds(tempids);
+                tempids=new ArrayList<>();
+            }
+        }
+
+        if(!tempids.isEmpty())
+        {
+            proEconEquipmentInfoDay2Service.removeByIds(tempids);
+        }
+
+
         List<ProEconEquipmentInfoDay2> templs=new ArrayList<>();
         for(ProEconEquipmentInfoDay2 vo:dayls)
         {

+ 56 - 26
realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo3Service.java

@@ -45,36 +45,37 @@ public class EquipmentInfo3Service {
 
         Date begin= DateUtils.truncate(c.getTime());
 
-        //判断是否有重复记录,先删除重复记录
-        QueryWrapper<ProEconEquipmentInfoDay3> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("record_date",recordDate);
-        List<String> idls = proEconEquipmentInfoDay3Service.list(queryWrapper).stream()
-                .map(ProEconEquipmentInfoDay3::getId)
-                .collect(Collectors.toList());
-
-//        if (idls.size() > 0) {
+//        //判断是否有重复记录,先删除重复记录
+//        QueryWrapper<ProEconEquipmentInfoDay3> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("record_date",recordDate);
+//        List<String> idls = proEconEquipmentInfoDay3Service.list(queryWrapper).stream()
+//                .map(ProEconEquipmentInfoDay3::getId)
+//                .collect(Collectors.toList());
+//
+////        if (idls.size() > 0) {
+////
+////            proEconEquipmentInfoDay3Service.removeByIds(idls);
+////
+////        }
 //
-//            proEconEquipmentInfoDay3Service.removeByIds(idls);
 //
+//        List<String> tempids=new ArrayList<>();
+//
+//        for(int i=0;i<idls.size();i++)
+//        {
+//            tempids.add(idls.get(i));
+//            if(tempids.size()==100)
+//            {
+//                proEconEquipmentInfoDay3Service.removeByIds(tempids);
+//                tempids=new ArrayList<>();
+//            }
+//        }
+//
+//        if(!tempids.isEmpty())
+//        {
+//            proEconEquipmentInfoDay3Service.removeByIds(tempids);
 //        }
 
-
-        List<String> tempids=new ArrayList<>();
-
-        for(int i=0;i<idls.size();i++)
-        {
-            tempids.add(idls.get(i));
-            if(tempids.size()==100)
-            {
-                proEconEquipmentInfoDay3Service.removeByIds(tempids);
-                tempids=new ArrayList<>();
-            }
-        }
-
-        if(!tempids.isEmpty())
-        {
-            proEconEquipmentInfoDay3Service.removeByIds(tempids);
-        }
         Map<String,ProEconEquipmentInfoDay3> pep3map=new HashMap<>();
         Calendar cl=Calendar.getInstance();
         cl.setTime(recordDate);
@@ -148,6 +149,35 @@ public class EquipmentInfo3Service {
         }
         latch.await();
 
+
+        c=Calendar.getInstance();
+        c.setTime(recordDate);
+
+        //判断是否有重复记录,先删除重复记录
+        QueryWrapper<ProEconEquipmentInfoDay3> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("record_date",recordDate);
+        List<String> idls = proEconEquipmentInfoDay3Service.list(queryWrapper).stream()
+                .map(ProEconEquipmentInfoDay3::getId)
+                .collect(Collectors.toList());
+
+
+        List<String> tempids=new ArrayList<>();
+
+        for(int i=0;i<idls.size();i++)
+        {
+            tempids.add(idls.get(i));
+            if(tempids.size()==100)
+            {
+                proEconEquipmentInfoDay3Service.removeByIds(tempids);
+                tempids=new ArrayList<>();
+            }
+        }
+
+        if(!tempids.isEmpty())
+        {
+            proEconEquipmentInfoDay3Service.removeByIds(tempids);
+        }
+
         List<ProEconEquipmentInfoDay3> templs=new ArrayList<>();
         for(ProEconEquipmentInfoDay3 vo:dayls)
         {

+ 59 - 23
realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo4Service.java

@@ -79,34 +79,36 @@ public class EquipmentInfo4Service {
 
         Date lastDay=DateUtils.addDays(begin,-1);
 
-        //判断是否有重复记录,先删除重复记录
-        QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("record_date",begin);
-        List<String> idls = proEconEquipmentInfoDay4Service.list(queryWrapper).stream()
-                .map(ProEconEquipmentInfoDay4::getId)
-                .collect(Collectors.toList());
-
-//        if (idls.size() > 0) {
+//        //判断是否有重复记录,先删除重复记录
+//        QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("record_date",begin);
+//        List<String> idls = proEconEquipmentInfoDay4Service.list(queryWrapper).stream()
+//                .map(ProEconEquipmentInfoDay4::getId)
+//                .collect(Collectors.toList());
 //
-//            proEconEquipmentInfoDay4Service.removeByIds(idls);
+////        if (idls.size() > 0) {
+////
+////            proEconEquipmentInfoDay4Service.removeByIds(idls);
+////
+////        }
+//        List<String> tempids=new ArrayList<>();
 //
+//        for(int i=0;i<idls.size();i++)
+//        {
+//            tempids.add(idls.get(i));
+//            if(tempids.size()==100)
+//            {
+//                proEconEquipmentInfoDay4Service.removeByIds(tempids);
+//                tempids=new ArrayList<>();
+//            }
+//        }
+//
+//        if(!tempids.isEmpty())
+//        {
+//            proEconEquipmentInfoDay4Service.removeByIds(tempids);
 //        }
-        List<String> tempids=new ArrayList<>();
 
-        for(int i=0;i<idls.size();i++)
-        {
-            tempids.add(idls.get(i));
-            if(tempids.size()==100)
-            {
-                proEconEquipmentInfoDay4Service.removeByIds(tempids);
-                tempids=new ArrayList<>();
-            }
-        }
 
-        if(!tempids.isEmpty())
-        {
-            proEconEquipmentInfoDay4Service.removeByIds(tempids);
-        }
         Map<String,ProEconEquipmentInfoDay2> pep2map=new HashMap<>();
         Map<String,ProEconEquipmentInfoDay3> pep3map=new HashMap<>();
         Map<String,ProEconEquipmentInfoDay4> pep4map=new HashMap<>();
@@ -291,6 +293,40 @@ public class EquipmentInfo4Service {
 
         latch.await();
 
+
+        c = Calendar.getInstance();
+        c.setTime(recordDate);
+
+
+        begin = DateUtils.truncate(c.getTime());
+
+
+        //判断是否有重复记录,先删除重复记录
+        QueryWrapper<ProEconEquipmentInfoDay4> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("record_date",begin);
+        List<String> idls = proEconEquipmentInfoDay4Service.list(queryWrapper).stream()
+                .map(ProEconEquipmentInfoDay4::getId)
+                .collect(Collectors.toList());
+
+        List<String> tempids=new ArrayList<>();
+
+        for(int i=0;i<idls.size();i++)
+        {
+            tempids.add(idls.get(i));
+            if(tempids.size()==100)
+            {
+                proEconEquipmentInfoDay4Service.removeByIds(tempids);
+                tempids=new ArrayList<>();
+            }
+        }
+
+        if(!tempids.isEmpty())
+        {
+            proEconEquipmentInfoDay4Service.removeByIds(tempids);
+        }
+
+
+
         List<ProEconEquipmentInfoDay4> templs=new ArrayList<>();
         for(ProEconEquipmentInfoDay4 vo:dayls)
         {

+ 48 - 20
realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfo5Service.java

@@ -154,20 +154,58 @@ public class EquipmentInfo5Service {
 
         stateRate(currentDate,rates);
         List<ProEconEquipmentInfoDay5> dayls=new ArrayList<>();
+//        QueryWrapper<ProEconEquipmentInfoDay5> queryWrapper2 = new QueryWrapper<>();
+//        queryWrapper2.ge("record_date",currentDate);
+//
+//            List<String> dayInfoids = proEconEquipmentInfoDay5Service.list(queryWrapper2)
+//                    .stream()
+////                    .filter(i -> i.getRecordDate().compareTo(currentDate) == 0
+////            )
+//        .map(ProEconEquipmentInfoDay5::getId).collect(Collectors.toList());
+//
+//
+////            if (!dayInfoids.isEmpty()) {
+////
+////                proEconEquipmentInfoDay5Service.removeByIds(dayInfoids);
+////            }
+//
+//        List<String> tempids=new ArrayList<>();
+//
+//        for(int i=0;i<dayInfoids.size();i++)
+//        {
+//            tempids.add(dayInfoids.get(i));
+//            if(tempids.size()==100)
+//            {
+//                proEconEquipmentInfoDay5Service.removeByIds(tempids);
+//                tempids=new ArrayList<>();
+//            }
+//        }
+//
+//        if(!tempids.isEmpty())
+//        {
+//            proEconEquipmentInfoDay5Service.removeByIds(tempids);
+//        }
+
+        ProEconEquipmentInfoDay5 dayInfo;
+            for (ProEconEquipmentInfoDay5 day : rates.values()) {
+
+                dayInfo = new ProEconEquipmentInfoDay5();
+
+                buildresetRate(dayInfo, day);
+
+                dayls.add(dayInfo);
+                //proEconEquipmentInfoDay5Service.save(dayInfo);
+
+            }
+
+
         QueryWrapper<ProEconEquipmentInfoDay5> queryWrapper2 = new QueryWrapper<>();
         queryWrapper2.ge("record_date",currentDate);
 
-            List<String> dayInfoids = proEconEquipmentInfoDay5Service.list(queryWrapper2)
-                    .stream()
-//                    .filter(i -> i.getRecordDate().compareTo(currentDate) == 0
-//            )
-        .map(ProEconEquipmentInfoDay5::getId).collect(Collectors.toList());
+        List<String> dayInfoids = proEconEquipmentInfoDay5Service.list(queryWrapper2)
+                .stream()
+                .map(ProEconEquipmentInfoDay5::getId).collect(Collectors.toList());
 
-            ProEconEquipmentInfoDay5 dayInfo;
-//            if (!dayInfoids.isEmpty()) {
-//
-//                proEconEquipmentInfoDay5Service.removeByIds(dayInfoids);
-//            }
 
         List<String> tempids=new ArrayList<>();
 
@@ -185,16 +223,6 @@ public class EquipmentInfo5Service {
         {
             proEconEquipmentInfoDay5Service.removeByIds(tempids);
         }
-            for (ProEconEquipmentInfoDay5 day : rates.values()) {
-
-                dayInfo = new ProEconEquipmentInfoDay5();
-
-                buildresetRate(dayInfo, day);
-
-                dayls.add(dayInfo);
-                //proEconEquipmentInfoDay5Service.save(dayInfo);
-
-            }
 
         List<ProEconEquipmentInfoDay5> templs=new ArrayList<>();
         for(ProEconEquipmentInfoDay5 vo:dayls)

+ 48 - 23
realtime/generationXK-service/src/main/java/com/gyee/generation/service/EquipmentInfoDayTopService.java

@@ -37,29 +37,29 @@ public class EquipmentInfoDayTopService {
         Calendar c = Calendar.getInstance();
         c.setTime(recordDate);
 
-        QueryWrapper<ProEconEquipmentInfoDayTop> queryWrapper = new QueryWrapper<>();
-        queryWrapper.ge("record_date",DateUtils.truncate(recordDate)).eq("types",1);
-        //判断是否有重复记录,先删除重复记录
-        List<Long> idls = proEconEquipmentInfoDayTopService.list(queryWrapper).stream()
-                .map(ProEconEquipmentInfoDayTop::getId)
-                .collect(Collectors.toList());
-
-        List<Long> tempids=new ArrayList<>();
-
-        for(int i=0;i<idls.size();i++)
-        {
-            tempids.add(idls.get(i));
-            if(tempids.size()==100)
-            {
-                proEconEquipmentInfoDayTopService.removeByIds(tempids);
-                tempids=new ArrayList<>();
-            }
-        }
-
-        if(!tempids.isEmpty())
-        {
-            proEconEquipmentInfoDayTopService.removeByIds(tempids);
-        }
+//        QueryWrapper<ProEconEquipmentInfoDayTop> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.ge("record_date",DateUtils.truncate(recordDate)).eq("types",1);
+//        //判断是否有重复记录,先删除重复记录
+//        List<Long> idls = proEconEquipmentInfoDayTopService.list(queryWrapper).stream()
+//                .map(ProEconEquipmentInfoDayTop::getId)
+//                .collect(Collectors.toList());
+//
+//        List<Long> tempids=new ArrayList<>();
+//
+//        for(int i=0;i<idls.size();i++)
+//        {
+//            tempids.add(idls.get(i));
+//            if(tempids.size()==100)
+//            {
+//                proEconEquipmentInfoDayTopService.removeByIds(tempids);
+//                tempids=new ArrayList<>();
+//            }
+//        }
+//
+//        if(!tempids.isEmpty())
+//        {
+//            proEconEquipmentInfoDayTopService.removeByIds(tempids);
+//        }
 
         for (ProBasicPowerstation wp : CacheContext.wpls) {
 
@@ -99,6 +99,31 @@ public class EquipmentInfoDayTopService {
                 top.setDayRank(i+1);
             }
 
+
+            QueryWrapper<ProEconEquipmentInfoDayTop> queryWrapper = new QueryWrapper<>();
+            queryWrapper.ge("record_date",DateUtils.truncate(recordDate)).eq("types",1);
+            //判断是否有重复记录,先删除重复记录
+            List<Long> idls = proEconEquipmentInfoDayTopService.list(queryWrapper).stream()
+                    .map(ProEconEquipmentInfoDayTop::getId)
+                    .collect(Collectors.toList());
+
+            List<Long> tempids=new ArrayList<>();
+
+            for(int i=0;i<idls.size();i++)
+            {
+                tempids.add(idls.get(i));
+                if(tempids.size()==100)
+                {
+                    proEconEquipmentInfoDayTopService.removeByIds(tempids);
+                    tempids=new ArrayList<>();
+                }
+            }
+
+            if(!tempids.isEmpty())
+            {
+                proEconEquipmentInfoDayTopService.removeByIds(tempids);
+            }
+
             List<ProEconEquipmentInfoDayTop> templs=new ArrayList<>();
             for(ProEconEquipmentInfoDayTop vo:topls)
             {

File diff suppressed because it is too large
+ 0 - 1952
realtime/generationXK-service/src/main/java/com/gyee/generation/service/PowerCurveFittingByTimeNewService.java


+ 59 - 27
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WindturbineGoodnessService.java

@@ -37,36 +37,36 @@ public class WindturbineGoodnessService {
 
 
 
-        //判断是否有重复记录,先删除重复记录
-        QueryWrapper<ProEconWindturbineGoodness> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
-        List<Long> idls = proEconWindturbineGoodnessService.list(queryWrapper).stream()
-//                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
-//                        && CacheContext.wtmap.containsKey(i.getWindturbineId()))
-                .map(ProEconWindturbineGoodness::getId)
-                .collect(Collectors.toList());
-
-//        if (idls.size() > 0) {
+//        //判断是否有重复记录,先删除重复记录
+//        QueryWrapper<ProEconWindturbineGoodness> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
+//        List<Long> idls = proEconWindturbineGoodnessService.list(queryWrapper).stream()
+////                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+////                        && CacheContext.wtmap.containsKey(i.getWindturbineId()))
+//                .map(ProEconWindturbineGoodness::getId)
+//                .collect(Collectors.toList());
 //
-//            proEconWindturbineGoodnessService.removeByIds(idls);
+////        if (idls.size() > 0) {
+////
+////            proEconWindturbineGoodnessService.removeByIds(idls);
+////
+////        }
+//        List<Long> tempids=new ArrayList<>();
 //
+//        for(int i=0;i<idls.size();i++)
+//        {
+//            tempids.add(idls.get(i));
+//            if(tempids.size()==100)
+//            {
+//                proEconWindturbineGoodnessService.removeByIds(tempids);
+//                tempids=new ArrayList<>();
+//            }
+//        }
+//
+//        if(!tempids.isEmpty())
+//        {
+//            proEconWindturbineGoodnessService.removeByIds(tempids);
 //        }
-        List<Long> tempids=new ArrayList<>();
-
-        for(int i=0;i<idls.size();i++)
-        {
-            tempids.add(idls.get(i));
-            if(tempids.size()==100)
-            {
-                proEconWindturbineGoodnessService.removeByIds(tempids);
-                tempids=new ArrayList<>();
-            }
-        }
-
-        if(!tempids.isEmpty())
-        {
-            proEconWindturbineGoodnessService.removeByIds(tempids);
-        }
 
         QueryWrapper<ProEconEquipmentInfoDay1> queryWrapper2 = new QueryWrapper<>();
         queryWrapper2.eq("record_date",DateUtils.truncate(recordDate));
@@ -168,6 +168,38 @@ public class WindturbineGoodnessService {
         }
         System.out.println("拟合优度风机存储数量"+vos.size());
 
+
+        //判断是否有重复记录,先删除重复记录
+        QueryWrapper<ProEconWindturbineGoodness> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
+        List<Long> idls = proEconWindturbineGoodnessService.list(queryWrapper).stream()
+//                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+//                        && CacheContext.wtmap.containsKey(i.getWindturbineId()))
+                .map(ProEconWindturbineGoodness::getId)
+                .collect(Collectors.toList());
+
+//        if (idls.size() > 0) {
+//
+//            proEconWindturbineGoodnessService.removeByIds(idls);
+//
+//        }
+        List<Long> tempids=new ArrayList<>();
+
+        for(int i=0;i<idls.size();i++)
+        {
+            tempids.add(idls.get(i));
+            if(tempids.size()==100)
+            {
+                proEconWindturbineGoodnessService.removeByIds(tempids);
+                tempids=new ArrayList<>();
+            }
+        }
+
+        if(!tempids.isEmpty())
+        {
+            proEconWindturbineGoodnessService.removeByIds(tempids);
+        }
+
         List<ProEconWindturbineGoodness> templs=new ArrayList<>();
         for(ProEconWindturbineGoodness vo:vos)
         {

+ 25 - 13
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WpwindDayInfoService.java

@@ -42,19 +42,19 @@ public class WpwindDayInfoService {
         Date end = c.getTime();
 
         Date begin = DateUtils.truncate(c.getTime());
-        //判断是否有重复记录,先删除重复记录
-        QueryWrapper<ProEconWpwindDayInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
-        List<Long> idls = proEconWpwindDayInfoService.list(queryWrapper).stream()
-//                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0)
-                .map(ProEconWpwindDayInfo::getId)
-                .collect(Collectors.toList());
-
-        if (idls.size() > 0) {
-
-            proEconWpwindDayInfoService.removeByIds(idls);
-
-        }
+//        //判断是否有重复记录,先删除重复记录
+//        QueryWrapper<ProEconWpwindDayInfo> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
+//        List<Long> idls = proEconWpwindDayInfoService.list(queryWrapper).stream()
+////                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0)
+//                .map(ProEconWpwindDayInfo::getId)
+//                .collect(Collectors.toList());
+//
+//        if (idls.size() > 0) {
+//
+//            proEconWpwindDayInfoService.removeByIds(idls);
+//
+//        }
 
 
         List<ProEconWpwindDayInfo> dayls = new ArrayList<>();
@@ -96,7 +96,19 @@ public class WpwindDayInfoService {
 
         }
 
+//判断是否有重复记录,先删除重复记录
+        QueryWrapper<ProEconWpwindDayInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
+        List<Long> idls = proEconWpwindDayInfoService.list(queryWrapper).stream()
+//                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0)
+                .map(ProEconWpwindDayInfo::getId)
+                .collect(Collectors.toList());
 
+        if (idls.size() > 0) {
+
+            proEconWpwindDayInfoService.removeByIds(idls);
+
+        }
         List<ProEconWpwindDayInfo> templs=new ArrayList<>();
         for(ProEconWpwindDayInfo vo:dayls)
         {

+ 61 - 28
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WtAlysisDayService.java

@@ -103,37 +103,37 @@ public class WtAlysisDayService {
 
         Date begin= DateUtils.truncate(c.getTime());
 
-        //判断是否有重复记录,
-        QueryWrapper<ProEconWtAlysisDay> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
-        List<Long> idls = proEconWtAlysisDayService.list(queryWrapper).stream()
-//                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
-//                        && CacheContext.wtmap.containsKey(i.getWindturbineId()))
-                .map(ProEconWtAlysisDay::getId)
-                .collect(Collectors.toList());
-
-//        if (idls.size() > 0) {
+//        //判断是否有重复记录,
+//        QueryWrapper<ProEconWtAlysisDay> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
+//        List<Long> idls = proEconWtAlysisDayService.list(queryWrapper).stream()
+////                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+////                        && CacheContext.wtmap.containsKey(i.getWindturbineId()))
+//                .map(ProEconWtAlysisDay::getId)
+//                .collect(Collectors.toList());
 //
-//            proEconWtAlysisDayService.removeByIds(idls);
+////        if (idls.size() > 0) {
+////
+////            proEconWtAlysisDayService.removeByIds(idls);
+////
+////        }
+//
+//        List<Long> tempids=new ArrayList<>();
 //
+//        for(int i=0;i<idls.size();i++)
+//        {
+//            tempids.add(idls.get(i));
+//            if(tempids.size()==100)
+//            {
+//                proEconWtAlysisDayService.removeByIds(tempids);
+//                tempids=new ArrayList<>();
+//            }
+//        }
+//
+//        if(!tempids.isEmpty())
+//        {
+//            proEconWtAlysisDayService.removeByIds(tempids);
 //        }
-
-        List<Long> tempids=new ArrayList<>();
-
-        for(int i=0;i<idls.size();i++)
-        {
-            tempids.add(idls.get(i));
-            if(tempids.size()==100)
-            {
-                proEconWtAlysisDayService.removeByIds(tempids);
-                tempids=new ArrayList<>();
-            }
-        }
-
-        if(!tempids.isEmpty())
-        {
-            proEconWtAlysisDayService.removeByIds(tempids);
-        }
 
         Map<String, ProEconEquipmentInfoDay1> eqday1map = queryEquipmentInfoDay1(recordDate);
         Map<String, ProEconEquipmentInfoDay2> eqday2map = queryEquipmentInfoDay2(recordDate);
@@ -291,6 +291,39 @@ public class WtAlysisDayService {
         latch.await();
 
 
+        //判断是否有重复记录,
+        QueryWrapper<ProEconWtAlysisDay> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
+        List<Long> idls = proEconWtAlysisDayService.list(queryWrapper).stream()
+//                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate))==0
+//                        && CacheContext.wtmap.containsKey(i.getWindturbineId()))
+                .map(ProEconWtAlysisDay::getId)
+                .collect(Collectors.toList());
+
+//        if (idls.size() > 0) {
+//
+//            proEconWtAlysisDayService.removeByIds(idls);
+//
+//        }
+
+        List<Long> tempids=new ArrayList<>();
+
+        for(int i=0;i<idls.size();i++)
+        {
+            tempids.add(idls.get(i));
+            if(tempids.size()==100)
+            {
+                proEconWtAlysisDayService.removeByIds(tempids);
+                tempids=new ArrayList<>();
+            }
+        }
+
+        if(!tempids.isEmpty())
+        {
+            proEconWtAlysisDayService.removeByIds(tempids);
+        }
+
+
         List<ProEconWtAlysisDay> templs=new ArrayList<>();
         for(ProEconWtAlysisDay vo:dayls)
         {

+ 26 - 13
realtime/generationXK-service/src/main/java/com/gyee/generation/service/WtwindDayInfoService.java

@@ -42,19 +42,19 @@ public class WtwindDayInfoService {
         Date end = c.getTime();
 
         Date begin = DateUtils.truncate(c.getTime());
-        //判断是否有重复记录,先删除重复记录
-        QueryWrapper<ProEconWtwindDayInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
-        List<Long> idls = proEconWtwindDayInfoService.list(queryWrapper).stream()
-//                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0)
-                .map(ProEconWtwindDayInfo::getId)
-                .collect(Collectors.toList());
-
-        if (idls.size() > 0) {
-
-            proEconWtwindDayInfoService.removeByIds(idls);
-
-        }
+//        //判断是否有重复记录,先删除重复记录
+//        QueryWrapper<ProEconWtwindDayInfo> queryWrapper = new QueryWrapper<>();
+//        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
+//        List<Long> idls = proEconWtwindDayInfoService.list(queryWrapper).stream()
+////                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0)
+//                .map(ProEconWtwindDayInfo::getId)
+//                .collect(Collectors.toList());
+//
+//        if (idls.size() > 0) {
+//
+//            proEconWtwindDayInfoService.removeByIds(idls);
+//
+//        }
 
 
         List<ProEconWtwindDayInfo> dayls = new ArrayList<>();
@@ -96,6 +96,19 @@ public class WtwindDayInfoService {
 
         }
 
+        //判断是否有重复记录,先删除重复记录
+        QueryWrapper<ProEconWtwindDayInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("record_date",DateUtils.truncate(recordDate));
+        List<Long> idls = proEconWtwindDayInfoService.list(queryWrapper).stream()
+//                .filter(i -> i.getRecordDate().compareTo(DateUtils.truncate(recordDate)) == 0)
+                .map(ProEconWtwindDayInfo::getId)
+                .collect(Collectors.toList());
+
+        if (idls.size() > 0) {
+
+            proEconWtwindDayInfoService.removeByIds(idls);
+
+        }
         List<ProEconWtwindDayInfo> templs=new ArrayList<>();
         for(ProEconWtwindDayInfo vo:dayls)
         {

+ 72 - 72
realtime/generationXK-service/src/main/java/com/gyee/generation/service/initalcache/CacheService.java

@@ -88,78 +88,78 @@ public class CacheService {
                 log.info("--------------------------完成");
 
 
-        log.info("--------------------------redisSQ");
-        List<ProBasicSquare> squareList = proBasicSquareService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
-        squareList.stream().forEach(i->{
-            Map<String, ProBasicPowerstationPoint> codeaimap = new HashMap<>();
-            QueryWrapper<ProBasicPowerstationPoint> qw = new QueryWrapper<>();
-            qw.eq("windpowerstation_id",i.getId());
-            List<ProBasicPowerstationPoint> windpowerstationtestingpoint2List = windpowerstationpointnewService.list(qw);
-            windpowerstationtestingpoint2List.stream().forEach(x->{
-                codeaimap.put(x.getUniformCode(),x);
-            });
-            String s = JSONObject.toJSONString(codeaimap);
-            redisService.set(i.getId(),s);
-        });
-
-        log.info("--------------------------redisLN");
-        List<ProBasicLine> lineList = lineService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
-        lineList.stream().forEach(i->{
-            Map<String, ProBasicPowerstationPoint> codeaimap = new HashMap<>();
-            QueryWrapper<ProBasicPowerstationPoint> qw = new QueryWrapper<>();
-            qw.eq("windpowerstation_id",i.getId());
-            List<ProBasicPowerstationPoint> windpowerstationtestingpoint2List = windpowerstationpointnewService.list(qw);
-            windpowerstationtestingpoint2List.stream().forEach(x->{
-                codeaimap.put(x.getUniformCode(),x);
-            });
-            String s = JSONObject.toJSONString(codeaimap);
-            redisService.set(i.getId(),s);
-        });
-
-
-
-        log.info("--------------------------redisPJ");
-        List<ProBasicProject> projectList = projectService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
-        projectList.stream().forEach(i->{
-            Map<String, ProBasicPowerstationPoint> codeaimap = new HashMap<>();
-            QueryWrapper<ProBasicPowerstationPoint> qw = new QueryWrapper<>();
-            qw.eq("windpowerstation_id",i.getId());
-            List<ProBasicPowerstationPoint> windpowerstationtestingpoint2List = windpowerstationpointnewService.list(qw);
-            windpowerstationtestingpoint2List.stream().forEach(x->{
-                codeaimap.put(x.getUniformCode(),x);
-            });
-            String s = JSONObject.toJSONString(codeaimap);
-            redisService.set(i.getId(),s);
-        });
-
-        log.info("--------------------------redisSubWP");
-        redisService.select(9);
-        List<ProBasicSubStation> subStationList = subStationService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
-        subStationList.stream().forEach(i->{
-            Map<String, ProBasicSubStationTestpoint> codeaimap = new HashMap<>();
-            QueryWrapper<ProBasicSubStationTestpoint> qw = new QueryWrapper<>();
-            qw.eq("windpowerstation_id",i.getId());
-            List<ProBasicSubStationTestpoint> windpowerstationtestingpoint2List = proBasicSubStationTestpointService.list(qw);
-            windpowerstationtestingpoint2List.stream().forEach(x->{
-                codeaimap.put(x.getUniformCode(),x);
-            });
-            String s = JSONObject.toJSONString(codeaimap);
-            redisService.set(i.getId(),s);
-        });
-
-        log.info("--------------------------redisWeatherWP");
-        List<ProBasicWeatherStation> weatherStationList = proBasicWeatherStationService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
-        weatherStationList.stream().forEach(i->{
-            Map<String, ProBasicPowerstationPoint> codeaimap = new HashMap<>();
-            QueryWrapper<ProBasicPowerstationPoint> qw = new QueryWrapper<>();
-            qw.eq("windpowerstation_id",i.getId());
-            List<ProBasicPowerstationPoint> windpowerstationtestingpoint2List = windpowerstationpointnewService.list(qw);
-            windpowerstationtestingpoint2List.stream().forEach(x->{
-                codeaimap.put(x.getUniformCode(),x);
-            });
-            String s = JSONObject.toJSONString(codeaimap);
-            redisService.set(i.getId(),s);
-        });
+//        log.info("--------------------------redisSQ");
+//        List<ProBasicSquare> squareList = proBasicSquareService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
+//        squareList.stream().forEach(i->{
+//            Map<String, ProBasicPowerstationPoint> codeaimap = new HashMap<>();
+//            QueryWrapper<ProBasicPowerstationPoint> qw = new QueryWrapper<>();
+//            qw.eq("windpowerstation_id",i.getId());
+//            List<ProBasicPowerstationPoint> windpowerstationtestingpoint2List = windpowerstationpointnewService.list(qw);
+//            windpowerstationtestingpoint2List.stream().forEach(x->{
+//                codeaimap.put(x.getUniformCode(),x);
+//            });
+//            String s = JSONObject.toJSONString(codeaimap);
+//            redisService.set(i.getId(),s);
+//        });
+//
+//        log.info("--------------------------redisLN");
+//        List<ProBasicLine> lineList = lineService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
+//        lineList.stream().forEach(i->{
+//            Map<String, ProBasicPowerstationPoint> codeaimap = new HashMap<>();
+//            QueryWrapper<ProBasicPowerstationPoint> qw = new QueryWrapper<>();
+//            qw.eq("windpowerstation_id",i.getId());
+//            List<ProBasicPowerstationPoint> windpowerstationtestingpoint2List = windpowerstationpointnewService.list(qw);
+//            windpowerstationtestingpoint2List.stream().forEach(x->{
+//                codeaimap.put(x.getUniformCode(),x);
+//            });
+//            String s = JSONObject.toJSONString(codeaimap);
+//            redisService.set(i.getId(),s);
+//        });
+//
+//
+//
+//        log.info("--------------------------redisPJ");
+//        List<ProBasicProject> projectList = projectService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
+//        projectList.stream().forEach(i->{
+//            Map<String, ProBasicPowerstationPoint> codeaimap = new HashMap<>();
+//            QueryWrapper<ProBasicPowerstationPoint> qw = new QueryWrapper<>();
+//            qw.eq("windpowerstation_id",i.getId());
+//            List<ProBasicPowerstationPoint> windpowerstationtestingpoint2List = windpowerstationpointnewService.list(qw);
+//            windpowerstationtestingpoint2List.stream().forEach(x->{
+//                codeaimap.put(x.getUniformCode(),x);
+//            });
+//            String s = JSONObject.toJSONString(codeaimap);
+//            redisService.set(i.getId(),s);
+//        });
+//
+//        log.info("--------------------------redisSubWP");
+//        redisService.select(9);
+//        List<ProBasicSubStation> subStationList = subStationService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
+//        subStationList.stream().forEach(i->{
+//            Map<String, ProBasicSubStationTestpoint> codeaimap = new HashMap<>();
+//            QueryWrapper<ProBasicSubStationTestpoint> qw = new QueryWrapper<>();
+//            qw.eq("windpowerstation_id",i.getId());
+//            List<ProBasicSubStationTestpoint> windpowerstationtestingpoint2List = proBasicSubStationTestpointService.list(qw);
+//            windpowerstationtestingpoint2List.stream().forEach(x->{
+//                codeaimap.put(x.getUniformCode(),x);
+//            });
+//            String s = JSONObject.toJSONString(codeaimap);
+//            redisService.set(i.getId(),s);
+//        });
+//
+//        log.info("--------------------------redisWeatherWP");
+//        List<ProBasicWeatherStation> weatherStationList = proBasicWeatherStationService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());
+//        weatherStationList.stream().forEach(i->{
+//            Map<String, ProBasicPowerstationPoint> codeaimap = new HashMap<>();
+//            QueryWrapper<ProBasicPowerstationPoint> qw = new QueryWrapper<>();
+//            qw.eq("windpowerstation_id",i.getId());
+//            List<ProBasicPowerstationPoint> windpowerstationtestingpoint2List = windpowerstationpointnewService.list(qw);
+//            windpowerstationtestingpoint2List.stream().forEach(x->{
+//                codeaimap.put(x.getUniformCode(),x);
+//            });
+//            String s = JSONObject.toJSONString(codeaimap);
+//            redisService.set(i.getId(),s);
+//        });
 //
 //        log.info("--------------------------redisWP");
 //        List<ProBasicPowerstation> wpList = windpowerstationService.list().stream().filter(i->i.getIsAble().equals(1)).collect(Collectors.toList());

+ 6 - 3
realtime/generationXK-service/src/main/java/com/gyee/generation/service/realtimelibrary/CycleCalculationService.java

@@ -4161,9 +4161,12 @@ public class CycleCalculationService {
                             double zsgl = zsglDatasSnap.get(i).getPointValueInDouble();
                             double power = powerDatasSnap.get(i).getPointValueInDouble();
 
-                            double temp1 = zsgl - power;
-                            if (temp1>0){
-                                zsss+=temp1;
+                            if(power>0)
+                            {
+                                double temp1 = zsgl - power;
+                                if (temp1>0){
+                                    zsss+=temp1;
+                                }
                             }
                         }
                     }

+ 491 - 14
realtime/generationXK-service/src/main/java/com/gyee/generation/service/realtimelibrary/RealtimeService.java

@@ -30,7 +30,12 @@ public class RealtimeService {
      * @throws Exception
      */
     public void savaRealtimeTarget() throws Exception {
+        Calendar c = Calendar.getInstance();
+        Date begin=null;
+        Date end=null;
 
+        begin=new Date();
+        System.out.println("实时指标调度程序执行开始!。。。。。。");
         List<ProBasicEquipment> wtls = CacheContext.wtls;
         List<ProBasicLine> lnls = CacheContext.lnls;
         List<ProBasicProject> pjls = CacheContext.pjls;
@@ -48,8 +53,37 @@ public class RealtimeService {
         Date minute15begin = DateUtils.addMinutes(currentDate, -15);
         //保存风机点
         List<PointData> wtResultList = new ArrayList<>();
-//        wtls.stream().forEach(wt -> {
+
+
+        List<String> pointls=new ArrayList<>();
+
+        List<PointData> pointDatals = new ArrayList<>();
+
         for(ProBasicEquipment wt:wtls) {
+
+            Map<String, ProBasicEquipmentPoint> equipmentPointMap = wtpAimap.get(wt.getId());
+
+            ProBasicEquipmentPoint mxztPoint = equipmentPointMap.get(ContantXk.MXZT);
+            ProBasicEquipmentPoint ssglPoint = equipmentPointMap.get(ContantXk.CJ_SSGL);
+
+            pointls.add(mxztPoint.getNemCode());
+            pointls.add(ssglPoint.getNemCode());
+
+            if(pointls.size()>=1000)
+            {
+                List<PointData> templs=edosUtil.getRealData(pointls);
+                pointDatals.addAll(templs);
+                pointls=new ArrayList<>();
+            }
+        }
+        if(!pointls.isEmpty())
+        {
+            List<PointData> templs=edosUtil.getRealData(pointls);
+            pointDatals.addAll(templs);
+        }
+//        wtls.stream().forEach(wt -> {
+        for(int i=0;i<wtls.size();i++) {
+            ProBasicEquipment wt=wtls.get(i);
             Map<String, ProBasicEquipmentPoint> equipmentPointMap = wtpAimap.get(wt.getId());
             ProBasicEquipmentPoint speedPoint = equipmentPointMap.get(ContantXk.CJ_SSFS);
             ProBasicEquipmentPoint mxztPoint = equipmentPointMap.get(ContantXk.MXZT);
@@ -78,28 +112,38 @@ public class RealtimeService {
             double speed = 0;
             double ssbf = 0;
             double ssgl = 0;
-            Optional<PointData> ssglOptional = null;
-            Optional<PointData> zsglOptional = null;
+
+            Optional<PointData> ssfsOptional = null;
+
             try {
 
                 double ssztmx = 0;
                 try {
-                    ssztmx = edosUtil.getRealData(mxztPoint).getPointValueInDouble();
+                    ssztmx =pointDatals.get(i*2).getPointValueInDouble();
                 } catch (Exception e) {
                     throw new RuntimeException(e);
                 }
                 if (ssztmx == 12 || ssztmx == 13) {
                     continue;
                 }
-                mxzt = edosUtil.getRealData(mxztPoint).getPointValueInDouble();
-                speed = edosUtil.getRealData(speedPoint).getPointValueInDouble();
-                ssgl = edosUtil.getRealData(ssglPoint).getPointValueInDouble();
-                ssglOptional = edosUtil.getHistStat(ssglPoint, minute15begin.getTime() / 1000, currentDate.getTime() / 1000, 1l, 900l, 2).stream().findFirst();
-                zsglOptional = edosUtil.getHistStat(zsglPoint, minute15begin.getTime() / 1000, currentDate.getTime() / 1000, 1l, 900l, 2).stream().findFirst();
+//                mxzt = edosUtil.getRealData(mxztPoint).getPointValueInDouble();
+//                speed = edosUtil.getRealData(speedPoint).getPointValueInDouble();
+//                ssgl = edosUtil.getRealData(ssglPoint).getPointValueInDouble();
+
+                mxzt =pointDatals.get(i*2).getPointValueInDouble();
+                ssgl =pointDatals.get(i*2+1).getPointValueInDouble();
+
+                ssfsOptional = edosUtil.getHistStat(speedPoint, minute15begin.getTime() / 1000, currentDate.getTime() / 1000, 1l, 900l, 2).stream().findFirst();
+//                ssglOptional = edosUtil.getHistStat(ssglPoint, minute15begin.getTime() / 1000, currentDate.getTime() / 1000, 1l, 900l, 2).stream().findFirst();
+//                zsglOptional = edosUtil.getHistStat(zsglPoint, minute15begin.getTime() / 1000, currentDate.getTime() / 1000, 1l, 900l, 2).stream().findFirst();
 
             } catch (Exception e) {
                 e.printStackTrace();
             }
+
+                if (ssfsOptional.isPresent()) {
+                 speed = ssfsOptional.get().getPointValueInDouble();
+                 }
             PointData ssbfPointDate = null;
             if (mxzt == 12 || mxzt == 13) {
                 //补风算法(后续补充)
@@ -136,10 +180,10 @@ public class RealtimeService {
                     double lsqfzt = 0;
                     double ssgl15 = 0;
                     double zsgl15 = 0;
-                    if (ssglOptional.isPresent()) {
-                        ssgl15 = ssglOptional.get().getPointValueInDouble();
-                        zsgl15 = zsglOptional.get().getPointValueInDouble();
-                    }
+//                    if (ssglOptional.isPresent()) {
+//                        ssgl15 = ssglOptional.get().getPointValueInDouble();
+                        zsgl15 = wtPowerCurveFitting.getActualPower();
+//                    }
                     if (Arrays.asList(underissuanceArray).contains(mxzt)) {
                         qfzt = Underdelivery.underdeliveryStatusReal(ssgl, actualPower);
                         lsqfzt = Underdelivery.underdeliveryStatusReal(ssgl15, zsgl15);
@@ -167,6 +211,437 @@ public class RealtimeService {
 //        });
         }
         edosUtil.sendMultiPoint(wtResultList);
+
+        end=new Date();
+        System.out.println("执行用时"+ DateUtils.millisecondDiff(begin,end) +"秒");
+        System.out.println("实时计算指标调度程序执行结束!。。。。。。");
+//        //保存线路点
+//        List<PointData> lineResultList = new ArrayList<>();
+//        lnls.stream().forEach(line -> {
+//            List<ProBasicEquipment> proBasicWindturbines = lnwtmap.get(line.getId());
+//            Map<String, ProBasicPowerstationPoint> proBasicWppointMap = linepointmap.get(line.getId());
+//            AtomicReference<Double> zssbf = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zssgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zllgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zbzgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zzsgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zzygl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zkygl = new AtomicReference<>((double) 0);
+//            ProBasicPowerstationPoint ssfsWpPoint = null;
+//            if (line.getSpare4().equals("1")){
+//                ssfsWpPoint = proBasicWppointMap.get(ContantXk.SSPJFS);
+//            }else if (line.getSpare4().equals("2")){
+//                ssfsWpPoint = proBasicWppointMap.get(ContantXk.SSPJGZD);
+//            }
+//            ProBasicPowerstationPoint ssglWpPoint = proBasicWppointMap.get(ContantXk.SSZGL);
+//            ProBasicPowerstationPoint llglWpPoint = proBasicWppointMap.get(ContantXk.SSZLLGL);
+//            ProBasicPowerstationPoint bzglWpPoint = proBasicWppointMap.get(ContantXk.SSZBZGL);
+//            ProBasicPowerstationPoint zsglWpPoint = proBasicWppointMap.get(ContantXk.SSZNHGLZS);
+//            ProBasicPowerstationPoint zyglWpPoint = proBasicWppointMap.get(ContantXk.SSZZYGL);
+////            ProBasicPowerstationPoint kyglWpPoint = proBasicWppointMap.get(ContantXk.SSZKYGL);
+//
+//            double ssglsyz = 0;
+//            if (proBasicWppointMap.containsKey(ContantXk.SSGLSYZ)){
+//                ProBasicPowerstationPoint ssglsyzpoint = proBasicWppointMap.get(ContantXk.SSGLSYZ);
+//                try {
+//                    ssglsyz = edosUtil.getRealData(ssglsyzpoint).getPointValueInDouble();
+//                } catch (Exception e) {
+//                    e.printStackTrace();
+//                }
+//            }
+//            if (proBasicWppointMap.containsKey(ContantXk.SSZGLSYZ)){
+//                ProBasicPowerstationPoint sszglsyzpoint = proBasicWppointMap.get(ContantXk.SSZGLSYZ);
+//                lineResultList.add(PointUtil.createPointData(currentDate, ssglsyz, sszglsyzpoint.getNemCode(), sszglsyzpoint.getName()));
+//            }
+//
+////            proBasicWindturbines.stream().forEach(wt -> {
+//            for(ProBasicEquipment wt:proBasicWindturbines) {
+//                Map<String, ProBasicEquipmentPoint> equipmentPointMap = wtpAimap.get(wt.getId());
+//
+//
+//                ProBasicEquipmentPoint mxztPoint = equipmentPointMap.get(ContantXk.MXZT);
+//                double ssztmx = 0;
+//                try {
+//                    ssztmx = edosUtil.getRealData(mxztPoint).getPointValueInDouble();
+//                } catch (Exception e) {
+//                    throw new RuntimeException(e);
+//                }
+//                if (ssztmx == 12 || ssztmx == 13) {
+//                    continue;
+//                }
+//
+//                ProBasicEquipmentPoint ssbfPoint = null;
+//                if (wt.getId().contains("_WT_")) {
+//                    ssbfPoint = equipmentPointMap.get(ContantXk.SSBF);
+//                } else if (wt.getId().contains("_IN_")) {
+//                    ssbfPoint = equipmentPointMap.get(ContantXk.SSBG);
+//                }
+//
+////                ProBasicEquipmentPoint ssbfPoint = equipmentPointMap.get(ContantXk.SSBF);
+//                ProBasicEquipmentPoint ssglPoint = equipmentPointMap.get(ContantXk.CJ_SSGL);
+//                //理论功率测点
+//                ProBasicEquipmentPoint llglPoint = equipmentPointMap.get(ContantXk.LLGL);
+//                //保证功率测点
+//                ProBasicEquipmentPoint bzglPoint = equipmentPointMap.get(ContantXk.BZGL);
+//                //自算功率测点
+//                ProBasicEquipmentPoint zsglPoint = equipmentPointMap.get(ContantXk.ZSGL);
+//                //最优功率测点
+//                ProBasicEquipmentPoint zyglPoint = equipmentPointMap.get(ContantXk.ZYGL);
+////                //可用功率测点
+////                ProBasicEquipmentPoint kyglPoint = equipmentPointMap.get(ContantXk.KYGL);
+//
+//                ProBasicEquipmentPoint finalSsbfPoint = ssbfPoint;
+//                zssbf.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(finalSsbfPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zssgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(ssglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zllgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(llglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zbzgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(bzglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zzsgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(zsglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zzygl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(zyglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+////                zkygl.updateAndGet(v -> {
+////                    try {
+////                        return new Double((double) (v + edosUtil.getRealData(kyglPoint).getPointValueInDouble()));
+////                    } catch (Exception e) {
+////                        e.printStackTrace();
+////                    }
+////                    return v;
+////                });
+////            });
+//            }
+//            lineResultList.add(PointUtil.createPointData(currentDate, zssbf.get() / proBasicWindturbines.size(), ssfsWpPoint.getNemCode(), ssfsWpPoint.getName()));
+//            lineResultList.add(PointUtil.createPointData(currentDate, zssgl.get(), ssglWpPoint.getNemCode(), ssglWpPoint.getName()));
+//            lineResultList.add(PointUtil.createPointData(currentDate, zllgl.get(), llglWpPoint.getNemCode(), llglWpPoint.getName()));
+//            lineResultList.add(PointUtil.createPointData(currentDate, zbzgl.get(), bzglWpPoint.getNemCode(), bzglWpPoint.getName()));
+//            lineResultList.add(PointUtil.createPointData(currentDate, zzsgl.get(), zsglWpPoint.getNemCode(), zsglWpPoint.getName()));
+//            lineResultList.add(PointUtil.createPointData(currentDate, zzygl.get(), zyglWpPoint.getNemCode(), zyglWpPoint.getName()));
+////            lineResultList.add(PointUtil.createPointData(currentDate, zkygl.get(), kyglWpPoint.getNemCode(), kyglWpPoint.getName()));
+//        });
+//        edosUtil.sendMultiPoint(lineResultList);
+//        //保存期次点
+//        List<PointData> projectResultList = new ArrayList<>();
+//        pjls.stream().forEach(project -> {
+//            List<ProBasicLine> proBasicLines = prolinemap.get(project.getId());
+//            Map<String, ProBasicPowerstationPoint> proBasicWppointMap = propointmap.get(project.getId());
+//            AtomicReference<Double> zssbf = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zssgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zllgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zbzgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zzsgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zzygl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zkygl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zssglsyz = new AtomicReference<>((double) 0);
+//
+//            ProBasicPowerstationPoint ssfsWpPoint = null;
+//            if (project.getSpare4().equals("1")){
+//                ssfsWpPoint = proBasicWppointMap.get(ContantXk.SSPJFS);
+//            }else if (project.getSpare4().equals("2")){
+//                ssfsWpPoint = proBasicWppointMap.get(ContantXk.SSPJGZD);
+//            }
+//            ProBasicPowerstationPoint ssglWpPoint = proBasicWppointMap.get(ContantXk.SSZGL);
+//            ProBasicPowerstationPoint llglWpPoint = proBasicWppointMap.get(ContantXk.SSZLLGL);
+//            ProBasicPowerstationPoint bzglWpPoint = proBasicWppointMap.get(ContantXk.SSZBZGL);
+//            ProBasicPowerstationPoint zsglWpPoint = proBasicWppointMap.get(ContantXk.SSZNHGLZS);
+//            ProBasicPowerstationPoint zyglWpPoint = proBasicWppointMap.get(ContantXk.SSZZYGL);
+////            ProBasicPowerstationPoint kyglWpPoint = proBasicWppointMap.get(ContantXk.SSZKYGL);
+//            ProBasicPowerstationPoint ssglsyzWpPoint = proBasicWppointMap.get(ContantXk.SSZGLSYZ);
+//
+//            proBasicLines.stream().forEach(wp -> {
+//                Map<String, ProBasicPowerstationPoint> basicWppointMap = linepointmap.get(wp.getId());
+//                ProBasicPowerstationPoint ssbfPoint = null;
+//                if (wp.getSpare4().equals("1")){
+//                    ssbfPoint = basicWppointMap.get(ContantXk.SSPJFS);
+//                }else if (wp.getSpare4().equals("2")){
+//                    ssbfPoint = basicWppointMap.get(ContantXk.SSPJGZD);
+//                }
+//
+//                ProBasicPowerstationPoint ssglPoint = basicWppointMap.get(ContantXk.SSZGL);
+//                ProBasicPowerstationPoint ssglsyzPoint = basicWppointMap.get(ContantXk.SSZGLSYZ);
+//                //理论功率测点
+//                ProBasicPowerstationPoint llglPoint = basicWppointMap.get(ContantXk.SSZLLGL);
+//                //保证功率测点
+//                ProBasicPowerstationPoint bzglPoint = basicWppointMap.get(ContantXk.SSZBZGL);
+//                //自算功率测点
+//                ProBasicPowerstationPoint zsglPoint = basicWppointMap.get(ContantXk.SSZNHGLZS);
+//                //最优功率测点
+//                ProBasicPowerstationPoint zyglPoint = basicWppointMap.get(ContantXk.SSZZYGL);
+////                //可用功率测点
+////                ProBasicPowerstationPoint kyglPoint = basicWppointMap.get(ContantXk.SSZKYGL);
+//
+//                ProBasicPowerstationPoint finalSsbfPoint = ssbfPoint;
+//                zssbf.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(finalSsbfPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zssgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(ssglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zssglsyz.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(ssglsyzPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zllgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(llglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zbzgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(bzglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zzsgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(zsglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zzygl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(zyglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+////                zkygl.updateAndGet(v -> {
+////                    try {
+////                        return new Double((double) (v + edosUtil.getRealData(kyglPoint).getPointValueInDouble()));
+////                    } catch (Exception e) {
+////                        e.printStackTrace();
+////                    }
+////                    return v;
+////                });
+//            });
+//            projectResultList.add(PointUtil.createPointData(currentDate, zssbf.get() / proBasicLines.size(), ssfsWpPoint.getNemCode(), ssfsWpPoint.getName()));
+//            projectResultList.add(PointUtil.createPointData(currentDate, zssgl.get(), ssglWpPoint.getNemCode(), ssglWpPoint.getName()));
+//            projectResultList.add(PointUtil.createPointData(currentDate, zssglsyz.get(), ssglsyzWpPoint.getNemCode(), ssglsyzWpPoint.getName()));
+//            projectResultList.add(PointUtil.createPointData(currentDate, zllgl.get(), llglWpPoint.getNemCode(), llglWpPoint.getName()));
+//            projectResultList.add(PointUtil.createPointData(currentDate, zbzgl.get(), bzglWpPoint.getNemCode(), bzglWpPoint.getName()));
+//            projectResultList.add(PointUtil.createPointData(currentDate, zzsgl.get(), zsglWpPoint.getNemCode(), zsglWpPoint.getName()));
+//            projectResultList.add(PointUtil.createPointData(currentDate, zzygl.get(), zyglWpPoint.getNemCode(), zyglWpPoint.getName()));
+////            projectResultList.add(PointUtil.createPointData(currentDate, zkygl.get(), kyglWpPoint.getNemCode(), kyglWpPoint.getName()));
+//        });
+//        edosUtil.sendMultiPoint(projectResultList);
+//        //保存场站点
+//        List<PointData> wpResultList = new ArrayList<>();
+//        wpls.stream().forEach(wps -> {
+//            List<ProBasicProject> proBasicProjects = wppromap.get(wps.getId());
+//            Map<String, ProBasicPowerstationPoint> proBasicWppointMap = wppointmap.get(wps.getId());
+//            AtomicReference<Double> zssbf = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zssgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zssglsyz = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zllgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zbzgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zzsgl = new AtomicReference<>((double) 0);
+//            AtomicReference<Double> zzygl = new AtomicReference<>((double) 0);
+////            AtomicReference<Double> zkygl = new AtomicReference<>((double) 0);
+//
+//            ProBasicPowerstationPoint ssfsWpPoint = null;
+//            if (wps.getSpare4().equals("1")){
+//                ssfsWpPoint = proBasicWppointMap.get(ContantXk.SSPJFS);
+//            }else if (wps.getSpare4().equals("2")){
+//                ssfsWpPoint = proBasicWppointMap.get(ContantXk.SSPJGZD);
+//            }
+//
+//            ProBasicPowerstationPoint ssglWpPoint = proBasicWppointMap.get(ContantXk.SSZGL);
+//            ProBasicPowerstationPoint ssglsyzWpPoint = proBasicWppointMap.get(ContantXk.SSZGLSYZ);
+//            ProBasicPowerstationPoint llglWpPoint = proBasicWppointMap.get(ContantXk.SSZLLGL);
+//            ProBasicPowerstationPoint bzglWpPoint = proBasicWppointMap.get(ContantXk.SSZBZGL);
+//            ProBasicPowerstationPoint zsglWpPoint = proBasicWppointMap.get(ContantXk.SSZNHGLZS);
+//            ProBasicPowerstationPoint zyglWpPoint = proBasicWppointMap.get(ContantXk.SSZZYGL);
+////            ProBasicPowerstationPoint kyglWpPoint = proBasicWppointMap.get(ContantXk.SSZKYGL);
+//
+//            proBasicProjects.stream().forEach(wp -> {
+//                Map<String, ProBasicPowerstationPoint> basicWppointMap = propointmap.get(wp.getId());
+//
+//                ProBasicPowerstationPoint ssbfPoint = null;
+//                if (wp.getSpare4().equals("1")){
+//                    ssbfPoint = basicWppointMap.get(ContantXk.SSPJFS);
+//                }else if (wp.getSpare4().equals("2")){
+//                    ssbfPoint = basicWppointMap.get(ContantXk.SSPJGZD);
+//                }
+//                ProBasicPowerstationPoint ssglPoint = basicWppointMap.get(ContantXk.SSZGL);
+//                ProBasicPowerstationPoint ssglsyzPoint = basicWppointMap.get(ContantXk.SSZGLSYZ);
+//                //理论功率测点
+//                ProBasicPowerstationPoint llglPoint = basicWppointMap.get(ContantXk.SSZLLGL);
+//                //保证功率测点
+//                ProBasicPowerstationPoint bzglPoint = basicWppointMap.get(ContantXk.SSZBZGL);
+//                //自算功率测点
+//                ProBasicPowerstationPoint zsglPoint = basicWppointMap.get(ContantXk.SSZNHGLZS);
+//                //最优功率测点
+//                ProBasicPowerstationPoint zyglPoint = basicWppointMap.get(ContantXk.SSZZYGL);
+////                //可用功率测点
+////                ProBasicPowerstationPoint kyglPoint = basicWppointMap.get(ContantXk.SSZKYGL);
+//
+//                ProBasicPowerstationPoint finalSsbfPoint = ssbfPoint;
+//                zssbf.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(finalSsbfPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zssgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(ssglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zssglsyz.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(ssglsyzPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zllgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(llglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zbzgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(bzglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zzsgl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(zsglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+//                zzygl.updateAndGet(v -> {
+//                    try {
+//                        return new Double((double) (v + edosUtil.getRealData(zyglPoint).getPointValueInDouble()));
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                    }
+//                    return v;
+//                });
+////                zkygl.updateAndGet(v -> {
+////                    try {
+////                        return new Double((double) (v + edosUtil.getRealData(kyglPoint).getPointValueInDouble()));
+////                    } catch (Exception e) {
+////                        e.printStackTrace();
+////                    }
+////                    return v;
+////                });
+//            });
+//            wpResultList.add(PointUtil.createPointData(currentDate, zssbf.get() / proBasicProjects.size(), ssfsWpPoint.getNemCode(), ssfsWpPoint.getName()));
+//            wpResultList.add(PointUtil.createPointData(currentDate, zssgl.get(), ssglWpPoint.getNemCode(), ssglWpPoint.getName()));
+//            wpResultList.add(PointUtil.createPointData(currentDate, zssglsyz.get(), ssglsyzWpPoint.getNemCode(), ssglsyzWpPoint.getName()));
+//            wpResultList.add(PointUtil.createPointData(currentDate, zllgl.get(), llglWpPoint.getNemCode(), llglWpPoint.getName()));
+//            wpResultList.add(PointUtil.createPointData(currentDate, zbzgl.get(), bzglWpPoint.getNemCode(), bzglWpPoint.getName()));
+//            wpResultList.add(PointUtil.createPointData(currentDate, zzsgl.get(), zsglWpPoint.getNemCode(), zsglWpPoint.getName()));
+//            wpResultList.add(PointUtil.createPointData(currentDate, zzygl.get(), zyglWpPoint.getNemCode(), zyglWpPoint.getName()));
+////            wpResultList.add(PointUtil.createPointData(currentDate, zkygl.get(), kyglWpPoint.getNemCode(), kyglWpPoint.getName()));
+//        });
+//        edosUtil.sendMultiPoint(wpResultList);
+
+    }
+
+
+    public void savaRealtimeTargetWp() throws Exception {
+        Calendar c = Calendar.getInstance();
+        Date begin=null;
+        Date end=null;
+
+        begin=new Date();
+        System.out.println("实时场站指标调度程序执行开始!。。。。。。");
+        List<ProBasicEquipment> wtls = CacheContext.wtls;
+        List<ProBasicLine> lnls = CacheContext.lnls;
+        List<ProBasicProject> pjls = CacheContext.pjls;
+        List<ProBasicPowerstation> wpls = CacheContext.wpls;
+        Map<String, List<ProBasicEquipment>> lnwtmap = CacheContext.lnwtmap;
+        Map<String, List<ProBasicLine>> prolinemap = CacheContext.prolinemap;
+        Map<String, List<ProBasicProject>> wppromap = CacheContext.wppromap;
+        Map<String, Map<Double, ProBasicModelPowerRd>> theoreticalPowerMap = CacheContext.theoreticalPowerMap; //理论保证功率
+        Map<String, Map<Double, ProEconWtPowerCurveFitting>> curveFittingPowerMap = CacheContext.curveFittingPowerMap; //最优自算功率
+        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
+        Map<String, Map<String, ProBasicPowerstationPoint>> linepointmap = CacheContext.linepointmap;
+        Map<String, Map<String, ProBasicPowerstationPoint>> propointmap = CacheContext.propointmap;
+        Map<String, Map<String, ProBasicPowerstationPoint>> wppointmap = CacheContext.wppointmap;
+        Date currentDate = DateUtils.getCurrentDate();
+        Date minute15begin = DateUtils.addMinutes(currentDate, -15);
+        //保存风机点
+        List<PointData> wtResultList = new ArrayList<>();
+
+
+
         //保存线路点
         List<PointData> lineResultList = new ArrayList<>();
         lnls.stream().forEach(line -> {
@@ -563,6 +1038,8 @@ public class RealtimeService {
 //            wpResultList.add(PointUtil.createPointData(currentDate, zkygl.get(), kyglWpPoint.getNemCode(), kyglWpPoint.getName()));
         });
         edosUtil.sendMultiPoint(wpResultList);
-
+        end=new Date();
+        System.out.println("执行用时"+ DateUtils.millisecondDiff(begin,end) +"秒");
+        System.out.println("实时场站计算指标调度程序执行结束!。。。。。。");
     }
 }

+ 4 - 3
realtime/generationXK-service/src/main/java/com/gyee/generation/service/realtimelibrary/StatusService.java

@@ -1545,7 +1545,7 @@ public class StatusService {
 //            Date end=null;
 //            System.out.println("状态判定调度程序执行开始!。。。。。。");
             statusReal();
-
+            Thread.sleep(200);
 //            end=new Date();
 //            System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
 //            System.out.println("状态判定调度程序执行结束!。。。。。。");
@@ -1563,6 +1563,7 @@ public class StatusService {
 //            System.out.println("中间状态判定调度程序执行开始!。。。。。。");
 
             middleStatusReal();
+            Thread.sleep(200);
 //            end=new Date();
 //            System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
 //            System.out.println("中间状态判定调度程序执行结束!。。。。。。");
@@ -1581,7 +1582,7 @@ public class StatusService {
 //            Date end=null;
 //            System.out.println("场站状态判定调度程序执行开始!。。。。。。");
             powerRationing();
-
+            Thread.sleep(200);
 //
 //            end=new Date();
 //            System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
@@ -1600,7 +1601,7 @@ public class StatusService {
 //            Date end=null;
 //            System.out.println("状态数量判定调度程序执行开始!。。。。。。");
             calculateStatusNumber();
-
+            Thread.sleep(200);
 
 //            end=new Date();
 //            System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");

+ 31 - 1
realtime/generationXK-service/src/main/java/com/gyee/generation/task/SaticScheduleCALTask.java

@@ -122,7 +122,35 @@ public class SaticScheduleCALTask {
 
         XxlJobHelper.log("实时指标调度程序执行开始!........");
         try {
-            realtimeService.savaRealtimeTarget();
+
+            while(true)
+            {
+                realtimeService.savaRealtimeTarget();
+                Thread.sleep(200);
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        XxlJobHelper.log("实时指标调度任务处理完成!........");
+    }
+
+
+    /**
+     * 实时场站计算指标合计
+     * 每秒执行一次
+     */
+    @XxlJob("realtime_Wp_CAL")
+    public void realtime_Wp_CAL()  {
+
+        XxlJobHelper.log("实时指标调度程序执行开始!........");
+        try {
+            while(true)
+            {
+                realtimeService.savaRealtimeTargetWp();
+                Thread.sleep(200);
+            }
+
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -130,6 +158,7 @@ public class SaticScheduleCALTask {
     }
 
 
+
     /**
      * 中间状态计算
      * 执行一次
@@ -139,6 +168,7 @@ public class SaticScheduleCALTask {
 
         XxlJobHelper.log("中间状态计算调度程序执行开始!........");
         try {
+
             statusService.startMiddleStatusReal();
 
         } catch (Exception e) {

+ 37 - 160
realtime/generationXK-service/src/main/java/com/gyee/generation/task/thread/EquipmentInfo1ThreadPool.java

@@ -17,6 +17,7 @@ import org.slf4j.LoggerFactory;
 import java.io.Serializable;
 import java.util.*;
 import java.util.concurrent.Callable;
+import java.util.stream.Collectors;
 
 public class EquipmentInfo1ThreadPool implements Callable<String>, Serializable {
 
@@ -112,6 +113,9 @@ public class EquipmentInfo1ThreadPool implements Callable<String>, Serializable
 			{
 				ProBasicEquipmentPoint point= pointmap.get(ContantXk.RPJFS);
 				List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
+
+				pointls = pointls.stream().filter(n -> (n.getPointValueInDouble() >0 && n.getPointValueInDouble() <30)).collect(Collectors.toList());
+
 				if(!pointls.isEmpty())
 				{
 					DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
@@ -119,11 +123,10 @@ public class EquipmentInfo1ThreadPool implements Callable<String>, Serializable
 					if(summaryStatistics.getMax()>30)
 					{
 						pewp.setRzdfs(StringUtils.round(25,2));
-						System.out.println(summaryStatistics.getMax());
+
 					}else
 					{
 						pewp.setRzdfs(StringUtils.round(summaryStatistics.getMax(),2));
-						System.out.println(summaryStatistics.getMax());
 					}
 
 					//日最小风速
@@ -144,7 +147,7 @@ public class EquipmentInfo1ThreadPool implements Callable<String>, Serializable
 					{
 						pewp.setRpjfs(StringUtils.round(0,2));
 					}
-						else
+					else
 					{
 						pewp.setRpjfs(StringUtils.round(summaryStatistics.getAverage(),2));
 					}
@@ -162,37 +165,11 @@ public class EquipmentInfo1ThreadPool implements Callable<String>, Serializable
 				{
 					DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
 					//日最大风速
-
-
-					if(summaryStatistics.getMax()>30)
-					{
-						pewp.setRzdfs(StringUtils.round(25.0,2));
-					}else
-					{
-						pewp.setRzdfs(StringUtils.round(summaryStatistics.getMax(),2));
-					}
+					pewp.setRzdfs(StringUtils.round(summaryStatistics.getMax(),2));
 					//日最小风速
-
-					if(summaryStatistics.getMin()<0)
-					{
-						pewp.setRzxfs(StringUtils.round(0,2));
-					}else
-					{
-						pewp.setRzxfs(StringUtils.round(summaryStatistics.getMin(),2));
-					}
+					pewp.setRzxfs(StringUtils.round(summaryStatistics.getMin(),2));
 					//日平均风速
-
-
-					if(summaryStatistics.getAverage()>30)
-					{
-						pewp.setRpjfs(StringUtils.round(25,2));
-					}else if(summaryStatistics.getAverage()<0)
-					{
-						pewp.setRpjfs(StringUtils.round(0,2));
-					}else
-					{
-						pewp.setRpjfs(StringUtils.round(summaryStatistics.getAverage(),2));
-					}
+					pewp.setRpjfs(StringUtils.round(summaryStatistics.getAverage(),2));
 				}
 
 			}
@@ -204,38 +181,30 @@ public class EquipmentInfo1ThreadPool implements Callable<String>, Serializable
 		{
 			ProBasicEquipmentPoint point= pointmap.get(ContantXk.RPJGL);
 			List<PointData> pointls=edosUtil.getHistoryDatasSnap(point.getNemCode(), begin.getTime()/1000, end.getTime()/1000);
+
+			double powerProduction=1500;
+			if(CacheContext.wtmap.containsKey(pewp.getWindturbineId()))
+			{
+				ProBasicEquipment wt=CacheContext.wtmap.get(pewp.getWindturbineId());
+				if(CacheContext.modelMap.containsKey(wt.getModelId()))
+				{
+					 powerProduction=CacheContext.modelMap.get(wt.getModelId()).getPowerProduction();
+				}
+			}
+			double finalPowerProduction = powerProduction;
+			pointls = pointls.stream().filter(n -> (n.getPointValueInDouble() >-100 && n.getPointValueInDouble() <= finalPowerProduction)).collect(Collectors.toList());
+
 			if(!pointls.isEmpty())
 			{
 				DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
 				//日最大功率
-				if(summaryStatistics.getMax()>48000)
-				{
-					pewp.setRzdgl(StringUtils.round(48000,2));
-				}else
-				{
-					pewp.setRzdgl(StringUtils.round(summaryStatistics.getMax(),2));
-				}
+				pewp.setRzdgl(StringUtils.round(summaryStatistics.getMax(),2));
 
 				//日最小功率
-				if(summaryStatistics.getMin()<0)
-				{
-					pewp.setRzxgl(StringUtils.round(0,2));
-				}else
-				{
-					pewp.setRzxgl(StringUtils.round(summaryStatistics.getMin(),2));
-				}
+				pewp.setRzxgl(StringUtils.round(summaryStatistics.getMin(),2));
 
 				//日平均功率
-				if(summaryStatistics.getAverage()>48000)
-				{
-					pewp.setRpjgl(StringUtils.round(48000,2));
-				}else if(summaryStatistics.getAverage()<0)
-				{
-					pewp.setRpjgl(StringUtils.round(0,2));
-				}else
-				{
-					pewp.setRpjgl(StringUtils.round(summaryStatistics.getAverage(),2));
-				}
+				pewp.setRpjgl(StringUtils.round(summaryStatistics.getAverage(),2));
 
 			}
 		}
@@ -487,37 +456,12 @@ public class EquipmentInfo1ThreadPool implements Callable<String>, Serializable
 				{
 					DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
 					//月最大风速
-					if(summaryStatistics.getMax()>30)
-					{
-						pewp.setYzdfs(StringUtils.round(25.0,2));
-					}else
-					{
-						pewp.setYzdfs(StringUtils.round(summaryStatistics.getMax(),2));
-					}
+					pewp.setYzdfs(StringUtils.round(summaryStatistics.getMax(),2));
 
 					//月最小风速
-
-
-					if(summaryStatistics.getMin()<0)
-					{
-						pewp.setYzxfs(StringUtils.round(0,2));
-					}else
-					{
-						pewp.setYzxfs(StringUtils.round(summaryStatistics.getMin(),2));
-					}
+					pewp.setYzxfs(StringUtils.round(summaryStatistics.getMin(),2));
 					//月平均风速
-
-
-					if(summaryStatistics.getAverage()>30)
-					{
-						pewp.setYpjfs(StringUtils.round(25,2));
-					}else if(summaryStatistics.getAverage()<0)
-					{
-						pewp.setYpjfs(StringUtils.round(0,2));
-					}else
-					{
-						pewp.setYpjfs(StringUtils.round(summaryStatistics.getAverage(),2));
-					}
+					pewp.setYpjfs(StringUtils.round(summaryStatistics.getAverage(),2));
 				}
 
 			}
@@ -530,35 +474,11 @@ public class EquipmentInfo1ThreadPool implements Callable<String>, Serializable
 				{
 					DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
 					//月最大功率
-
-					if(summaryStatistics.getMax()>1440000)
-					{
-						pewp.setYzdgl(StringUtils.round(1440000,2));
-					}else
-					{
-						pewp.setYzdgl(StringUtils.round(summaryStatistics.getMax(),2));
-					}
+					pewp.setYzdgl(StringUtils.round(summaryStatistics.getMax(),2));
 					//月最小功率
-
-					if(summaryStatistics.getMin()<0)
-					{
-						pewp.setYzxgl(StringUtils.round(0,2));
-					}else
-					{
-						pewp.setYzxgl(StringUtils.round(summaryStatistics.getMin(),2));
-					}
+					pewp.setYzxgl(StringUtils.round(summaryStatistics.getMin(),2));
 					//月平均功率
-					if(summaryStatistics.getAverage()>1440000)
-					{
-						pewp.setYpjgl(StringUtils.round(1440000,2));
-					}else if(summaryStatistics.getAverage()<0)
-					{
-						pewp.setYpjgl(StringUtils.round(0,2));
-					}else
-					{
-						pewp.setYpjgl(StringUtils.round(summaryStatistics.getAverage(),2));
-					}
-
+					pewp.setYpjgl(StringUtils.round(summaryStatistics.getAverage(),2));
 				}
 			}
 
@@ -818,35 +738,13 @@ public class EquipmentInfo1ThreadPool implements Callable<String>, Serializable
 				{
 					DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
 					//年最大风速
-					if(summaryStatistics.getMax()>30)
-					{
-						pewp.setNzdfs(StringUtils.round(25.0,2));
-					}else
-					{
-						pewp.setNzdfs(StringUtils.round(summaryStatistics.getMax(),2));
-					}
+					pewp.setNzdfs(StringUtils.round(summaryStatistics.getMax(),2));
 
 					//年最小风速
 
-					if(summaryStatistics.getMin()<0)
-					{
-						pewp.setNzxfs(StringUtils.round(0,2));
-					}else
-					{
-						pewp.setNzxfs(StringUtils.round(summaryStatistics.getMin(),2));
-					}
+					pewp.setNzxfs(StringUtils.round(summaryStatistics.getMin(),2));
 					//年平均风速
-
-					if(summaryStatistics.getAverage()>30)
-					{
-						pewp.setNpjfs(StringUtils.round(25.0,2));
-					}else if(summaryStatistics.getAverage()<0)
-					{
-						pewp.setNpjfs(StringUtils.round(0,2));
-					}else
-					{
-						pewp.setNpjfs(StringUtils.round(summaryStatistics.getAverage(),2));
-					}
+					pewp.setNpjfs(StringUtils.round(summaryStatistics.getAverage(),2));
 				}
 
 			}
@@ -860,33 +758,12 @@ public class EquipmentInfo1ThreadPool implements Callable<String>, Serializable
 					DoubleSummaryStatistics summaryStatistics=pointls.stream().mapToDouble(PointData::getPointValueInDouble).summaryStatistics();
 					//年最大功率
 
-					if(summaryStatistics.getMax()>17520000)
-					{
-						pewp.setNzdgl(StringUtils.round(17520000,2));
-					}else
-					{
-						pewp.setNzdgl(StringUtils.round(summaryStatistics.getMax(),2));
-					}
+					pewp.setNzdgl(StringUtils.round(summaryStatistics.getMax(),2));
 					//年最小功率
+					pewp.setNzxgl(StringUtils.round(summaryStatistics.getMin(),2));
 
-					if(summaryStatistics.getMin()<0)
-					{
-						pewp.setNzxgl(StringUtils.round(0,2));
-					}else
-					{
-						pewp.setNzxgl(StringUtils.round(summaryStatistics.getMin(),2));
-					}
 					//年平均功率
-					if(summaryStatistics.getAverage()>17520000)
-					{
-						pewp.setNpjgl(StringUtils.round(17520000,2));
-					}else if(summaryStatistics.getAverage()<0)
-					{
-						pewp.setNpjgl(StringUtils.round(0,2));
-					}else
-					{
-						pewp.setNpjgl(StringUtils.round(summaryStatistics.getAverage(),2));
-					}
+					pewp.setNpjgl(StringUtils.round(summaryStatistics.getAverage(),2));
 
 				}
 			}

File diff suppressed because it is too large
+ 91 - 48
realtime/generationXK-service/src/main/resources/application-dev.yml


File diff suppressed because it is too large
+ 1 - 1
realtime/generationXK-service/src/main/resources/application-jn.yml


+ 5 - 3
realtime/generationXK-service/src/test/java/com/gyee/generation/RealTest.java

@@ -35,9 +35,11 @@ public class RealTest {
 //        statusService.middleStatusReal();
 //        statusService.startStatusReal();
 //        calculationService.calWp();
-        cycleCalculationService.saveCyle();
+//        cycleCalculationService.saveCyle();
+
+        realtimeService.savaRealtimeTarget();
+
 
-//        realtimeService.savaRealtimeTarget();
 
 //
 //        realtimeService.savaRealtimeTarget();
@@ -45,7 +47,7 @@ public class RealTest {
 //        regionCalreService.aqts();
 
         end=new Date();
-        System.out.println("执行用时"+ DateUtils.secondsDiff(begin,end) +"秒");
+        System.out.println("执行用时"+ DateUtils.millisecondDiff(begin,end) +"秒");
         System.out.println("状态判定调度程序执行结束!。。。。。。");
         System.out.println("完成!。。。。。。");
 //

File diff suppressed because it is too large
+ 272 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlarmTsMapper.java


+ 0 - 45
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlarmcountMapper.java

@@ -1,45 +0,0 @@
-package com.gyee.healthmodel.mapper.auto;
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.gyee.healthmodel.model.auto.Alarmcount;
-import com.gyee.healthmodel.model.vo.AlarmcountVo;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-public interface AlarmcountMapper extends BaseMapper<Alarmcount> {
-
-    @DS("slave")
-    @Select(" select * from alarmcount where time is not null and snapid=#{snapid} and  alarmdate>=#{beginDate} and alarmdate<=#{endDate}   ")
-    public List<Alarmcount> findAlarmcount(@Param(value = "snapid") Long snapid,@Param(value = "beginDate") Date beginDate, @Param(value = "endDate")Date endDate);
-
-    @DS("slave")
-    @Select(" select s.alerttext as alertText,p.name as name ,s.windturbineid as wtId ,a.count as counts,a.time as times " +
-            "    from   (select snapid,sum(count) as count,sum(time) as time from alarmcount" +
-            "    where alarmdate>=#{beginDate} and  alarmdate<=#{endDate} group by snapid )" +
-            "    a,alarmsnap s,windturbine_parts p where s.id=a.snapid and s.category3=p.id" +
-            " and s.windturbineid=#{wtId}  ")
-    public List<AlarmcountVo> findAlarmCountByWt(@Param(value = "wtId") String wtId, @Param(value = "beginDate") Date beginDate, @Param(value = "endDate")Date endDate);
-
-    @DS("slave")
-    @Select(" select s.alerttext as alertText,p.name as name ,w.modelid as modelId ,a.count as counts,a.time as times " +
-            "    from   (select snapid,sum(count) as count,sum(time) as time from alarmcount" +
-            "    where alarmdate>=#{beginDate} and  alarmdate<=#{endDate} group by snapid )" +
-            "    a,alarmsnap s,windturbine_parts p,windturbine w where s.id=a.snapid and s.category3=p.id" +
-            "  and w.id=s.windturbineid and  s.modelid =w.modelid and w.modelid=#{wtId}  ")
-    public List<AlarmcountVo> findAlarmCountByModelId(@Param(value = "modelId") String modelId, @Param(value = "beginDate") Date beginDate, @Param(value = "endDate")Date endDate);
-
-
-   
-}

+ 0 - 24
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlarmsnapMapper.java

@@ -1,24 +0,0 @@
-package com.gyee.healthmodel.mapper.auto;
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.gyee.healthmodel.model.auto.Alarmsnap;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-
-import java.util.List;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-public interface AlarmsnapMapper extends BaseMapper<Alarmsnap> {
-    @DS("slave")
-    @Select(" select * from alarmsnap where alertvalue=#{alertvalue}  and windturbineid=#{wtid} ")
-    List<Alarmsnap> getAlarmsnapList(  @Param(value = "wtid")String wtid,@Param(value = "alertvalue") Long alertvalue);
-
-}

+ 0 - 29
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/Alertrule2Mapper.java

@@ -1,29 +0,0 @@
-package com.gyee.healthmodel.mapper.auto;
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.gyee.healthmodel.model.auto.Alertrule2;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-
-import java.util.List;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-public interface Alertrule2Mapper extends BaseMapper<Alertrule2> {
-
-    @DS("slave")
-    @Select(" select * from alertrule2 where station=#{station} and modelid=#{modelid} ")
-    List<Alertrule2> findAlertRuleList(@Param(value = "station") String station, @Param(value = "modelid")String modelid);
-
-    @DS("slave")
-    @Select(" select * from alertrule2 where station=#{station} and modelid=#{modelid} and name=#{name} ")
-    List<Alertrule2> getAlertRuleIdByName(@Param(value = "station") String station, @Param(value = "modelid")String modelid, @Param(value = "name")String name);
-
-}

+ 0 - 25
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlertrulefailureMapper.java

@@ -1,25 +0,0 @@
-package com.gyee.healthmodel.mapper.auto;
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.gyee.healthmodel.model.auto.Alertrulefailure;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-
-import java.util.List;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-public interface AlertrulefailureMapper extends BaseMapper<Alertrulefailure> {
-
-    @DS("slave")
-    @Select(" select * from public.alertrulefailure f " +
-            "where name=#{name} and model= #{model} order by name")
-    public List<Alertrulefailure> getPartByAlertrule(@Param(value = "name") String name,@Param(value = "model") String model);
-}

+ 0 - 24
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlertrulefailuresubMapper.java

@@ -1,24 +0,0 @@
-package com.gyee.healthmodel.mapper.auto;
-
-import com.baomidou.dynamic.datasource.annotation.DS;
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.gyee.healthmodel.model.auto.Alertrulefailuresub;
-import org.apache.ibatis.annotations.Param;
-import org.apache.ibatis.annotations.Select;
-
-import java.util.List;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-public interface AlertrulefailuresubMapper extends BaseMapper<Alertrulefailuresub> {
-    @DS("slave")
-    @Select(" select altype from alertrulefailuresub where tid=#{tid}  ")
-    public List<String> getPartByAlertruleid(@Param(value = "tid") String tid);
-
-}

+ 0 - 16
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/AlertrulesubMapper.java

@@ -1,16 +0,0 @@
-package com.gyee.healthmodel.mapper.auto;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.gyee.healthmodel.model.auto.Alertrulesub;
-
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author 石林
- * @since 2022-01-20
- */
-public interface AlertrulesubMapper extends BaseMapper<Alertrulesub> {
-
-}

+ 41 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProBasicFeatureStatMapper.java

@@ -0,0 +1,41 @@
+package com.gyee.healthmodel.mapper.auto;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.healthmodel.model.auto.ProBasicFeatureStat;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 设备功能统计 Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-14
+ */
+public interface ProBasicFeatureStatMapper extends BaseMapper<ProBasicFeatureStat> {
+
+
+    @Select({"<script>",
+            "select * from pro_basic_feature_stat " ,
+            "<where>" ,
+            "<if test='begin != null &amp;&amp; end != null '>",
+            " stat_Date &gt;= #{begin}",
+            "and stat_Date &lt;= #{end}",
+            "</if>",
+            "<if test='stationId != null'>",
+            "and station_id = #{stationId}",
+            "</if>",
+            "<if test='wtId != null'>",
+            "and wt_id = #{wtId}",
+            "</if>",
+            "</where>",
+            " order by wt_id  ",
+            "</script>"})
+    List<ProBasicFeatureStat> searchByCondition(@Param("begin") Date begin, @Param("end")Date end, @Param("stationId")String stationId, @Param("wtId")String wtId);
+
+}

+ 68 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconAlarmConfigurationMapper.java

@@ -0,0 +1,68 @@
+package com.gyee.healthmodel.mapper.auto;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.healthmodel.model.auto.ProEconAlarmConfiguration;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 报警配置表 Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-06-19
+ */
+public interface ProEconAlarmConfigurationMapper extends BaseMapper<ProEconAlarmConfiguration> {
+
+
+    @Select({"<script>",
+            "select * from pro_econ_alarm_configuration ",
+            "<where>",
+            " 1=1 ",
+            "<if test='wpId !=null  '>",
+            "and station_id = #{wpId} ",
+            "</if>",
+            "<if test='description !=null  '>",
+            "and description like #{description} ",
+            "</if>",
+            "<if test='modelId !=null  '>",
+            "and model_id = #{modelId} ",
+            "</if>",
+            "<if test='alarmType !=null  '>",
+            "and alarm_type = #{alarmType} ",
+            "</if>",
+            "</where>",
+            " order by id ",
+            "</script>"})
+    IPage<ProEconAlarmConfiguration> pageQueryAll(Page page,
+                                         @Param("description") String description,
+                                         @Param("wpId") String wpId,
+                                         @Param("modelId") String modelId,@Param("alarmType")String alarmType);
+
+
+    @Select({"<script>",
+            "select * from pro_econ_alarm_configuration ",
+            "<where>",
+            " 1=1 ",
+
+            "<if test='wpId !=null  '>",
+            "and station_id  = #{wpId} ",
+            "</if>",
+            "<if test='description !=null  '>",
+            "and description = #{description} ",
+            "</if>",
+            "<if test='modelId !=null  '>",
+            "and model_id = #{modelId} ",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+    List<ProEconAlarmConfiguration> queryObject(@Param("description") String description,
+                                       @Param("wpId") String wpId,
+                                       @Param("modelId") String modelId);
+}

+ 41 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconAlarmRuleFailureMapper.java

@@ -0,0 +1,41 @@
+package com.gyee.healthmodel.mapper.auto;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.healthmodel.model.auto.ProEconAlarmRuleFailure;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 故障规则 Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-10-04
+ */
+public interface ProEconAlarmRuleFailureMapper extends BaseMapper<ProEconAlarmRuleFailure> {
+
+    @Select({"<script>",
+            "select * from pro_econ_alarm_configuration ",
+            "<where>",
+            " 1=1 ",
+
+            "<if test='wpId !=null  '>",
+            "and station_id  = #{wpId} ",
+            "</if>",
+            "<if test='name !=null  '>",
+            "and description = #{description} ",
+            "</if>",
+            "<if test='modelId !=null  '>",
+            "and model_id = #{modelId} ",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+    List<ProEconAlarmRuleFailure> queryObject(@Param("description") String description,
+                                                @Param("wpId") String wpId,
+                                                @Param("modelId") String modelId);
+}

+ 17 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/mapper/auto/ProEconAlarmTypeMapper.java

@@ -0,0 +1,17 @@
+package com.gyee.healthmodel.mapper.auto;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.healthmodel.model.auto.ProEconAlarmType;
+
+/**
+ * <p>
+ * 自定义类型 Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+public interface ProEconAlarmTypeMapper extends BaseMapper<ProEconAlarmType> {
+
+}

+ 16 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/AlarmTs.java

@@ -0,0 +1,16 @@
+package com.gyee.healthmodel.model.auto;
+
+import lombok.Data;
+import lombok.ToString;
+
+import java.sql.Timestamp;
+@Data
+@ToString
+public class AlarmTs {
+
+    private Timestamp ts;
+    private Integer val;
+    private Integer oval;
+    private Boolean confirmed;
+    private String tbName;
+}

+ 0 - 42
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alarmcount.java

@@ -1,42 +0,0 @@
-package com.gyee.healthmodel.model.auto;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-import java.util.Date;
-
-/**
- * <p>
- * 
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@TableName("ALARMCOUNT")
-public class Alarmcount extends Model {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableField("ID")
-    private Long id;
-
-    @TableField("ALARMDATE")
-    private Date alarmdate;
-
-    @TableField("SNAPID")
-    private Long snapid;
-
-    @TableField("COUNT")
-    private Integer count;
-
-    @TableField("TIME")
-    private Double time;
-
-
-}

+ 0 - 113
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alarmsnap.java

@@ -1,113 +0,0 @@
-package com.gyee.healthmodel.model.auto;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * <p>
- * 
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@TableName("ALARMSNAP")
-public class Alarmsnap extends Model {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId("ID")
-    private Long id;
-
-    @TableField("STATIONID")
-    private String stationid;
-
-    @TableField("PROJECTID")
-    private String projectid;
-
-    @TableField("LINEID")
-    private String lineid;
-
-    @TableField("WINDTURBINEID")
-    private String windturbineid;
-
-    @TableField("ALERTVALUE")
-    private BigDecimal alertvalue;
-
-    @TableField("CATEGORY1")
-    private String category1;
-
-    @TableField("CATEGORY2")
-    private String category2;
-
-    @TableField("CATEGORY3")
-    private String category3;
-
-    @TableField("RANK")
-    private String rank;
-
-    @TableField("ISOPENED")
-    private Integer isopened;
-
-    @TableField("STATIONNAME")
-    private String stationname;
-
-    @TableField("PROJECTNAME")
-    private String projectname;
-
-    @TableField("LINENAME")
-    private String linename;
-
-    @TableField("WINDTURBINENAME")
-    private String windturbinename;
-
-    @TableField("ALERTTEXT")
-    private String alerttext;
-
-    @TableField("MODELID")
-    private String modelid;
-
-    @TableField("TESTINGPOINTKEY")
-    private String testingpointkey;
-
-    @TableField("LASTUPDATETIME")
-    private Date lastupdatetime;
-
-    @TableField("DATAINFO")
-    private String datainfo;
-
-    @TableField("ISCONFIRMED")
-    private Integer isconfirmed;
-
-    @TableField("CONFIRMTIME")
-    private Date confirmtime;
-
-    @TableField("LASTUPDATEPERSON")
-    private String lastupdateperson;
-
-    @TableField("IFIXPICTURE")
-    private String ifixpicture;
-
-    @TableField("IFIXTAG")
-    private String ifixtag;
-
-    @TableField("LASTCLOSETIME")
-    private Date lastclosetime;
-
-    @TableField("LASTCLOSEPERSON")
-    private String lastcloseperson;
-
-    @TableField("CONFIRMPERSON")
-    private String confirmperson;
-
-
-}

+ 0 - 80
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alertrule2.java

@@ -1,80 +0,0 @@
-package com.gyee.healthmodel.model.auto;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-/**
- * <p>
- * 
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@TableName("ALERTRULE2")
-public class Alertrule2 extends Model {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId("ID")
-    private String id;
-
-    @TableField("NAME")
-    private String name;
-
-    @TableField("DESCRIPTION")
-    private String description;
-
-    @TableField("EXPRESSION")
-    private String expression;
-
-    @TableField("TAG")
-    private String tag;
-
-    @TableField("RANK")
-    private String rank;
-
-    @TableField("ENABLED")
-    private Integer enabled;
-
-    @TableField("MODELID")
-    private String modelid;
-
-    @TableField("EDNAVALUE")
-    private Long ednavalue;
-
-    @TableField("CATEGORY")
-    private String category;
-
-    @TableField("RANGE")
-    private String range;
-
-    @TableField("STATION")
-    private String station;
-
-    @TableField("WINDTURBINE")
-    private String windturbine;
-
-    @TableField("LINE")
-    private String line;
-
-    @TableField("PROJECT")
-    private String project;
-
-    @TableField("ELECTRICAL")
-    private String electrical;
-
-    @TableField("TASKSTART")
-    private String taskstart;
-
-    @TableField("RELATEDPARTS")
-    private String relatedparts;
-
-
-}

+ 0 - 50
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alertrulefailure.java

@@ -1,50 +0,0 @@
-package com.gyee.healthmodel.model.auto;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-/**
- * <p>
- * 
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@TableName("ALERTRULEFAILURE")
-public class Alertrulefailure extends Model {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId("ID")
-    private String id;
-
-    @TableField("TID")
-    private String tid;
-
-    @TableField("GZPC")
-    private String gzpc;
-
-    @TableField("GZYY")
-    private String gzyy;
-
-    @TableField("GQJ")
-    private String gqj;
-
-    @TableField("XQSC")
-    private Double xqsc;
-
-    @TableField("NAME")
-    private String name;
-
-    @TableField("MODEL")
-    private String model;
-
-
-}

+ 0 - 38
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alertrulefailuresub.java

@@ -1,38 +0,0 @@
-package com.gyee.healthmodel.model.auto;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-/**
- * <p>
- * 
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@TableName("ALERTRULEFAILURESUB")
-public class Alertrulefailuresub extends Model {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId("ID")
-    private String id;
-
-    @TableField("TID")
-    private String tid;
-
-    @TableField("NAME")
-    private String name;
-
-    @TableField("ALTYPE")
-    private String altype;
-
-
-}

+ 0 - 46
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/Alertrulesub.java

@@ -1,46 +0,0 @@
-package com.gyee.healthmodel.model.auto;
-
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-
-import java.math.BigDecimal;
-
-/**
- * <p>
- * 
- * </p>
- *
- * @author 石林
- * @since 2022-01-20
- */
-@Data
-@EqualsAndHashCode(callSuper = true)
-@TableName("ALERTRULESUB")
-public class Alertrulesub extends Model {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId("ID")
-    private String id;
-
-    @TableField("RID")
-    private String rid;
-
-    @TableField("FREQUENCY")
-    private BigDecimal frequency;
-
-    @TableField("TIMEINTERVAL")
-    private BigDecimal timeinterval;
-
-    @TableField("TIMERANGE")
-    private String timerange;
-
-    @TableField("TIMENUM")
-    private BigDecimal timenum;
-
-
-}

+ 91 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProBasicFeatureStat.java

@@ -0,0 +1,91 @@
+package com.gyee.healthmodel.model.auto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.sql.Timestamp;
+
+/**
+ * <p>
+ * 设备功能统计
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-14
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProBasicFeatureStat extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    @TableId(value = "ID",type = IdType.INPUT)
+    private String id;
+
+    /**
+     * 设备编号
+     */
+    private String wtId;
+
+    /**
+     * 场站编号
+     */
+    private String stationId;
+
+    /**
+     * 统计时间
+     */
+    private Timestamp statDate;
+
+    /**
+     * 总次数
+     */
+    private Long total;
+
+    /**
+     * 总时间
+     */
+    private Double totalSeconds;
+
+    /**
+     * 平均时长
+     */
+    private Double avgSeconds;
+
+    /**
+     * 最大时长
+     */
+    private Double maxSeconds;
+
+    /**
+     * 最小时长
+     */
+    private Double minSeconds;
+
+    /**
+     * 类型编码
+     */
+    private String typeCode;
+
+    /**
+     * 类型名称
+     */
+    private String typeName;
+    /**
+     * 报警编号
+     */
+    private String alarmid;
+
+    /**
+     * 描述
+     */
+    private String description;
+
+
+}

+ 157 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmConfiguration.java

@@ -0,0 +1,157 @@
+package com.gyee.healthmodel.model.auto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 报警配置表
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-06-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@ToString
+@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
+public class ProEconAlarmConfiguration extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    @ExcelProperty("编号")
+    @TableId(value = "ID",type = IdType.INPUT)
+    private String id;
+
+    /**
+     * 测点(如果根据uniformcode配置此字段可为空)
+     */
+    @ExcelProperty("测点")
+    private String tagId;
+
+    /**
+     * 触发条件,0触发,1触发,-1变化触发,4ai点触发
+     */
+    @ExcelProperty("触发条件")
+    private Integer triggerType;
+
+    /**
+     * 设备ID
+     */
+    @ExcelProperty("设备ID")
+    private String deviceId;
+
+    /**
+     * 后缀
+     */
+    @ExcelProperty("后缀")
+    private String suffix;
+
+    /**
+     * 报警级别
+     */
+    @ExcelProperty("报警级别")
+    private Integer rank;
+
+    /**
+     * 统一识别码(如果通过uniformCode配置,则设备类型,场站,机型不能为空)
+     */
+    @ExcelProperty("统一识别码")
+    private String uniformCode;
+
+    /**
+     * 场站ID
+     */
+    @ExcelProperty("场站ID")
+    private String stationId;
+
+    /**
+     * 机型
+     */
+    @ExcelProperty("机型")
+    private String modelId;
+
+    /**
+     * 报警类型 /自定义报警 custom,风机 windturbine,场站 station,升压站 booststation
+     */
+    @ExcelProperty("报警类型")
+    private String alarmType;
+
+    /**
+     * 设备类型,场站 station,风机 windturbine,升压站 booststation
+     */
+    @ExcelProperty("设备类型")
+    private String deviceType;
+
+    /**
+     * 设备部件
+     */
+    @ExcelProperty("设备部件")
+    private String components;
+
+    /**
+     * 设备子部件
+     */
+    @ExcelProperty("设备子部件")
+    private String subcomponents;
+
+    /**
+     * 报警描述
+     */
+    @ExcelProperty("报警描述")
+    private String description;
+
+    /**
+     * 特性
+     */
+    @ExcelProperty("特性")
+    private String characteristic;
+
+    /**
+     * 是否可复位
+     */
+    @ExcelProperty("是否可复位")
+    private Boolean resetTable;
+
+    /**
+     * 是否启用
+     */
+    @ExcelProperty("是否启用")
+    private Boolean enable;
+
+    /**
+     * 故障名称
+     */
+    @ExcelProperty("故障名称")
+    private String name;
+
+    /**
+     *故障码
+     */
+    @ExcelProperty("故障码")
+    private String nemCode;
+
+    /**
+     * 故障原因
+     */
+    @ExcelProperty("故障原因")
+    private String faultCause;
+
+    /**
+     * 排查方法
+     */
+    @ExcelProperty("排查方法")
+    private String resolvent;
+
+
+}

+ 135 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmRule.java

@@ -0,0 +1,135 @@
+package com.gyee.healthmodel.model.auto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.*;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * <p>
+ * 自定义报警配置
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@ToString
+@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
+public class ProEconAlarmRule extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+
+    @TableId(value = "ID",type = IdType.INPUT)
+    private String id;
+
+    /**
+     * 自定义报警名称
+     */
+
+    private String name;
+
+    /**
+     * 报警描述
+     */
+    private String description;
+
+    /**
+     * 公式
+     */
+    private String expression;
+
+    /**
+     * 标签
+     */
+    private String tag;
+
+    /**
+     * 报警级别
+     */
+    private Integer rank;
+
+    /**
+     * 机型
+     */
+    private String modelId;
+
+    /**
+     * 报警类别
+     */
+    private String category;
+
+    /**
+     * 范围
+     */
+    private String range;
+
+    /**
+     * 场站ID
+     */
+
+    private String stationId;
+
+    /**
+     * 项目ID
+     */
+
+    private String projectId;
+
+    /**
+     * 线路ID
+     */
+
+    private String lineId;
+
+    /**
+     * 设备ID
+     */
+
+    private String deviceId;
+
+    /**
+     * 电气ID
+     */
+
+    private String electricalId;
+
+    /**
+     * 关联部件
+     */
+
+    private String relatedParts;
+
+    /**
+     * 创建时间
+     */
+
+    private Date createTime;
+
+    /**
+     * 是否启用
+     */
+
+    private Boolean enable;
+    /**
+     * 统一识别码(如果通过uniformCode配置,则设备类型,场站,机型不能为空)
+     */
+    private String uniformCode;
+
+    @TableField(exist = false)
+    private String stationName;
+    @TableField(exist = false)
+    private String relatedPartsName;
+}

+ 84 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmRuleFailure.java

@@ -0,0 +1,84 @@
+package com.gyee.healthmodel.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.math.BigDecimal;
+
+/**
+ * <p>
+ * 故障规则
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-10-04
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconAlarmRuleFailure extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    private String id;
+
+    /**
+     * 故障码
+     */
+    private String nemCode;
+
+    /**
+     * 故障英文描述
+     */
+    private String describe;
+
+    /**
+     * 故障名称
+     */
+    private String name;
+
+    /**
+     * 故障原因
+     */
+    private String faultCause;
+
+    /**
+     * 排查方法
+     */
+    private String resolvent;
+
+    /**
+     * 故障类型
+     */
+    private String types;
+
+    /**
+     * 关联报警
+     */
+    private String alarmId;
+
+    /**
+     * 型号
+     */
+    private String modelId;
+
+    /**
+     * 场站编号
+     */
+    private String stationId;
+
+    /**
+     * 故障时长
+     */
+    private BigDecimal faultTimes;
+
+    /**
+     * 关联部件
+     */
+    private String relatedParts;
+
+
+}

+ 52 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/auto/ProEconAlarmType.java

@@ -0,0 +1,52 @@
+package com.gyee.healthmodel.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 自定义类型
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconAlarmType extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    private String id;
+
+    /**
+     * 报警类别
+     */
+    private String category;
+
+    /**
+     * 编码
+     */
+    private String nemCode;
+
+    /**
+     * 类型名称
+     */
+    private String name;
+
+    /**
+     * 范围
+     */
+    private Integer orderNumber;
+
+    /**
+     * 是否启用
+     */
+    private Integer enable;
+
+
+}

+ 21 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmConfigurationVo.java

@@ -0,0 +1,21 @@
+package com.gyee.healthmodel.model.vo;
+
+import lombok.Data;
+
+@Data
+public class AlarmConfigurationVo {
+
+    /**
+     * 报警标号
+     */
+    private String alarmId;
+
+    /**
+     * 报警描述
+     */
+    private String description;
+
+
+
+
+}

+ 52 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmCustomTag.java

@@ -0,0 +1,52 @@
+package com.gyee.healthmodel.model.vo;
+
+import lombok.Data;
+
+@Data
+public class AlarmCustomTag {
+
+    /**
+     * 表名
+     */
+    private String id;
+
+    /**
+     * 时间戳
+     */
+    private Long ts;
+
+    /**
+     * 当前值
+     */
+    private Double val;
+
+    /**
+     * 公式
+     */
+    private String tagId;
+
+    /**
+     * 公式解析
+     */
+    private String description;
+    /**
+     * 设备编号
+     */
+    private String deviceid;
+    /**
+     * 设备类型
+     */
+    private String devicetype;
+    /**
+     * 型号编号
+     */
+    private String modelId;
+    /**
+     * 报警类型
+     */
+    private String alarmtype;
+    /**
+     * 场站编号
+     */
+    private String stationid;
+}

+ 53 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmCustomType.java

@@ -0,0 +1,53 @@
+package com.gyee.healthmodel.model.vo;
+
+public enum AlarmCustomType {
+
+    WT("windturbine", "设备自定义报警"),
+    BT("booststation", "升压站报警"),
+    IN("inverter", "逆变器报警");
+
+    private String code;
+    private String name;
+
+    AlarmCustomType(String code) {
+        this.code = code;
+    }
+
+    AlarmCustomType(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (AlarmCustomType ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 24 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmRuleVo.java

@@ -0,0 +1,24 @@
+package com.gyee.healthmodel.model.vo;
+
+import lombok.Data;
+
+@Data
+public class AlarmRuleVo {
+
+    /**
+     * 关联部件编码
+     */
+    private String relatedParts;
+
+    /**
+     * 报警名称
+     */
+    private String alarmName;
+
+    /**
+     * 部件名称
+     */
+    private String typeName;
+
+
+}

+ 19 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmSimpleVo.java

@@ -0,0 +1,19 @@
+package com.gyee.healthmodel.model.vo;
+
+
+import lombok.Data;
+
+import java.sql.Timestamp;
+
+@Data
+public class AlarmSimpleVo {
+
+    private  String tbName;
+    private Timestamp ts;
+    private Integer val;
+    private Integer oval;
+    private  Boolean confirmed;
+    private Timestamp endts;
+    private Double timelong;
+
+}

+ 31 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmStatVo.java

@@ -0,0 +1,31 @@
+package com.gyee.healthmodel.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class AlarmStatVo implements Serializable{
+
+    private Long snapId;
+
+    private String stationId;
+
+    private String windturbineId;
+
+    private String alertText;
+
+    private long count;
+    private String alarmid;
+    private double time;
+    //关联部件编号
+    private String relateParts;
+    //关联部件名称
+    private String relatePartsText;
+
+    private String code;
+
+    private String windturbineCode;
+
+
+}

+ 54 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmSuperTalbeType.java

@@ -0,0 +1,54 @@
+package com.gyee.healthmodel.model.vo;
+
+public enum AlarmSuperTalbeType {
+
+    WT("alarmWt", "设备报警超级表"),
+
+    BT("alarmBt", "升压站报警超级表"),
+    CT("alarmCt", "自定义报警超级表");
+
+    private String code;
+    private String name;
+
+    AlarmSuperTalbeType(String code) {
+        this.code = code;
+    }
+
+    AlarmSuperTalbeType(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (AlarmSuperTalbeType ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 119 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmTag.java

@@ -0,0 +1,119 @@
+package com.gyee.healthmodel.model.vo;
+
+import com.gyee.common.model.PointData;
+import lombok.Data;
+
+@Data
+public class AlarmTag {
+
+    /**
+     * 表名
+     */
+    private String id;
+
+    /**
+     * 时间戳
+     */
+    private Long ts;
+
+    /**
+     * 当前值
+     */
+    private Double val;
+
+    /**
+     * 报警类别,0触发,1触发,-1变化触发,大于等于3ai点触发
+     */
+    private Integer triggerType=0;
+
+    /**
+     * 测点
+     */
+    private String tagId;
+
+    /**
+     * 过去值
+     */
+    private Double oval=0.0;
+
+    /**
+     * 报警级别
+     */
+    private Integer rank;
+
+    /**
+     * 结束时间戳
+     */
+    private Long endts;
+    /**
+     * 报警时长
+     */
+    private Double timeLong;
+    /**
+     * 报警描述
+     */
+    private String description;
+
+
+    private  Boolean confirmed;
+
+    private String superTalbe;
+
+    /**
+     * 报警类型 /自定义报警 custom,风机 windturbine,场站 station,升压站 booststation
+     */
+    private String alarmType;
+
+    /**
+     * 设备类型,场站 station,风机 windturbine,升压站 booststation
+     */
+    private String deviceType;
+
+    /**
+     * 更新并检测是否触发报警
+     */
+    public Boolean updateAndCheck(PointData pointData) {
+
+        if (pointData.getPointValueInDouble() == oval) {
+            return false;
+        }
+        ts = pointData.getPointTime();
+        oval = pointData.getPointValueInDouble();
+
+        endts= pointData.getPointTime();
+        val=0.0;
+        if(triggerType==-1)
+        {
+            val=1.0;
+        }else  if(triggerType==0)
+        {
+            if (oval == 0)
+            {
+                val=1.0;
+            }else
+            {
+                val=0.0;
+                return false;
+            }
+        }else  if(triggerType==1)
+        {
+            if (oval == 1)
+            {
+                val=1.0;
+            }else
+            {
+                val=0.0;
+                return false;
+            }
+        }else {
+            if (oval.intValue() == triggerType) {
+                val=1.0;
+            } else if (oval == 0) {
+                val=0.0;
+                return false;
+            }
+        }
+
+        return true;
+    }
+}

+ 54 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmTime.java

@@ -0,0 +1,54 @@
+package com.gyee.healthmodel.model.vo;
+
+
+public enum AlarmTime {
+
+    H("h", "时"),
+    M("m", "分"),
+    S("s", "秒");
+
+    private String code;
+    private String name;
+
+    AlarmTime(String code) {
+        this.code = code;
+    }
+
+    AlarmTime(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (AlarmTime ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 17 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmTsVo.java

@@ -0,0 +1,17 @@
+package com.gyee.healthmodel.model.vo;
+
+
+import lombok.Data;
+
+@Data
+public class AlarmTsVo {
+
+
+    private String alarmid;
+    private String description;
+    private String deviceid;
+    private Integer val;
+    private Integer rank;
+    private Double timeLong;
+
+}

+ 54 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmType.java

@@ -0,0 +1,54 @@
+package com.gyee.healthmodel.model.vo;
+
+public enum AlarmType {
+
+    FJBJ("alertrule_category", "风机部件"),
+    GFBJ("alertrule_category_GF", "光伏部件"),
+    YJ("early_category", "预警"),
+    SD("userset", "用户设定");
+
+    private String code;
+    private String name;
+
+    AlarmType(String code) {
+        this.code = code;
+    }
+
+    AlarmType(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (AlarmType ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 56 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmTypeValue.java

@@ -0,0 +1,56 @@
+package com.gyee.healthmodel.model.vo;
+
+public enum AlarmTypeValue {
+
+    BT("booststation", "升压站报警"),
+
+    BTE("booststationevent", "升压站报警事件"),
+    IN("inverter", "逆变器报警"),
+    WT("windturbine", "设备报警"),
+    CT("custom", "自定义报警");
+
+    private String code;
+    private String name;
+
+    AlarmTypeValue(String code) {
+        this.code = code;
+    }
+
+    AlarmTypeValue(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (AlarmTypeValue ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 68 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/AlarmVo.java

@@ -0,0 +1,68 @@
+package com.gyee.healthmodel.model.vo;
+
+
+import lombok.Data;
+
+@Data
+public class AlarmVo {
+
+    private  String tbName;
+    private String alarmId;
+    private String alarmType;
+    private String characteristic;
+    private String components;
+    private Boolean confirmed;
+    private String description;
+    private String deviceId;
+    private String devicename;
+    private String deviceType;
+    private Boolean enabled;
+    private String lineid;
+    private String linename;
+    private String modelId;
+    private String projectid;
+    private String projectname;
+    private Integer rank;
+    private Boolean resettable;
+    private String stationid;
+    private String stationname;
+    private String subcomponents;
+    private String suffix;
+    private String tagid;
+    private Integer triggertype;
+    private String uniformcode;
+    private String superTableName;
+
+    private long ts;
+    private Integer val;
+    private Integer oval;
+
+    private long endts;
+
+    private Double timelong;
+
+    /**
+     * 故障名称
+     */
+    private String name;
+
+    /**
+     *故障码
+     */
+    private String nemCode;
+
+    /**
+     * 故障原因
+     */
+    private String faultCause;
+
+    /**
+     * 排查方法
+     */
+    private String resolvent;
+    private String wpName;
+    private String code;
+    private String wpId;
+    private String faultType;
+    private String id;
+}

+ 54 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/model/vo/DeviceTypeValue.java

@@ -0,0 +1,54 @@
+package com.gyee.healthmodel.model.vo;
+
+public enum DeviceTypeValue {
+
+    BT("booststation", "升压站报警"),
+    IN("inverter", "逆变器报警"),
+    WP("station", "场站报警"),
+    WT("windturbine", "风机报警");
+
+    private String code;
+    private String name;
+
+    DeviceTypeValue(String code) {
+        this.code = code;
+    }
+
+    DeviceTypeValue(String code, String name) {
+        this.code = code;
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * 根据code获取message
+     *
+     * @param code
+     * @return
+     */
+    public static String getNmaeByCode(String code) {
+        for (DeviceTypeValue ele : values()) {
+            if (ele.getCode().equals(code)) {
+                return ele.getName();
+            }
+        }
+        return null;
+    }
+
+
+}

+ 294 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmCtService.java

@@ -0,0 +1,294 @@
+package com.gyee.healthmodel.service;
+
+
+import com.gyee.healthmodel.init.CacheContext;
+import com.gyee.healthmodel.model.auto.*;
+import com.gyee.healthmodel.model.vo.AlarmSuperTalbeType;
+import com.gyee.healthmodel.model.vo.AlarmTypeValue;
+import com.gyee.healthmodel.model.vo.AlarmVo;
+import com.gyee.healthmodel.model.vo.DeviceTypeValue;
+import com.gyee.healthmodel.service.auto.IAlarmTsService;
+import com.gyee.healthmodel.util.StringUtils;
+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;
+
+@Service
+
+public class AlarmCtService {
+    @Resource
+    private IAlarmTsService alarmTsService;
+
+
+    public List<AlarmVo> initalAlarmVo() {
+
+        List<AlarmVo> alarmVoList = new ArrayList<>();
+        Map<String, List<ProEconAlarmRule>> alarmRulesMap = CacheContext.alarmRulesMap;
+
+        //风机自定义报警
+        wtCustomAlarm(alarmVoList, alarmRulesMap);
+        //逆变器自定义报警
+        lnCustomAlarm(alarmVoList, alarmRulesMap);
+//        //场站自定义报警
+//        wpCustomAlarm(alarmVoList, alarmRulesMap);
+        //升压站自定义报警
+        btCustomAlarm(alarmVoList, alarmRulesMap);
+        return alarmVoList;
+    }
+
+    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()) {
+                for (ProEconAlarmRule ar : arls) {
+                    StringBuilder sb = new StringBuilder();
+                    sb.append(ar.getStationId() + ar.getModelId());
+                    if (armap.containsKey(String.valueOf(sb))) {
+                        List<ProEconAlarmRule> ls = armap.get(String.valueOf(sb));
+                        ls.add(ar);
+                    } else {
+                        List<ProEconAlarmRule> ls = new ArrayList<>();
+                        ls.add(ar);
+                        armap.put(String.valueOf(sb), ls);
+                    }
+                }
+            }
+        }
+
+        for (ProBasicEquipment wt : CacheContext.wtls) {
+            StringBuilder sb = new StringBuilder();
+            sb.append(wt.getWindpowerstationId() + wt.getModelId());
+
+            if (armap.containsKey(String.valueOf(sb))) {
+                List<ProEconAlarmRule> alarmls = armap.get(String.valueOf(sb));
+
+                if (!alarmls.isEmpty()) {
+                    for (ProEconAlarmRule alarm : alarmls) {
+                        AlarmVo vo = new AlarmVo();
+                        StringBuilder tbName = new StringBuilder();
+                        tbName.append(wt.getId()).append("_").append(alarm.getId());
+                        vo.setTbName(String.valueOf(tbName));
+                        vo.setAlarmId(alarm.getId());
+                        vo.setTagid(alarm.getExpression());
+                        vo.setAlarmType(AlarmTypeValue.CT.getCode());
+                        vo.setCharacteristic(alarm.getName());
+                        vo.setComponents(alarm.getRelatedParts());
+                        vo.setDescription(alarm.getDescription());
+                        vo.setDeviceId(wt.getId());
+                        vo.setDevicename(wt.getName());
+                        vo.setDeviceType(DeviceTypeValue.WT.getCode());
+                        vo.setEnabled(alarm.getEnable());
+                        vo.setLineid(wt.getLineId());
+                        if (CacheContext.lnmap.containsKey(wt.getLineId())) {
+                            ProBasicLine ln = CacheContext.lnmap.get(wt.getLineId());
+                            vo.setLinename(ln.getName());
+                        }
+                        vo.setModelId(wt.getModelId());
+                        vo.setProjectid(wt.getProjectId());
+                        if (CacheContext.pjmap.containsKey(wt.getProjectId())) {
+                            ProBasicProject pj = CacheContext.pjmap.get(wt.getProjectId());
+                            vo.setProjectname(pj.getName());
+                        }
+                        vo.setRank(alarm.getRank());
+                        vo.setResettable(false);
+                        vo.setStationid(wt.getWindpowerstationId());
+                        if (CacheContext.wpmap.containsKey(wt.getWindpowerstationId())) {
+                            ProBasicPowerstation wp = CacheContext.wpmap.get(wt.getWindpowerstationId());
+                            vo.setStationname(wp.getName());
+                        }
+                        vo.setSubcomponents("");
+                        vo.setSuffix("");
+                        vo.setTriggertype(1);
+                        vo.setUniformcode("");
+                        vo.setSuperTableName(AlarmSuperTalbeType.CT.getCode());
+                        vo.setVal(0);
+
+                        vo.setCharacteristic("自定义");
+                        vo.setFaultCause(alarm.getDescription());
+                        vo.setResolvent(alarm.getExpression());
+                        alarmVoList.add(vo);
+                    }
+                }
+            }
+        }
+    }
+
+    private void lnCustomAlarm(List<AlarmVo> alarmVoList, Map<String, List<ProEconAlarmRule>> alarmRulesMap) {
+
+        Map<String, List<ProEconAlarmRule>> armap = new HashMap<>();
+
+        if (alarmRulesMap.containsKey(DeviceTypeValue.IN.getCode())) {
+            List<ProEconAlarmRule> arls = alarmRulesMap.get(DeviceTypeValue.IN.getCode());
+            if (!arls.isEmpty()) {
+                for (ProEconAlarmRule ar : arls) {
+                    StringBuilder sb = new StringBuilder();
+                    sb.append(ar.getStationId() + ar.getModelId());
+                    if (armap.containsKey(String.valueOf(sb))) {
+                        List<ProEconAlarmRule> ls = armap.get(String.valueOf(sb));
+                        ls.add(ar);
+                    } else {
+                        List<ProEconAlarmRule> ls = new ArrayList<>();
+                        ls.add(ar);
+                        armap.put(String.valueOf(sb), ls);
+                    }
+                }
+            }
+        }
+//
+//        HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
+//        List<ProBasicEquipment> wtls = tokenService.getWtls(request);
+        for (ProBasicEquipment wt : CacheContext.wtls) {
+            StringBuilder sb = new StringBuilder();
+            sb.append(wt.getWindpowerstationId() + wt.getModelId());
+
+            if (armap.containsKey(String.valueOf(sb))) {
+                List<ProEconAlarmRule> alarmls = armap.get(String.valueOf(sb));
+
+                if (!alarmls.isEmpty()) {
+                    for (ProEconAlarmRule alarm : alarmls) {
+                        AlarmVo vo = new AlarmVo();
+                        StringBuilder tbName = new StringBuilder();
+                        tbName.append(wt.getId()).append("_").append(alarm.getId());
+                        vo.setTbName(String.valueOf(tbName));
+                        vo.setAlarmId(alarm.getId());
+                        vo.setTagid(alarm.getExpression());
+                        vo.setAlarmType(AlarmTypeValue.CT.getCode());
+                        vo.setCharacteristic(alarm.getName());
+                        vo.setComponents(alarm.getRelatedParts());
+                        vo.setDescription(alarm.getDescription());
+                        vo.setDeviceId(wt.getId());
+                        vo.setDevicename(wt.getName());
+                        vo.setDeviceType(DeviceTypeValue.IN.getCode());
+                        vo.setEnabled(alarm.getEnable());
+                        vo.setLineid(wt.getLineId());
+                        if (CacheContext.lnmap.containsKey(wt.getLineId())) {
+                            ProBasicLine ln = CacheContext.lnmap.get(wt.getLineId());
+                            vo.setLinename(ln.getName());
+                        }
+                        vo.setModelId(wt.getModelId());
+                        vo.setProjectid(wt.getProjectId());
+                        if (CacheContext.pjmap.containsKey(wt.getProjectId())) {
+                            ProBasicProject pj = CacheContext.pjmap.get(wt.getProjectId());
+                            vo.setProjectname(pj.getName());
+                        }
+                        vo.setRank(alarm.getRank());
+                        vo.setResettable(false);
+                        vo.setStationid(wt.getWindpowerstationId());
+                        if (CacheContext.wpmap.containsKey(wt.getWindpowerstationId())) {
+                            ProBasicPowerstation wp = CacheContext.wpmap.get(wt.getWindpowerstationId());
+                            vo.setStationname(wp.getName());
+                        }
+                        vo.setSubcomponents("");
+                        vo.setSuffix("");
+                        vo.setTriggertype(1);
+                        vo.setUniformcode("");
+                        vo.setSuperTableName(AlarmSuperTalbeType.CT.getCode());
+                        vo.setVal(0);
+
+                        vo.setCharacteristic("自定义");
+                        vo.setFaultCause(alarm.getDescription());
+                        vo.setResolvent(alarm.getExpression());
+                        alarmVoList.add(vo);
+                    }
+                }
+            }
+        }
+    }
+
+    private void btCustomAlarm(List<AlarmVo> alarmVoList, Map<String, List<ProEconAlarmRule>> alarmRulesMap) {
+
+
+        Map<String,List<ProEconAlarmRule>> alarmMap=new HashMap<>();
+
+        if (alarmRulesMap.containsKey(DeviceTypeValue.BT.getCode())) {
+
+            List<ProEconAlarmRule>  alarmls = alarmRulesMap.get(DeviceTypeValue.BT.getCode());
+
+            if(!alarmls.isEmpty())
+            {
+                for(ProEconAlarmRule alarm:alarmls)
+                {
+                    if (StringUtils.notEmp(alarm) && StringUtils.notEmp(alarm.getElectricalId()))
+                    {
+                        String [] ids=alarm.getElectricalId().split(",");
+                        if(ids.length>0)
+                        {
+                            for(int i=0;i<ids.length;i++)
+                            {
+                                if(alarmMap.containsKey(ids[i]))
+                                {
+                                    List<ProEconAlarmRule> arls=alarmMap.get(ids[i]);
+                                    arls.add(alarm);
+
+                                }else
+                                {
+                                    List<ProEconAlarmRule> arls=new ArrayList<>();
+                                    arls.add(alarm);
+                                    alarmMap.put(ids[i],arls);
+                                }
+
+                            }
+                        }
+                    }
+
+                }
+            }
+        }
+//        HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
+//        List<ProBasicSubStation> subwpls = tokenService.getSubwpls(request);
+        for (ProBasicSubStation wp : CacheContext.subwpls) {
+
+            if (!alarmMap.isEmpty() && alarmMap.containsKey(wp.getId())) {
+
+                List<ProEconAlarmRule> alarmls = alarmMap.get(wp.getId());
+                for (ProEconAlarmRule alarm : alarmls) {
+                    AlarmVo vo = new AlarmVo();
+                    StringBuilder tbName = new StringBuilder();
+
+                    tbName.append(wp.getId()).append("_").append(alarm.getId());
+                    vo.setTbName(String.valueOf(tbName));
+                    vo.setAlarmId(alarm.getId());
+                    vo.setTagid(alarm.getExpression());
+                    vo.setAlarmType(AlarmTypeValue.CT.getCode());
+                    vo.setCharacteristic(alarm.getName());
+                    vo.setComponents(alarm.getRelatedParts());
+                    vo.setDescription(alarm.getDescription());
+                    vo.setDeviceId("");
+                    vo.setDevicename("");
+                    vo.setDeviceType(DeviceTypeValue.BT.getCode());
+                    vo.setEnabled(alarm.getEnable());
+                    vo.setLineid("");
+                    vo.setLinename("");
+                    vo.setModelId("");
+                    vo.setProjectid("");
+                    vo.setProjectname("");
+                    vo.setRank(alarm.getRank());
+                    vo.setResettable(false);
+                    vo.setStationid(wp.getId());
+                    vo.setStationname(wp.getName());
+                    vo.setSubcomponents("");
+                    vo.setSuffix("");
+                    vo.setTriggertype(1);
+                    vo.setUniformcode("");
+                    vo.setSuperTableName(AlarmSuperTalbeType.CT.getCode());
+                    vo.setVal(0);
+                    vo.setOval(0);
+
+                    vo.setCharacteristic("自定义");
+                    vo.setFaultCause(alarm.getDescription());
+                    vo.setResolvent(alarm.getExpression());
+                    alarmVoList.add(vo);
+                }
+            }
+        }
+    }
+
+
+}

+ 570 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmHistoryService.java

@@ -0,0 +1,570 @@
+package com.gyee.healthmodel.service;
+
+
+import cn.hutool.core.bean.BeanUtil;
+import com.gyee.healthmodel.init.CacheContext;
+import com.gyee.healthmodel.mapper.auto.AlarmTsMapper;
+import com.gyee.healthmodel.model.auto.*;
+import com.gyee.healthmodel.model.vo.*;
+import com.gyee.healthmodel.util.DateUtils;
+import com.gyee.healthmodel.util.SnowflakeGenerator;
+import com.gyee.healthmodel.util.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.sql.Timestamp;
+import java.util.*;
+
+
+@Service
+
+public class AlarmHistoryService {
+
+    @Resource
+    private AlarmTsMapper alarmTsMapper;
+
+    @Value("${home_pagep_size}")
+    private int home_pagep_size;
+    /**
+     * 查询报警信息接口
+     * @param begin 开始时间
+     * @param end 结束时间
+     * @param alarmType 报警类型
+     * @param stationid 场站
+     * @param description 描述
+     * @param pageNum 页数
+     * @param pageSize 每页多少条
+     * @return
+     */
+    public Map<String,Object> findAlarmlist(String modelId, long begin,long end ,String alarmType,String stationid,String deviceid,String description,String deviceType,String components,String alarmId,Boolean isclose, int pageNum, int pageSize) {
+
+        Map<String,Object> map=new HashMap<>();
+
+        List<AlarmVo> vos =new ArrayList<>();
+        String superTableName= null;
+        StringBuilder descriptionSql=new StringBuilder();
+        if(StringUtils.notEmp(alarmType) && StringUtils.notEmp(begin) && StringUtils.notEmp(end) )
+        {
+
+//            whereSql.append(" where  ts>=").append(begin).append("  and ts<= ").append(end);
+//
+//            whereSql.append(" and alarmtype=CONCAT('',").append(alarmType).append(",'')");
+
+            if(AlarmTypeValue.BT.getCode().equals(alarmType))
+            {
+                superTableName= AlarmSuperTalbeType.BT.getCode();
+
+            }else if(AlarmTypeValue.WT.getCode().equals(alarmType))
+            {
+                superTableName= AlarmSuperTalbeType.WT.getCode();
+
+            }
+            else if(AlarmTypeValue.IN.getCode().equals(alarmType))
+            {
+                superTableName= AlarmSuperTalbeType.WT.getCode();
+
+            }else if(AlarmTypeValue.CT.getCode().equals(alarmType))
+            {
+                superTableName= AlarmSuperTalbeType.CT.getCode();
+
+            }
+        }
+
+
+//
+        if(StringUtils.notEmp(description)  )
+        {
+            descriptionSql.append("%").append(description).append("%");
+            description=String.valueOf(descriptionSql);
+        }
+        if(StringUtils.empty(deviceid)  )
+        {
+            deviceid=null;
+        }
+
+        if(StringUtils.empty(stationid)  )
+        {
+            stationid=null;
+        }
+        if(StringUtils.empty(modelId)  )
+        {
+            modelId=null;
+        }
+        if(StringUtils.empty(description)  )
+        {
+            description=null;
+        }
+        if(StringUtils.empty(deviceType)  )
+        {
+            deviceType=null;
+        }
+
+        if(StringUtils.empty(components)  )
+        {
+            components=null;
+        }
+        if(StringUtils.empty(alarmId)  )
+        {
+            alarmId=null;
+        }
+
+        if(StringUtils.empty(isclose)  )
+        {
+            isclose=null;
+        }
+        vos = alarmTsMapper.selectByWtLimit(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components, alarmId,isclose,pageNum*pageSize, pageSize);
+
+        for(AlarmVo vo:vos)
+        {
+
+            if(StringUtils.notEmp(vo.getDeviceId()) && CacheContext.wtmap.containsKey(vo.getDeviceId()))
+            {
+                vo.setCode(CacheContext.wtmap.get(vo.getDeviceId()).getNemCode());
+            }
+
+            if(CacheContext.wpmap.containsKey(vo.getStationid()))
+            {
+                vo.setWpName(CacheContext.wpmap.get(vo.getStationid()).getName());
+            }
+
+            if(CacheContext.subwpmap.containsKey(vo.getStationid()))
+            {
+                vo.setWpName(CacheContext.subwpmap.get(vo.getStationid()).getName());
+            }
+        }
+
+
+        map.put("ls",vos);
+        List<Integer> total=alarmTsMapper.selectByWtCount(begin,end,modelId,superTableName, alarmType, stationid, deviceid, description,deviceType,components,alarmId,isclose);
+
+        if(!total.isEmpty())
+        {
+            Integer all= total.get(0);
+            map.put("total",all);
+        }
+
+        return map;
+    }
+
+
+
+    public List<AlarmVo> findAlarmByTypelist(String type) {
+
+
+        List<AlarmVo> vos=new ArrayList<>();
+
+
+        if(StringUtils.notEmp(type) )
+        {
+            Date endDate = new Date();
+//            Date beginDate = DateUtils.addHours(endDate,-1);
+            Date beginDate = DateUtils.truncate(endDate);
+            if(type.equals(AlarmTypeValue.BT.getCode()))
+            {
+                vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.BT.getCode(), AlarmTypeValue.BT.getCode(), null, null, null,null,null, null,null,1, home_pagep_size);
+
+            }else if(type.equals(AlarmTypeValue.WT.getCode()))
+            {
+                vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.WT.getCode(), AlarmTypeValue.WT.getCode(), null, null, null,null, null,null,null,1, home_pagep_size);
+
+            }else if(type.equals(AlarmTypeValue.CT.getCode()))
+            {
+                vos = alarmTsMapper.selectByWtLimit(beginDate.getTime(),endDate.getTime(),null,AlarmSuperTalbeType.CT.getCode(), AlarmTypeValue.CT.getCode(), null, null, null,null, null,null,null,1, home_pagep_size);
+
+            }
+
+        }
+
+        return vos;
+    }
+
+
+    public List<AlarmStatVo> findWtFeatureStat(String stationId, String modelId, Date startTime, Date endTime, String components, String alarmIds, String alarmType, String timeType) {
+        List<AlarmStatVo> resultList = new ArrayList<>();
+
+        StringBuilder alarmIdList=new StringBuilder();
+        StringBuilder componentsList=new StringBuilder();
+
+        Map<String,String> alarmIdMap=new HashMap<>();
+        Map<String,String> componentsMap=new HashMap();
+
+        if(StringUtils.notEmp(components))
+        {
+            String [] componentsStr=components.split(",");
+            for(String c:componentsStr)
+            {
+                componentsList.append("'").append(c).append("',");
+                componentsMap.put(c,c);
+            }
+
+        }
+        if(StringUtils.notEmp(alarmIds))
+        {
+            String [] alarmIdStr=alarmIds.split(",");
+            for(String c:alarmIdStr)
+            {
+                alarmIdList.append("'").append(c).append("',");
+                alarmIdMap.put(c,c);
+            }
+
+        }
+        String alarmId=null;
+        String component=null;
+        if(alarmIdList.length()>0)
+        {
+             alarmId=String.valueOf(alarmIdList.substring(0,alarmIdList.length()-1));
+        }
+        if(componentsList.length()>0)
+        {
+            component=String.valueOf(componentsList.substring(0,componentsList.length()-1));
+        }
+        List<ProBasicFeatureStat> fsls = new ArrayList<>();
+        if(alarmType.equals(AlarmTypeValue.BT.getCode()))
+        {
+            fsls = alarmTsMapper.findWtFeatureStat(AlarmSuperTalbeType.BT.getCode(), startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId, alarmType);
+
+        }else if(alarmType.equals(AlarmTypeValue.WT.getCode()))
+        {
+            fsls = alarmTsMapper.findWtFeatureStat(AlarmSuperTalbeType.WT.getCode(),startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId, alarmType);
+        }else if(alarmType.equals(AlarmTypeValue.IN.getCode()))
+        {
+            fsls = alarmTsMapper.findWtFeatureStat(AlarmSuperTalbeType.WT.getCode(),startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId, alarmType);
+        }
+
+        Map<String, ProBasicFeatureStat> map = new HashMap<>();
+        Date statDate=DateUtils.truncate(new Date());
+
+        if (!fsls.isEmpty()) {
+            for (ProBasicFeatureStat fs : fsls) {
+                if (StringUtils.notEmp(fs.getTypeCode()) && CacheContext.alarmTypeMap.containsKey(fs.getTypeCode())) {
+                    ProEconAlarmType at = CacheContext.alarmTypeMap.get(fs.getTypeCode());
+                    fs.setTypeName(at.getName());
+                }
+                fs.setStatDate(new Timestamp(statDate.getTime()));
+                fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
+                StringBuilder sb = new StringBuilder();
+                sb.append(fs.getWtId()).append("_").append(fs.getAlarmid());
+                map.put(String.valueOf(sb), fs);
+            }
+        }
+        List<ProBasicFeatureStat> vos = new ArrayList<>();
+
+        if(CacheContext.wpwtmap.containsKey(stationId))
+        {
+            List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(stationId);
+            for (ProBasicEquipment wt : wtls) {
+
+                StringBuilder sb=new StringBuilder();
+                sb.append(wt.getWindpowerstationId()).append(wt.getModelId());
+                if(CacheContext.wtAlarmMap.containsKey(String.valueOf(sb))) {
+                    List<ProEconAlarmConfiguration> ls = CacheContext.wtAlarmMap.get(String.valueOf(sb));
+                    for (ProEconAlarmConfiguration at : ls) {
+                        if(StringUtils.notEmp(components) )
+                        {
+                            if(componentsMap.containsKey(at.getComponents()) )
+                            {
+                                if(StringUtils.notEmp(alarmIdMap) && !alarmIdMap.isEmpty())
+                                {
+                                    if( alarmIdMap.containsKey(at.getId()))
+                                    {
+                                        setWtValues(statDate, map, vos, wt, at);
+                                    }
+
+                                }else
+                                {
+                                    setWtValues(statDate, map, vos, wt, at);
+                                }
+                            }
+                        }else
+                        {
+                            setWtValues(statDate, map, vos, wt, at);
+                        }
+
+                    }
+                }
+            }
+        }
+
+
+        Map<String,List<AlarmStatVo>> vomap=new HashMap<>();
+        for(ProBasicFeatureStat fs:vos)
+        {
+            AlarmStatVo d = new AlarmStatVo();
+            d.setRelateParts(fs.getTypeCode());
+            d.setRelatePartsText(fs.getTypeName());
+            d.setAlertText(fs.getDescription());
+            d.setCount(fs.getTotal());
+
+            if(StringUtils.notEmp(timeType))
+            {
+                if(AlarmTime.H.getCode().equals(timeType))
+                {
+                    double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(360), 2, RoundingMode.HALF_EVEN).doubleValue();
+                    d.setTime(times);
+                }else if(AlarmTime.M.getCode().equals(timeType))
+                {
+                    double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                    d.setTime(times);
+                }else
+                {
+                    d.setTime(fs.getTotalSeconds());
+                }
+            }else
+            {
+                d.setTime(fs.getTotalSeconds());
+            }
+
+            d.setStationId(fs.getStationId());
+            d.setSnapId(SnowflakeGenerator.generateId());
+            d.setWindturbineId(fs.getWtId());
+            d.setAlarmid(fs.getAlarmid());
+            if(CacheContext.wtmap.containsKey(fs.getWtId()))
+            {
+                ProBasicEquipment wt= CacheContext.wtmap.get(fs.getWtId());
+                d.setWindturbineCode(wt.getNemCode());
+            }
+
+            StringBuilder sb=new StringBuilder();
+            sb.append(fs.getWtId()).append("_").append(fs.getTypeCode()).append("_").append(fs.getAlarmid());
+
+            if(map.containsKey(String.valueOf(sb)))
+            {
+                List<AlarmStatVo> ls=vomap.get(String.valueOf(sb));
+                ls.add(d);
+            }else
+            {
+                List<AlarmStatVo> ls=new ArrayList<>();
+                ls.add(d);
+                vomap.put(String.valueOf(sb),ls);
+            }
+            resultList.add(d);
+        }
+
+
+
+
+        return resultList;
+    }
+    private  static void setWtValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmConfiguration at) {
+
+        ProBasicFeatureStat fs = new ProBasicFeatureStat();
+
+        StringBuilder sb = new StringBuilder();
+        sb.append(wt.getId()).append("_").append(at.getId());
+        if (map.containsKey(String.valueOf(sb))) {
+            ProBasicFeatureStat old = map.get(String.valueOf(sb));
+            BeanUtil.copyProperties(old, fs);
+        } else {
+            fs.setStatDate(new Timestamp(statDate.getTime()));
+            fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
+            fs.setWtId(wt.getId());
+            fs.setStationId(wt.getWindpowerstationId());
+            fs.setTypeCode(at.getComponents());
+            if(CacheContext.alarmTypeMap.containsKey(at.getComponents()))
+            {
+                fs.setTypeName(CacheContext.alarmTypeMap.get(at.getComponents()).getName());
+            }
+            fs.setAlarmid(at.getId());
+            fs.setDescription(at.getDescription());
+            fs.setTotal(0l);
+            fs.setAvgSeconds(0.0);
+            fs.setMaxSeconds(0.0);
+            fs.setMinSeconds(0.0);
+            fs.setTotalSeconds(0.0);
+
+        }
+        vos.add(fs);
+    }
+
+    public List<AlarmStatVo> findCtFeatureStat(String stationId,String modelId, Date startTime, Date endTime,String components,String deviceType,String alarmIds,String timeType) {
+        List<AlarmStatVo> resultList = new ArrayList<>();
+
+
+        StringBuilder alarmIdList=new StringBuilder();
+        StringBuilder componentsList=new StringBuilder();
+
+        Map<String,String> alarmIdMap=new HashMap<>();
+        Map<String,String> componentsMap=new HashMap();
+
+        if(StringUtils.notEmp(components))
+        {
+            String [] componentsStr=components.split(",");
+            for(String c:componentsStr)
+            {
+                componentsList.append("'").append(c).append("',");
+                componentsMap.put(c,c);
+            }
+
+        }
+        if(StringUtils.notEmp(alarmIds))
+        {
+            String [] alarmIdStr=alarmIds.split(",");
+            for(String c:alarmIdStr)
+            {
+                alarmIdList.append("'").append(c).append("',");
+                alarmIdMap.put(c,c);
+            }
+
+        }
+        String alarmId=null;
+        String component=null;
+        if(alarmIdList.length()>0)
+        {
+            alarmId=String.valueOf(alarmIdList.substring(0,alarmIdList.length()-1));
+        }
+        if(componentsList.length()>0)
+        {
+            component=String.valueOf(componentsList.substring(0,componentsList.length()-1));
+        }
+        List<ProBasicFeatureStat> fsls = alarmTsMapper.findCtFeatureStat(startTime.getTime(), endTime.getTime(),stationId,modelId,component,alarmId,deviceType);
+
+
+        Map<String, ProBasicFeatureStat> map = new HashMap<>();
+        Date statDate=DateUtils.truncate(new Date());
+
+        if (!fsls.isEmpty()) {
+            for (ProBasicFeatureStat fs : fsls) {
+                if (StringUtils.notEmp(fs.getTypeCode()) && CacheContext.alarmTypeMap.containsKey(fs.getTypeCode())) {
+                    ProEconAlarmType at = CacheContext.alarmTypeMap.get(fs.getTypeCode());
+                    fs.setTypeName(at.getName());
+                }
+                fs.setStatDate(new Timestamp(statDate.getTime()));
+                fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
+                StringBuilder sb = new StringBuilder();
+                sb.append(fs.getWtId()).append("_").append(fs.getAlarmid());
+                map.put(String.valueOf(sb), fs);
+            }
+        }
+        List<ProBasicFeatureStat> vos = new ArrayList<>();
+
+        if(CacheContext.wpwtmap.containsKey(stationId))
+        {
+            List<ProBasicEquipment> wtls=CacheContext.wpwtmap.get(stationId);
+            for (ProBasicEquipment wt : wtls) {
+
+                StringBuilder sb=new StringBuilder();
+                sb.append(wt.getWindpowerstationId()).append(wt.getModelId());
+
+                if(CacheContext.ctAlarmlsMap.containsKey(String.valueOf(sb))) {
+
+                    List<ProEconAlarmRule> wtCustomls=CacheContext.ctAlarmlsMap.get(String.valueOf(sb));
+
+                    for (ProEconAlarmRule at : wtCustomls) {
+
+                        if(StringUtils.notEmp(components) )
+                        {
+                            if(componentsMap.containsKey(at.getRelatedParts()) )
+                            {
+                                if(StringUtils.notEmp(alarmIdMap) && !alarmIdMap.isEmpty())
+                                {
+                                    if( alarmIdMap.containsKey(at.getId()))
+                                    {
+                                        setCtValues(statDate, map, vos, wt, at);
+                                    }
+
+                                }else
+                                {
+                                    setCtValues(statDate, map, vos, wt, at);
+                                }
+                            }
+                        }else
+                        {
+                            setCtValues(statDate, map, vos, wt, at);
+                        }
+
+                    }
+
+                }
+            }
+        }
+
+
+        Map<String,List<AlarmStatVo>> vomap=new HashMap<>();
+        for(ProBasicFeatureStat fs:vos)
+        {
+            AlarmStatVo d = new AlarmStatVo();
+            d.setRelateParts(fs.getTypeCode());
+            d.setRelatePartsText(fs.getTypeName());
+            d.setAlertText(fs.getDescription());
+            d.setCount(fs.getTotal());
+            if(StringUtils.notEmp(timeType))
+            {
+                if(AlarmTime.H.getCode().equals(timeType))
+                {
+                    double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(360), 2, RoundingMode.HALF_EVEN).doubleValue();
+                    d.setTime(times);
+                }else if(AlarmTime.M.getCode().equals(timeType))
+                {
+                    double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                    d.setTime(times);
+                }else
+                {
+                    d.setTime(fs.getTotalSeconds());
+                }
+            }else
+            {
+                double times= new BigDecimal(fs.getTotalSeconds()).divide(new BigDecimal(60), 2, RoundingMode.HALF_EVEN).doubleValue();
+                d.setTime(times);
+            }
+            d.setStationId(fs.getStationId());
+            d.setSnapId(SnowflakeGenerator.generateId());
+            d.setWindturbineId(fs.getWtId());
+            if(CacheContext.wtmap.containsKey(fs.getWtId()))
+            {
+                ProBasicEquipment wt= CacheContext.wtmap.get(fs.getWtId());
+                d.setWindturbineCode(wt.getNemCode());
+            }
+
+            StringBuilder sb=new StringBuilder();
+            sb.append(fs.getWtId()).append("_").append(fs.getTypeCode()).append("_").append(fs.getAlarmid());
+
+            if(map.containsKey(String.valueOf(sb)))
+            {
+                List<AlarmStatVo> ls=vomap.get(String.valueOf(sb));
+                ls.add(d);
+            }else
+            {
+                List<AlarmStatVo> ls=new ArrayList<>();
+                ls.add(d);
+                vomap.put(String.valueOf(sb),ls);
+            }
+            resultList.add(d);
+        }
+
+
+        return resultList;
+    }
+    private  static void setCtValues(Date statDate,Map<String, ProBasicFeatureStat> map, List<ProBasicFeatureStat> vos, ProBasicEquipment wt, ProEconAlarmRule at) {
+
+        ProBasicFeatureStat fs = new ProBasicFeatureStat();
+
+        StringBuilder sb = new StringBuilder();
+        sb.append(fs.getWtId()).append("_").append(at.getId());
+        if (map.containsKey(String.valueOf(sb))) {
+            ProBasicFeatureStat old = map.get(String.valueOf(sb));
+            BeanUtil.copyProperties(old, fs);
+        } else {
+            fs.setStatDate(new Timestamp(statDate.getTime()));
+            fs.setId(String.valueOf(SnowflakeGenerator.generateId()));
+            fs.setWtId(wt.getId());
+            fs.setStationId(wt.getWindpowerstationId());
+            fs.setTypeCode(at.getCategory());
+            if(CacheContext.alarmTypeMap.containsKey(at.getCategory()))
+            {
+                fs.setTypeName(CacheContext.alarmTypeMap.get(at.getCategory()).getName());
+            }
+            fs.setAlarmid(at.getId());
+            fs.setDescription(at.getDescription());
+            fs.setTotal(0l);
+            fs.setAvgSeconds(0.0);
+            fs.setMaxSeconds(0.0);
+            fs.setMinSeconds(0.0);
+            fs.setTotalSeconds(0.0);
+
+        }
+        vos.add(fs);
+    }
+}

+ 132 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmInService.java

@@ -0,0 +1,132 @@
+package com.gyee.healthmodel.service;
+
+
+import com.gyee.common.model.StringUtils;
+import com.gyee.healthmodel.init.CacheContext;
+import com.gyee.healthmodel.model.auto.*;
+import com.gyee.healthmodel.model.vo.AlarmSuperTalbeType;
+import com.gyee.healthmodel.model.vo.AlarmTypeValue;
+import com.gyee.healthmodel.model.vo.AlarmVo;
+import com.gyee.healthmodel.service.auto.IAlarmTsService;
+import com.gyee.healthmodel.util.realtimesource.IEdosUtil;
+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;
+
+@Service
+
+public class AlarmInService {
+    @Resource
+    private IAlarmTsService alarmTsService;
+
+    @Value("${initialcode}")
+    private String initialcode;
+
+
+    @Resource
+    private IEdosUtil edosUtil;
+
+
+    public List<AlarmVo> initalAlarmVo() throws Exception {
+
+        List<AlarmVo> alarmVoList=new ArrayList<>();
+        Map<String, List<ProEconAlarmConfiguration>> wtAlarmMap = CacheContext.wtAlarmMap;
+        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
+        for (ProBasicEquipment wt : CacheContext.wtls) {
+
+            if(wt.getId().contains("_F_"))
+            {
+                continue;
+            }
+            if (wtpAimap.containsKey(wt.getId())) {
+                Map<String, ProBasicEquipmentPoint> pointMap = wtpAimap.get(wt.getId());
+
+                StringBuilder sb = new StringBuilder();
+                sb.append(wt.getWindpowerstationId() + wt.getModelId());
+                if (StringUtils.notEmp(pointMap) && wtAlarmMap.containsKey(String.valueOf(sb))) {
+                    List<ProEconAlarmConfiguration> alarmls = wtAlarmMap.get(String.valueOf(sb));
+
+                    if (!alarmls.isEmpty()) {
+                        for (ProEconAlarmConfiguration alarm : alarmls) {
+                            if (pointMap.containsKey(alarm.getUniformCode())) {
+                                ProBasicEquipmentPoint equipmentPoint = pointMap.get(alarm.getUniformCode());
+
+                                if(StringUtils.notEmp(initialcode) &&
+                                        StringUtils.notEmp(equipmentPoint.getNemCode()) &&
+                                        !equipmentPoint.getNemCode().equals(initialcode) &&
+                                        alarm.getAlarmType().equals(AlarmTypeValue.IN.getCode())
+                                )
+                                {
+                                    AlarmVo vo=new AlarmVo();
+                                    StringBuilder tbName = new StringBuilder();
+                                    tbName.append(wt.getId()).append("_").append(alarm.getId());
+                                    vo.setTbName(String.valueOf(tbName));
+                                    vo.setAlarmid(alarm.getId());
+                                    vo.setTagid(equipmentPoint.getNemCode());
+                                    vo.setAlarmtype(alarm.getAlarmType());
+                                    vo.setCharacteristic(alarm.getCharacteristic());
+                                    vo.setComponents(alarm.getComponents());
+                                    vo.setDescription(alarm.getDescription());
+                                    vo.setDeviceid(wt.getId());
+                                    vo.setDevicename(wt.getName());
+                                    vo.setDevicetype(alarm.getDeviceType());
+                                    vo.setEnabled(alarm.getEnable());
+                                    vo.setLineid(wt.getLineId());
+                                    if(CacheContext.lnmap.containsKey(wt.getLineId()))
+                                    {
+                                        ProBasicLine ln=CacheContext.lnmap.get(wt.getLineId());
+                                        vo.setLinename(ln.getName());
+                                    }
+                                    vo.setModelId(wt.getModelId());
+                                    vo.setProjectid(wt.getProjectId());
+                                    if(CacheContext.pjmap.containsKey(wt.getProjectId()))
+                                    {
+                                        ProBasicProject pj=CacheContext.pjmap.get(wt.getProjectId());
+                                        vo.setProjectname(pj.getName());
+                                    }
+                                    vo.setRank(alarm.getRank());
+                                    vo.setResettable(alarm.getResetTable());
+                                    vo.setStationid(wt.getWindpowerstationId());
+                                    if(CacheContext.wpmap.containsKey(wt.getWindpowerstationId()))
+                                    {
+                                        ProBasicPowerstation wp=CacheContext.wpmap.get(wt.getWindpowerstationId());
+                                        vo.setStationname(wp.getName());
+                                    }
+                                    vo.setSubcomponents(alarm.getSubcomponents());
+                                    vo.setSuffix(alarm.getSuffix());
+                                    vo.setTriggertype(alarm.getTriggerType());
+                                    vo.setUniformcode(alarm.getUniformCode());
+                                    vo.setSuperTableName(AlarmSuperTalbeType.WT.getCode());
+//                                    PointData temp=edosUtil.getRealData(equipmentPoint.getNemCode());
+//                                    vo.setVal((int)temp.getPointValueInDouble());
+//                                    vo.setOval((int)temp.getPointValueInDouble());
+
+                                    vo.setVal(null);
+                                    vo.setOval(null);
+                                    vo.setFaultType(alarm.getDeviceId());
+                                    vo.setAname(alarm.getSuffix());
+                                    vo.setName(alarm.getName());
+                                    vo.setNemCode(alarm.getNemCode());
+                                    vo.setFaultCause(alarm.getFaultCause());
+                                    vo.setResolvent(alarm.getResolvent());
+
+                                    alarmVoList.add(vo);
+                                }
+
+                            }
+
+                        }
+                    }
+                }
+            }
+
+        }
+        return  alarmVoList;
+    }
+
+
+}

+ 144 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmWtService.java

@@ -0,0 +1,144 @@
+package com.gyee.healthmodel.service;
+
+
+import com.gyee.healthmodel.init.CacheContext;
+import com.gyee.healthmodel.model.auto.*;
+import com.gyee.healthmodel.model.vo.AlarmSuperTalbeType;
+import com.gyee.healthmodel.model.vo.AlarmTypeValue;
+import com.gyee.healthmodel.model.vo.AlarmVo;
+import com.gyee.healthmodel.service.auto.IAlarmTsService;
+import com.gyee.healthmodel.util.StringUtils;
+import com.gyee.healthmodel.util.realtimesource.IEdosUtil;
+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.Map;
+
+@Service
+public class AlarmWtService {
+    @Resource
+    private IAlarmTsService alarmTsService;
+
+    @Value("${initialcode}")
+    private String initialcode;
+
+
+    @Resource
+    private IEdosUtil edosUtil;
+
+    private static Logger logger = LoggerFactory.getLogger(AlarmWtService.class);
+
+
+
+    public List<AlarmVo> initalAlarmVo() throws Exception {
+
+        List<AlarmVo> alarmVoList=new ArrayList<>();
+        Map<String, List<ProEconAlarmConfiguration>> wtAlarmMap = CacheContext.wtAlarmMap;
+        Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
+        for (ProBasicEquipment wt : CacheContext.wtls) {
+
+            if(wt.getId().contains("_G_"))
+            {
+                continue;
+            }
+
+            if (wtpAimap.containsKey(wt.getId())) {
+                Map<String, ProBasicEquipmentPoint> pointMap = wtpAimap.get(wt.getId());
+
+                StringBuilder sb = new StringBuilder();
+                sb.append(wt.getWindpowerstationId() + wt.getModelId());
+
+
+                if (StringUtils.notEmp(pointMap) && wtAlarmMap.containsKey(String.valueOf(sb))) {
+                    List<ProEconAlarmConfiguration> alarmls = wtAlarmMap.get(String.valueOf(sb));
+
+                    if (!alarmls.isEmpty()) {
+//                        System.out.println(wt.getId());
+                        for (ProEconAlarmConfiguration alarm : alarmls) {
+                            if (pointMap.containsKey(alarm.getUniformCode())) {
+                                ProBasicEquipmentPoint equipmentPoint = pointMap.get(alarm.getUniformCode());
+
+                                if(StringUtils.notEmp(initialcode) &&
+                                        StringUtils.notEmp(equipmentPoint.getNemCode()) &&
+                                        !equipmentPoint.getNemCode().equals(initialcode) &&
+                                        alarm.getAlarmType().equals(AlarmTypeValue.WT.getCode())
+                                )
+
+
+                                {
+
+//                                    System.out.println("ok");
+                                    AlarmVo vo=new AlarmVo();
+                                    StringBuilder tbName = new StringBuilder();
+                                    tbName.append(wt.getId()).append("_").append(alarm.getId());
+                                    vo.setTbName(String.valueOf(tbName));
+                                    vo.setAlarmId(alarm.getId());
+                                    vo.setTagid(equipmentPoint.getNemCode());
+                                    vo.setAlarmType(alarm.getAlarmType());
+                                    vo.setCharacteristic(alarm.getCharacteristic());
+                                    vo.setComponents(alarm.getComponents());
+                                    vo.setDescription(alarm.getDescription());
+                                    vo.setDeviceId(wt.getId());
+                                    vo.setDevicename(wt.getName());
+                                    vo.setDeviceType(alarm.getDeviceType());
+                                    vo.setEnabled(alarm.getEnable());
+                                    vo.setLineid(wt.getLineId());
+                                    if(CacheContext.lnmap.containsKey(wt.getLineId()))
+                                    {
+                                        ProBasicLine ln=CacheContext.lnmap.get(wt.getLineId());
+                                        vo.setLinename(ln.getName());
+                                    }
+                                    vo.setModelId(wt.getModelId());
+                                    vo.setProjectid(wt.getProjectId());
+                                    if(CacheContext.pjmap.containsKey(wt.getProjectId()))
+                                    {
+                                        ProBasicProject pj=CacheContext.pjmap.get(wt.getProjectId());
+                                        vo.setProjectname(pj.getName());
+                                    }
+                                    vo.setRank(alarm.getRank());
+                                    vo.setResettable(alarm.getResetTable());
+                                    vo.setStationid(wt.getWindpowerstationId());
+                                    if(CacheContext.wpmap.containsKey(wt.getWindpowerstationId()))
+                                    {
+                                        ProBasicPowerstation wp=CacheContext.wpmap.get(wt.getWindpowerstationId());
+                                        vo.setStationname(wp.getName());
+                                    }
+                                    vo.setSubcomponents(alarm.getSubcomponents());
+                                    vo.setSuffix(alarm.getSuffix());
+                                    vo.setTriggertype(alarm.getTriggerType());
+                                    vo.setUniformcode(alarm.getUniformCode());
+                                    vo.setSuperTableName(AlarmSuperTalbeType.WT.getCode());
+                                    vo.setFaultType(alarm.getDeviceId());
+                                    vo.setAname(alarm.getSuffix());
+//                                    PointData temp=edosUtil.getRealData(equipmentPoint.getNemCode());
+//                                    vo.setVal((int)temp.getPointValueInDouble());
+//                                    vo.setOval((int)temp.getPointValueInDouble());
+
+                                    vo.setVal(null);
+                                    vo.setOval(null);
+                                    vo.setName(alarm.getName());
+                                    vo.setNemCode(alarm.getNemCode());
+                                    vo.setFaultCause(alarm.getFaultCause());
+                                    vo.setResolvent(alarm.getResolvent());
+                                    alarmVoList.add(vo);
+                                }
+
+                            }
+
+                        }
+                    }
+                }
+            }
+
+        }
+        return  alarmVoList;
+    }
+
+
+
+}

+ 0 - 80
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmcountsService.java

@@ -1,80 +0,0 @@
-package com.gyee.healthmodel.service;
-
-import com.gyee.healthmodel.model.auto.Alarmcount;
-import com.gyee.healthmodel.service.auto.IAlarmcountService;
-import com.gyee.healthmodel.util.DateUtils;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @ClassName : AlarmcountsService
- * @Description : 自定义报警统计service
- */
-@Service
-public class AlarmcountsService {
-
-    private final int DIGIT=2;
-    @Resource
-    private IAlarmcountService alarmcountService;
-
-
-    public String findAlarmcount(Long snapid, Date beginDate,Date endDate)  {
-
-        List<Alarmcount> alarmlist = alarmcountService.findAlarmcount(snapid, DateUtils.truncate(beginDate),DateUtils.truncate(endDate));
-        if (!alarmlist.isEmpty()) {
-            for (int i = 0; i < alarmlist.size() - 1; i++) {
-                for (int j = alarmlist.size() - 1; j > i; j--) {
-                    if (alarmlist.get(i).getAlarmdate()
-                            .equals(alarmlist.get(j).getAlarmdate())
-                            && alarmlist.get(i).getSnapid()
-                            .equals(alarmlist.get(j).getSnapid())) {
-                        alarmlist.remove(j);
-                    }
-                }
-            }
-            double sumCount = 0;
-            double count = 0;
-            for (Alarmcount ac : alarmlist) {
-                sumCount += ac.getCount();
-                count++;
-
-            }
-
-            return sumCount + "," + count;
-        }
-        return "0.0,0.0";
-    }
-
-
-    public Double findyearstodayAlarmcount(Long snapid, Date beginDate,Date endDate)  {
-
-        List<Alarmcount> alarmlist = alarmcountService.findAlarmcount(snapid, DateUtils.truncate(beginDate),DateUtils.truncate(endDate));
-        if (!alarmlist.isEmpty()) {
-            for (int i = 0; i < alarmlist.size() - 1; i++) {
-                for (int j = alarmlist.size() - 1; j > i; j--) {
-                    if (alarmlist.get(i).getAlarmdate()
-                            .equals(alarmlist.get(j).getAlarmdate())
-                            && alarmlist.get(i).getSnapid()
-                            .equals(alarmlist.get(j).getSnapid())) {
-                        alarmlist.remove(j);
-                    }
-                }
-            }
-            double sumCount = 0;
-            for (Alarmcount ac : alarmlist) {
-
-                sumCount += ac.getCount();
-
-
-            }
-
-            return sumCount;
-        }
-        return 0.0;
-    }
-
-
-}

+ 0 - 35
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlarmsnapsService.java

@@ -1,35 +0,0 @@
-package com.gyee.healthmodel.service;
-
-import com.gyee.healthmodel.model.auto.Alarmsnap;
-import com.gyee.healthmodel.service.auto.IAlarmsnapService;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * @ClassName : CurvefittingmainsService
- * @Description : 风电机拟合曲线主表service
- */
-@Service
-public class AlarmsnapsService {
-
-    private final int DIGIT=2;
-    @Resource
-    private IAlarmsnapService alarmsnapService;
-
-
-
-    public Long getAlarmsnapid( String wtid,Long ednavalue) {
-
-        List<Alarmsnap> snapls = alarmsnapService.getAlarmsnapList(wtid,ednavalue);
-        if (!snapls.isEmpty()) {
-            return snapls.get(0).getId();
-        }
-        return 0l;
-    }
-
-
-
-
-}

+ 0 - 44
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/Alertrule2sService.java

@@ -1,44 +0,0 @@
-package com.gyee.healthmodel.service;
-
-import com.gyee.healthmodel.model.auto.Alertrule2;
-import com.gyee.healthmodel.service.auto.IAlertrule2Service;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @ClassName : Alertrule2sService
- * @Description : 自定义报警规则service
- */
-@Service
-public class Alertrule2sService {
-
-    private final int DIGIT=2;
-    @Resource
-    private IAlertrule2Service alertrule2Service;
-
-
-    public List<Alertrule2> findAlertRuleList(String station, String modelid)  {
-
-        List<Alertrule2> snapls = alertrule2Service.findAlertRuleList(station,modelid);
-        if (!snapls.isEmpty()) {
-            return snapls;
-        }
-        return new ArrayList<>();
-    }
-
-
-    public String getAlertRuleIdByName(String station, String modelid,String name)  {
-
-        List<Alertrule2> snapls = alertrule2Service.getAlertRuleIdByName(station,modelid,name);
-        if (snapls != null && snapls.size() > 0) {
-            return snapls.get(0).getId();
-        }
-        return null;
-    }
-
-
-
-}

+ 0 - 35
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/AlertrulefailuresubsService.java

@@ -1,35 +0,0 @@
-package com.gyee.healthmodel.service;
-
-import com.gyee.healthmodel.service.auto.IAlertrulefailuresubService;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @ClassName : CurvefittingmainsService
- * @Description : 风电机拟合曲线主表service
- */
-@Service
-public class AlertrulefailuresubsService {
-
-    private final int DIGIT=2;
-    @Resource
-    private IAlertrulefailuresubService alertrulefailuresubService;
-
-
-
-    public List<String> getPartByAlertruleid(String tid) {
-
-        List<String> ls = alertrulefailuresubService.getPartByAlertruleid(tid);
-        if (!ls.isEmpty()) {
-            return ls;
-        }
-        return new ArrayList<>();
-    }
-
-
-
-
-}

+ 60 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlarmTsService.java

@@ -0,0 +1,60 @@
+package com.gyee.healthmodel.service.auto;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.healthmodel.model.auto.AlarmTs;
+import com.gyee.healthmodel.model.vo.AlarmSimpleVo;
+import com.gyee.healthmodel.model.vo.AlarmTag;
+import com.gyee.healthmodel.model.vo.AlarmTsVo;
+import com.gyee.healthmodel.model.vo.AlarmVo;
+
+import java.util.List;
+
+
+public interface IAlarmTsService extends IService<AlarmTs> {
+
+    public void createSuperTable(String type);
+
+
+    public void dropSuperTable(String type);
+
+
+    public int createTable(AlarmVo vo) ;
+
+    public int createTable(String tbName, String alarmid, String alarmtype,
+                           String characteristic, String components,
+                           String description,
+                           String deviceid, String devicename,
+                           String devicetype, Boolean enabled,
+                           String lineid, String linename,
+                           String modelId, String projectid,
+                           String projectname, Integer rank,
+                           Boolean resettable, String stationid,
+                           String stationname, String subcomponents,
+                           String suffix, String tagid,
+                           Integer triggertype, String uniformcode,String superTableName
+
+    );
+
+
+
+    public int insertOne(AlarmTs one);
+
+
+
+
+    public void insertList(List<AlarmTag>  alarmTags ) ;
+
+    public void createSql(List<AlarmTag>  alarmTags )  ;
+
+
+    public List<AlarmVo> findTags(String stbaleName);
+
+    public List<AlarmTsVo> selectByWpGroup(String superTableName, String stationid, long begin, long end);
+
+
+    public   List<AlarmVo> selectByTbName(String tbName,long limit,long offset);
+
+    public List<AlarmSimpleVo> selectLastRowByTbname(String superTableName, String tbnames);
+}
+

+ 0 - 25
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlarmcountService.java

@@ -1,25 +0,0 @@
-package com.gyee.healthmodel.service.auto;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.gyee.healthmodel.model.auto.Alarmcount;
-import com.gyee.healthmodel.model.vo.AlarmcountVo;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * <p>
- *  服务类
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-public interface IAlarmcountService extends IService<Alarmcount> {
-
-      public List<Alarmcount> findAlarmcount(Long snapid, Date beginDate, Date endDate);
-      public List<AlarmcountVo> findAlarmCountByWt(String wtId, Date beginDate, Date endDate);
-
-      public List<AlarmcountVo> findAlarmCountByModelId(String modelId, Date beginDate, Date endDate);
-}
-

+ 0 - 21
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlarmsnapService.java

@@ -1,21 +0,0 @@
-package com.gyee.healthmodel.service.auto;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.gyee.healthmodel.model.auto.Alarmsnap;
-
-import java.util.List;
-
-/**
- * <p>
- *  服务类
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-public interface IAlarmsnapService extends IService<Alarmsnap> {
-
-    public List<Alarmsnap> getAlarmsnapList(String wtid,Long ednavalue);
-
-
-}

+ 0 - 22
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlertrule2Service.java

@@ -1,22 +0,0 @@
-package com.gyee.healthmodel.service.auto;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.gyee.healthmodel.model.auto.Alertrule2;
-
-import java.util.List;
-
-/**
- * <p>
- *  服务类
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-public interface IAlertrule2Service extends IService<Alertrule2> {
-
-    public List<Alertrule2> findAlertRuleList(String station, String modelid);
-
-    public List<Alertrule2> getAlertRuleIdByName(String station, String modelid,String name);
-
-}

+ 0 - 20
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlertrulefailureService.java

@@ -1,20 +0,0 @@
-package com.gyee.healthmodel.service.auto;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.gyee.healthmodel.model.auto.Alertrulefailure;
-
-import java.util.List;
-
-/**
- * <p>
- *  服务类
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-public interface IAlertrulefailureService extends IService<Alertrulefailure> {
-
-    public List<Alertrulefailure> getPartByAlertrule(String name,String model);
-
-}

+ 0 - 19
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlertrulefailuresubService.java

@@ -1,19 +0,0 @@
-package com.gyee.healthmodel.service.auto;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.gyee.healthmodel.model.auto.Alertrulefailuresub;
-
-import java.util.List;
-
-/**
- * <p>
- *  服务类
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-public interface IAlertrulefailuresubService extends IService<Alertrulefailuresub> {
-
-    public List<String> getPartByAlertruleid(String tid);
-}

+ 0 - 16
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IAlertrulesubService.java

@@ -1,16 +0,0 @@
-package com.gyee.healthmodel.service.auto;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.gyee.healthmodel.model.auto.Alertrulesub;
-
-/**
- * <p>
- *  服务类
- * </p>
- *
- * @author 石林
- * @since 2022-01-20
- */
-public interface IAlertrulesubService extends IService<Alertrulesub> {
-
-}

+ 21 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProBasicFeatureStatService.java

@@ -0,0 +1,21 @@
+package com.gyee.healthmodel.service.auto;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.healthmodel.model.auto.ProBasicFeatureStat;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 设备功能统计 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-14
+ */
+public interface IProBasicFeatureStatService extends IService<ProBasicFeatureStat> {
+
+    public List<ProBasicFeatureStat> searchByCondition(Date begin, Date end, String stationId,String wtId);
+}

+ 24 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconAlarmConfigurationService.java

@@ -0,0 +1,24 @@
+package com.gyee.healthmodel.service.auto;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.healthmodel.model.auto.ProEconAlarmConfiguration;
+
+/**
+ * <p>
+ * 报警配置表 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-06-19
+ */
+public interface IProEconAlarmConfigurationService extends IService<ProEconAlarmConfiguration> {
+
+
+    public IPage<ProEconAlarmConfiguration> pageQueryAll(Page page,
+                                                         String description,
+                                                         String wpId,
+                                                         String modelId, String alarmType);
+}

+ 17 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconAlarmRuleFailureService.java

@@ -0,0 +1,17 @@
+package com.gyee.healthmodel.service.auto;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.healthmodel.model.auto.ProEconAlarmRuleFailure;
+
+/**
+ * <p>
+ * 故障规则 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-10-04
+ */
+public interface IProEconAlarmRuleFailureService extends IService<ProEconAlarmRuleFailure> {
+
+}

+ 16 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconAlarmRuleService.java

@@ -0,0 +1,16 @@
+package com.gyee.healthmodel.service.auto;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.healthmodel.model.auto.ProEconAlarmRule;
+
+/**
+ * <p>
+ * 自定义报警配置 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+public interface IProEconAlarmRuleService extends IService<ProEconAlarmRule> {
+
+}

+ 17 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/IProEconAlarmTypeService.java

@@ -0,0 +1,17 @@
+package com.gyee.healthmodel.service.auto;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.healthmodel.model.auto.ProEconAlarmType;
+
+/**
+ * <p>
+ * 自定义类型 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+public interface IProEconAlarmTypeService extends IService<ProEconAlarmType> {
+
+}

+ 172 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlarmTsServiceImpl.java

@@ -0,0 +1,172 @@
+package com.gyee.healthmodel.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.healthmodel.mapper.auto.AlarmTsMapper;
+import com.gyee.healthmodel.model.auto.AlarmTs;
+import com.gyee.healthmodel.model.vo.AlarmSimpleVo;
+import com.gyee.healthmodel.model.vo.AlarmTag;
+import com.gyee.healthmodel.model.vo.AlarmTsVo;
+import com.gyee.healthmodel.model.vo.AlarmVo;
+import com.gyee.healthmodel.service.auto.IAlarmTsService;
+import com.gyee.healthmodel.util.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+
+@Service
+public class AlarmTsServiceImpl extends ServiceImpl<AlarmTsMapper, AlarmTs> implements IAlarmTsService {
+
+    @Resource
+    private AlarmTsMapper alarmTsMapper;
+
+
+
+    public void createSuperTable(String type) {
+
+        alarmTsMapper.createAlarmSuperTable(type);
+
+    }
+
+
+    public void dropSuperTable(String type) {
+
+        alarmTsMapper.dropSuperTable(type);
+
+    }
+
+    public int createTable(String tbName, String alarmid, String alarmtype,
+                           String characteristic, String components,
+                           String description,
+                           String deviceid, String devicename,
+                           String devicetype, Boolean enabled,
+                           String lineid, String linename,
+                           String modelId, String projectid,
+                           String projectname, Integer rank,
+                           Boolean resettable, String stationid,
+                           String stationname, String subcomponents,
+                           String suffix, String tagid,
+                           Integer triggertype, String uniformcode,String superTableName
+
+    ) {
+        return alarmTsMapper.createTable(tbName, alarmid, alarmtype,
+                characteristic, components,
+                description,
+                deviceid, devicename,
+                devicetype, enabled,
+                lineid, linename,
+                modelId, projectid,
+                projectname, rank,
+                resettable, stationid,
+                stationname, subcomponents,
+                suffix, tagid,
+                triggertype, uniformcode,superTableName);
+    }
+
+
+    public int createTable(AlarmVo vo) {
+        return alarmTsMapper.createTable(vo);
+    }
+
+
+
+    public int insertOne(AlarmTs one) {
+        return alarmTsMapper.insertOne(one);
+    }
+
+
+
+    public void insertList(List<AlarmTag>  alarmTags )  {
+
+        if(StringUtils.notEmp(alarmTags) && !alarmTags.isEmpty())
+        {
+
+            createSql(alarmTags);
+        }
+
+
+    }
+
+    public void createSql(List<AlarmTag>  alarmTags )   {
+
+        StringBuilder sb = new StringBuilder("INSERT INTO ");
+
+        int i=0;
+        for (AlarmTag tag:alarmTags) {
+
+
+            String tableName = tag.getId();
+            StringBuilder sub_sb = new StringBuilder(tableName);
+
+            sub_sb.append( " values ");
+            sub_sb.append(" (");
+            sub_sb.append(tag.getTs()).append(",").append(tag.getVal().intValue()).append(",").append(tag.getConfirmed()).append(",")
+                    .append(tag.getEndts()).append(",").append(tag.getTimeLong());
+            sub_sb.append(" ) ");
+            i++;
+            if (i==100) {
+                alarmTsMapper.insertList(String.valueOf(sb));
+                sb = new StringBuilder("INSERT INTO ");
+                i=0;
+            }
+            sb.append(sub_sb);
+
+        }
+
+        if(i!=0)
+        {
+            alarmTsMapper.insertList(String.valueOf(sb));
+        }
+
+    }
+    public List<AlarmVo> findTags(String stbaleName)
+    {
+        List<AlarmVo> ls=new ArrayList<>();
+        if(StringUtils.notEmp(stbaleName))
+        {
+           ls= alarmTsMapper.findTags(stbaleName);
+        }
+
+        return ls;
+    }
+
+    @Override
+    public List<AlarmTsVo> selectByWpGroup(String superTableName, String stationid, long begin, long end) {
+        List<AlarmTsVo> ls=new ArrayList<>();
+        if(StringUtils.notEmp(superTableName) && StringUtils.notEmp(stationid) && StringUtils.notEmp(begin) && StringUtils.notEmp(end))
+        {
+            ls= alarmTsMapper.selectByWpGroup(superTableName, stationid, begin, end);
+        }
+
+        return ls;
+    }
+
+
+
+    public   List<AlarmVo> selectByTbName(String tbName,long limit,long offset)
+    {
+        List<AlarmVo> ls=new ArrayList<>();
+        if(StringUtils.notEmp(tbName) && StringUtils.notEmp(limit) && StringUtils.notEmp(offset))
+        {
+            ls= alarmTsMapper.selectByTbName(tbName, limit, offset);
+        }
+
+        return ls;
+    }
+
+    public List<AlarmSimpleVo> selectLastRowByTbname(String superTableName, String tbnames){
+        List<AlarmSimpleVo> ls=new ArrayList<>();
+        if(StringUtils.notEmp(superTableName) && StringUtils.notEmp(tbnames))
+        {
+            StringBuilder sb=new StringBuilder();
+            sb.append("select last_row(*),tbname from ").append(superTableName).append(" where tbname in( ").append(tbnames).append(" ) group by tbname");
+
+            ls= alarmTsMapper.selectLastRowByTbname(String.valueOf(sb));
+        }
+
+        return ls;
+    }
+}

+ 0 - 44
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlarmcountServiceImpl.java

@@ -1,44 +0,0 @@
-package com.gyee.healthmodel.service.auto.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.gyee.healthmodel.mapper.auto.AlarmcountMapper;
-import com.gyee.healthmodel.model.auto.Alarmcount;
-import com.gyee.healthmodel.model.vo.AlarmcountVo;
-import com.gyee.healthmodel.service.auto.IAlarmcountService;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-@Service
-public class AlarmcountServiceImpl extends ServiceImpl<AlarmcountMapper, Alarmcount> implements IAlarmcountService {
-
-    @Resource
-    private AlarmcountMapper alarmcountMapper;
-
-    @Override
-    public List<Alarmcount> findAlarmcount(Long snapid, Date beginDate, Date endDate)
-    {
-        return alarmcountMapper.findAlarmcount(snapid, beginDate, endDate);
-    }
-
-    @Override
-    public List<AlarmcountVo> findAlarmCountByWt(String wtId, Date beginDate, Date endDate)
-    {
-        return alarmcountMapper.findAlarmCountByWt(wtId, beginDate, endDate);
-    }
-    @Override
-    public List<AlarmcountVo> findAlarmCountByModelId(String modelId, Date beginDate, Date endDate)
-    {
-        return alarmcountMapper.findAlarmCountByModelId(modelId, beginDate, endDate);
-    }
-}

+ 0 - 33
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlarmsnapServiceImpl.java

@@ -1,33 +0,0 @@
-package com.gyee.healthmodel.service.auto.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.gyee.healthmodel.mapper.auto.AlarmsnapMapper;
-import com.gyee.healthmodel.model.auto.Alarmsnap;
-import com.gyee.healthmodel.service.auto.IAlarmsnapService;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-@Service
-public class AlarmsnapServiceImpl extends ServiceImpl<AlarmsnapMapper, Alarmsnap> implements IAlarmsnapService {
-
-
-    @Resource
-    private AlarmsnapMapper alarmsnapMapper;
-
-    @Override
-    public List<Alarmsnap> getAlarmsnapList(String wtid,Long ednavalue)
-    {
-        return  alarmsnapMapper.getAlarmsnapList( wtid, ednavalue);
-    }
-
-}

+ 0 - 36
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/Alertrule2ServiceImpl.java

@@ -1,36 +0,0 @@
-package com.gyee.healthmodel.service.auto.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.gyee.healthmodel.mapper.auto.Alertrule2Mapper;
-import com.gyee.healthmodel.model.auto.Alertrule2;
-import com.gyee.healthmodel.service.auto.IAlertrule2Service;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-@Service
-public class Alertrule2ServiceImpl extends ServiceImpl<Alertrule2Mapper, Alertrule2> implements IAlertrule2Service {
-
-    @Resource
-    private Alertrule2Mapper alertrule2Mapper;
-    @Override
-     public List<Alertrule2> findAlertRuleList(String station, String modelid) {
-        return  alertrule2Mapper.findAlertRuleList(station, modelid);
-    }
-
-    @Override
-    public List<Alertrule2> getAlertRuleIdByName(String station, String modelid,String name) {
-        return  alertrule2Mapper.getAlertRuleIdByName(station, modelid,name);
-    }
-
-
-}

+ 0 - 33
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlertrulefailureServiceImpl.java

@@ -1,33 +0,0 @@
-package com.gyee.healthmodel.service.auto.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.gyee.healthmodel.mapper.auto.AlertrulefailureMapper;
-import com.gyee.healthmodel.model.auto.Alertrulefailure;
-import com.gyee.healthmodel.service.auto.IAlertrulefailureService;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-@Service
-public class AlertrulefailureServiceImpl extends ServiceImpl<AlertrulefailureMapper, Alertrulefailure> implements IAlertrulefailureService {
-
-    @Resource
-    private AlertrulefailureMapper alertrulefailureMapper;
-    @Override
-    public List<Alertrulefailure> getPartByAlertrule(String name, String model)
-    {
-        return alertrulefailureMapper.getPartByAlertrule(name,model);
-    }
-
-
-
-}

+ 0 - 31
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlertrulefailuresubServiceImpl.java

@@ -1,31 +0,0 @@
-package com.gyee.healthmodel.service.auto.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.gyee.healthmodel.mapper.auto.AlertrulefailuresubMapper;
-import com.gyee.healthmodel.model.auto.Alertrulefailuresub;
-import com.gyee.healthmodel.service.auto.IAlertrulefailuresubService;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.List;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author 石林
- * @since 2022-01-21
- */
-@Service
-public class AlertrulefailuresubServiceImpl extends ServiceImpl<AlertrulefailuresubMapper, Alertrulefailuresub> implements IAlertrulefailuresubService {
-
-    @Resource
-    private AlertrulefailuresubMapper alertrulefailuresubMapper;
-
-    @Override
-    public List<String> getPartByAlertruleid(String tid)
-    {
-        return  alertrulefailuresubMapper.getPartByAlertruleid(tid);
-    }
-}

+ 0 - 20
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/AlertrulesubServiceImpl.java

@@ -1,20 +0,0 @@
-package com.gyee.healthmodel.service.auto.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.gyee.healthmodel.mapper.auto.AlertrulesubMapper;
-import com.gyee.healthmodel.model.auto.Alertrulesub;
-import com.gyee.healthmodel.service.auto.IAlertrulesubService;
-import org.springframework.stereotype.Service;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author 石林
- * @since 2022-01-20
- */
-@Service
-public class AlertrulesubServiceImpl extends ServiceImpl<AlertrulesubMapper, Alertrulesub> implements IAlertrulesubService {
-
-}

+ 40 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProBasicFeatureStatServiceImpl.java

@@ -0,0 +1,40 @@
+package com.gyee.healthmodel.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.healthmodel.mapper.auto.ProBasicFeatureStatMapper;
+import com.gyee.healthmodel.model.auto.ProBasicFeatureStat;
+import com.gyee.healthmodel.service.auto.IProBasicFeatureStatService;
+import com.gyee.healthmodel.util.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 设备功能统计 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-14
+ */
+@Service
+public class ProBasicFeatureStatServiceImpl extends ServiceImpl<ProBasicFeatureStatMapper, ProBasicFeatureStat> implements IProBasicFeatureStatService {
+
+    @Resource
+    private ProBasicFeatureStatMapper proBasicFeatureStatMapper;
+
+    public List<ProBasicFeatureStat> searchByCondition(Date begin, Date end, String stationId,String wtId)
+    {
+        List<ProBasicFeatureStat> ls=new ArrayList<>();
+
+        if(StringUtils.notEmp(begin) && StringUtils.notEmp(end) && StringUtils.notEmp(end))
+        {
+            ls=proBasicFeatureStatMapper.searchByCondition(begin,end,stationId,wtId);
+        }
+        return  ls;
+    }
+}

+ 42 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconAlarmConfigurationServiceImpl.java

@@ -0,0 +1,42 @@
+package com.gyee.healthmodel.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.healthmodel.mapper.auto.ProEconAlarmConfigurationMapper;
+import com.gyee.healthmodel.model.auto.ProEconAlarmConfiguration;
+import com.gyee.healthmodel.service.auto.IProEconAlarmConfigurationService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * <p>
+ * 报警配置表 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-06-19
+ */
+@Service
+public class ProEconAlarmConfigurationServiceImpl extends ServiceImpl<ProEconAlarmConfigurationMapper, ProEconAlarmConfiguration> implements IProEconAlarmConfigurationService {
+
+    @Resource
+    private  ProEconAlarmConfigurationMapper proEconAlarmConfigurationMapper;
+
+    public IPage<ProEconAlarmConfiguration> pageQueryAll(Page page,
+                                                         String description,
+                                                         String wpId,
+                                                         String modelId, String alarmType)
+    {
+        IPage<ProEconAlarmConfiguration> pages=  proEconAlarmConfigurationMapper.pageQueryAll(page,
+                description,
+                 wpId,
+                 modelId, alarmType);
+
+        return pages;
+    }
+
+
+}

+ 21 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconAlarmRuleFailureServiceImpl.java

@@ -0,0 +1,21 @@
+package com.gyee.healthmodel.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.healthmodel.mapper.auto.ProEconAlarmRuleFailureMapper;
+import com.gyee.healthmodel.model.auto.ProEconAlarmRuleFailure;
+import com.gyee.healthmodel.service.auto.IProEconAlarmRuleFailureService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 故障规则 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-10-04
+ */
+@Service
+public class ProEconAlarmRuleFailureServiceImpl extends ServiceImpl<ProEconAlarmRuleFailureMapper, ProEconAlarmRuleFailure> implements IProEconAlarmRuleFailureService {
+
+}

+ 21 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconAlarmRuleServiceImpl.java

@@ -0,0 +1,21 @@
+package com.gyee.healthmodel.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.healthmodel.mapper.auto.ProEconAlarmRuleMapper;
+import com.gyee.healthmodel.model.auto.ProEconAlarmRule;
+import com.gyee.healthmodel.service.auto.IProEconAlarmRuleService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 自定义报警配置 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@Service
+public class ProEconAlarmRuleServiceImpl extends ServiceImpl<ProEconAlarmRuleMapper, ProEconAlarmRule> implements IProEconAlarmRuleService {
+
+}

+ 21 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/service/auto/impl/ProEconAlarmTypeServiceImpl.java

@@ -0,0 +1,21 @@
+package com.gyee.healthmodel.service.auto.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.healthmodel.mapper.auto.ProEconAlarmTypeMapper;
+import com.gyee.healthmodel.model.auto.ProEconAlarmType;
+import com.gyee.healthmodel.service.auto.IProEconAlarmTypeService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 自定义类型 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@Service
+public class ProEconAlarmTypeServiceImpl extends ServiceImpl<ProEconAlarmTypeMapper, ProEconAlarmType> implements IProEconAlarmTypeService {
+
+}

+ 161 - 0
realtime/healthmodel-server/src/main/java/com/gyee/healthmodel/util/SnowflakeGenerator.java

@@ -0,0 +1,161 @@
+package com.gyee.healthmodel.util;
+
+/**
+ * Twitter_Snowflake<br>
+ * SnowFlake的结构如下(每部分用-分开):<br>
+ * 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>
+ * 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br>
+ * 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截)
+ * 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>
+ * 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br>
+ * 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号<br>
+ * 加起来刚好64位,为一个Long型。<br>
+ * SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。
+ */
+public class SnowflakeGenerator {
+
+    // ==============================Fields===========================================
+    /** 开始时间截 (2015-01-01) */
+    private final long twepoch = 1420041600000L;
+
+    /** 机器id所占的位数 */
+    private final long workerIdBits = 5L;
+
+    /** 数据标识id所占的位数 */
+    private final long datacenterIdBits = 5L;
+
+    /** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
+    private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
+
+    /** 支持的最大数据标识id,结果是31 */
+    private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
+
+    /** 序列在id中占的位数 */
+    private final long sequenceBits = 12L;
+
+    /** 机器ID向左移12位 */
+    private final long workerIdShift = sequenceBits;
+
+    /** 数据标识id向左移17位(12+5) */
+    private final long datacenterIdShift = sequenceBits + workerIdBits;
+
+    /** 时间截向左移22位(5+5+12) */
+    private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
+
+    /** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */
+    private final long sequenceMask = -1L ^ (-1L << sequenceBits);
+
+    /** 工作机器ID(0~31) */
+    private long workerId;
+
+    /** 数据中心ID(0~31) */
+    private long datacenterId;
+
+    /** 毫秒内序列(0~4095) */
+    private long sequence = 0L;
+
+    /** 上次生成ID的时间截 */
+    private long lastTimestamp = -1L;
+
+    //==============================Constructors=====================================
+    /**
+     * 构造函数
+     * @param workerId 工作ID (0~31)
+     * @param datacenterId 数据中心ID (0~31)
+     */
+    public SnowflakeGenerator(long workerId, long datacenterId) {
+        if (workerId > maxWorkerId || workerId < 0) {
+            throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
+        }
+        if (datacenterId > maxDatacenterId || datacenterId < 0) {
+            throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
+        }
+        this.workerId = workerId;
+        this.datacenterId = datacenterId;
+    }
+
+    // ==============================Methods==========================================
+    /**
+     * 获得下一个ID (该方法是线程安全的)
+     * @return SnowflakeId
+     */
+    public synchronized long nextId() {
+        long timestamp = timeGen();
+
+        //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
+        if (timestamp < lastTimestamp) {
+            throw new RuntimeException(
+                    String.format("Clock moved backwards.  Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
+        }
+
+        //如果是同一时间生成的,则进行毫秒内序列
+        if (lastTimestamp == timestamp) {
+            sequence = (sequence + 1) & sequenceMask;
+            //毫秒内序列溢出
+            if (sequence == 0) {
+                //阻塞到下一个毫秒,获得新的时间戳
+                timestamp = tilNextMillis(lastTimestamp);
+            }
+        }
+        //时间戳改变,毫秒内序列重置
+        else {
+            sequence = 0L;
+        }
+
+        //上次生成ID的时间截
+        lastTimestamp = timestamp;
+
+        //移位并通过或运算拼到一起组成64位的ID
+        return ((timestamp - twepoch) << timestampLeftShift) //
+                | (datacenterId << datacenterIdShift) //
+                | (workerId << workerIdShift) //
+                | sequence;
+    }
+
+    /**
+     * 阻塞到下一个毫秒,直到获得新的时间戳
+     * @param lastTimestamp 上次生成ID的时间截
+     * @return 当前时间戳
+     */
+    protected long tilNextMillis(long lastTimestamp) {
+        long timestamp = timeGen();
+        while (timestamp <= lastTimestamp) {
+            timestamp = timeGen();
+        }
+        return timestamp;
+    }
+
+    /**
+     * 返回以毫秒为单位的当前时间
+     * @return 当前时间(毫秒)
+     */
+    protected long timeGen() {
+        return System.currentTimeMillis();
+    }
+
+
+    private static SnowflakeGenerator idWorker = null;
+
+    public synchronized static SnowflakeGenerator getIdWorker() {
+
+        if (idWorker == null)
+            idWorker = new SnowflakeGenerator(2, 3);
+
+        return idWorker;
+    }
+
+    public static long generateId() {
+        //if (idWorker == null)
+            //idWorker = new SnowflakeGenerator(0, 0);
+
+        //return idWorker.nextId();
+        SnowflakeGenerator snowflakeGenerator = getIdWorker();
+
+        return snowflakeGenerator.nextId();
+//        for (int i = 0; i < 1000; i++) {
+//            long id = idWorker.nextId();
+//            System.out.println(Long.toBinaryString(id));
+//            System.out.println(id);
+//        }
+    }
+}