|
@@ -168,6 +168,61 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
|
|
|
return monitorDataChartReportDeviceDtos;
|
|
|
}
|
|
|
@Override
|
|
|
+ public List<MonitorDataChartReportDeviceDto> monitorWaterPowerConsumptionReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, Integer sceneType) {
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
|
|
|
+ if (type != null && type == 3){
|
|
|
+ monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByDay(sceneType,sceneIds,year,month,day,
|
|
|
+ loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
+ } else if(type != null && type == 2){
|
|
|
+ monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByMonth(sceneType,sceneIds,year,month,
|
|
|
+ loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
+ } else if(type != null && type == 1){
|
|
|
+ monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByYear(sceneType,sceneIds,year,
|
|
|
+ loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
+ }
|
|
|
+ if (monitorDataChartReportDeviceDtos != null) {
|
|
|
+ FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
|
|
|
+ }
|
|
|
+ for (MonitorDataChartReportDeviceDto water: monitorDataChartReportDeviceDtos) {
|
|
|
+ List<MonitorDataChartReportAttributeDto> newAttrDataList = new ArrayList();
|
|
|
+ MonitorDataChartReportAttributeDto newAttrData = new MonitorDataChartReportAttributeDto();
|
|
|
+ List<MonitorDataChartReportAttributeDto> attributeDtos = water.getAttributeData();
|
|
|
+ newAttrData.setAttributeName("水电耗");
|
|
|
+ newAttrData.setUnit("kwh/㎡");
|
|
|
+ if (attributeDtos.size() == 2) {
|
|
|
+ MonitorDataChartReportAttributeDto attributeDto1 = attributeDtos.get(0);
|
|
|
+ MonitorDataChartReportAttributeDto attributeDto2 = attributeDtos.get(1);
|
|
|
+ Map<Integer,MonitorDataChartReportValueDto> map1 = attributeDto1.getMonitorDataChartReportValue().stream().collect(Collectors.toMap(MonitorDataChartReportValueDto::getDateLabel, a -> a,(k1, k2)->k1));
|
|
|
+ Map<Integer,MonitorDataChartReportValueDto> map2 = attributeDto2.getMonitorDataChartReportValue().stream().collect(Collectors.toMap(MonitorDataChartReportValueDto::getDateLabel, a -> a,(k1, k2)->k1));
|
|
|
+ // 耗电量
|
|
|
+ if ("5".equals(attributeDto1.getAttributeType())) {
|
|
|
+ calculation(attributeDto1, map2);
|
|
|
+ newAttrData.setMonitorDataChartReportValue(attributeDto1.getMonitorDataChartReportValue());
|
|
|
+ } else {
|
|
|
+ calculation(attributeDto2, map1);
|
|
|
+ newAttrData.setMonitorDataChartReportValue(attributeDto2.getMonitorDataChartReportValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newAttrDataList.add(newAttrData);
|
|
|
+ water.setAttributeData(newAttrDataList);
|
|
|
+ }
|
|
|
+ return monitorDataChartReportDeviceDtos;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void calculation(MonitorDataChartReportAttributeDto attributeDto, Map<Integer,MonitorDataChartReportValueDto> map){
|
|
|
+ for (MonitorDataChartReportValueDto valueDto : attributeDto.getMonitorDataChartReportValue()) {
|
|
|
+ BigDecimal b1 = new BigDecimal(valueDto.getData());
|
|
|
+ BigDecimal b2 = new BigDecimal(map.get(valueDto.getDateLabel()).getData());
|
|
|
+ valueDto.setMonitorData("");
|
|
|
+ if (b1.compareTo(new BigDecimal(0)) == 0 || b2.compareTo(new BigDecimal(0)) == 0) {
|
|
|
+ valueDto.setData(0d);
|
|
|
+ } else {
|
|
|
+ valueDto.setData(b1.divide(b2, 5, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).doubleValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @Override
|
|
|
public List<DeviceEntity> getDeviceBySceneTypeName(String sceneTypeName){
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
return monitorDataReportMapper.getDeviceBySceneTypeName(sceneTypeName,loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|