Selaa lähdekoodia

峰平谷模型

guoqiang 7 kuukautta sitten
vanhempi
sitoutus
b11e5aad31

+ 36 - 10
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java

@@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
 import org.jeecg.modules.fpgJob.service.IFpgLeanModelService;
+import org.jeecg.modules.gatherData.entity.FpgGatherData;
+import org.jeecg.modules.gatherData.entity.FpgStatiscsModelData;
+import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -11,6 +14,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
+import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.List;
 
@@ -23,6 +27,9 @@ public class LeanModelStatistics {
     @Autowired
     IFpgLeanModelService fpgLeanModelService;
 
+    @Autowired
+    IFpgGatherDataService fpgGatherDataService;
+
     @Autowired
     MongoTemplate mongoTemplate;
 
@@ -38,24 +45,43 @@ public class LeanModelStatistics {
     public void opc(String freq){
         // 峰平谷精益模型配置获取
         LambdaQueryWrapper<FpgLeanModel> leanmodelQuery = new LambdaQueryWrapper<FpgLeanModel>().eq(FpgLeanModel::getStatus, "1");
-        List<FpgLeanModel> opclist = fpgLeanModelService.list(leanmodelQuery);
+        List<FpgLeanModel> fpgLeanModellist = fpgLeanModelService.list(leanmodelQuery);
         log.info("峰平谷模型");
-
         //获取当前时间
         Date curentDate = new Date();
-      /*  //遍历设备集合
-        opclist.forEach(opcConn -> {
-            //获取设备下所有点位
-            List<DevicePoint> opcPoints = devicePointService.list( new LambdaQueryWrapper<DevicePoint>().eq(DevicePoint::getDeviceId,opcConn.getId()));
-            OpcUaClient opcUaClient = null;
-            String readText = "";
+        //遍历设备集合
+        fpgLeanModellist.forEach(fpgLeanModeInfo -> {
+            String datestr = "";
+            String classs = "night";
             try {
-
+                // 统计单位
+                if("hour". equals(fpgLeanModeInfo.getTotalUnit())){ // 小时
+                    datestr = new SimpleDateFormat("H").format(curentDate);
+                } else if("day". equals(fpgLeanModeInfo.getTotalUnit())){ //
+                    datestr = new SimpleDateFormat("dd").format(curentDate);
+                } else if("week". equals(fpgLeanModeInfo.getTotalUnit())){ //
+                    datestr = new SimpleDateFormat("").format(curentDate);
+                } else if("month". equals(fpgLeanModeInfo.getTotalUnit())){ //
+                    datestr = new SimpleDateFormat("MM").format(curentDate);
+                }
+                // 班次处理
+                if(fpgLeanModeInfo.getClassUnit() == 1){ // 开启了班次统计
+                    if("night". equals(fpgLeanModeInfo.getTotalUnit())){ // 夜班
+                        classs = "";
+                    } else if("white". equals(fpgLeanModeInfo.getTotalUnit())){ // 白班
+                        classs = "";
+                    } else if("center". equals(fpgLeanModeInfo.getTotalUnit())){ // 中班
+                        classs = "";
+                    }
+                }
+                FpgGatherData FpgGatherData = fpgGatherDataService.getById("1836591252581129108");
+                //将点位数据存入mongo中
+                mongoTemplate.insert(new FpgStatiscsModelData(FpgGatherData, fpgLeanModeInfo, datestr,  new SimpleDateFormat("yyyy-MM-dd").format(curentDate), classs, curentDate, curentDate),  fpgLeanModeInfo.getLeanModelCode());
             } catch (Exception e) {
                 log.error(e.getMessage());
             } finally {
 
             }
-        });*/
+        });
     }
 }

+ 1 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/entity/FpgLeanModel.java

