Przeglądaj źródła

实时 数据调整

guoqiang 7 miesięcy temu
rodzic
commit
69f9f50ec7

+ 15 - 5
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java

@@ -66,7 +66,7 @@ public class LeanModelStatistics {
     @Scheduled(cron = "0 0 03 * * *")
 //    @Scheduled(fixedDelay = 1000)
     public void t2(){
-        changeProportion();
+//        changeProportion();
     } // 1ms
     public void changeProportion(){
         log.info("变更占比");
@@ -113,7 +113,7 @@ public class LeanModelStatistics {
 
     @Scheduled(fixedDelay = 500)
     public void t3(){
-        deviceStatistics("500");
+//        deviceStatistics("500");
     } // 1ms
     // 设备启停统计数据
     public void deviceStatistics(String freq) {
@@ -324,7 +324,10 @@ public class LeanModelStatistics {
                     } else if("month". equals(fpgLeanModeInfo.getTotalUnit())){ // 月
                         finalDatestr = new SimpleDateFormat("yyyy-MM").format(fpgGatherData.getCreateTime());
                     } else if("real_time". equals(fpgLeanModeInfo.getTotalUnit())){ // 实时
-                        finalDatestr = new SimpleDateFormat("yyyy-MM-dd HH:ii:ss").format(fpgGatherData.getCreateTime());
+                        fpgLeanModeInfo.setProportion(2);
+                        fpgLeanModeInfo.setElectricCurrent(2);
+                        fpgLeanModeInfo.setRunTime(2);
+                        finalDatestr = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(fpgGatherData.getCreateTime());
                     }
                     String dayDate = new SimpleDateFormat("yyyy-MM-dd").format(fpgGatherData.getCreateTime());
                     String classs = "";
@@ -341,6 +344,15 @@ public class LeanModelStatistics {
                             classs = "center";
                         }
                     }
+                    // 重组对象
+                    FpgStatiscsModelData fpgStatiscsModelData = new FpgStatiscsModelData(fpgGatherData, fpgLeanModeInfo, finalDatestr, dayDate, classs, curentDate, curentDate);
+                    // 实时统计直接插入
+                    if("real_time". equals(fpgLeanModeInfo.getTotalUnit())){
+                        fpgStatiscsModelData.setSelectricCurrent(fpgGatherData.getRunCurrent());
+                        fpgStatiscsModelData.setPower(fpgGatherData.getActivePower());
+                        mongoTemplate.insert(fpgStatiscsModelData, "leanmodel_" + fpgLeanModeInfo.getLeanModelCode());
+                        return;
+                    }
                     // 定义尖峰平谷
                     AtomicReference<String> jfpgStr = new AtomicReference<>("");
                     // 判断尖峰平谷时段
@@ -350,8 +362,6 @@ public class LeanModelStatistics {
                             return;
                         }
                     });
-                    // 重组对象
-                    FpgStatiscsModelData fpgStatiscsModelData = new FpgStatiscsModelData(fpgGatherData, fpgLeanModeInfo, finalDatestr, dayDate, classs, curentDate, curentDate);
                     // 组合mongodb条件
                     Query query = new Query();
                     query.addCriteria(Criteria.where("devicePointId").is(fpgGatherData.getDevicePointId())).addCriteria(Criteria.where("dates").is(dayDate)).addCriteria(Criteria.where("datestr").is(finalDatestr));

+ 12 - 6
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgStatiscsModelData.java

@@ -33,6 +33,9 @@ public class FpgStatiscsModelData{
     /**运行时长*/
     @ApiModelProperty(value = "运行时长")
     private BigDecimal ingTime;
+    /**运行电流*/
+    @ApiModelProperty(value = "运行电流")
+    private BigDecimal selectricCurrent;
     /**运行总功率*/
     @ApiModelProperty(value = "运行总功率")
     private BigDecimal power;
@@ -134,12 +137,15 @@ public class FpgStatiscsModelData{
             this.deviceInformationId = fpgGather.getDeviceInformationId(); // 设备id
         }
         this.devicePointId = fpgGather.getDevicePointId(); // 采集点id
-        this.ingTime = new BigDecimal("0.00"); // 累计时长
-        this.power = new BigDecimal("0.00"); // 累计功率
-        this.topsPower = new BigDecimal("0.00"); // 尖功率
-        this.peaksPower = new BigDecimal("0.00"); // 峰功率
-        this.flatPower = new BigDecimal("0.00"); // 平功率
-        this.valleysPower = new BigDecimal("0.00"); // 谷功率
+        this.ingTime = new BigDecimal("0.00"); // 运行时长
+        this.power = new BigDecimal("0.00"); // 运行功率
+        this.selectricCurrent = new BigDecimal("0.00"); // 运行电流
+        if(!"real_time".equals(fpgLeanModel.getTotalUnit())){ // 非实时存储
+            this.topsPower = new BigDecimal("0.00"); // 尖功率
+            this.peaksPower = new BigDecimal("0.00"); // 峰功率
+            this.flatPower = new BigDecimal("0.00"); // 平功率
+            this.valleysPower = new BigDecimal("0.00"); // 谷功率
+        }
         if(fpgLeanModel.getClassUnit() != null && fpgLeanModel.getClassUnit() == 1){ // 班次统计
             this.classs = classs;
         }

+ 3 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgStatiscsModelMongodb.java

@@ -30,6 +30,9 @@ public class FpgStatiscsModelMongodb {
     /**产生费用*/
     @ApiModelProperty(value = "产生费用")
     private BigDecimal amount;
+    /**运行电流*/
+    @ApiModelProperty(value = "运行电流")
+    private BigDecimal selectricCurrent;
 	/**运行时长*/
     @ApiModelProperty(value = "运行时长")
     private BigDecimal ingTime;