parent
fc2e72ce87
commit
de6b7624c2
@ -0,0 +1,40 @@ |
|||||||
|
package com.dky.calculate; |
||||||
|
|
||||||
|
|
||||||
|
import com.dky.entity.MatchedDevice; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class CalC { |
||||||
|
|
||||||
|
public static List<Map<String, Double>> getC(List<Map<String, List<List<MatchedDevice>>>> list) { |
||||||
|
List<Map<String, Double>> maps = new ArrayList<>(); |
||||||
|
list.parallelStream().forEach(stringListMap -> { |
||||||
|
// 区分热泵、电锅炉
|
||||||
|
stringListMap.forEach((k,v)->{ |
||||||
|
// 循环遍历各个方案
|
||||||
|
final Double[] maxPower = {0.0}; |
||||||
|
v.parallelStream().forEach((plan)->{ |
||||||
|
Double power = 0.0; |
||||||
|
for (MatchedDevice device : plan){ |
||||||
|
power = power + (device.getCount() * device.getDevice().getDevicePower()) ; |
||||||
|
} |
||||||
|
if (power >= maxPower[0]){ |
||||||
|
maxPower[0] = power; |
||||||
|
} |
||||||
|
}); |
||||||
|
Map<String, Double> map = new HashMap<>(); |
||||||
|
map.put(k, maxPower[0]); |
||||||
|
maps.add(map); |
||||||
|
}); |
||||||
|
}); |
||||||
|
return maps; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,30 @@ |
|||||||
|
package com.dky.calculate; |
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class CalD { |
||||||
|
|
||||||
|
/** |
||||||
|
* 改造后最大需量 |
||||||
|
* @param lastYearNeed 上年最大需量 |
||||||
|
* @param list 设备总功率集合 |
||||||
|
*/ |
||||||
|
public static List<Map> getD(Double lastYearNeed, List<Map<String, Double>> list) { |
||||||
|
List<Map> maps = new ArrayList<>(); |
||||||
|
list.parallelStream().forEach((s)->{ |
||||||
|
Map<String, Double> map = new HashMap<>(); |
||||||
|
s.forEach((k,v)->{ |
||||||
|
map.put(k, lastYearNeed + v); |
||||||
|
maps.add(map); |
||||||
|
}); |
||||||
|
}); |
||||||
|
return maps; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
package com.dky.calculate; |
||||||
|
|
||||||
|
|
||||||
|
import com.dky.entity.MatchedDevice; |
||||||
|
import com.dky.entity.SysDeviceHeatScene; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
public class Scheme { |
||||||
|
|
||||||
|
public static List<Map<String, List<List<MatchedDevice>>>> calScheme(Double buildArea, List<SysDeviceHeatScene> list) { |
||||||
|
// 区分电锅炉、热泵
|
||||||
|
Map<String, List<SysDeviceHeatScene>> grouped = list.stream() |
||||||
|
.collect(Collectors.groupingBy(SysDeviceHeatScene::getDeviceSubType)); |
||||||
|
List<Map<String, List<List<MatchedDevice>>>> maps = new ArrayList<>(); |
||||||
|
// 区分技术类型
|
||||||
|
grouped.forEach((k, v) -> { |
||||||
|
Map<String, List<List<MatchedDevice>>> map = new HashMap<>(); |
||||||
|
List<List<MatchedDevice>> planList = new ArrayList<>(); |
||||||
|
Map<String, List<SysDeviceHeatScene>> collect = v.stream().collect(Collectors.groupingBy(SysDeviceHeatScene::getTechnologyType)); |
||||||
|
collect.forEach((k2, v2) -> { |
||||||
|
List<MatchedDevice> matchedDevices = calSchemeByTechType(buildArea, v2); |
||||||
|
planList.add(matchedDevices); |
||||||
|
}); |
||||||
|
map.put(k, planList); |
||||||
|
maps.add(map); |
||||||
|
}); |
||||||
|
return maps; |
||||||
|
} |
||||||
|
|
||||||
|
public static List<MatchedDevice> calSchemeByTechType(Double buildArea, List<SysDeviceHeatScene> list) { |
||||||
|
// 对List按照单台设备可参考供暖面积进行排序
|
||||||
|
list.sort((o1, o2) -> Double.compare(o2.getDevReferenceArea(), o1.getDevReferenceArea())); |
||||||
|
Double remainArea = buildArea; |
||||||
|
// 遍历设备,根据建筑面积进行匹配设备数量
|
||||||
|
List<MatchedDevice> matchedDeviceList = new ArrayList<>(); |
||||||
|
for (SysDeviceHeatScene deviceHeatScene : list) { |
||||||
|
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; |
||||||
|
} |
||||||
|
} |
||||||
|
return matchedDeviceList; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,83 @@ |
|||||||
|
package com.dky.calculate; |
||||||
|
|
||||||
|
|
||||||
|
import com.dky.entity.MatchedDevice; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.concurrent.atomic.AtomicReference; |
||||||
|
|
||||||
|
public class SchemeRating { |
||||||
|
|
||||||
|
|
||||||
|
public static void getOptimalScheme(List<Map<String, List<List<MatchedDevice>>>> list) { |
||||||
|
list.parallelStream().forEach(stringListMap -> { |
||||||
|
// 区分热泵、电锅炉
|
||||||
|
stringListMap.forEach((k,v)->{ |
||||||
|
// 循环遍历各个方案
|
||||||
|
final Double[] maxRating = {0.0}; |
||||||
|
v.parallelStream().forEach((plan)->{ |
||||||
|
AtomicReference<Double> rating = new AtomicReference<>(0.0); |
||||||
|
List<Map<String, Double[]>> maps = getIndex(list); |
||||||
|
for (Map<String, Double[]> map : maps) { |
||||||
|
map.forEach((k1, v1) -> { |
||||||
|
if (k1.equals(k)){ |
||||||
|
Double eff = 0.0; |
||||||
|
Double cost = 0.0; |
||||||
|
for (MatchedDevice device : plan) { |
||||||
|
eff = device.getDevice().getHeatingEffciency(); |
||||||
|
} |
||||||
|
for (MatchedDevice device : plan) { |
||||||
|
cost = cost + ((device.getCount() * device.getDevice().getDevicePrice()) + (device.getCount()) * device.getDevice().getArtificialCost() * device.getDevice().getDeviceLife()); |
||||||
|
} |
||||||
|
rating.set(((1 - ((v1[0] - eff) / v1[0])) * 100 * 0.8) + ((1 - ((cost - v1[1]) / v1[1])) * 100 * 0.2)); |
||||||
|
System.out.println("方案: " + plan + ",评分 = " + rating + "\n"); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static List<Map<String, Double[]>> getIndex(List<Map<String, List<List<MatchedDevice>>>> list) { |
||||||
|
List<Map<String, Double[]>> maps = new ArrayList<>(); |
||||||
|
list.parallelStream().forEach(stringListMap -> { |
||||||
|
// 区分热泵、电锅炉
|
||||||
|
stringListMap.forEach((k, v) -> { |
||||||
|
// 循环遍历各个方案
|
||||||
|
// 热效率、成本
|
||||||
|
final Double[] index = {0.0, Double.MAX_VALUE}; |
||||||
|
v.parallelStream().forEach((plan) -> { |
||||||
|
Double eff = 0.0; |
||||||
|
Double cost = 0.0; |
||||||
|
for (MatchedDevice device : plan) { |
||||||
|
eff = device.getDevice().getHeatingEffciency(); |
||||||
|
} |
||||||
|
for (MatchedDevice device : plan) { |
||||||
|
cost = cost + ((device.getCount() * device.getDevice().getDevicePrice()) + (device.getCount()) * device.getDevice().getArtificialCost() * device.getDevice().getDeviceLife()); |
||||||
|
} |
||||||
|
if (eff >= index[0]) { |
||||||
|
index[0] = eff; |
||||||
|
} |
||||||
|
if (cost <= index[1]) { |
||||||
|
index[1] = cost; |
||||||
|
} |
||||||
|
}); |
||||||
|
Map<String, Double[]> map = new HashMap<>(); |
||||||
|
map.put(k, index); |
||||||
|
maps.add(map); |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
return maps; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
package com.dky.entity; |
||||||
|
|
||||||
|
|
||||||
|
public class MatchedDevice { |
||||||
|
|
||||||
|
private Integer count; |
||||||
|
|
||||||
|
private SysDeviceHeatScene device; |
||||||
|
|
||||||
|
public MatchedDevice() { } |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "MatchedDevice{" + |
||||||
|
"count=" + count + |
||||||
|
", device=" + device + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
|
||||||
|
public MatchedDevice(Integer count, SysDeviceHeatScene device) { |
||||||
|
this.count = count; |
||||||
|
this.device = device; |
||||||
|
} |
||||||
|
|
||||||
|
public Integer getCount() { |
||||||
|
return count; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCount(Integer count) { |
||||||
|
this.count = count; |
||||||
|
} |
||||||
|
|
||||||
|
public SysDeviceHeatScene getDevice() { |
||||||
|
return device; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDevice(SysDeviceHeatScene device) { |
||||||
|
this.device = device; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,166 @@ |
|||||||
|
package com.dky.entity; |
||||||
|
|
||||||
|
|
||||||
|
public class SysDeviceHeatScene { |
||||||
|
|
||||||
|
/** 序号 */ |
||||||
|
private Integer id ; |
||||||
|
/** 设备类型 */ |
||||||
|
private String deviceType ; |
||||||
|
/** 设备细类 */ |
||||||
|
private String deviceSubType ; |
||||||
|
/** 技术类型 */ |
||||||
|
private String technologyType ; |
||||||
|
/** 热效率 */ |
||||||
|
private Double heatingEffciency ; |
||||||
|
/** 设备功率(kW) */ |
||||||
|
private Double devicePower ; |
||||||
|
/** 设备单价(万元) */ |
||||||
|
private Double devicePrice ; |
||||||
|
/** 电替代设备年人工费用(万元) */ |
||||||
|
private Double artificialCost ; |
||||||
|
/** 原设备的人工费用(万元) */ |
||||||
|
private Double laborCost ; |
||||||
|
/** 单台电设备参考的可供暖面积(万平方米) */ |
||||||
|
private Double devReferenceArea ; |
||||||
|
/** 设备使用年限(年) */ |
||||||
|
private Integer deviceLife ; |
||||||
|
/** 设备年运行时长(小时) */ |
||||||
|
private Integer deviceRunHours ; |
||||||
|
/** 备注 */ |
||||||
|
private String remarkInfo ; |
||||||
|
|
||||||
|
|
||||||
|
public SysDeviceHeatScene(Integer id, String deviceType, String deviceSubType, String technologyType, Double heatingEffciency, Double devicePower, Double devicePrice, Double artificialCost, Double laborCost, Double devReferenceArea, Integer deviceLife, Integer deviceRunHours, String remarkInfo) { |
||||||
|
this.id = id; |
||||||
|
this.deviceType = deviceType; |
||||||
|
this.deviceSubType = deviceSubType; |
||||||
|
this.technologyType = technologyType; |
||||||
|
this.heatingEffciency = heatingEffciency; |
||||||
|
this.devicePower = devicePower; |
||||||
|
this.devicePrice = devicePrice; |
||||||
|
this.artificialCost = artificialCost; |
||||||
|
this.laborCost = laborCost; |
||||||
|
this.devReferenceArea = devReferenceArea; |
||||||
|
this.deviceLife = deviceLife; |
||||||
|
this.deviceRunHours = deviceRunHours; |
||||||
|
this.remarkInfo = remarkInfo; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return "SysDeviceHeatScene{" + |
||||||
|
"id=" + id + |
||||||
|
", deviceSubType='" + deviceSubType + '\'' + |
||||||
|
", technologyType='" + technologyType + '\'' + |
||||||
|
", heatingEffciency=" + heatingEffciency + |
||||||
|
", devicePrice=" + devicePrice + |
||||||
|
", laborCost=" + laborCost + |
||||||
|
", deviceLife=" + deviceLife + |
||||||
|
'}'; |
||||||
|
} |
||||||
|
|
||||||
|
public Integer getId() { |
||||||
|
return id; |
||||||
|
} |
||||||
|
|
||||||
|
public void setId(Integer id) { |
||||||
|
this.id = id; |
||||||
|
} |
||||||
|
|
||||||
|
public String getDeviceType() { |
||||||
|
return deviceType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDeviceType(String deviceType) { |
||||||
|
this.deviceType = deviceType; |
||||||
|
} |
||||||
|
|
||||||
|
public String getDeviceSubType() { |
||||||
|
return deviceSubType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDeviceSubType(String deviceSubType) { |
||||||
|
this.deviceSubType = deviceSubType; |
||||||
|
} |
||||||
|
|
||||||
|
public String getTechnologyType() { |
||||||
|
return technologyType; |
||||||
|
} |
||||||
|
|
||||||
|
public void setTechnologyType(String technologyType) { |
||||||
|
this.technologyType = technologyType; |
||||||
|
} |
||||||
|
|
||||||
|
public Double getHeatingEffciency() { |
||||||
|
return heatingEffciency; |
||||||
|
} |
||||||
|
|
||||||
|
public void setHeatingEffciency(Double heatingEffciency) { |
||||||
|
this.heatingEffciency = heatingEffciency; |
||||||
|
} |
||||||
|
|
||||||
|
public Double getDevicePower() { |
||||||
|
return devicePower; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDevicePower(Double devicePower) { |
||||||
|
this.devicePower = devicePower; |
||||||
|
} |
||||||
|
|
||||||
|
public Double getDevicePrice() { |
||||||
|
return devicePrice; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDevicePrice(Double devicePrice) { |
||||||
|
this.devicePrice = devicePrice; |
||||||
|
} |
||||||
|
|
||||||
|
public Double getArtificialCost() { |
||||||
|
return artificialCost; |
||||||
|
} |
||||||
|
|
||||||
|
public void setArtificialCost(Double artificialCost) { |
||||||
|
this.artificialCost = artificialCost; |
||||||
|
} |
||||||
|
|
||||||
|
public Double getLaborCost() { |
||||||
|
return laborCost; |
||||||
|
} |
||||||
|
|
||||||
|
public void setLaborCost(Double laborCost) { |
||||||
|
this.laborCost = laborCost; |
||||||
|
} |
||||||
|
|
||||||
|
public Double getDevReferenceArea() { |
||||||
|
return devReferenceArea; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDevReferenceArea(Double devReferenceArea) { |
||||||
|
this.devReferenceArea = devReferenceArea; |
||||||
|
} |
||||||
|
|
||||||
|
public Integer getDeviceLife() { |
||||||
|
return deviceLife; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDeviceLife(Integer deviceLife) { |
||||||
|
this.deviceLife = deviceLife; |
||||||
|
} |
||||||
|
|
||||||
|
public Integer getDeviceRunHours() { |
||||||
|
return deviceRunHours; |
||||||
|
} |
||||||
|
|
||||||
|
public void setDeviceRunHours(Integer deviceRunHours) { |
||||||
|
this.deviceRunHours = deviceRunHours; |
||||||
|
} |
||||||
|
|
||||||
|
public String getRemarkInfo() { |
||||||
|
return remarkInfo; |
||||||
|
} |
||||||
|
|
||||||
|
public void setRemarkInfo(String remarkInfo) { |
||||||
|
this.remarkInfo = remarkInfo; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue