|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.os.ems.report.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.os.common.utils.DateUtils;
|
|
|
|
|
import com.os.common.utils.StringUtils;
|
|
|
|
|
import com.os.ems.base.domain.EmsBaseMonitorWorkUnit;
|
|
|
|
|
import com.os.ems.base.domain.EmsBaseWorkUnit;
|
|
|
|
|
@ -16,6 +17,8 @@ import java.math.BigDecimal;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static com.os.common.utils.DateUtils.getTimeIntervals;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 能源报表Service业务层处理
|
|
|
|
|
@ -49,7 +52,7 @@ public class EmsReportServiceImpl implements IEmsReportService {
|
|
|
|
|
hashMap.put("timeSub", Integer.parseInt(String.valueOf(hashMap.get("dateType"))));
|
|
|
|
|
List<EnergyStatisticalReport> reportList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if (Objects.equals(String.valueOf(hashMap.get("energyType")), "2")){
|
|
|
|
|
if (Objects.equals(String.valueOf(hashMap.get("energyType")), "2")) {
|
|
|
|
|
reportList = emsReportMapper.energyStatisticalDnbReportList(hashMap);
|
|
|
|
|
}
|
|
|
|
|
return reportList;
|
|
|
|
|
@ -115,4 +118,83 @@ public class EmsReportServiceImpl implements IEmsReportService {
|
|
|
|
|
return resultList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 能源对比分析接口
|
|
|
|
|
*
|
|
|
|
|
* @param hashMap
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> comparativeAnalysisReport(Map hashMap) {
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
if (!hashMap.containsKey("beginCollectTime") || !hashMap.containsKey("endCollectTime") || !hashMap.containsKey("workUnitCodeList")) {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
String beginCollectTime = String.valueOf(hashMap.get("beginCollectTime"));
|
|
|
|
|
String endCollectTime = String.valueOf(hashMap.get("endCollectTime"));
|
|
|
|
|
String dateType = String.valueOf(hashMap.get("dateType"));
|
|
|
|
|
String workUnitCodeList = String.valueOf(hashMap.get("workUnitCodeList"));
|
|
|
|
|
String monitorType = String.valueOf(hashMap.get("monitorType"));
|
|
|
|
|
//时间范围
|
|
|
|
|
List<String> timeIntervalList = getTimeIntervals(beginCollectTime, endCollectTime, dateType);
|
|
|
|
|
//已勾选的统计单元
|
|
|
|
|
List<String> workUnitCodeSplitList = Arrays.asList(workUnitCodeList.split(","));
|
|
|
|
|
|
|
|
|
|
EmsBaseWorkUnit workUnit = new EmsBaseWorkUnit();
|
|
|
|
|
workUnit.setWorkUnitCodeList(workUnitCodeSplitList);
|
|
|
|
|
List<EmsBaseWorkUnit> workUnitList = emsBaseWorkUnitMapper.selectEmsBaseWorkUnitList(workUnit);
|
|
|
|
|
//已勾选的统计单元名称
|
|
|
|
|
List<String> workUnitNameList = workUnitList.stream().map(EmsBaseWorkUnit::getWorkUnitName).collect(Collectors.toList());
|
|
|
|
|
//查询耗量
|
|
|
|
|
hashMap.put("workUnitCodeList", workUnitCodeSplitList);
|
|
|
|
|
hashMap.put("energyType", monitorType);
|
|
|
|
|
hashMap.put("beginCollectTime", beginCollectTime + " 00:00:00");
|
|
|
|
|
hashMap.put("endCollectTime", endCollectTime + " 23:59:59");
|
|
|
|
|
List<EnergyStatisticalReport> statisticalReportList = this.energyStatisticalReportList(hashMap);
|
|
|
|
|
// 按照 workUnitCode 分组
|
|
|
|
|
Map<String, List<EnergyStatisticalReport>> groupedByWorkUnitCode =
|
|
|
|
|
statisticalReportList.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(EnergyStatisticalReport::getWorkUnitCode));
|
|
|
|
|
// 生成柱状图系列数据
|
|
|
|
|
List<Map<String, Object>> seriesBar = new ArrayList<>();
|
|
|
|
|
// 生成折线图系列数据
|
|
|
|
|
List<Map<String, Object>> seriesLine = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (EmsBaseWorkUnit unit : workUnitList) {
|
|
|
|
|
List<EnergyStatisticalReport> reportList = groupedByWorkUnitCode.get(unit.getWorkUnitCode());
|
|
|
|
|
if (reportList == null) {
|
|
|
|
|
reportList = new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<BigDecimal> expendList = new ArrayList<>();
|
|
|
|
|
for (String time : timeIntervalList) {
|
|
|
|
|
BigDecimal initExpend = new BigDecimal(0);
|
|
|
|
|
for (EnergyStatisticalReport report : reportList) {
|
|
|
|
|
BigDecimal expend = report.getExpend();
|
|
|
|
|
if (time.equals(report.getBeginTime())){
|
|
|
|
|
initExpend = initExpend.add(expend);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
expendList.add(initExpend);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, Object> barSeries = new HashMap<>();
|
|
|
|
|
barSeries.put("type", "bar");
|
|
|
|
|
barSeries.put("name", unit.getWorkUnitName());
|
|
|
|
|
barSeries.put("data", expendList);
|
|
|
|
|
seriesBar.add(barSeries);
|
|
|
|
|
Map<String, Object> lineSeries = new HashMap<>();
|
|
|
|
|
lineSeries.put("type", "line");
|
|
|
|
|
lineSeries.put("name", unit.getWorkUnitName());
|
|
|
|
|
lineSeries.put("data", expendList);
|
|
|
|
|
seriesLine.add(lineSeries);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.put("times", timeIntervalList);
|
|
|
|
|
result.put("deviceNames", workUnitNameList);
|
|
|
|
|
result.put("seriesBar", seriesBar);
|
|
|
|
|
result.put("seriesLine", seriesLine);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|