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.
260 lines
12 KiB
260 lines
12 KiB
package com.dky.generate;
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
import com.dky.calculate.*;
|
|
import com.dky.entity.SchemeRatingRes;
|
|
import com.dky.modelI.DntdModelI;
|
|
import com.dky.utils.CalculateUtils;
|
|
import com.dky.utils.GetTargetDeviceList;
|
|
import com.dky.utils.GetThisEnergyEmissions;
|
|
import com.dky.utils.entity.SysDeviceHeatScene;
|
|
import com.dky.utils.enums.DeviceSubType;
|
|
import com.dky.utils.enums.EnergyEmissions;
|
|
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.screeningInstallation(DeviceSubType.Boiler_Heating.getDesc(), list);
|
|
// System.out.println("工业锅炉供热: " + alternateDeviceList + "\n");
|
|
|
|
JSONObject distInfo = new JSONObject();
|
|
JSONObject heatUseNeedInfo = new JSONObject();
|
|
JSONObject originalDevInfo = new JSONObject();
|
|
|
|
HeatBoilerScheme scheme = new HeatBoilerScheme();
|
|
HeatCalC heatCalC = new HeatCalC();
|
|
HeatSchemeRating schemeRating = new HeatSchemeRating();
|
|
HeatAdvantage advantage = new HeatAdvantage();
|
|
HeatBoilerModel model = new HeatBoilerModel();
|
|
|
|
Double runCapacity = null;
|
|
Double lastYearNeed = null;
|
|
Double heatingNeedPower = null;
|
|
Integer energyCode = null;
|
|
try {
|
|
distInfo = (JSONObject) jsonObject.get("distInfo");
|
|
heatUseNeedInfo = (JSONObject) jsonObject.get("heatUseNeedInfo");
|
|
originalDevInfo = (JSONObject) jsonObject.get("originalDevInfo");
|
|
// 出口温度(摄氏度)
|
|
Double thermometerValueOut = Double.parseDouble(heatUseNeedInfo.get("thermometerValueOut").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
// 上年最大需量
|
|
lastYearNeed = Double.parseDouble(distInfo.get("lastYearNeed").toString());
|
|
} catch (NullPointerException e1) {
|
|
e1.printStackTrace();
|
|
System.err.println("模型计算必须元素上年最大需量传的为null或者没有传参");
|
|
} catch (NumberFormatException e2) {
|
|
e2.printStackTrace();
|
|
System.err.println("模型计算必须元素上年最大需量为非数字,禁止传参空字符串");
|
|
}
|
|
|
|
try {
|
|
// 运行容量
|
|
runCapacity = Double.parseDouble(distInfo.get("runCapacity").toString());
|
|
} catch (NullPointerException e1) {
|
|
e1.printStackTrace();
|
|
System.err.println("模型计算必须元素运行容量传的为null或者没有传参");
|
|
} catch (NumberFormatException e2) {
|
|
e2.printStackTrace();
|
|
System.err.println("模型计算必须元素运行容量为非数字,禁止传参空字符串");
|
|
}
|
|
|
|
try {
|
|
// 供热需量设备功率(单位: kW)【 1蒸吨等于770KW 】
|
|
heatingNeedPower = Double.parseDouble(heatUseNeedInfo.get("heatingNeedPower").toString()) * 770;
|
|
} catch (NullPointerException e1) {
|
|
e1.printStackTrace();
|
|
System.err.println("模型计算必须元素供热需量设备功率传的为null或者没有传参");
|
|
} catch (NumberFormatException e2) {
|
|
e2.printStackTrace();
|
|
System.err.println("模型计算必须元素供热需量设备功率为非数字,禁止传参空字符串");
|
|
}
|
|
|
|
try {
|
|
// 替代前原能源类型编码
|
|
energyCode = (Integer) originalDevInfo.get("energyCode");
|
|
} catch (NullPointerException e1) {
|
|
e1.printStackTrace();
|
|
System.err.println("模型计算必须元素替代前原能源类型编码传的为null或者没有传参");
|
|
} catch (NumberFormatException e2) {
|
|
e2.printStackTrace();
|
|
System.err.println("模型计算必须元素替代前原能源类型编码为非数字,禁止传参空字符串");
|
|
}
|
|
|
|
// 根据供热需量设备功率计算出不同技术类型下所需要不同功率设备数据
|
|
List<List<MatchedDevice>> matchedDeviceGroupList = scheme.calScheme(heatingNeedPower, alternateDeviceList);
|
|
|
|
// 实际可承载容量A = 运行(或合同容量)x0.9 [将运行容量或合同容量折算成容量] x85%
|
|
double A = runCapacity * COEFFICIENT_1 * COEFFICIENT_2;
|
|
// 根据供热需量设备功率计算每个技术类型下需要的不同功率的设备的数量,然后将不同功率及对应的数量进行计算得出总功率C1,取最大
|
|
Double C1 = heatCalC.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();
|
|
System.out.println("计算因子采用默认值");
|
|
}
|
|
|
|
|
|
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 + (model.calculateAnnualOperatingCost(matchedDevice.getDeviceHeatScene().getDevPower(), matchedDevice.getCount(), matchedDevice.getDeviceHeatScene().getDevSubstituteLaborCost(), matchedDevice.getDeviceHeatScene().getDevAnnualOperationTime()));
|
|
|
|
allCost = allCost + (model.calculateAnnualTotalCost(matchedDevice.getDeviceHeatScene().getDevPower(), matchedDevice.getCount(), matchedDevice.getDeviceHeatScene().getDevSubstituteLaborCost(),
|
|
matchedDevice.getDeviceHeatScene().getDevAnnualOperationTime(), matchedDevice.getDeviceHeatScene().getDevPrice(), matchedDevice.getDeviceHeatScene().getDevServiceLife()));
|
|
|
|
electric = electric + (model.calculateSubstituteElectricity(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));
|
|
//年减碳量
|
|
|
|
|
|
Double previousYearEnergyUsage = 1.0;
|
|
Double lastYearFee = 0.0;
|
|
Double energyPrice = 0.0;
|
|
try {
|
|
energyPrice = Double.parseDouble(originalDevInfo.get("energyPrice").toString());
|
|
} catch (NullPointerException e){
|
|
System.out.println("计算因子采用默认值");
|
|
energyPrice = GetThisEnergyEmissions.getThisEnergyPrice(energyCode);
|
|
}
|
|
|
|
try {
|
|
// 替代前年能源用量
|
|
previousYearEnergyUsage = Double.parseDouble(originalDevInfo.get("previousYearEnergyUsage").toString());
|
|
} catch (NullPointerException e){
|
|
try {
|
|
lastYearFee = Double.parseDouble(originalDevInfo.get("lastYearFee").toString());
|
|
previousYearEnergyUsage = CalculateUtils.divide(lastYearFee, energyPrice);
|
|
} catch (ArithmeticException nfe){
|
|
nfe.printStackTrace();
|
|
System.err.println("数学错误,替代前原使用能源平均单价不可为0");
|
|
} catch (NullPointerException npe){
|
|
System.err.println("替代前年能源使用量和上年运行费用都为空");
|
|
}
|
|
} catch (NumberFormatException nfe){
|
|
nfe.printStackTrace();
|
|
System.err.println("替代前年能源用量为非数字,禁止传参空字符串");
|
|
}
|
|
|
|
try {
|
|
// 上年运行费用(元)
|
|
lastYearFee = Double.parseDouble(originalDevInfo.get("lastYearFee").toString());
|
|
} catch (NullPointerException e) {
|
|
lastYearFee = model.calLastYearFee(0.0, previousYearEnergyUsage, energyPrice);
|
|
} catch (NumberFormatException nfe){
|
|
nfe.printStackTrace();
|
|
System.err.println("上年运行费用(元)为非数字,禁止传参空字符串");
|
|
}
|
|
// 替代前上年原设备碳排放量
|
|
double energyLastYearFactor = model.calLastYearFactor(previousYearEnergyUsage, GetThisEnergyEmissions.getThisEnergyEmission(energyCode));
|
|
// 年减碳量
|
|
calculateAnnualCarbon = model.calculateAnnualCarbonReduction(energyLastYearFactor, electric, EnergyEmissions.ELECTRIC.getCo2EmissionFactor());
|
|
|
|
|
|
returnJsonObject.set("calculate", decimalFormat.format(calculateAnnualCarbon / 1000));
|
|
//替代电量
|
|
returnJsonObject.set("electric", decimalFormat.format(electric));
|
|
//备注
|
|
returnJsonObject.set("remark", remark);
|
|
//封装需配置设备情况
|
|
returnJsonObject.set("deviceList", deviceList);
|
|
|
|
//封装方案优势
|
|
returnJsonObject.set("safety", advantage.safety());
|
|
returnJsonObject.set("economy", advantage.economy(startCost, runCost, lastYearFee));
|
|
returnJsonObject.set("intelligence", advantage.intelligence());
|
|
returnJsonObject.set("environment", advantage.environment(Double.valueOf(decimalFormat.format(calculateAnnualCarbon / 1000))));
|
|
|
|
// 封装方案评分
|
|
// returnJsonObject.set("matchedDeviceList", maps);
|
|
|
|
return returnJsonObject;
|
|
}
|
|
|
|
|
|
}
|
|
|