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.
248 lines
12 KiB
248 lines
12 KiB
package com.dky.generate;
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
import com.dky.calculate.MaterialAdvantage;
|
|
import com.dky.calculate.MaterialKilnModel;
|
|
import com.dky.calculate.MaterialKilnScheme;
|
|
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.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
public class MaterialKilnScene 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> list1 = GetTargetDeviceList.screeningInstallation(DeviceSubType.Material_Kiln.getDesc(), list);
|
|
List<SysDeviceHeatScene> list2 = GetTargetDeviceList.screeningInstallation(DeviceSubType.Metal_Kiln.getDesc(), list);
|
|
List<SysDeviceHeatScene> alternateDeviceList = new ArrayList<>(list1);
|
|
alternateDeviceList.addAll(list2);
|
|
|
|
MaterialKilnModel model = new MaterialKilnModel();
|
|
MaterialAdvantage advantage = new MaterialAdvantage();
|
|
|
|
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");
|
|
// 预计年产量(吨)
|
|
Double yearOutPut = Double.parseDouble(heatUseNeedInfo.get("yearOutPut").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
double lastYearNeed = 0;
|
|
double runCapacity = 0;
|
|
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("模型计算必须元素运行容量为非数字,禁止传参空字符串");
|
|
}
|
|
|
|
Double workArea = null;
|
|
try {
|
|
// 工作容积(单位: m³)【 1 立方米=1000 升 】
|
|
workArea = Double.parseDouble(heatUseNeedInfo.get("workArea").toString()) / 1000;
|
|
} catch (NullPointerException e1) {
|
|
e1.printStackTrace();
|
|
System.err.println("模型计算必须元素工作容积传的为null或者没有传参");
|
|
} catch (NumberFormatException e2) {
|
|
e2.printStackTrace();
|
|
System.err.println("模型计算必须元素工作容积为非数字,禁止传参空字符串");
|
|
}
|
|
|
|
|
|
Double needTemp = null;
|
|
try {
|
|
// 温度要求(摄氏度)
|
|
needTemp = Double.parseDouble(heatUseNeedInfo.get("needTemp").toString());
|
|
} catch (NullPointerException e1) {
|
|
e1.printStackTrace();
|
|
System.err.println("模型计算必须元素温度要求(摄氏度)传的为null或者没有传参");
|
|
} catch (NumberFormatException e2) {
|
|
e2.printStackTrace();
|
|
System.err.println("模型计算必须元素温度要求(摄氏度)为非数字,禁止传参空字符串");
|
|
}
|
|
|
|
// 用户所属行业编码
|
|
String userIndustry = null;
|
|
try {
|
|
userIndustry = jsonObject.get("userIndustry").toString();
|
|
} catch (NullPointerException e) {
|
|
System.out.println("用户所属行业编码为空");
|
|
}
|
|
|
|
// 替代前原能源类型编码
|
|
Integer energyCode = null;
|
|
try {
|
|
// 替代前原能源类型编码
|
|
energyCode = (Integer) originalDevInfo.get("energyCode");
|
|
} catch (NullPointerException e1) {
|
|
e1.printStackTrace();
|
|
System.err.println("模型计算必须元素替代前原能源类型编码传的为null或者没有传参");
|
|
} catch (NumberFormatException e2) {
|
|
e2.printStackTrace();
|
|
System.err.println("模型计算必须元素替代前原能源类型编码为非数字,禁止传参空字符串");
|
|
}
|
|
|
|
// 根据供热需量设备功率计算出不同技术类型下所需要不同功率设备数据
|
|
List<SysDeviceHeatScene> schemeList = MaterialKilnScheme.getSchemeList(userIndustry, needTemp, alternateDeviceList);
|
|
List<MatchedDevice> matchedDeviceGroupList = MaterialKilnScheme.calSchemeByTechType(workArea, schemeList);
|
|
|
|
// 实际可承载容量A = 运行(或合同容量)x0.9 [将运行容量或合同容量折算成容量] x85%
|
|
double A = runCapacity * COEFFICIENT_1 * COEFFICIENT_2;
|
|
// 根据供热需量设备功率计算每个技术类型下需要的不同功率的设备的数量,然后将不同功率及对应的数量进行计算得出总功率C1,取最大
|
|
Double C1 = model.getC1(Collections.singletonList(matchedDeviceGroupList));
|
|
|
|
// 改造后最大需量
|
|
double D1 = lastYearNeed + C1;
|
|
|
|
String remark = "";
|
|
|
|
// 同时考虑热泵和电锅炉
|
|
if (A < D1) {
|
|
remark = "本方案存在扩容投资需求,扩容投资不计入初次投资费用";
|
|
}
|
|
|
|
|
|
/*
|
|
封装返回
|
|
*/
|
|
JSONObject returnJsonObject = new JSONObject();
|
|
Double startCost = 0.0;
|
|
Double runCost = 0.0;
|
|
Double allCost = 0.0;
|
|
Double calculateAnnualCarbon = 0.0;
|
|
Double laborFee1 = 0.0;
|
|
Double electric = 0.0;
|
|
List<HashMap<String, Object>> deviceList = new ArrayList<>();
|
|
for (MatchedDevice matchedDevice : matchedDeviceGroupList) {
|
|
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()));
|
|
|
|
laborFee1 = laborFee1 + (matchedDevice.getCount() * matchedDevice.getDeviceHeatScene().getLaborCost() / matchedDevice.getDeviceHeatScene().getDevServiceLife());
|
|
|
|
}
|
|
|
|
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((Integer) originalDevInfo.get("energyCode")));
|
|
// 年减碳量
|
|
calculateAnnualCarbon = model.calculateAnnualCarbonReduction(energyLastYearFactor, electric, EnergyEmissions.ELECTRIC.getCo2EmissionFactor());
|
|
|
|
//初次投资费用
|
|
returnJsonObject.set("startCost", decimalFormat.format(startCost));
|
|
// 设备总价
|
|
returnJsonObject.set("devCost", decimalFormat.format(startCost));
|
|
//年运行费用
|
|
returnJsonObject.set("yearRunCost", decimalFormat.format(runCost));
|
|
//年总费用
|
|
returnJsonObject.set("yearCost", decimalFormat.format(allCost));
|
|
|
|
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))));
|
|
|
|
|
|
return returnJsonObject;
|
|
}
|
|
|
|
|
|
}
|
|
|