|
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.mh.common.core.domain.dto.SysPerformanceDTO; |
|
|
|
import com.mh.common.core.domain.dto.SysPerformanceDTO; |
|
|
|
import com.mh.common.core.domain.dto.WeatherDataDTO; |
|
|
|
import com.mh.common.core.domain.dto.WeatherDataDTO; |
|
|
|
import com.mh.common.core.domain.entity.CollectionParamsManage; |
|
|
|
import com.mh.common.core.domain.entity.CollectionParamsManage; |
|
|
|
|
|
|
|
import com.mh.common.core.domain.entity.SysDictData; |
|
|
|
import com.mh.common.core.domain.entity.SysParams; |
|
|
|
import com.mh.common.core.domain.entity.SysParams; |
|
|
|
import com.mh.common.core.domain.entity.WeatherData; |
|
|
|
import com.mh.common.core.domain.entity.WeatherData; |
|
|
|
import com.mh.common.core.domain.vo.DeviceOperateMonitorVO; |
|
|
|
import com.mh.common.core.domain.vo.DeviceOperateMonitorVO; |
|
|
|
@ -13,6 +14,7 @@ import com.mh.common.utils.WeatherUtil; |
|
|
|
import com.mh.system.mapper.SysParamsMapper; |
|
|
|
import com.mh.system.mapper.SysParamsMapper; |
|
|
|
import com.mh.system.mapper.WeatherDataMapper; |
|
|
|
import com.mh.system.mapper.WeatherDataMapper; |
|
|
|
import com.mh.system.mapper.device.CollectionParamsManageMapper; |
|
|
|
import com.mh.system.mapper.device.CollectionParamsManageMapper; |
|
|
|
|
|
|
|
import com.mh.system.mapper.energy.OverviewMapper; |
|
|
|
import com.mh.system.service.device.ICollectionParamsManageService; |
|
|
|
import com.mh.system.service.device.ICollectionParamsManageService; |
|
|
|
import com.mh.system.service.device.ICoolingSystemMonitorService; |
|
|
|
import com.mh.system.service.device.ICoolingSystemMonitorService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
@ -21,9 +23,12 @@ import org.springframework.stereotype.Service; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDate; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.temporal.TemporalAdjusters; |
|
|
|
import java.time.temporal.TemporalAdjusters; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author LJF |
|
|
|
* @author LJF |
|
|
|
@ -42,10 +47,13 @@ public class CoolingSystemMonitorServiceImpl implements ICoolingSystemMonitorSer |
|
|
|
|
|
|
|
|
|
|
|
private final CollectionParamsManageMapper collectionParamsManageMapper; |
|
|
|
private final CollectionParamsManageMapper collectionParamsManageMapper; |
|
|
|
|
|
|
|
|
|
|
|
public CoolingSystemMonitorServiceImpl(SysParamsMapper sysParamsMapper, WeatherDataMapper weatherDataMapper, CollectionParamsManageMapper collectionParamsManageMapper) { |
|
|
|
private final OverviewMapper overviewMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CoolingSystemMonitorServiceImpl(SysParamsMapper sysParamsMapper, WeatherDataMapper weatherDataMapper, CollectionParamsManageMapper collectionParamsManageMapper, OverviewMapper overviewMapper) { |
|
|
|
this.sysParamsMapper = sysParamsMapper; |
|
|
|
this.sysParamsMapper = sysParamsMapper; |
|
|
|
this.weatherDataMapper = weatherDataMapper; |
|
|
|
this.weatherDataMapper = weatherDataMapper; |
|
|
|
this.collectionParamsManageMapper = collectionParamsManageMapper; |
|
|
|
this.collectionParamsManageMapper = collectionParamsManageMapper; |
|
|
|
|
|
|
|
this.overviewMapper = overviewMapper; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@ -245,6 +253,80 @@ public class CoolingSystemMonitorServiceImpl implements ICoolingSystemMonitorSer |
|
|
|
sysPerformanceDTO.setRealCold(totalRealCold); |
|
|
|
sysPerformanceDTO.setRealCold(totalRealCold); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 计算今年电量、冷量
|
|
|
|
|
|
|
|
// 今年开始时间,格式是yyyy-01-01 00:00:00
|
|
|
|
|
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
|
|
|
LocalDateTime startTime = now.with(TemporalAdjusters.firstDayOfYear()).atStartOfDay(); |
|
|
|
|
|
|
|
// 今年结束时间,格式是yyyy-MM-dd 23:59:59.999999999
|
|
|
|
|
|
|
|
LocalDateTime endTime = now.atTime(23, 59, 59, 999_000_000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 批量构建查询条件
|
|
|
|
|
|
|
|
String[] paramTypes = {"16", "17"}; |
|
|
|
|
|
|
|
List<Map<String, Object>> queryConditions = new ArrayList<>(); |
|
|
|
|
|
|
|
for (String paramType : paramTypes) { |
|
|
|
|
|
|
|
Map<String, Object> condition = new HashMap<>(); |
|
|
|
|
|
|
|
condition.put("paramType", paramType); |
|
|
|
|
|
|
|
condition.put("sysType", "0"); |
|
|
|
|
|
|
|
condition.put("startTime", startTime); |
|
|
|
|
|
|
|
condition.put("endTime", endTime); |
|
|
|
|
|
|
|
queryConditions.add(condition); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 并行处理所有查询条件
|
|
|
|
|
|
|
|
List<CompletableFuture<Map<String, Object>>> futures = queryConditions.stream() |
|
|
|
|
|
|
|
.map(condition -> CompletableFuture.supplyAsync(() -> { |
|
|
|
|
|
|
|
String paramType = (String) condition.get("paramType"); |
|
|
|
|
|
|
|
String sysType = (String) condition.get("sysType"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<CollectionParamsManage> queryWrapper1 = new QueryWrapper<>(); |
|
|
|
|
|
|
|
queryWrapper1.eq("param_type", paramType); |
|
|
|
|
|
|
|
queryWrapper1.eq("system_type", sysType); |
|
|
|
|
|
|
|
queryWrapper1.eq("grade", 40); |
|
|
|
|
|
|
|
queryWrapper1.eq("mt_is_sum", 0); |
|
|
|
|
|
|
|
queryWrapper1.eq("is_use", 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long count = collectionParamsManageMapper.selectCount(queryWrapper1); |
|
|
|
|
|
|
|
HashMap<String, BigDecimal> totalData = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (count > 0) { |
|
|
|
|
|
|
|
totalData = getTotalData(paramType, queryWrapper1, startTime, endTime); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
queryWrapper1 = new QueryWrapper<>(); |
|
|
|
|
|
|
|
queryWrapper1.eq("param_type", paramType); |
|
|
|
|
|
|
|
queryWrapper1.eq("system_type", sysType); |
|
|
|
|
|
|
|
queryWrapper1.eq("grade", 40); |
|
|
|
|
|
|
|
queryWrapper1.eq("mt_is_sum", 1); |
|
|
|
|
|
|
|
totalData = getTotalData(paramType, queryWrapper, startTime, endTime); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
|
|
|
|
result.put("paramType", paramType); |
|
|
|
|
|
|
|
result.put("yearValue", totalData.get("yearValue") == null ? BigDecimal.ZERO : totalData.get("yearValue")); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
.toList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 收集所有结果
|
|
|
|
|
|
|
|
List<Map<String, Object>> results = futures.stream() |
|
|
|
|
|
|
|
.map(CompletableFuture::join) |
|
|
|
|
|
|
|
.toList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 汇总结果
|
|
|
|
|
|
|
|
for (Map<String, Object> result : results) { |
|
|
|
|
|
|
|
String paramType = (String) result.get("paramType"); |
|
|
|
|
|
|
|
BigDecimal yearValue = (BigDecimal) result.get("yearValue"); |
|
|
|
|
|
|
|
if (yearValue != null) { |
|
|
|
|
|
|
|
switch (Integer.parseInt(paramType)) { |
|
|
|
|
|
|
|
case 16: |
|
|
|
|
|
|
|
sysPerformanceDTO.setYearPower(yearValue); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 17: |
|
|
|
|
|
|
|
sysPerformanceDTO.setYearCold(yearValue); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 开始计算瞬时EER和累计EER
|
|
|
|
// 开始计算瞬时EER和累计EER
|
|
|
|
BigDecimal yearPower = sysPerformanceDTO.getYearPower(); |
|
|
|
BigDecimal yearPower = sysPerformanceDTO.getYearPower(); |
|
|
|
@ -255,7 +337,7 @@ public class CoolingSystemMonitorServiceImpl implements ICoolingSystemMonitorSer |
|
|
|
// 计算瞬时EER
|
|
|
|
// 计算瞬时EER
|
|
|
|
if (realPower != null && realCold != null) { |
|
|
|
if (realPower != null && realCold != null) { |
|
|
|
if (realPower.compareTo(BigDecimal.ZERO) == 0) { |
|
|
|
if (realPower.compareTo(BigDecimal.ZERO) == 0) { |
|
|
|
sysPerformanceDTO.setRealEER(BigDecimal.ZERO.setScale(1)); // 除数为0时赋值为0.0
|
|
|
|
sysPerformanceDTO.setRealEER(BigDecimal.ZERO.setScale(1, RoundingMode.HALF_UP)); // 除数为0时赋值为0.0
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
BigDecimal eer = realCold.divide(realPower, 1, RoundingMode.HALF_UP); |
|
|
|
BigDecimal eer = realCold.divide(realPower, 1, RoundingMode.HALF_UP); |
|
|
|
sysPerformanceDTO.setRealEER(eer); |
|
|
|
sysPerformanceDTO.setRealEER(eer); |
|
|
|
@ -265,7 +347,7 @@ public class CoolingSystemMonitorServiceImpl implements ICoolingSystemMonitorSer |
|
|
|
// 计算累计EER
|
|
|
|
// 计算累计EER
|
|
|
|
if (yearPower != null && yearCold != null) { |
|
|
|
if (yearPower != null && yearCold != null) { |
|
|
|
if (yearPower.compareTo(BigDecimal.ZERO) == 0) { |
|
|
|
if (yearPower.compareTo(BigDecimal.ZERO) == 0) { |
|
|
|
sysPerformanceDTO.setYearEER(BigDecimal.ZERO.setScale(1)); // 除数为0时赋值为0.0
|
|
|
|
sysPerformanceDTO.setYearEER(BigDecimal.ZERO.setScale(1, RoundingMode.HALF_UP)); // 除数为0时赋值为0.0
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
BigDecimal yearEer = yearCold.divide(yearPower, 1, RoundingMode.HALF_UP); |
|
|
|
BigDecimal yearEer = yearCold.divide(yearPower, 1, RoundingMode.HALF_UP); |
|
|
|
sysPerformanceDTO.setYearEER(yearEer); |
|
|
|
sysPerformanceDTO.setYearEER(yearEer); |
|
|
|
@ -274,6 +356,20 @@ public class CoolingSystemMonitorServiceImpl implements ICoolingSystemMonitorSer |
|
|
|
return sysPerformanceDTO; |
|
|
|
return sysPerformanceDTO; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private HashMap<String, BigDecimal> getTotalData(String paramType, |
|
|
|
|
|
|
|
QueryWrapper<CollectionParamsManage> queryWrapper, LocalDateTime startTime, LocalDateTime endTime) { |
|
|
|
|
|
|
|
List<CollectionParamsManage> collectionParamsManages = collectionParamsManageMapper.selectList(queryWrapper); |
|
|
|
|
|
|
|
HashMap<String, BigDecimal> result = new HashMap<>(); |
|
|
|
|
|
|
|
// 计算得出今年的各个参数用量
|
|
|
|
|
|
|
|
if (!collectionParamsManages.isEmpty()) { |
|
|
|
|
|
|
|
// 开始计时
|
|
|
|
|
|
|
|
BigDecimal yearValue = overviewMapper.queryByDeviceNum(collectionParamsManages, DateUtils.localDateToStr(startTime), DateUtils.localDateToStr(endTime)); |
|
|
|
|
|
|
|
result.put("yearValue", yearValue == null ? BigDecimal.ZERO : yearValue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, String> getWeatherData() { |
|
|
|
public Map<String, String> getWeatherData() { |
|
|
|
Map<String, String> result = new HashMap<>(); |
|
|
|
Map<String, String> result = new HashMap<>(); |
|
|
|
|