电科院-电能替代模型工具开发
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.5 KiB

package com.dky.calculate;
import com.dky.utils.entity.SysDeviceHeatScene;
import com.dky.utils.result.MatchedDevice;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class HeatBoilerScheme {
public static List<List<MatchedDevice>> calScheme(Double heatEfficiency, List<SysDeviceHeatScene> sysDeviceHeatSceneList) {
// 根据设备细类筛选出一个以设备细类为键,该细类下设备列表为值的Map
Map<String, List<SysDeviceHeatScene>> groupByDevSubTypeMap = sysDeviceHeatSceneList.stream()
.collect(Collectors.groupingBy(SysDeviceHeatScene::getDevSubType));
// 区分技术类型
List<List<MatchedDevice>> planList = new ArrayList<>();
groupByDevSubTypeMap.forEach((devSubType, v) -> {
// 该细类下的设备根据技术类型筛选出一个以技术类型为键,该技术类型下设备列表为值的Map
Map<String, List<SysDeviceHeatScene>> groupByDevTechTypeMap = v.stream().collect(Collectors.groupingBy(SysDeviceHeatScene::getDevTechType));
groupByDevTechTypeMap.forEach((devTechType, devList) -> {
List<MatchedDevice> matchedDevices = calSchemeByTechType(heatEfficiency, devList);
planList.add(matchedDevices);
});
});
return planList;
}
public static List<MatchedDevice> calSchemeByTechType(Double heatEfficiency, List<SysDeviceHeatScene> sysDeviceHeatSceneList) {
// 对技术类型下的设备list按照单台设备功率进行排序
sysDeviceHeatSceneList.sort((o1, o2) -> Double.compare(o2.getDevPower(), o1.getDevPower()));
Double remainArea = heatEfficiency;
// 遍历设备,根据建筑面积进行匹配设备数量
List<MatchedDevice> matchedDeviceList = new ArrayList<>();
for (SysDeviceHeatScene deviceHeatScene : sysDeviceHeatSceneList) {
double v = remainArea / deviceHeatScene.getDevPower();
int count = (int) (v);
if (v < 1) {
count = count + 1;
}
remainArea = remainArea - count * deviceHeatScene.getDevPower();
matchedDeviceList.add(new MatchedDevice(count, deviceHeatScene));
if (remainArea <= 0) {
// 当总供暖面积已经满足需求时,跳出循环,不再选择其他设备
break;
}
}
return matchedDeviceList;
}
}