|
@@ -1,6 +1,7 @@
|
|
|
package org.jeecg.modules.fpgJob;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
@@ -14,7 +15,9 @@ import org.jeecg.modules.fpgJob.service.IFpgLeanModelService;
|
|
|
import org.jeecg.modules.gatherData.entity.*;
|
|
|
import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
|
|
|
import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
|
|
|
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.SystemVariable;
|
|
|
import org.jeecg.modules.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
|
|
|
+import org.jeecg.modules.peaksAndValleysTimeConfig.service.ISystemVariableService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
@@ -57,6 +60,9 @@ public class LeanModelStatistics {
|
|
|
@Autowired
|
|
|
private IPeaksAndValleysTimeConfigService peaksAndValleysTimeConfigService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISystemVariableService systemVariableService;
|
|
|
+
|
|
|
@Autowired
|
|
|
MongoTemplate mongoTemplate;
|
|
|
|
|
@@ -65,7 +71,7 @@ public class LeanModelStatistics {
|
|
|
* 精益模型统计数据
|
|
|
* 执行完后,间隔1秒继续执行
|
|
|
*/
|
|
|
- @Scheduled(fixedDelay = 1000)
|
|
|
+ @Scheduled(fixedDelay = 10000)
|
|
|
public void t1(){
|
|
|
leanModel();
|
|
|
}
|
|
@@ -83,7 +89,7 @@ public class LeanModelStatistics {
|
|
|
/**
|
|
|
* 设备启停统计数据
|
|
|
*/
|
|
|
- @Scheduled(fixedDelay = 1000)
|
|
|
+ @Scheduled(fixedDelay = 10000)
|
|
|
public void t3(){
|
|
|
deviceStatistics();
|
|
|
}
|
|
@@ -150,8 +156,15 @@ public class LeanModelStatistics {
|
|
|
// 采集点组合
|
|
|
// List<String> idsPoint = devicePointList.stream().map(DevicePoint::getId).collect(Collectors.toList());
|
|
|
// 查询设备对应数据
|
|
|
- LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().eq(FpgGatherData::getFpgTotalUpdatetime, null).in(FpgGatherData::getDeviceInformationId, deviceInformationlinfo.getId());
|
|
|
+ LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().isNull(FpgGatherData::getFpgTotalUpdatetime).eq(FpgGatherData::getDeviceInformationId, deviceInformationlinfo.getId());
|
|
|
List<FpgGatherData> fpgGatherList = fpgGatherDataService.list(fpgGatherQuery);
|
|
|
+
|
|
|
+ // 系统变量查询
|
|
|
+ QueryWrapper<SystemVariable> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("variable_address", "sys_run_current_limit");
|
|
|
+ queryWrapper.eq("status", 0);
|
|
|
+ SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
|
|
|
+
|
|
|
// 处理数据业务逻辑
|
|
|
fpgGatherList.forEach(fpgGatherData -> { // 循环处理采集数据处理
|
|
|
try {
|
|
@@ -178,7 +191,7 @@ public class LeanModelStatistics {
|
|
|
}
|
|
|
});
|
|
|
// 功率
|
|
|
- BigDecimal runPower = fpgGatherData.getActivePower();
|
|
|
+ BigDecimal runPower = fpgGatherData.getActivePower().compareTo(new BigDecimal("0.00")) > 0 ? fpgGatherData.getActivePower().divide(new BigDecimal(12), 6, RoundingMode.HALF_UP) : fpgGatherData.getActivePower();
|
|
|
// 运行时常
|
|
|
BigDecimal runTime = new BigDecimal("300");
|
|
|
// 电流
|
|
@@ -191,7 +204,7 @@ public class LeanModelStatistics {
|
|
|
.addCriteria(Criteria.where("deviceRegionId").is(fpgGatherData.getDeviceRegionId()))
|
|
|
.addCriteria(Criteria.where("deviceInformationId").is(fpgGatherData.getDeviceInformationId()));
|
|
|
// 设备停止 start
|
|
|
- if(fpgGatherData.getRunCurrent().compareTo(new BigDecimal("5")) < 0){ // 设备停止运行 直接更新停止时间结束不用统计任何东西
|
|
|
+ if(fpgGatherData.getRunCurrent().compareTo(new BigDecimal(systemVariable.getDefaultValue())) < 0){ // 设备停止运行 直接更新停止时间结束不用统计任何东西
|
|
|
// queryStartStop.addCriteria(Criteria.where("deviceStopTime").is(null));
|
|
|
UpdateDefinition updateStartStop = new Update()
|
|
|
.set("updateTime", curentDate).set("deviceStopTime", DateUtils.date2Str(curentDate, DateUtils.datetimeFormat.get()));
|
|
@@ -207,7 +220,7 @@ public class LeanModelStatistics {
|
|
|
BigDecimal oldSelectricCurrent = startStopMongo.getSelectricCurrent() == null ? new BigDecimal("0.00") : startStopMongo.getSelectricCurrent();
|
|
|
// 更新启动运行数据
|
|
|
UpdateDefinition updateStartStop = new Update()
|
|
|
- .set("power", oldPower.add(runPower.divide(new BigDecimal("12"))))
|
|
|
+ .set("power", runPower.compareTo(new BigDecimal("0.00")) > 0 ? oldPower.add(runPower) : 0.00)
|
|
|
.set("selectricCurrent", oldSelectricCurrent.add(selectricCurrent))
|
|
|
.set("ingTime", oldRunTime.add(runTime))
|
|
|
.set("updateTime", curentDate);
|
|
@@ -239,7 +252,7 @@ public class LeanModelStatistics {
|
|
|
if("tops".equals(jfpgStr.get())){ // 尖
|
|
|
// 功率处理
|
|
|
BigDecimal oldtopsPower = dayPowerproportioncurrentMongo.getTopsPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getTopsPower();
|
|
|
- BigDecimal topsPower = oldtopsPower.add(runPower.divide(new BigDecimal("12")));
|
|
|
+ BigDecimal topsPower = oldtopsPower.add(runPower);
|
|
|
((Update) update).set("topsPower", topsPower);
|
|
|
// 运行时常处理
|
|
|
BigDecimal oldtopsIngTime = dayPowerproportioncurrentMongo.getTopsIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getTopsIngTime();
|
|
@@ -251,7 +264,7 @@ public class LeanModelStatistics {
|
|
|
} else if("peaks".equals(jfpgStr.get())){ // 峰
|
|
|
// 功率处理
|
|
|
BigDecimal oldpeaksPower = dayPowerproportioncurrentMongo.getPeaksPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getPeaksPower();
|
|
|
- BigDecimal peaksPower = oldpeaksPower.add(runPower.divide(new BigDecimal("12")));
|
|
|
+ BigDecimal peaksPower = oldpeaksPower.add(runPower);
|
|
|
((Update) update).set("peaksPower", peaksPower);
|
|
|
// 运行时常处理
|
|
|
BigDecimal oldpeaksIngTime = dayPowerproportioncurrentMongo.getPeaksIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getPeaksIngTime();
|
|
@@ -263,7 +276,7 @@ public class LeanModelStatistics {
|
|
|
} else if("flat".equals(jfpgStr.get())){ // 平
|
|
|
// 功率处理
|
|
|
BigDecimal oldflatPower = dayPowerproportioncurrentMongo.getFlatPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getFlatPower();
|
|
|
- BigDecimal flatPower = oldflatPower.add(runPower.divide(new BigDecimal("12")));
|
|
|
+ BigDecimal flatPower = oldflatPower.add(runPower);
|
|
|
((Update) update).set("flatPower", flatPower);
|
|
|
// 运行时常处理
|
|
|
BigDecimal oldflatIngTime = dayPowerproportioncurrentMongo.getFlatIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getFlatIngTime();
|
|
@@ -275,7 +288,7 @@ public class LeanModelStatistics {
|
|
|
} else if("valleys".equals(jfpgStr.get())){ // 谷
|
|
|
// 功率处理
|
|
|
BigDecimal oldvalleysPower = dayPowerproportioncurrentMongo.getValleysPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getValleysPower();
|
|
|
- BigDecimal valleysPower = oldvalleysPower.add(runPower.divide(new BigDecimal("12")));
|
|
|
+ BigDecimal valleysPower = oldvalleysPower.add(runPower);
|
|
|
((Update) update).set("valleysPower", oldvalleysPower.add(runPower));
|
|
|
// 运行时常处理
|
|
|
BigDecimal oldvalleysIngTime = dayPowerproportioncurrentMongo.getValleysIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getValleysIngTime();
|
|
@@ -316,7 +329,7 @@ public class LeanModelStatistics {
|
|
|
List<FpgGatherData> fpgGatherUpdateList= new ArrayList<>();
|
|
|
// 遍历设备集合
|
|
|
fpgLeanModellist.forEach(fpgLeanModeInfo -> {
|
|
|
- LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().eq(FpgGatherData::getFpgModelUpdatetime, null);
|
|
|
+ LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().isNull(FpgGatherData::getFpgModelUpdatetime);
|
|
|
// 检测是否配置设备特殊条件
|
|
|
if(oConvertUtils.isNotEmpty(fpgLeanModeInfo.getDeviceInformationIds()) && oConvertUtils.isNotEmpty(fpgLeanModeInfo.getDeviceInformationIds())){
|
|
|
fpgGatherQuery.in(FpgGatherData::getDeviceInformationId, Arrays.asList(fpgLeanModeInfo.getDeviceInformationIds().split(",")));
|
|
@@ -398,7 +411,7 @@ public class LeanModelStatistics {
|
|
|
UpdateDefinition update = new Update();
|
|
|
((Update) update).set("updateTime", curentDate);
|
|
|
// 功率 5 分钟上报一次 除以 12
|
|
|
- BigDecimal activePower = fpgGatherData.getActivePower() == null ? new BigDecimal("0.00") : fpgGatherData.getActivePower().divide(new BigDecimal("12"));
|
|
|
+ BigDecimal activePower = fpgGatherData.getActivePower() == null ? new BigDecimal("0.00") : fpgGatherData.getActivePower().divide(new BigDecimal("12"), 6, RoundingMode.HALF_UP);
|
|
|
// 电流
|
|
|
BigDecimal selectricCurrent = fpgGatherData.getRunCurrent() == null ? new BigDecimal("0.00") : fpgGatherData.getRunCurrent();
|
|
|
BigDecimal runTime = new BigDecimal("300");
|