|
@@ -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 = "";
|
|
|
// 统计单位
|