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.
78 lines
3.5 KiB
78 lines
3.5 KiB
package com.dky.calculate;
|
|
|
|
|
|
import com.dky.utils.entity.SysDeviceHeatScene;
|
|
import com.dky.utils.result.MatchedDevice;
|
|
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class Scheme {
|
|
|
|
/**
|
|
* 根据设备细类筛选出不同技术类型的不同功率设备需要的数量
|
|
* List<MatchedDevice> 同一个技术类型下的设备列表以及每个设备所需要的台数
|
|
* Map<String, List<List<MatchedDevice>>> 键为设备细类
|
|
*
|
|
* @param buildArea 建筑面积
|
|
* @param sysDeviceHeatSceneList 替代设备列表
|
|
*/
|
|
public static List<List<MatchedDevice>> calScheme(Double buildArea, 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(buildArea, devList);
|
|
planList.add(matchedDevices);
|
|
});
|
|
|
|
});
|
|
return planList;
|
|
}
|
|
|
|
|
|
/**
|
|
* 根据建筑面积和其中一个设备细类-技术类型下的不同功率的设备,计算出该技术类型分别需要不同功率的设备的的数量
|
|
*
|
|
* @param buildArea 建筑面积
|
|
* @param sysDeviceHeatSceneList 不同设备细类-技术类型下的设备列表
|
|
* @return 不同功率的设备对应所需要的数量
|
|
*/
|
|
public static List<MatchedDevice> calSchemeByTechType(Double buildArea, List<SysDeviceHeatScene> sysDeviceHeatSceneList) {
|
|
// 对技术类型下的设备list按照单台设备可参考供暖面积进行排序
|
|
sysDeviceHeatSceneList.sort((o1, o2) -> Double.compare(o2.getDevReferenceArea(), o1.getDevReferenceArea()));
|
|
Double remainArea = buildArea;
|
|
// 遍历设备,根据建筑面积进行匹配设备数量
|
|
List<MatchedDevice> matchedDeviceList = new ArrayList<>();
|
|
|
|
for (int i = 0; i < sysDeviceHeatSceneList.size(); i++) {
|
|
SysDeviceHeatScene deviceHeatScene = sysDeviceHeatSceneList.get(i);
|
|
double v = remainArea / deviceHeatScene.getDevReferenceArea();
|
|
int count = (int) (v);
|
|
if (v < 1) {
|
|
count = count + 1;
|
|
}
|
|
remainArea = remainArea - count * deviceHeatScene.getDevReferenceArea();
|
|
matchedDeviceList.add(new MatchedDevice(count, deviceHeatScene));
|
|
if (remainArea <= 0) {
|
|
// 当总供暖面积已经满足需求时,跳出循环,不再选择其他设备
|
|
break;
|
|
} else {
|
|
if (i == sysDeviceHeatSceneList.size() - 1 && remainArea > 0) {
|
|
MatchedDevice device = matchedDeviceList.get(matchedDeviceList.size() - 1);
|
|
device.setCount(device.getCount() + 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
return matchedDeviceList;
|
|
}
|
|
}
|
|
|