guoqiang 7 hónapja
szülő
commit
508cc4fd6f

+ 30 - 4
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java

@@ -2,6 +2,8 @@ package org.jeecg.modules.fpgJob;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.device.entity.DeviceInformation;
+import org.jeecg.modules.device.service.IDeviceInformationService;
 import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
 import org.jeecg.modules.fpgJob.service.IFpgLeanModelService;
 import org.jeecg.modules.gatherData.entity.FpgGatherData;
@@ -18,6 +20,7 @@ import org.springframework.data.mongodb.core.query.Update;
 import org.springframework.data.mongodb.core.query.UpdateDefinition;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
@@ -33,7 +36,7 @@ import java.util.concurrent.atomic.AtomicReference;
 @Slf4j
 @EnableAsync
 @Component
-//@EnableScheduling
+@EnableScheduling
 public class LeanModelStatistics {
 
     @Autowired
@@ -42,6 +45,9 @@ public class LeanModelStatistics {
     @Autowired
     IFpgGatherDataService fpgGatherDataService;
 
+    @Autowired
+    IDeviceInformationService deviceInformationService;
+
     @Autowired
     private IPeaksAndValleysTimeConfigService peaksAndValleysTimeConfigService;
 
@@ -100,6 +106,26 @@ public class LeanModelStatistics {
         });
     }
 
+    @Scheduled(fixedDelay = 1000)
+    public void t2(){
+        leanModel("1000");
+    } // 1ms
+    // 设备启停统计数据
+    public void startStop(String freq) {
+        log.info("设备启停");
+        // 峰平谷精益模型配置获取
+//        LambdaQueryWrapper<DeviceInformation> leanmodelQuery = new LambdaQueryWrapper<DeviceInformation>().eq(DeviceInformation::getDeviceCode, "");
+//        List<DeviceInformation> deviceInformationllist = deviceInformationService.list(leanmodelQuery);
+//        //遍历设备集合
+//        deviceInformationllist.forEach(deviceInformationlinfo -> {
+//            LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().eq(FpgGatherData::getFpgModelState, "0");
+//            // 检测是否配置设备特殊条件
+//            if(!fpgLeanModeInfo.getDeviceInformationIds().isEmpty()){
+//                fpgGatherQuery.in(FpgGatherData::getDeviceInformationId, Arrays.asList(fpgLeanModeInfo.getDeviceInformationIds().split(",")));
+//            }
+//            List<FpgGatherData> fpgGatherList = fpgGatherDataService.list(fpgGatherQuery);
+//        });
+    }
     @Scheduled(fixedDelay = 1000)
     public void t1(){
         leanModel("1000");
@@ -107,10 +133,10 @@ public class LeanModelStatistics {
 
     // 精益模型统计数据
     public void leanModel(String freq){
+        log.info("峰平谷模型");
         // 峰平谷精益模型配置获取
         LambdaQueryWrapper<FpgLeanModel> leanmodelQuery = new LambdaQueryWrapper<FpgLeanModel>().eq(FpgLeanModel::getStatus, "1");
         List<FpgLeanModel> fpgLeanModellist = fpgLeanModelService.list(leanmodelQuery);
-        log.info("峰平谷模型");
         // 获取当前时间
         Date curentDate = new Date(new Date().getTime() + 8 * 60 * 60 * 1000);
         // 尖峰平谷时段配置
@@ -119,7 +145,7 @@ public class LeanModelStatistics {
         fpgLeanModellist.forEach(fpgLeanModeInfo -> {
             LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().eq(FpgGatherData::getFpgModelState, "0");
             // 检测是否配置设备特殊条件
-            if(!fpgLeanModeInfo.getDeviceInformationIds().isEmpty()){
+            if(fpgLeanModeInfo.getDeviceInformationIds() != null && !fpgLeanModeInfo.getDeviceInformationIds().isEmpty()){
                 fpgGatherQuery.in(FpgGatherData::getDeviceInformationId, Arrays.asList(fpgLeanModeInfo.getDeviceInformationIds().split(",")));
             }
             List<FpgGatherData> fpgGatherList = fpgGatherDataService.list(fpgGatherQuery);
@@ -127,7 +153,7 @@ public class LeanModelStatistics {
             fpgGatherList.forEach(fpgGatherData -> { // 循环处理采集数据处理
                 try {
                     // 变更记录状态
-                    fpgGatherData.setFpgModelState("1");
+//                    fpgGatherData.setFpgModelState("1");
                     fpgGatherDataService.updateById(fpgGatherData);
                     String finalDatestr = "";
                     // 统计单位

+ 8 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgStatiscsModelData.java

@@ -27,6 +27,12 @@ public class FpgStatiscsModelData{
     /**设备id*/
     @ApiModelProperty(value = "设备id")
     private String deviceInformationId;
+    /**设备启动时间*/
+    @ApiModelProperty(value = "设备启动时间")
+    private Date deviceStartTime;
+    /**设备关停时间*/
+    @ApiModelProperty(value = "设备关停时间")
+    private Date deviceStopTime;
     /**产生费用*/
     @ApiModelProperty(value = "产生费用")
     private BigDecimal amount;
@@ -181,6 +187,8 @@ public class FpgStatiscsModelData{
         if(fpgLeanModel.getTopsPrice() != null || fpgLeanModel.getPeaksPrice() != null || fpgLeanModel.getFlatPrice() != null || fpgLeanModel.getValleysPrice() != null){
             this.amount = new BigDecimal("0.00");
         }
+        this.deviceStartTime = createTime;
+        this.deviceStopTime = createTime;
         this.dates = dates;
         this.datestr = datestr;
         this.createTime = createTime;

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

@@ -27,6 +27,12 @@ public class FpgStatiscsModelMongodb {
 	/**设备id*/
     @ApiModelProperty(value = "设备id")
     private String deviceInformationId;
+    /**设备启动时间*/
+    @ApiModelProperty(value = "设备启动时间")
+    private String deviceStartTime;
+    /**设备关停时间*/
+    @ApiModelProperty(value = "设备关停时间")
+    private String deviceStopTime;
     /**产生费用*/
     @ApiModelProperty(value = "产生费用")
     private BigDecimal amount;

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

@@ -102,7 +102,6 @@ public class OpcGatherWatch {
         opc("60000");
     }
 
-
     //opc数据采集
     public void opc(String freq){
         // 获取所有运行中设备(峰平谷)