Browse Source

调整 数据统计 峰平谷

guoqiang 5 months ago
parent
commit
4e945c4cf6

+ 11 - 18
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java

@@ -71,8 +71,8 @@ public class LeanModelStatistics {
      * 精益模型统计数据
      * 执行完后,间隔1秒继续执行
      */
-//    @Scheduled(cron = "0 */1 * * * ?")
-    @Scheduled(cron = "*/30 * * * * ?")
+    @Scheduled(cron = "0 */1 * * * ?")
+//    @Scheduled(cron = "*/30 * * * * ?")
     public void t1(){
         leanModel();
     }
@@ -90,8 +90,8 @@ public class LeanModelStatistics {
     /**
      * 设备启停统计数据
      */
-//    @Scheduled(cron = "0 */1 * * * ?")
-    @Scheduled(cron = "*/30 * * * * ?")
+    @Scheduled(cron = "0 */1 * * * ?")
+//    @Scheduled(cron = "*/30 * * * * ?")
     public void t3(){
         deviceStatistics();
     }
@@ -164,13 +164,6 @@ public class LeanModelStatistics {
             fpgGatherList.forEach(fpgGatherData -> { // 循环处理采集数据处理
                 try {
                     fpgGatherData.setFpgTotalUpdatetime(new Date());
-                    // -数情况直接退出
-                    if (fpgGatherData.getActivePower().compareTo(BigDecimal.ZERO) < 0) {
-                        // 执行完成数据 标记已处理
-                        fpgGatherData.setId(fpgGatherData.getId());
-                        fpgGatherDataService.updateById(fpgGatherData);
-                        return;
-                    }
                     // 采集时间
                     Instant instant = fpgGatherData.getCreateTime().toInstant();
                     LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
@@ -194,7 +187,7 @@ public class LeanModelStatistics {
                         }
                     });
                     // 功率
-                    BigDecimal runPower = fpgGatherData.getActivePower().compareTo(new BigDecimal("0.00")) > 0 ? fpgGatherData.getActivePower().divide(new BigDecimal(12), 8, RoundingMode.HALF_UP) : fpgGatherData.getActivePower();
+                    BigDecimal runPower = fpgGatherData.getActivePower().compareTo(new BigDecimal("0.00")) > 0 ? fpgGatherData.getActivePower().divide(new BigDecimal(12), 8, RoundingMode.HALF_UP) : new BigDecimal("0.00");
                     // 占比
                     BigDecimal proportion = new BigDecimal("0.00");
                     // 运行时常
@@ -426,11 +419,6 @@ public class LeanModelStatistics {
                     return;
                 }
                 try {
-                    // 设备停止运行不统计
-                    if (fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) < 0) { // 设备停止运行
-                        fpgGatherUpdateList.add(fpgGatherData);
-                        return;
-                    }
                     String finalDatestr = "";
                     // 统计单位
                     if("minute".equals(fpgLeanModeInfo.getTotalUnit())){ // 分钟
@@ -477,6 +465,11 @@ public class LeanModelStatistics {
                         fpgGatherUpdateList.add(fpgGatherData);
                         return;
                     }
+                    // 设备停止运行不统计
+                    if (fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) < 0) { // 设备停止运行
+                        fpgGatherUpdateList.add(fpgGatherData);
+                        return;
+                    }
                     // 定义尖峰平谷
                     AtomicReference<String> jfpgStr = new AtomicReference<>("");
                     // 判断尖峰平谷时段
@@ -512,7 +505,7 @@ public class LeanModelStatistics {
 
                     FpgStatiscsModelMongodb fpgStatiscsModelMongo = mongoTemplate.findOne(query, FpgStatiscsModelMongodb.class, collectionName);
                     // 功率
-                    BigDecimal activePower =  fpgGatherData.getActivePower().compareTo(new BigDecimal("0.00")) > 0 ? fpgGatherData.getActivePower().divide(new BigDecimal("12"), 8, RoundingMode.HALF_UP) : fpgGatherData.getActivePower();
+                    BigDecimal activePower =  fpgGatherData.getActivePower().compareTo(new BigDecimal("0.00")) > 0 ? fpgGatherData.getActivePower().divide(new BigDecimal("12"), 8, RoundingMode.HALF_UP) : new BigDecimal("0.00");
                     // 电流
                     BigDecimal selectricCurrent = fpgGatherData.getRunCurrent() == null ? new BigDecimal("0.00") : fpgGatherData.getRunCurrent();
                     // 运行时常