|
@@ -76,6 +76,33 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
|
|
|
return monitorDataChartReportDeviceDtos;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<MonitorDataChartReportDeviceDto> monthMonitorData(Long sceneId, String startTime, String endTime) {
|
|
|
+ startTime += " 00:00:00";
|
|
|
+ endTime += " 23:59:59";
|
|
|
+ LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
+ List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = monitorDataReportMapper.monthMonitorData(startTime, endTime,sceneId,
|
|
|
+ loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
+ LocalDateTime startDate = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ LocalDateTime endDate = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ if (startDate.getYear() == endDate.getYear()){
|
|
|
+ for (int i = startDate.getMonth().getValue();i <= endDate.getMonth().getValue(); i++){
|
|
|
+ FillLoseData(monitorDataChartReportDeviceDtos,2, startDate.getYear(), i, 1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ int start = 0;
|
|
|
+ int end = 0;
|
|
|
+ for (int i = startDate.getYear(); i <= endDate.getYear(); i++){
|
|
|
+ start = i == startDate.getYear() ? startDate.getMonth().getValue() : 1;
|
|
|
+ end = i == endDate.getYear() ? endDate.getMonthValue() : 12;
|
|
|
+ for (int m = start;m <= end; m++){
|
|
|
+ FillLoseData(monitorDataChartReportDeviceDtos,2, i , m,1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return monitorDataChartReportDeviceDtos;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<MonitorDataChartReportDeviceDto> monitorDataChartReportByYear(Long sceneId, Integer year) {
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
@@ -86,26 +113,34 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<MonitorDataChartReportDeviceDto> deviceAlarmReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day) {
|
|
|
+ public List<MonitorDataChartReportDeviceDto> deviceAlarmReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, String startTime, String endTime) {
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
- LocalDate beginDate;
|
|
|
- LocalDate endDate;
|
|
|
- String dateType ;
|
|
|
- if(type != null && type ==1){
|
|
|
+ LocalDate beginDate = null;
|
|
|
+ LocalDate endDate = null;
|
|
|
+ String dateType = null;
|
|
|
+ if (type == null){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ if (type ==1) {
|
|
|
beginDate=LocalDate.of(year,1,1);
|
|
|
endDate=beginDate.plusYears(1);
|
|
|
dateType="month";
|
|
|
- }else
|
|
|
- if(type != null && type ==2){
|
|
|
+ }else if(type ==2) {
|
|
|
beginDate=LocalDate.of(year,month,1);
|
|
|
endDate=beginDate.plusMonths(1);
|
|
|
dateType="day";
|
|
|
- }else
|
|
|
- if(type != null && type ==3){
|
|
|
+ } else if(type ==3) {
|
|
|
beginDate=LocalDate.of(year,month,day);
|
|
|
endDate=beginDate.plusDays(1);
|
|
|
dateType="hour";
|
|
|
- }else{
|
|
|
+ } else if (type == 4){
|
|
|
+ startTime += " 00:00:00";
|
|
|
+ endTime += " 23:59:59";
|
|
|
+ beginDate = LocalDate.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ endDate = LocalDate.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ dateType="day";
|
|
|
+ }
|
|
|
+ if (beginDate == null || endDate == null){
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = monitorDataReportMapper.DeviceAlarmReport(dateType,sceneIds,beginDate,endDate,
|
|
@@ -116,42 +151,60 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<MonitorDataChartReportDeviceDto> monitorDataQualityReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day) {
|
|
|
+ public List<MonitorDataChartReportDeviceDto> monitorDataQualityReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, String startTime, String endTime) {
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
-
|
|
|
List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
|
|
|
- if(type != null && type == 3){
|
|
|
+ if (type == null) {
|
|
|
+ return monitorDataChartReportDeviceDtos;
|
|
|
+ }
|
|
|
+ if(type == 3){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataQualityReportByDay(sceneIds,year,month,day,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
- } else if(type != null && type == 2){
|
|
|
+ } else if(type == 2){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataQualityReportByMonth(sceneIds,year,month,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
- } else if(type != null && type == 1){
|
|
|
+ } else if(type == 1){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataQualityReportByYear(sceneIds,year,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
+ } else if (type == 4) {
|
|
|
+ startTime += " 00:00:00";
|
|
|
+ endTime += " 23:59:59";
|
|
|
+ monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataQualityReport(sceneIds,startTime,endTime,
|
|
|
+ loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
}
|
|
|
- if(monitorDataChartReportDeviceDtos != null){
|
|
|
+ if (monitorDataChartReportDeviceDtos != null && type == 4){
|
|
|
+ FillLoseData(startTime, endTime, monitorDataChartReportDeviceDtos);
|
|
|
+ } else if (monitorDataChartReportDeviceDtos != null){
|
|
|
FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
|
|
|
}
|
|
|
-
|
|
|
return monitorDataChartReportDeviceDtos;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<MonitorDataChartReportDeviceDto> monitorDataEnergyReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, Integer sceneType) {
|
|
|
+ public List<MonitorDataChartReportDeviceDto> monitorDataEnergyReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, Integer sceneType,String startTime, String endTime) {
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
|
|
|
- if(type != null && type == 3){
|
|
|
+ if (type == null) {
|
|
|
+ return monitorDataChartReportDeviceDtos;
|
|
|
+ }
|
|
|
+ if(type == 3){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByDay(sceneType,sceneIds,year,month,day,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
- } else if(type != null && type == 2){
|
|
|
+ } else if(type == 2){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByMonth(sceneType,sceneIds,year,month,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
- } else if(type != null && type == 1){
|
|
|
+ } else if(type == 1){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByYear(sceneType,sceneIds,year,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
- }
|
|
|
- if(monitorDataChartReportDeviceDtos != null){
|
|
|
+ } else if (type == 4) {
|
|
|
+ startTime += " 00:00:00";
|
|
|
+ endTime += " 23:59:59";
|
|
|
+ monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReport(sceneType,sceneIds,startTime,endTime,
|
|
|
+ loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
+ }
|
|
|
+ if (monitorDataChartReportDeviceDtos != null && type == 4) {
|
|
|
+ FillLoseData(startTime, endTime, monitorDataChartReportDeviceDtos);
|
|
|
+ }else if (monitorDataChartReportDeviceDtos != null){
|
|
|
FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
|
|
|
}
|
|
|
//单位转换为“万”
|
|
@@ -168,20 +221,30 @@ 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) {
|
|
|
+ public List<MonitorDataChartReportDeviceDto> monitorWaterPowerConsumptionReport(Integer type, List<Long> sceneIds, Integer year, Integer month , Integer day, Integer sceneType, String startTime, String endTime) {
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
|
|
|
- if (type != null && type == 3){
|
|
|
+ if (type == null) {
|
|
|
+ return monitorDataChartReportDeviceDtos;
|
|
|
+ }
|
|
|
+ if ( type == 3){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByDay(sceneType,sceneIds,year,month,day,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
- } else if(type != null && type == 2){
|
|
|
+ } else if(type == 2){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByMonth(sceneType,sceneIds,year,month,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
- } else if(type != null && type == 1){
|
|
|
+ } else if(type == 1){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReportByYear(sceneType,sceneIds,year,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
+ } else if (type == 4) {
|
|
|
+ startTime += " 00:00:00";
|
|
|
+ endTime += " 23:59:59";
|
|
|
+ monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataEnergyReport(sceneType,sceneIds,startTime,endTime,
|
|
|
+ loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
}
|
|
|
- if (monitorDataChartReportDeviceDtos != null) {
|
|
|
+ if (monitorDataChartReportDeviceDtos != null && type == 4){
|
|
|
+ FillLoseData(startTime, endTime, monitorDataChartReportDeviceDtos);
|
|
|
+ } else if (monitorDataChartReportDeviceDtos != null) {
|
|
|
FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
|
|
|
}
|
|
|
for (MonitorDataChartReportDeviceDto water: monitorDataChartReportDeviceDtos) {
|
|
@@ -190,16 +253,21 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
|
|
|
List<MonitorDataChartReportAttributeDto> attributeDtos = water.getAttributeData();
|
|
|
newAttrData.setAttributeName("水电耗");
|
|
|
newAttrData.setUnit("kwh/㎡");
|
|
|
+ newAttrData.setAttributeType("99");
|
|
|
+ // 计算水电耗=每日电量/每日用水量*100
|
|
|
+ // 缺失每日电量或者每日水量将不进行计算
|
|
|
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));
|
|
|
- // 耗电量
|
|
|
+ // attributeType == 5 --> 每日电量
|
|
|
+ // attributeType == 4 --> 每日用水量
|
|
|
if ("5".equals(attributeDto1.getAttributeType())) {
|
|
|
+ Map<Integer,MonitorDataChartReportValueDto> map2 = attributeDto2.getMonitorDataChartReportValue().stream().collect(Collectors.toMap(MonitorDataChartReportValueDto::getDateLabel, a -> a,(k1, k2)->k1));
|
|
|
calculation(attributeDto1, map2);
|
|
|
newAttrData.setMonitorDataChartReportValue(attributeDto1.getMonitorDataChartReportValue());
|
|
|
} else {
|
|
|
+ Map<Integer,MonitorDataChartReportValueDto> map1 = attributeDto1.getMonitorDataChartReportValue().stream().collect(Collectors.toMap(MonitorDataChartReportValueDto::getDateLabel, a -> a,(k1, k2)->k1));
|
|
|
calculation(attributeDto2, map1);
|
|
|
newAttrData.setMonitorDataChartReportValue(attributeDto2.getMonitorDataChartReportValue());
|
|
|
}
|
|
@@ -210,6 +278,7 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
|
|
|
return monitorDataChartReportDeviceDtos;
|
|
|
}
|
|
|
|
|
|
+ // 计算水电耗=每日电量/每日用水量*100
|
|
|
private void calculation(MonitorDataChartReportAttributeDto attributeDto, Map<Integer,MonitorDataChartReportValueDto> map){
|
|
|
for (MonitorDataChartReportValueDto valueDto : attributeDto.getMonitorDataChartReportValue()) {
|
|
|
BigDecimal b1 = new BigDecimal(valueDto.getData());
|
|
@@ -217,8 +286,10 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
|
|
|
valueDto.setMonitorData("");
|
|
|
if (b1.compareTo(new BigDecimal(0)) == 0 || b2.compareTo(new BigDecimal(0)) == 0) {
|
|
|
valueDto.setData(0d);
|
|
|
+ valueDto.setMonitorData("0 kwh/㎡");
|
|
|
} else {
|
|
|
valueDto.setData(b1.divide(b2, 5, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).doubleValue());
|
|
|
+ valueDto.setMonitorData(valueDto.getData() + " kwh/㎡");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -228,24 +299,33 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
|
|
|
return monitorDataReportMapper.getDeviceBySceneTypeName(sceneTypeName,loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
}
|
|
|
@Override
|
|
|
- public List<MonitorDataChartReportDeviceDto> monitorDataDeviceReport(Integer type, List<Long> deviceIds, Integer searchType, Integer year, Integer month , Integer day){
|
|
|
+ public List<MonitorDataChartReportDeviceDto> monitorDataDeviceReport(Integer type, List<Long> deviceIds, Integer searchType, Integer year, Integer month , Integer day, String startTime, String endTime){
|
|
|
|
|
|
LoginUser loginUser = UserUtil.getCurrentUser();
|
|
|
List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos = null;
|
|
|
- if(type != null && type == 3){
|
|
|
+ if (type == null) {
|
|
|
+ return monitorDataChartReportDeviceDtos;
|
|
|
+ }
|
|
|
+ if (type == 3){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataDeviceReportByDay(deviceIds,searchType,year,month,day,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
- } else if(type != null && type == 2){
|
|
|
+ } else if(type == 2){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataDeviceReportByMonth(deviceIds,searchType,year,month,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
- } else if(type != null && type == 1){
|
|
|
+ } else if(type == 1){
|
|
|
monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataDeviceReportByYear(deviceIds,searchType,year,
|
|
|
loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
+ } else if (type == 4){
|
|
|
+ startTime += " 00:00:00";
|
|
|
+ endTime += " 23:59:59";
|
|
|
+ monitorDataChartReportDeviceDtos = monitorDataReportMapper.MonitorDataDeviceReport(deviceIds,searchType,startTime,endTime,
|
|
|
+ loginUser.getTenantId(),loginUser.getType(),loginUser.getPermissonType(),loginUser.getProgramItemList());
|
|
|
}
|
|
|
- if(monitorDataChartReportDeviceDtos != null){
|
|
|
+ if (monitorDataChartReportDeviceDtos != null && type == 4){
|
|
|
+ FillLoseData(startTime,endTime, monitorDataChartReportDeviceDtos);
|
|
|
+ } else if (monitorDataChartReportDeviceDtos != null){
|
|
|
FillLoseData(monitorDataChartReportDeviceDtos,type,year,month,day);
|
|
|
}
|
|
|
-
|
|
|
return monitorDataChartReportDeviceDtos;
|
|
|
}
|
|
|
|
|
@@ -1320,4 +1400,25 @@ public class MonitorDataReportServiceImpl implements MonitorDataReportService {
|
|
|
amountMonth = BigDecimal.ZERO;
|
|
|
return amountMonth;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private void FillLoseData(String startTime, String endTime,List<MonitorDataChartReportDeviceDto> monitorDataChartReportDeviceDtos){
|
|
|
+ LocalDateTime startDate = LocalDateTime.parse(startTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ LocalDateTime endDate = LocalDateTime.parse(endTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
|
|
+ if (startDate.getYear() == endDate.getYear()){
|
|
|
+ for (int i = startDate.getMonth().getValue();i <= endDate.getMonth().getValue(); i++){
|
|
|
+ FillLoseData(monitorDataChartReportDeviceDtos,2, startDate.getYear(), i, 1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ int start = 0;
|
|
|
+ int end = 0;
|
|
|
+ for (int i = startDate.getYear(); i <= endDate.getYear(); i++){
|
|
|
+ start = i == startDate.getYear() ? startDate.getMonth().getValue() : 1;
|
|
|
+ end = i == endDate.getYear() ? endDate.getMonthValue() : 12;
|
|
|
+ for (int m = start;m <= end; m++){
|
|
|
+ FillLoseData(monitorDataChartReportDeviceDtos,2, i , m,1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|