parent
99a1ad074c
commit
8c81724b9e
@ -0,0 +1,21 @@ |
|||||||
|
package com.dky.utils; |
||||||
|
|
||||||
|
|
||||||
|
import com.dky.utils.entity.SysDeviceHeatScene; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public class GetTargetDeviceList { |
||||||
|
|
||||||
|
public static List<SysDeviceHeatScene> main(String args, List<SysDeviceHeatScene> alternateDeviceList) { |
||||||
|
List<SysDeviceHeatScene> ary = new ArrayList<>(); |
||||||
|
|
||||||
|
alternateDeviceList.forEach((device) -> { |
||||||
|
if (device.getDevSubType().equals(args)) { |
||||||
|
ary.add(device); |
||||||
|
} |
||||||
|
}); |
||||||
|
return ary; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
package com.dky.utils.enums; |
||||||
|
|
||||||
|
|
||||||
|
public enum DeviceSubType { |
||||||
|
|
||||||
|
Boiler_Heating(0101, "工业供热电锅炉"), |
||||||
|
Cooling_Heating(0201, "供冷/暖"), |
||||||
|
Cooling_Heating_Electric_Boiler(0202, "供冷/暖电锅炉"); |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 编码 |
||||||
|
*/ |
||||||
|
private final Integer code; |
||||||
|
/** |
||||||
|
* 中文描述 |
||||||
|
*/ |
||||||
|
private final String desc; |
||||||
|
|
||||||
|
public Integer getCode() { |
||||||
|
return code; |
||||||
|
} |
||||||
|
|
||||||
|
public String getDesc() { |
||||||
|
return desc; |
||||||
|
} |
||||||
|
|
||||||
|
DeviceSubType(Integer code, String desc) { |
||||||
|
this.code = code; |
||||||
|
this.desc = desc; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,59 @@ |
|||||||
|
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; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,169 @@ |
|||||||
|
package com.dky.generate; |
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject; |
||||||
|
import com.dky.calculate.*; |
||||||
|
import com.dky.modelI.DntdModelI; |
||||||
|
import com.dky.utils.GetTargetDeviceList; |
||||||
|
import com.dky.utils.entity.SysDeviceHeatScene; |
||||||
|
import com.dky.utils.enums.DeviceSubType; |
||||||
|
import com.dky.utils.result.MatchedDevice; |
||||||
|
|
||||||
|
import java.text.DecimalFormat; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class HeatBoilerScene implements DntdModelI { |
||||||
|
|
||||||
|
DecimalFormat decimalFormat = new DecimalFormat("#.00"); |
||||||
|
|
||||||
|
// 首先A=由运行/合同容量折合成kW(x0.9)x85%,
|
||||||
|
static final Double COEFFICIENT_1 = 0.9; |
||||||
|
static final Double COEFFICIENT_2 = 0.85; |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public JSONObject createReport(JSONObject jsonObject, List<SysDeviceHeatScene> list) { |
||||||
|
|
||||||
|
List<SysDeviceHeatScene> alternateDeviceList = GetTargetDeviceList.main(DeviceSubType.Boiler_Heating.getDesc(), list); |
||||||
|
// System.out.println("工业锅炉供热: " + alternateDeviceList + "\n");
|
||||||
|
|
||||||
|
JSONObject distInfo = new JSONObject(); |
||||||
|
JSONObject heatUseNeedInfo = new JSONObject(); |
||||||
|
JSONObject originalDevInfo = new JSONObject(); |
||||||
|
|
||||||
|
try { |
||||||
|
distInfo = (JSONObject) jsonObject.get("distInfo"); |
||||||
|
heatUseNeedInfo = (JSONObject) jsonObject.get("heatUseNeedInfo"); |
||||||
|
originalDevInfo = (JSONObject) jsonObject.get("originalDevInfo"); |
||||||
|
} catch (Exception e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
|
||||||
|
// 运行容量
|
||||||
|
Double runCapacity = Double.parseDouble(distInfo.get("runCapacity").toString()); |
||||||
|
// 上年最大需量
|
||||||
|
Double lastYearNeed = Double.parseDouble(distInfo.get("lastYearNeed").toString()); |
||||||
|
// 供热需量设备功率(单位: kW)【 1蒸吨等于770KW 】
|
||||||
|
Double heatingNeedPower = Double.parseDouble(heatUseNeedInfo.get("heatingNeedPower").toString()) * 770; |
||||||
|
// 出口温度(摄氏度)
|
||||||
|
Double thermometerValueOut = Double.parseDouble(heatUseNeedInfo.get("thermometerValueOut").toString()); |
||||||
|
// 替代前年能源用量
|
||||||
|
Double previousYearEnergyUsage = Double.parseDouble(originalDevInfo.get("previousYearEnergyUsage").toString()); |
||||||
|
// 上年运行费用(元)
|
||||||
|
Double lastYearFee = Double.parseDouble(originalDevInfo.get("lastYearFee").toString()); |
||||||
|
|
||||||
|
// 根据供热需量设备功率计算出不同技术类型下所需要不同功率设备数据
|
||||||
|
List<List<MatchedDevice>> matchedDeviceGroupList = HeatBoilerScheme.calScheme(heatingNeedPower, alternateDeviceList); |
||||||
|
|
||||||
|
// 实际可承载容量A = 运行(或合同容量)x0.9 [将运行容量或合同容量折算成容量] x85%
|
||||||
|
double A = runCapacity * COEFFICIENT_1 * COEFFICIENT_2; |
||||||
|
// 根据供热需量设备功率计算每个技术类型下需要的不同功率的设备的数量,然后将不同功率及对应的数量进行计算得出总功率C1,取最大
|
||||||
|
Double C1 = CalC.getC1(matchedDeviceGroupList); |
||||||
|
|
||||||
|
// 改造后最大需量
|
||||||
|
double D1 = lastYearNeed + C1; |
||||||
|
|
||||||
|
double costRatio = 0.2; |
||||||
|
double effRatio = 0.8; |
||||||
|
try { |
||||||
|
double costRatio1 = Double.parseDouble(jsonObject.get("costRatio").toString()); |
||||||
|
double effRatio1 = Double.parseDouble(jsonObject.get("effRatio").toString()); |
||||||
|
if (costRatio1 < 1 && costRatio1 + costRatio1 == 1) { |
||||||
|
costRatio = costRatio1; |
||||||
|
effRatio = effRatio1; |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
List<MatchedDevice> matchedDeviceList; |
||||||
|
Map<String, SchemeRatingRes> listMap; |
||||||
|
|
||||||
|
// 根据具体容量与需量判断可使用的技术并计算评分
|
||||||
|
// 计算不同细类下成本最小值与效率最大值
|
||||||
|
Map<String, Double> maxEffMap = SchemeRating.getMaxEfficiencyGroupByDevSubType(alternateDeviceList); |
||||||
|
Map<String, Double> minPrice = SchemeRating.getMinPriceGroupByDevSubType(matchedDeviceGroupList); |
||||||
|
String remark = ""; |
||||||
|
|
||||||
|
// 同时考虑热泵和电锅炉
|
||||||
|
if (A < D1) { |
||||||
|
remark = "本方案存在扩容投资需求,扩容投资不计入初次投资费用"; |
||||||
|
} |
||||||
|
listMap = SchemeRating.getOptimalList(matchedDeviceGroupList, costRatio, effRatio, maxEffMap, minPrice); |
||||||
|
matchedDeviceList = SchemeRating.getOptimalScheme(listMap); |
||||||
|
|
||||||
|
List<Map<String, Object>> maps = new ArrayList<>(); |
||||||
|
listMap.forEach((k, v) -> { |
||||||
|
Map<String, Object> map = new HashMap<>(); |
||||||
|
map.put("rating", decimalFormat.format(v.getSchemeRating())); |
||||||
|
map.put("plan", v.getList()); |
||||||
|
map.put("planName", v.getPlanName()); |
||||||
|
maps.add(map); |
||||||
|
}); |
||||||
|
|
||||||
|
|
||||||
|
/* |
||||||
|
封装返回 |
||||||
|
*/ |
||||||
|
JSONObject returnJsonObject = new JSONObject(); |
||||||
|
Double startCost = 0.0; |
||||||
|
Double runCost = 0.0; |
||||||
|
Double allCost = 0.0; |
||||||
|
Double calculateAnnualCarbon = 0.0; |
||||||
|
Double electric = 0.0; |
||||||
|
List<HashMap<String, Object>> deviceList = new ArrayList<>(); |
||||||
|
for (MatchedDevice matchedDevice : matchedDeviceList) { |
||||||
|
HashMap<String, Object> map = new HashMap<>(); |
||||||
|
map.put("devSubType", matchedDevice.getDeviceHeatScene().getDevSubType()); |
||||||
|
map.put("devTechType", matchedDevice.getDeviceHeatScene().getDevTechType()); |
||||||
|
map.put("devCount", matchedDevice.getCount()); |
||||||
|
map.put("devPrice", matchedDevice.getDeviceHeatScene().getDevPrice()); |
||||||
|
deviceList.add(map); |
||||||
|
|
||||||
|
startCost = startCost + (matchedDevice.getCount() * matchedDevice.getDeviceHeatScene().getDevPrice()); |
||||||
|
|
||||||
|
runCost = runCost + (HeatBoilerModel.calculateAnnualOperatingCost(matchedDevice.getDeviceHeatScene().getDevPower(), matchedDevice.getCount(), matchedDevice.getDeviceHeatScene().getDevSubstituteLaborCost(), matchedDevice.getDeviceHeatScene().getDevAnnualOperationTime())); |
||||||
|
|
||||||
|
allCost = allCost + (HeatBoilerModel.calculateAnnualTotalCost(matchedDevice.getDeviceHeatScene().getDevPower(), matchedDevice.getCount(), matchedDevice.getDeviceHeatScene().getDevSubstituteLaborCost(), |
||||||
|
matchedDevice.getDeviceHeatScene().getDevAnnualOperationTime(), matchedDevice.getDeviceHeatScene().getDevPrice(), matchedDevice.getDeviceHeatScene().getDevServiceLife())); |
||||||
|
|
||||||
|
electric = electric + (HeatBoilerModel.calculateSubstituteElectricity(matchedDevice.getDeviceHeatScene().getDevPower(), matchedDevice.getCount(), matchedDevice.getDeviceHeatScene().getDevAnnualOperationTime())); |
||||||
|
|
||||||
|
// calculateAnnualCarbon = calculateAnnualCarbon + (HeatBoilerModel.calculateAnnualCarbonReduction(previousYearEnergyUsage, matchedDevice.getDeviceHeatScene().getDevPower(), matchedDevice.getCount(), matchedDevice.getDeviceHeatScene().getDevAnnualOperationTime()));
|
||||||
|
|
||||||
|
} |
||||||
|
//初次投资费用
|
||||||
|
returnJsonObject.set("startCost", decimalFormat.format(startCost)); |
||||||
|
// 设备总价
|
||||||
|
returnJsonObject.set("devCost", decimalFormat.format(startCost)); |
||||||
|
//年运行费用
|
||||||
|
returnJsonObject.set("yearRunCost", decimalFormat.format(runCost)); |
||||||
|
//年总费用
|
||||||
|
returnJsonObject.set("yearCost", decimalFormat.format(allCost)); |
||||||
|
//年减碳量
|
||||||
|
calculateAnnualCarbon = HeatBoilerModel.calculateAnnualCarbonReduction(previousYearEnergyUsage, electric); |
||||||
|
returnJsonObject.set("calculate", decimalFormat.format(calculateAnnualCarbon / 1000)); |
||||||
|
//替代电量
|
||||||
|
returnJsonObject.set("electric", decimalFormat.format(electric)); |
||||||
|
//备注
|
||||||
|
returnJsonObject.set("remark", remark); |
||||||
|
//封装需配置设备情况
|
||||||
|
returnJsonObject.set("deviceList", deviceList); |
||||||
|
|
||||||
|
//封装方案优势
|
||||||
|
returnJsonObject.set("safety", BuildHeatingAdvantage.safety()); |
||||||
|
returnJsonObject.set("economy", Advantage.economy(startCost, runCost, lastYearFee)); |
||||||
|
returnJsonObject.set("intelligence", BuildHeatingAdvantage.intelligence()); |
||||||
|
returnJsonObject.set("environment", BuildHeatingAdvantage.environment(Double.valueOf(decimalFormat.format(calculateAnnualCarbon / 1000)))); |
||||||
|
|
||||||
|
//封装方案评分
|
||||||
|
returnJsonObject.set("matchedDeviceList", maps); |
||||||
|
|
||||||
|
return returnJsonObject; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -1,82 +0,0 @@ |
|||||||
package com.dky.generate; |
|
||||||
|
|
||||||
import cn.hutool.json.JSONObject; |
|
||||||
import com.dky.calculate.Advantage; |
|
||||||
import com.dky.calculate.Overall; |
|
||||||
import com.dky.entity.Heatboiler; |
|
||||||
import com.dky.modelI.DntdModelI; |
|
||||||
import com.dky.utils.entity.SysDeviceHeatScene; |
|
||||||
|
|
||||||
import java.util.HashSet; |
|
||||||
import java.util.List; |
|
||||||
import java.util.Set; |
|
||||||
|
|
||||||
public class HeatBoilerSence implements DntdModelI { |
|
||||||
@Override |
|
||||||
public JSONObject createReport(JSONObject jsonObject, List<SysDeviceHeatScene> alternateDeviceList) { |
|
||||||
JSONObject jsonReport = new JSONObject(); |
|
||||||
Heatboiler heatboiler = jsonObject.toBean(Heatboiler.class); |
|
||||||
// 生成报告
|
|
||||||
// List<DevSpec> specList = ModelTool.specList;
|
|
||||||
// List<DevPrice> priceList = ModelTool.priceList;
|
|
||||||
// MatchedDeviceResult matchedDeviceResult = RequireDevice.matchDevices(heatboiler.getHotDevicePower(), specList, priceList);
|
|
||||||
Overall overall = new Overall(); |
|
||||||
//初次投资费用(万元)
|
|
||||||
// Double firstInvestFee = Math.round(matchedDeviceResult.getTotalPriceInTenThousand()*100.0)/100.0;
|
|
||||||
//年运行费用(万元)
|
|
||||||
Double yearRunFee = Math.round(overall.yearRunFee(heatboiler.getYearEnergy(), heatboiler.getElectricityPrice())*100.0)/100.0; |
|
||||||
//年总费用(万元)
|
|
||||||
Double yearTotalFee = Math.round(overall.yearTotalFee(yearRunFee)*100.0)/100.0; |
|
||||||
//年减碳(吨)
|
|
||||||
Double yearReduceCarbon = Math.round(overall.yearReduceCarbon(heatboiler.getYearEnergy())*100.0)/100.0; |
|
||||||
//替代电量
|
|
||||||
Double replaceEnergy = Math.round(overall.replaceEnergy(heatboiler.getYearEnergy())*100.0)/100.0; |
|
||||||
// List<MatchedDevice> devices = matchedDeviceResult.getMatchedDevices();
|
|
||||||
//需配置设备情况
|
|
||||||
//方案详情
|
|
||||||
String reportDetail = "用直热式电锅炉替代原设备"; |
|
||||||
/*//设备类型
|
|
||||||
String deviceType = ""; |
|
||||||
//设备规格
|
|
||||||
String deviceSpec = ""; |
|
||||||
//设备数量
|
|
||||||
String deviceNum = "";*/ |
|
||||||
//单位(元/台、元/套)
|
|
||||||
String unit = ""; |
|
||||||
Set<String> devTypeSet = new HashSet<>(); |
|
||||||
/* for (MatchedDevice : matchedDeviceResult.getMatchedDevices()) { |
|
||||||
devTypeSet.add(matchedDevice.getDevSpec().getDevType()); |
|
||||||
deviceSpec = deviceSpec + matchedDevice.getDevSpec().getDevType() + ":"+matchedDevicematchedDevice.getDevSpec().getCapacity()+"蒸吨、"; |
|
||||||
deviceNum = deviceNum + matchedDevice.getCount() + "台/"+matchedDevice.getDevSpec().getDevType()+";"; |
|
||||||
int devId = matchedDevice.getDevSpec().getId(); |
|
||||||
for (DevPrice devPrice : priceList) { |
|
||||||
if (devId == devPrice.getId()) { |
|
||||||
unit = unit+devPrice.getDevPrice()+"元/台;"; |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
}*/ |
|
||||||
/* for (String s : devTypeSet) { |
|
||||||
deviceType = deviceType + s + "、"; |
|
||||||
}*/ |
|
||||||
Advantage advantage = new Advantage(); |
|
||||||
//总价
|
|
||||||
// String totalPrice = matchedDeviceResult.getTotalPriceInTenThousand()+"万元";
|
|
||||||
// jsonReport.put("firstInvestFee", firstInvestFee);
|
|
||||||
jsonReport.put("yearRunFee", yearRunFee); |
|
||||||
jsonReport.put("yearTotalFee", yearTotalFee); |
|
||||||
jsonReport.put("yearReduceCarbon", yearReduceCarbon); |
|
||||||
jsonReport.put("replaceEnergy", replaceEnergy); |
|
||||||
jsonReport.put("reportDetail", reportDetail); |
|
||||||
/*jsonReport.put("deviceType", deviceType); |
|
||||||
jsonReport.put("deviceSpec", deviceSpec);*/ |
|
||||||
// jsonReport.put("devices", devices);
|
|
||||||
jsonReport.put("unit", unit); |
|
||||||
// jsonReport.put("totalPrice", totalPrice);
|
|
||||||
jsonReport.put("safety", advantage.safety()); |
|
||||||
// jsonReport.put("economy", advantage.economy(firstInvestFee,yearTotalFee,yearRunFee,heatboiler.getOriginalDevice().getLastYearFee()));
|
|
||||||
jsonReport.put("intelligence", advantage.intelligence()); |
|
||||||
jsonReport.put("environment", advantage.environment(yearReduceCarbon)); |
|
||||||
return jsonReport; |
|
||||||
} |
|
||||||
} |
|
@ -1,2 +1,2 @@ |
|||||||
0101=generate.BuildHeatingScene |
0101=generate.BuildHeatingScene |
||||||
0102=generate.HeatBoilerSence |
0102=generate.HeatBoilerScene |
Loading…
Reference in new issue