diff --git a/dntd-model-coolheat/src/main/java/com/dky/calculate/CalC.java b/dntd-model-coolheat/src/main/java/com/dky/calculate/CalC.java new file mode 100644 index 0000000..65c6f40 --- /dev/null +++ b/dntd-model-coolheat/src/main/java/com/dky/calculate/CalC.java @@ -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> getC(List>>> list) { + List> 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 map = new HashMap<>(); + map.put(k, maxPower[0]); + maps.add(map); + }); + }); + return maps; + } + + + + +} diff --git a/dntd-model-coolheat/src/main/java/com/dky/calculate/CalD.java b/dntd-model-coolheat/src/main/java/com/dky/calculate/CalD.java new file mode 100644 index 0000000..7c339a0 --- /dev/null +++ b/dntd-model-coolheat/src/main/java/com/dky/calculate/CalD.java @@ -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 getD(Double lastYearNeed, List> list) { + List maps = new ArrayList<>(); + list.parallelStream().forEach((s)->{ + Map map = new HashMap<>(); + s.forEach((k,v)->{ + map.put(k, lastYearNeed + v); + maps.add(map); + }); + }); + return maps; + } + + + +} diff --git a/dntd-model-coolheat/src/main/java/com/dky/calculate/Scheme.java b/dntd-model-coolheat/src/main/java/com/dky/calculate/Scheme.java new file mode 100644 index 0000000..998d70b --- /dev/null +++ b/dntd-model-coolheat/src/main/java/com/dky/calculate/Scheme.java @@ -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>>> calScheme(Double buildArea, List list) { + // 区分电锅炉、热泵 + Map> grouped = list.stream() + .collect(Collectors.groupingBy(SysDeviceHeatScene::getDeviceSubType)); + List>>> maps = new ArrayList<>(); + // 区分技术类型 + grouped.forEach((k, v) -> { + Map>> map = new HashMap<>(); + List> planList = new ArrayList<>(); + Map> collect = v.stream().collect(Collectors.groupingBy(SysDeviceHeatScene::getTechnologyType)); + collect.forEach((k2, v2) -> { + List matchedDevices = calSchemeByTechType(buildArea, v2); + planList.add(matchedDevices); + }); + map.put(k, planList); + maps.add(map); + }); + return maps; + } + + public static List calSchemeByTechType(Double buildArea, List list) { + // 对List按照单台设备可参考供暖面积进行排序 + list.sort((o1, o2) -> Double.compare(o2.getDevReferenceArea(), o1.getDevReferenceArea())); + Double remainArea = buildArea; + // 遍历设备,根据建筑面积进行匹配设备数量 + List 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; + } + + + +} diff --git a/dntd-model-coolheat/src/main/java/com/dky/calculate/SchemeRating.java b/dntd-model-coolheat/src/main/java/com/dky/calculate/SchemeRating.java new file mode 100644 index 0000000..d658aec --- /dev/null +++ b/dntd-model-coolheat/src/main/java/com/dky/calculate/SchemeRating.java @@ -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>>> list) { + list.parallelStream().forEach(stringListMap -> { + // 区分热泵、电锅炉 + stringListMap.forEach((k,v)->{ + // 循环遍历各个方案 + final Double[] maxRating = {0.0}; + v.parallelStream().forEach((plan)->{ + AtomicReference rating = new AtomicReference<>(0.0); + List> maps = getIndex(list); + for (Map 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> getIndex(List>>> list) { + List> 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 map = new HashMap<>(); + map.put(k, index); + maps.add(map); + }); + }); + + return maps; + } + + + + +} diff --git a/dntd-model-coolheat/src/main/java/com/dky/entity/MatchedDevice.java b/dntd-model-coolheat/src/main/java/com/dky/entity/MatchedDevice.java new file mode 100644 index 0000000..c6a9e86 --- /dev/null +++ b/dntd-model-coolheat/src/main/java/com/dky/entity/MatchedDevice.java @@ -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; + } +} diff --git a/dntd-model-coolheat/src/main/java/com/dky/entity/SysDeviceHeatScene.java b/dntd-model-coolheat/src/main/java/com/dky/entity/SysDeviceHeatScene.java new file mode 100644 index 0000000..cc9ffeb --- /dev/null +++ b/dntd-model-coolheat/src/main/java/com/dky/entity/SysDeviceHeatScene.java @@ -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; + } +} diff --git a/dntd-tool/src/main/java/com/dky/tool/ModelTool.java b/dntd-tool/src/main/java/com/dky/tool/ModelTool.java index 394f48b..c5c839b 100644 --- a/dntd-tool/src/main/java/com/dky/tool/ModelTool.java +++ b/dntd-tool/src/main/java/com/dky/tool/ModelTool.java @@ -48,7 +48,7 @@ public class ModelTool { String localCpuId = GetCpuInfo.getCpuId(); if (cpuIds.contains(localCpuId)){ if (new Date().before(date)){ - //判断模型使用权限 + // 判断模型使用权限 // 根据给定的类名初始化类 加密不需要反实例化new Class modelI = Class.forName("com.dky"+"."+ ConfigReader.getProperty(jsonObject.getStr("type"))); // 实例化这个类