|
@@ -2,14 +2,14 @@ package org.jeecg.modules.fpgJob;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.device.entity.DeviceInformation;
|
|
|
import org.jeecg.modules.device.service.IDeviceInformationService;
|
|
|
+import org.jeecg.modules.devicePoint.entity.DevicePoint;
|
|
|
+import org.jeecg.modules.devicePoint.service.IDevicePointService;
|
|
|
import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
|
|
|
import org.jeecg.modules.fpgJob.service.IFpgLeanModelService;
|
|
|
-import org.jeecg.modules.gatherData.entity.DeviceStatiscsModelData;
|
|
|
-import org.jeecg.modules.gatherData.entity.FpgGatherData;
|
|
|
-import org.jeecg.modules.gatherData.entity.FpgStatiscsModelData;
|
|
|
-import org.jeecg.modules.gatherData.entity.FpgStatiscsModelMongodb;
|
|
|
+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.service.IPeaksAndValleysTimeConfigService;
|
|
@@ -32,6 +32,7 @@ import java.time.*;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
@@ -46,6 +47,9 @@ public class LeanModelStatistics {
|
|
|
@Autowired
|
|
|
IFpgGatherDataService fpgGatherDataService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ IDevicePointService devicePointService;
|
|
|
+
|
|
|
@Autowired
|
|
|
IDeviceInformationService deviceInformationService;
|
|
|
|
|
@@ -61,9 +65,9 @@ public class LeanModelStatistics {
|
|
|
// 每日3点执行 测试期间1ms一次
|
|
|
@Scheduled(cron = "0 0 03 * * *")
|
|
|
// @Scheduled(fixedDelay = 1000)
|
|
|
-// public void t2(){
|
|
|
-// changeProportion("1000");
|
|
|
-// } // 1ms
|
|
|
+ public void t2(){
|
|
|
+ changeProportion();
|
|
|
+ } // 1ms
|
|
|
public void changeProportion(){
|
|
|
log.info("变更占比");
|
|
|
// 峰平谷精益模型配置获取
|
|
@@ -107,20 +111,31 @@ public class LeanModelStatistics {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- @Scheduled(fixedDelay = 1000)
|
|
|
- public void t2(){
|
|
|
- leanModel("1000");
|
|
|
+ @Scheduled(fixedDelay = 500)
|
|
|
+ public void t3(){
|
|
|
+ deviceStatistics("500");
|
|
|
} // 1ms
|
|
|
// 设备启停统计数据
|
|
|
- public void startStop(String freq) {
|
|
|
- log.info("设备启停");
|
|
|
+ public void deviceStatistics(String freq) {
|
|
|
+ log.info("设备日常统计");
|
|
|
// 获取当前时间
|
|
|
Date curentDate = new Date(new Date().getTime() + 8 * 60 * 60 * 1000);
|
|
|
// 峰平谷精益模型配置获取
|
|
|
List<DeviceInformation> deviceInformationllist = deviceInformationService.list();
|
|
|
+ // 尖峰平谷时段配置
|
|
|
+ List<PeaksAndValleysTimeConfig> peaksAndValleysTimeConfiglist = peaksAndValleysTimeConfigService.list();
|
|
|
+ BigDecimal zb = new BigDecimal("100");
|
|
|
//遍历设备集合
|
|
|
deviceInformationllist.forEach(deviceInformationlinfo -> {
|
|
|
- LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().eq(FpgGatherData::getFpgModelState, "0");
|
|
|
+ // 查询采集点
|
|
|
+ LambdaQueryWrapper<DevicePoint> devicePointQuery = new LambdaQueryWrapper<DevicePoint>().eq(DevicePoint::getDeviceId, deviceInformationlinfo.getId());
|
|
|
+ List<DevicePoint> devicePointList = devicePointService.list(devicePointQuery);
|
|
|
+ if(devicePointList == null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 采集点组合
|
|
|
+ List<String> idsPoint = devicePointList.stream().map(DevicePoint::getId).collect(Collectors.toList());
|
|
|
+ LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().eq(FpgGatherData::getFpgModelState, "0").in(FpgGatherData::getDevicePointId, idsPoint);
|
|
|
List<FpgGatherData> fpgGatherList = fpgGatherDataService.list(fpgGatherQuery);
|
|
|
// 处理数据业务逻辑
|
|
|
fpgGatherList.forEach(fpgGatherData -> { // 循环处理采集数据处理
|
|
@@ -139,45 +154,128 @@ public class LeanModelStatistics {
|
|
|
} else if (containsCreateTime(localDateTime, dayDate + " 16:00:00", dayDate + " 23:59:59")) { // 中班
|
|
|
classs = "center";
|
|
|
}
|
|
|
+ // 定义尖峰平谷
|
|
|
+ AtomicReference<String> jfpgStr = new AtomicReference<>("");
|
|
|
+ // 判断尖峰平谷时段
|
|
|
+ peaksAndValleysTimeConfiglist.forEach(peaksAndValleysTimeConfig -> {
|
|
|
+ if (containsCreateTime(localDateTime, dayDate + " " + peaksAndValleysTimeConfig.getStartTime(), dayDate + " " + peaksAndValleysTimeConfig.getEndTime())) {
|
|
|
+ jfpgStr.set(peaksAndValleysTimeConfig.getType());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 功率
|
|
|
+ BigDecimal runPower = fpgGatherData.getActivePower();
|
|
|
+ // 运行时常
|
|
|
+ BigDecimal runTime = new BigDecimal("1");
|
|
|
+ // 电流
|
|
|
+ BigDecimal selectricCurrent = fpgGatherData.getRunCurrent();
|
|
|
// 设备启停统计 start
|
|
|
- String startStopMonKey = "leanmodel_start_stop_total";
|
|
|
- DeviceStatiscsModelData startStopStatiscsModelData = new DeviceStatiscsModelData(fpgGatherData, "startstop_total", dayDate, classs, curentDate, curentDate);
|
|
|
+ String startStopMonKey = "total_startstop";
|
|
|
+ DeviceStatiscsModelData startStopStatiscsData = new DeviceStatiscsModelData(fpgGatherData, startStopMonKey, dayDate, classs, curentDate, curentDate);
|
|
|
// 组合mongodb条件
|
|
|
Query queryStartStop = new Query()
|
|
|
.addCriteria(Criteria.where("deviceRegionId").is(fpgGatherData.getDeviceRegionId())).addCriteria(Criteria.where("deviceInformationId").is(fpgGatherData.getDeviceInformationId()));
|
|
|
// 设备停止
|
|
|
- if(fpgGatherData.getRunCurrent().compareTo(new BigDecimal("0.00")) < 5){ // 设备停止运行 直接更新停止时间结束不用统计任何东西
|
|
|
- queryStartStop.addCriteria(Criteria.where("deviceStopTime").is(null));
|
|
|
+ if(fpgGatherData.getRunCurrent().compareTo(new BigDecimal("5")) < 0){ // 设备停止运行 直接更新停止时间结束不用统计任何东西
|
|
|
+// queryStartStop.addCriteria(Criteria.where("deviceStopTime").is(null));
|
|
|
UpdateDefinition updateStartStop = new Update()
|
|
|
- .set("updateTime", curentDate);
|
|
|
- mongoTemplate.updateFirst(queryStartStop, updateStartStop, FpgStatiscsModelMongodb.class, startStopMonKey);
|
|
|
+ .set("updateTime", curentDate).set("deviceStopTime", DateUtils.date2Str(curentDate, DateUtils.datetimeFormat.get()));
|
|
|
+ mongoTemplate.updateFirst(queryStartStop, updateStartStop, DeviceStatiscsModelMongodb.class, startStopMonKey);
|
|
|
return;
|
|
|
} else { // 设备运行状态
|
|
|
// 查找上一次运行记录
|
|
|
- FpgStatiscsModelMongodb startStopMongo = mongoTemplate.findOne(queryStartStop, FpgStatiscsModelMongodb.class, startStopMonKey);
|
|
|
+ DeviceStatiscsModelMongodb startStopMongo = mongoTemplate.findOne(queryStartStop, DeviceStatiscsModelMongodb.class, startStopMonKey);
|
|
|
if(startStopMongo != null){
|
|
|
- // 功率
|
|
|
- BigDecimal runPower = new BigDecimal(String.valueOf(fpgGatherData.getActivePower()));
|
|
|
- // 运行时常
|
|
|
- BigDecimal runTime = new BigDecimal("1");
|
|
|
// 历史数据
|
|
|
- BigDecimal oldPower = new BigDecimal(String.valueOf(startStopMongo.getPower()));
|
|
|
- BigDecimal oldRunTime = new BigDecimal(String.valueOf(startStopMongo.getIngTime()));
|
|
|
+ BigDecimal oldPower = startStopMongo.getPower() == null ? new BigDecimal("0.00") : startStopMongo.getPower();
|
|
|
+ BigDecimal oldRunTime = startStopMongo.getIngTime() == null ? new BigDecimal("0.00") : startStopMongo.getIngTime();
|
|
|
+ BigDecimal oldSelectricCurrent = startStopMongo.getSelectricCurrent() == null ? new BigDecimal("0.00") : startStopMongo.getSelectricCurrent();
|
|
|
// 更新启动运行数据
|
|
|
UpdateDefinition updateStartStop = new Update()
|
|
|
.set("power", oldPower.add(runPower))
|
|
|
+ .set("selectricCurrent", oldSelectricCurrent.add(selectricCurrent))
|
|
|
.set("ingTime", oldRunTime.add(runTime))
|
|
|
.set("updateTime", curentDate);
|
|
|
mongoTemplate.updateFirst(queryStartStop, updateStartStop, FpgStatiscsModelMongodb.class, startStopMonKey);
|
|
|
- return;
|
|
|
} else { // 直接插入
|
|
|
- mongoTemplate.insert(startStopStatiscsModelData, startStopMonKey);
|
|
|
- return;
|
|
|
+ mongoTemplate.insert(startStopStatiscsData, startStopMonKey);
|
|
|
}
|
|
|
}
|
|
|
// 设备启停统计 end
|
|
|
- // 日统计尖峰平谷数据(功率+占比+电流+运行时长)
|
|
|
- }catch (Exception e) {
|
|
|
+ // 日统计尖峰平谷数据(功率+占比+电流+运行时长) start
|
|
|
+ String dayPowerproportioncurrentRunMonKey = "total_day_powerproportioncurrent";
|
|
|
+ DeviceStatiscsModelData dayPowerproportioncurrentRunData = new DeviceStatiscsModelData(fpgGatherData, dayPowerproportioncurrentRunMonKey, dayDate, classs, curentDate, curentDate);
|
|
|
+ // 组合mongodb条件
|
|
|
+ Query queryDayPowerproportioncurrentRun = new Query()
|
|
|
+ .addCriteria(Criteria.where("deviceRegionId").is(fpgGatherData.getDeviceRegionId())).addCriteria(Criteria.where("deviceInformationId").is(fpgGatherData.getDeviceInformationId())).addCriteria(Criteria.where("dates").is(dayDate));
|
|
|
+ DeviceStatiscsModelMongodb dayPowerproportioncurrentMongo = mongoTemplate.findOne(queryDayPowerproportioncurrentRun, DeviceStatiscsModelMongodb.class, dayPowerproportioncurrentRunMonKey);
|
|
|
+ if(dayPowerproportioncurrentMongo != null){ // 不为空更新
|
|
|
+ // 历史数据
|
|
|
+ BigDecimal runNewPower = dayPowerproportioncurrentMongo.getPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getPower().add(runPower);
|
|
|
+ BigDecimal oldRunTime = dayPowerproportioncurrentMongo.getIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getIngTime();
|
|
|
+ BigDecimal oldSelectricCurrent = dayPowerproportioncurrentMongo.getSelectricCurrent() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getSelectricCurrent();
|
|
|
+ // 更新运行数据
|
|
|
+ UpdateDefinition update = new Update();
|
|
|
+ ((Update) update).set("power", runNewPower);
|
|
|
+ ((Update) update).set("selectricCurrent", oldSelectricCurrent.add(selectricCurrent));
|
|
|
+ ((Update) update).set("ingTime", oldRunTime.add(runTime));
|
|
|
+ ((Update) update).set("updateTime", curentDate);
|
|
|
+ // 尖峰平谷判定
|
|
|
+ if("tops".equals(jfpgStr.get())){ // 尖
|
|
|
+ // 功率处理
|
|
|
+ BigDecimal oldtopsPower = dayPowerproportioncurrentMongo.getTopsPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getTopsPower();
|
|
|
+ BigDecimal topsPower = oldtopsPower.add(runPower);
|
|
|
+ ((Update) update).set("topsPower", topsPower);
|
|
|
+ // 运行时常处理
|
|
|
+ BigDecimal oldtopsIngTime = dayPowerproportioncurrentMongo.getTopsIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getTopsIngTime();
|
|
|
+ ((Update) update).set("topsIngTime", oldtopsIngTime.add(runTime));
|
|
|
+ // 占比
|
|
|
+ if(topsPower.compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
+ ((Update) update).set("topsProportion", topsPower.divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
|
|
|
+ }
|
|
|
+ } else if("peaks".equals(jfpgStr.get())){ // 峰
|
|
|
+ // 功率处理
|
|
|
+ BigDecimal oldpeaksPower = dayPowerproportioncurrentMongo.getPeaksPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getPeaksPower();
|
|
|
+ BigDecimal peaksPower = oldpeaksPower.add(runPower);
|
|
|
+ ((Update) update).set("peaksPower", peaksPower);
|
|
|
+ // 运行时常处理
|
|
|
+ BigDecimal oldpeaksIngTime = dayPowerproportioncurrentMongo.getPeaksIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getPeaksIngTime();
|
|
|
+ ((Update) update).set("peaksIngTime", oldpeaksIngTime.add(runTime));
|
|
|
+ // 占比
|
|
|
+ if(peaksPower.compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
+ ((Update) update).set("peaksProportion", peaksPower.divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
|
|
|
+ }
|
|
|
+ } else if("flat".equals(jfpgStr.get())){ // 平
|
|
|
+ // 功率处理
|
|
|
+ BigDecimal oldflatPower = dayPowerproportioncurrentMongo.getFlatPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getFlatPower();
|
|
|
+ BigDecimal flatPower = oldflatPower.add(runPower);
|
|
|
+ ((Update) update).set("flatPower", flatPower);
|
|
|
+ // 运行时常处理
|
|
|
+ BigDecimal oldflatIngTime = dayPowerproportioncurrentMongo.getFlatIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getFlatIngTime();
|
|
|
+ ((Update) update).set("topsIngTime", oldflatIngTime.add(runTime));
|
|
|
+ // 占比
|
|
|
+ if(flatPower.compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
+ ((Update) update).set("flatProportion", flatPower.divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
|
|
|
+ }
|
|
|
+ } else if("valleys".equals(jfpgStr.get())){ // 谷
|
|
|
+ // 功率处理
|
|
|
+ BigDecimal oldvalleysPower = dayPowerproportioncurrentMongo.getValleysPower() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getValleysPower();
|
|
|
+ BigDecimal valleysPower = oldvalleysPower.add(runPower);
|
|
|
+ ((Update) update).set("valleysPower", oldvalleysPower.add(runPower));
|
|
|
+ // 运行时常处理
|
|
|
+ BigDecimal oldvalleysIngTime = dayPowerproportioncurrentMongo.getValleysIngTime() == null ? new BigDecimal("0.00") : dayPowerproportioncurrentMongo.getValleysIngTime();
|
|
|
+ ((Update) update).set("valleysIngTime", oldvalleysIngTime.add(runTime));
|
|
|
+ // 占比
|
|
|
+ if(valleysPower.compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
+ ((Update) update).set("valleysProportion", valleysPower.divide(runNewPower, 2, RoundingMode.HALF_UP).multiply(zb));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mongoTemplate.updateFirst(queryDayPowerproportioncurrentRun, update, DeviceStatiscsModelMongodb.class, dayPowerproportioncurrentRunMonKey);
|
|
|
+ } else { // 为空直接插入
|
|
|
+ mongoTemplate.insert(dayPowerproportioncurrentRunData, dayPowerproportioncurrentRunMonKey);
|
|
|
+ }
|
|
|
+ // 日统计尖峰平谷数据(功率+占比+电流+运行时长) end
|
|
|
+ } catch (Exception e) {
|
|
|
log.error(e.getMessage());
|
|
|
}
|
|
|
});
|
|
@@ -270,12 +368,12 @@ public class LeanModelStatistics {
|
|
|
UpdateDefinition update = new Update();
|
|
|
((Update) update).set("updateTime", curentDate);
|
|
|
// 功率
|
|
|
- BigDecimal activePower = new BigDecimal(String.valueOf(fpgGatherData.getActivePower()));
|
|
|
+ BigDecimal activePower = fpgGatherData.getActivePower() == null ? new BigDecimal("0.00") : fpgGatherData.getActivePower();
|
|
|
// 电流
|
|
|
- BigDecimal selectricCurrent = new BigDecimal(String.valueOf(fpgGatherData.getRunCurrent()));
|
|
|
+ BigDecimal selectricCurrent = fpgGatherData.getRunCurrent() == null ? new BigDecimal("0.00") : fpgGatherData.getRunCurrent();
|
|
|
BigDecimal runTime = new BigDecimal("1");
|
|
|
- BigDecimal oldPower = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getPower()));
|
|
|
- BigDecimal oldingTime = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getIngTime()));
|
|
|
+ BigDecimal oldPower = FpgStatiscsModelMongo.getPower() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getPower();
|
|
|
+ BigDecimal oldingTime = FpgStatiscsModelMongo.getIngTime() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getIngTime();
|
|
|
// 总运行时间处理
|
|
|
if(fpgLeanModeInfo.getRunTime() != null && fpgLeanModeInfo.getRunTime() == 1) { // 运行时长统计
|
|
|
((Update) update).set("ingTime", oldingTime.add(runTime));
|
|
@@ -283,16 +381,16 @@ public class LeanModelStatistics {
|
|
|
// 电流处理
|
|
|
if(fpgLeanModeInfo.getElectricCurrent() != null && fpgLeanModeInfo.getElectricCurrent() == 1){
|
|
|
if("tops".equals(jfpgStr.get())) { // 尖
|
|
|
- BigDecimal oldtopsSelectricCurrent = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getTopsSelectricCurrent()));
|
|
|
+ BigDecimal oldtopsSelectricCurrent = FpgStatiscsModelMongo.getTopsSelectricCurrent() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getTopsSelectricCurrent();
|
|
|
((Update) update).set("topSelectricCurrent", oldtopsSelectricCurrent.add(selectricCurrent));
|
|
|
} else if("peaks".equals(jfpgStr.get())){ // 峰
|
|
|
- BigDecimal oldpeaksSelectricCurrent = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getPeaksSelectricCurrent()));
|
|
|
+ BigDecimal oldpeaksSelectricCurrent = FpgStatiscsModelMongo.getPeaksSelectricCurrent() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getPeaksSelectricCurrent();
|
|
|
((Update) update).set("peaksSelectricCurrent", oldpeaksSelectricCurrent.add(selectricCurrent));
|
|
|
} else if("flat".equals(jfpgStr.get())) { // 平
|
|
|
- BigDecimal oldtflatSelectricCurrent = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getFlatSelectricCurrent()));
|
|
|
+ BigDecimal oldtflatSelectricCurrent = FpgStatiscsModelMongo.getFlatSelectricCurrent() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getFlatSelectricCurrent();
|
|
|
((Update) update).set("flatSelectricCurrent", oldtflatSelectricCurrent.add(selectricCurrent));
|
|
|
} else if("valleys".equals(jfpgStr.get())) { // 谷
|
|
|
- BigDecimal oldvalleysSelectricCurrent = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getValleysSelectricCurrent()));
|
|
|
+ BigDecimal oldvalleysSelectricCurrent = FpgStatiscsModelMongo.getValleysSelectricCurrent() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getValleysSelectricCurrent();
|
|
|
((Update) update).set("valleysSelectricCurrent", oldvalleysSelectricCurrent.add(selectricCurrent));
|
|
|
}
|
|
|
}
|
|
@@ -301,65 +399,65 @@ public class LeanModelStatistics {
|
|
|
// 尖峰平谷判定
|
|
|
if("tops".equals(jfpgStr.get())){ // 尖
|
|
|
// 功率处理
|
|
|
- BigDecimal oldtopsPower = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getTopsPower()));
|
|
|
+ BigDecimal oldtopsPower = FpgStatiscsModelMongo.getTopsPower() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getTopsPower();
|
|
|
((Update) update).set("topsPower", oldtopsPower.add(activePower));
|
|
|
// 运行时常处理
|
|
|
if(fpgLeanModeInfo.getRunTime() != null && fpgLeanModeInfo.getRunTime() == 1){ // 运行时长统计
|
|
|
- BigDecimal oldtopsIngTime = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getTopsIngTime()));
|
|
|
+ BigDecimal oldtopsIngTime = FpgStatiscsModelMongo.getTopsIngTime() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getTopsIngTime();
|
|
|
((Update) update).set("topsIngTime", oldtopsIngTime.add(runTime));
|
|
|
}
|
|
|
// 金额处理
|
|
|
if(fpgLeanModeInfo.getTopsPrice() != null && fpgLeanModeInfo.getTopsPrice().compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
// 总金额
|
|
|
- BigDecimal totalAmount = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getAmount()));
|
|
|
+ BigDecimal totalAmount = FpgStatiscsModelMongo.getAmount() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getAmount();
|
|
|
((Update) update).set("amount", activePower.multiply(fpgLeanModeInfo.getTopsPrice()).add(totalAmount));
|
|
|
((Update) update).set("topsAmount", oldtopsPower.add(activePower).multiply(fpgLeanModeInfo.getTopsPrice()));
|
|
|
}
|
|
|
} else if("peaks".equals(jfpgStr.get())){ // 峰
|
|
|
// 功率处理
|
|
|
- BigDecimal oldpeaksPower = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getPeaksPower()));
|
|
|
+ BigDecimal oldpeaksPower = FpgStatiscsModelMongo.getPeaksPower() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getPeaksPower();
|
|
|
((Update) update).set("peaksPower", oldpeaksPower.add(activePower));
|
|
|
// 运行时常处理
|
|
|
if(fpgLeanModeInfo.getRunTime() != null && fpgLeanModeInfo.getRunTime() == 1){ // 运行时长统计
|
|
|
- BigDecimal oldpeaksIngTime = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getPeaksIngTime()));
|
|
|
+ BigDecimal oldpeaksIngTime = FpgStatiscsModelMongo.getPeaksIngTime() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getPeaksIngTime();
|
|
|
((Update) update).set("peaksIngTime", oldpeaksIngTime.add(runTime));
|
|
|
}
|
|
|
// 金额处理
|
|
|
if(fpgLeanModeInfo.getPeaksPrice() != null && fpgLeanModeInfo.getPeaksPrice().compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
// 总金额
|
|
|
- BigDecimal totalAmount = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getAmount()));
|
|
|
+ BigDecimal totalAmount = FpgStatiscsModelMongo.getAmount() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getAmount();
|
|
|
((Update) update).set("amount", activePower.multiply(fpgLeanModeInfo.getPeaksPrice()).add(totalAmount));
|
|
|
((Update) update).set("topsAmount", oldpeaksPower.add(activePower).multiply(fpgLeanModeInfo.getPeaksPrice()));
|
|
|
}
|
|
|
} else if("flat".equals(jfpgStr.get())){ // 平
|
|
|
// 功率处理
|
|
|
- BigDecimal oldflatPower = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getFlatPower()));
|
|
|
+ BigDecimal oldflatPower = FpgStatiscsModelMongo.getFlatPower() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getFlatPower();
|
|
|
((Update) update).set("flatPower", oldflatPower.add(activePower));
|
|
|
// 运行时常处理
|
|
|
if(fpgLeanModeInfo.getRunTime() != null && fpgLeanModeInfo.getRunTime() == 1){
|
|
|
- BigDecimal oldflatIngTime = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getTopsIngTime()));
|
|
|
+ BigDecimal oldflatIngTime = FpgStatiscsModelMongo.getFlatIngTime() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getFlatIngTime();
|
|
|
((Update) update).set("topsIngTime", oldflatIngTime.add(runTime));
|
|
|
}
|
|
|
// 金额处理
|
|
|
if(fpgLeanModeInfo.getFlatPrice() != null && fpgLeanModeInfo.getFlatPrice().compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
// 总金额
|
|
|
- BigDecimal totalAmount = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getAmount()));
|
|
|
+ BigDecimal totalAmount = FpgStatiscsModelMongo.getAmount() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getAmount();
|
|
|
((Update) update).set("amount", activePower.multiply(fpgLeanModeInfo.getFlatPrice()).add(totalAmount));
|
|
|
((Update) update).set("flatAmount", oldflatPower.add(activePower).multiply(fpgLeanModeInfo.getFlatPrice()));
|
|
|
}
|
|
|
} else if("valleys".equals(jfpgStr.get())){ // 谷
|
|
|
// 功率处理
|
|
|
- BigDecimal oldvalleysPower = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getValleysPower()));
|
|
|
+ BigDecimal oldvalleysPower = FpgStatiscsModelMongo.getValleysPower() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getValleysPower();
|
|
|
((Update) update).set("valleysPower", oldvalleysPower.add(activePower));
|
|
|
// 运行时常处理
|
|
|
if(fpgLeanModeInfo.getRunTime() != null && fpgLeanModeInfo.getRunTime() == 1){
|
|
|
- BigDecimal oldvalleysIngTime = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getValleysIngTime()));
|
|
|
+ BigDecimal oldvalleysIngTime = FpgStatiscsModelMongo.getValleysIngTime() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getValleysIngTime();
|
|
|
((Update) update).set("valleysIngTime", oldvalleysIngTime.add(runTime));
|
|
|
}
|
|
|
// 金额处理
|
|
|
if(fpgLeanModeInfo.getValleysPrice() != null && fpgLeanModeInfo.getValleysPrice().compareTo(new BigDecimal("0.00")) > 0) {
|
|
|
// 总金额
|
|
|
- BigDecimal totalAmount = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getAmount()));
|
|
|
+ BigDecimal totalAmount = FpgStatiscsModelMongo.getAmount() == null ? new BigDecimal("0.00") : FpgStatiscsModelMongo.getAmount();
|
|
|
((Update) update).set("amount", activePower.multiply(fpgLeanModeInfo.getValleysPrice()).add(totalAmount));
|
|
|
((Update) update).set("valleysAmount", oldvalleysPower.add(activePower).multiply(fpgLeanModeInfo.getValleysPrice()));
|
|
|
}
|