|
@@ -140,6 +140,7 @@ public class MonitorDataServiceImpl implements MonitorDataService , Initializing
|
|
|
.max("$dataValues.dataValue").as("maxValue")
|
|
|
.avg("$dataValues.dataValue").as("avgValue")
|
|
|
// .sum("$dataValues.dataValue").as("sumValue")
|
|
|
+ .first("$dataValues.dataValue").as("firstValue")
|
|
|
.last("$dataValues.dataValue").as("latestValue")
|
|
|
.last("$collectDate").as("collectDate")
|
|
|
.count().as("countNum")
|
|
@@ -164,9 +165,14 @@ public class MonitorDataServiceImpl implements MonitorDataService , Initializing
|
|
|
if(hourDatas.size()>0){
|
|
|
//计算累计值
|
|
|
for(DayReportEntity dayReportEntity : hourDatas){
|
|
|
- if(dayReportEntity.getLatestValue()!=null && lastHourDataMap.containsKey(dayReportEntity.getMapkey())
|
|
|
- && lastHourDataMap.get(dayReportEntity.getMapkey()).getLatestValue() != null){
|
|
|
- dayReportEntity.setSumValue(new BigDecimal(dayReportEntity.getLatestValue().toString()).subtract(new BigDecimal(lastHourDataMap.get(dayReportEntity.getMapkey()).getLatestValue().toString())).doubleValue());
|
|
|
+ if(dayReportEntity.getLatestValue()!=null && lastHourDataMap.containsKey(dayReportEntity.getMapkey())){
|
|
|
+ //上一个小时有值
|
|
|
+ if( lastHourDataMap.get(dayReportEntity.getMapkey()).getLatestValue() != null){
|
|
|
+ dayReportEntity.setSumValue(new BigDecimal(dayReportEntity.getLatestValue().toString()).subtract(new BigDecimal(lastHourDataMap.get(dayReportEntity.getMapkey()).getLatestValue().toString())).doubleValue());
|
|
|
+ }else if(dayReportEntity.getFirstValue() != null){//上一个小时没有值,取本小时的初始值
|
|
|
+ dayReportEntity.setSumValue(new BigDecimal(dayReportEntity.getLatestValue().toString()).subtract(new BigDecimal(dayReportEntity.getFirstValue().toString())).doubleValue());
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
monitorDataMapper.batchInsertDayReport(hourDatas);
|