@@ -75,7 +75,7 @@ public class FpgLeanModel implements Serializable {
 	@Excel(name = "班次 1", width = 15)
     @Dict(dicCode = "lean_model_class")
     @ApiModelProperty(value = "班次 1")
-    private String classUnit;
+    private Integer classUnit;
 	/**尖计费单价(元)*/
 	@Excel(name = "尖计费单价(元)", width = 15)
     @ApiModelProperty(value = "尖计费单价(元)")

+ 44 - 5
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgStatiscsModelData.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.gatherData.entity;
 
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -101,21 +102,59 @@ public class FpgStatiscsModelData{
     /**日期*/
     @ApiModelProperty(value = "日期")
     private String dates;
+    /**统计单位存储对应时间格式*/
+    @ApiModelProperty(value = "日期")
+    private String datestr;
     /**创建时间*/
     @ApiModelProperty(value = "创建时间")
     private Date createTime;
 
     // 峰平谷精益模型数据统计
-    public void fpgStatisticsModelData(FpgStatiscsModelData fpgGather, String fpgType, String classs, BigDecimal amount, String dates, Date createTime, Date updateTime) {
+
+    public FpgStatiscsModelData(FpgGatherData fpgGather, FpgLeanModel fpgLeanModel, String datestr, String dates, String classs, Date createTime, Date updateTime) {
+
         // 基础信息配置
         this.deviceRegionId = fpgGather.getDeviceRegionId(); // 区域id
         this.deviceInformationId = fpgGather.getDeviceInformationId(); // 设备id
         this.devicePointId = fpgGather.getDevicePointId(); // 采集点id
-        this.ingTime = fpgGather.getIngTime(); // 运行时常
-        this.power = fpgGather.getPower();
-        this.classs = classs;
-        this.amount = amount;
+        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"); // 谷功率
+        if(fpgLeanModel.getClassUnit() == 1){ // 班次统计
+            this.classs = classs;
+        }
+        if(fpgLeanModel.getProportion() == 1){ // 占比统计
+            this.topsProportion = new BigDecimal("0.00");
+            this.peaksProportion = new BigDecimal("0.00");
+            this.flatProportion = new BigDecimal("0.00");
+            this.valleysProportion = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getRunTime() == 1){ // 运行时长统计
+            this.topsIngTime = new BigDecimal("0.00");
+            this.peaksIngTime = new BigDecimal("0.00");
+            this.flatIngTime = new BigDecimal("0.00");
+            this.valleysIngTime = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getPeaksPrice() != null){ // 峰单价电费
+            this.peaksPrice = fpgLeanModel.getPeaksPrice();
+            this.topsAmount = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getFlatPrice() != null){ // 平单价电费
+            this.flatPrice = fpgLeanModel.getFlatPrice();
+            this.flatAmount = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getValleysPrice() != null){ // 谷单价电费
+            this.valleysPrice = fpgLeanModel.getValleysPrice();
+            this.valleysAmount = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getTopsPrice() != null || fpgLeanModel.getPeaksPrice() != null || fpgLeanModel.getFlatPrice() != null || fpgLeanModel.getValleysPrice() != null){
+            this.amount = new BigDecimal("0.00");
+        }
         this.dates = dates;
+        this.datestr = datestr;
         this.createTime = createTime;
         this.updateTime = updateTime;
     }

+ 1 - 2
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/DbWatch.java

@@ -16,11 +16,10 @@ import org.springframework.stereotype.Component;
 
 import java.util.Calendar;
 
-//@EnableScheduling
 @EnableAsync
 @Component
 @Slf4j
-
+//@EnableScheduling
 public class DbWatch {
 
 

+ 1 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java

@@ -26,10 +26,10 @@ import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
-//@EnableScheduling
 @Slf4j
 @EnableAsync
 @Component
+//@EnableScheduling
 
 public class OpcGatherWatch {
 

+ 1 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/modBusGatherWatch.java

@@ -19,10 +19,10 @@ import org.springframework.stereotype.Component;
 import java.util.Date;
 import java.util.List;
 
-//@EnableScheduling
 @Slf4j
 @EnableAsync
 @Component
+//@EnableScheduling
 
 public class modBusGatherWatch {
 

+ 1 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/s7gatherWatch.java

@@ -21,10 +21,10 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
-//@EnableScheduling
 @EnableAsync
 @Component
 @Slf4j
+//@EnableScheduling
 
 public class s7gatherWatch {