parent
418a98dfef
commit
d515b1f804
@ -0,0 +1,54 @@ |
||||
package com.dky.calculate; |
||||
|
||||
|
||||
|
||||
import com.dky.utils.result.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.getDeviceHeatScene().getDevPower()) ; |
||||
} |
||||
if (power >= maxPower[0]){ |
||||
maxPower[0] = power; |
||||
} |
||||
}); |
||||
Map<String, Double> map = new HashMap<>(); |
||||
map.put(k, maxPower[0]); |
||||
maps.add(map); |
||||
}); |
||||
}); |
||||
return maps; |
||||
} |
||||
|
||||
public Double getC1(List<List<MatchedDevice>> args) { |
||||
// 循环遍历各个方案
|
||||
final Double[] maxPower = {-100.0}; |
||||
args.parallelStream().forEach(plan -> { |
||||
Double power = 0.0; |
||||
for (MatchedDevice device : plan){ |
||||
power = power + (device.getCount() * device.getDeviceHeatScene().getDevPower()) ; |
||||
} |
||||
if (power >= maxPower[0]){ |
||||
maxPower[0] = power; |
||||
} |
||||
}); |
||||
return maxPower[0]; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,42 @@ |
||||
package com.dky.calculate; |
||||
|
||||
import java.text.DecimalFormat; |
||||
|
||||
//方案优势
|
||||
public class HeatAdvantage { |
||||
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.00"); |
||||
|
||||
/** |
||||
* 经济性 |
||||
* @param firstInvestFee 初始投资金额 |
||||
* @param yearRunFee 年运行费用 |
||||
* @param lastYearFee 替代前上年运行费用 |
||||
* @return |
||||
*/ |
||||
public String economy(Double firstInvestFee ,Double yearRunFee, Double lastYearFee){ |
||||
// 运行收益 = 上年运行费用(即原设备运行费用)- 今年运行费用
|
||||
Double hsq = Math.round((lastYearFee - yearRunFee) * 100.0)/100.0; |
||||
if (hsq <= 0){ |
||||
return "本技术方案中替代技术相对于原生产设备在经济性上优势不大,但从环保效益上具有较高的优势"; |
||||
} |
||||
// 投资回收期 = 初次投资费用/运行收益
|
||||
Double js = Math.round((firstInvestFee / hsq) * 100.0)/100.0; |
||||
return "本次改造投资回收期为"+js+"年,本改造方案相比较原技术节省年运行费用成本"+decimalFormat.format(hsq)+"元。"; |
||||
} |
||||
|
||||
// 智能性
|
||||
public String safety(){ |
||||
return "精准控温"; |
||||
} |
||||
|
||||
// 智能性
|
||||
public String intelligence() { |
||||
return "以电锅炉替代和实现精准控温。"; |
||||
} |
||||
|
||||
// 环保性
|
||||
public String environment(Double yearReduceCarbon) { |
||||
return "本次改造方案减排" + yearReduceCarbon + "吨"; |
||||
} |
||||
} |
@ -0,0 +1,153 @@ |
||||
package com.dky.calculate; |
||||
|
||||
|
||||
import com.dky.entity.SchemeRatingRes; |
||||
import com.dky.utils.entity.SysDeviceHeatScene; |
||||
import com.dky.utils.result.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 HeatSchemeRating { |
||||
|
||||
/** |
||||
* 计算每一种方案的效率和成本评分 |
||||
* @param list |
||||
* @return |
||||
*/ |
||||
public Map<String, SchemeRatingRes> getOptimalList(List<List<MatchedDevice>> list, Double costRatio, Double effRatio, Map<String,Double> maxEff, Map<String, Double> minPrice) { |
||||
|
||||
Map<String, SchemeRatingRes> optimalMap = new HashMap<>(); |
||||
list.forEach(plan->{ |
||||
String devTechType = plan.get(0).getDeviceHeatScene().getDevTechType(); |
||||
AtomicReference<Double> rating = new AtomicReference<>(0.0); |
||||
String devSubType = plan.get(0).getDeviceHeatScene().getDevSubType(); |
||||
Double eff = 0.0; |
||||
Double cost = 0.0; |
||||
for (MatchedDevice device : plan) { |
||||
eff = device.getDeviceHeatScene().getHeatEfficiency(); |
||||
} |
||||
for (MatchedDevice device : plan) { |
||||
cost = cost + ((device.getCount() * device.getDeviceHeatScene().getDevPrice()) + (device.getCount()) * device.getDeviceHeatScene().getDevSubstituteLaborCost() * device.getDeviceHeatScene().getDevServiceLife()); |
||||
} |
||||
|
||||
double v1 = (maxEff.get(devSubType) - eff) / maxEff.get(devSubType); // 热效率占比计算
|
||||
double v = (cost - minPrice.get(devSubType)) / minPrice.get(devSubType); // 成本占比计算
|
||||
|
||||
// 3、(1-(选择对应设备细类的效率最大的效率值(效率最大值)-当前设备的效率值值)/效率最大值)*100*系数 +(1-(当前成本值-对应设备细类的成本最小值)/对应设备细类的成本最小值)*100*0.2。取最高得分。
|
||||
rating.set(((1 - v1) * 100 * effRatio) + ((1 - v) * 100 * costRatio)); |
||||
|
||||
System.out.println("当前方案成本 = " + cost + ",方案详情 = "); |
||||
for (MatchedDevice matchedDevice : plan){ |
||||
System.out.println(matchedDevice); |
||||
} |
||||
System.out.println("当前方案评分: " + rating.get() + "\n"); |
||||
|
||||
// 方案评分结果
|
||||
SchemeRatingRes schemeRatingRes = new SchemeRatingRes(plan, rating.get(), devTechType); |
||||
optimalMap.put(devTechType, schemeRatingRes); |
||||
|
||||
}); |
||||
return optimalMap; |
||||
} |
||||
|
||||
/** |
||||
* 获取最优评分的方案 |
||||
* @param map |
||||
* @return |
||||
*/ |
||||
public List<MatchedDevice> getOptimalScheme(Map<String, SchemeRatingRes> map) { |
||||
|
||||
final AtomicReference<Double>[] rating = new AtomicReference[]{new AtomicReference<>(-100.0)}; |
||||
final List<MatchedDevice>[] list = new List[]{new ArrayList<>()}; |
||||
map.forEach((k,v)->{ |
||||
if (v.getSchemeRating() > rating[0].get()) { |
||||
rating[0].set(v.getSchemeRating()); |
||||
list[0] = v.getList(); |
||||
} |
||||
}); |
||||
|
||||
return list[0]; |
||||
} |
||||
|
||||
/** |
||||
* 获取不同设备细类下的效率最大值 |
||||
* @param alternateDeviceList 可替代设备列表 |
||||
* @return 不同设备细类下的效率最大值map |
||||
*/ |
||||
public Map<String,Double> getMaxEfficiencyGroupByDevSubType(List<SysDeviceHeatScene> alternateDeviceList){ |
||||
Map<String,Double> map = new HashMap<>(); |
||||
alternateDeviceList.forEach(alternateDevice ->{ |
||||
String devSubType = alternateDevice.getDevSubType(); |
||||
Double v = map.get(devSubType); |
||||
if ( v == null){ |
||||
map.put(devSubType,alternateDevice.getHeatEfficiency()); |
||||
} else { |
||||
if( alternateDevice.getHeatEfficiency() > v){ |
||||
map.put(devSubType,alternateDevice.getHeatEfficiency()); |
||||
} |
||||
} |
||||
}); |
||||
return map; |
||||
} |
||||
|
||||
/** |
||||
* 获取不同设备细类下的成本最小值 |
||||
* @param alternateDeviceList 可替代设备列表 |
||||
* @return 不同设备细类下的成本最小值 |
||||
*/ |
||||
public Map<String,Double> getMinPriceGroupByDevSubType(List<List<MatchedDevice>> alternateDeviceList){ |
||||
Map<String,Double> map = new HashMap<>(); |
||||
alternateDeviceList.forEach(plan -> { |
||||
Double thisPlanCost = 0.0; |
||||
String devSubType = plan.get(0).getDeviceHeatScene().getDevSubType(); |
||||
for (MatchedDevice device : plan) { |
||||
thisPlanCost = thisPlanCost + ((device.getCount() * device.getDeviceHeatScene().getDevPrice()) + (device.getCount()) * device.getDeviceHeatScene().getDevSubstituteLaborCost() * device.getDeviceHeatScene().getDevServiceLife()); |
||||
} |
||||
|
||||
Double v = map.get(devSubType); |
||||
if ( v == null){ |
||||
map.put(devSubType, thisPlanCost); |
||||
} else { |
||||
if(thisPlanCost < v){ |
||||
map.put(devSubType, thisPlanCost); |
||||
} |
||||
} |
||||
}); |
||||
return map; |
||||
} |
||||
|
||||
|
||||
public List<Map<String, Double[]>> getIndex(List<List<MatchedDevice>> list) { |
||||
List<Map<String, Double[]>> maps = new ArrayList<>(); |
||||
final Double[] index = {0.0, Double.MAX_VALUE}; |
||||
Map<String, Double[]> map = new HashMap<>(); |
||||
|
||||
list.parallelStream().forEach((plan) -> { |
||||
Double eff = 0.0; |
||||
Double cost = 0.0; |
||||
for (MatchedDevice device : plan) { |
||||
eff = device.getDeviceHeatScene().getHeatEfficiency(); |
||||
} |
||||
for (MatchedDevice device : plan) { |
||||
cost = cost + ((device.getCount() * device.getDeviceHeatScene().getDevPrice()) + (device.getCount()) * device.getDeviceHeatScene().getDevSubstituteLaborCost() * device.getDeviceHeatScene().getDevServiceLife()); |
||||
} |
||||
if (eff >= index[0]) { |
||||
index[0] = eff; |
||||
} |
||||
if (cost <= index[1]) { |
||||
index[1] = cost; |
||||
} |
||||
map.put(plan.get(0).getDeviceHeatScene().getDevSubType(), index); |
||||
maps.add(map); |
||||
}); |
||||
return maps; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,47 @@ |
||||
package com.dky.entity; |
||||
|
||||
|
||||
import com.dky.utils.result.MatchedDevice; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class SchemeRatingRes { |
||||
|
||||
List<MatchedDevice> list; |
||||
|
||||
Double schemeRating; |
||||
|
||||
String planName; |
||||
|
||||
public SchemeRatingRes() { } |
||||
|
||||
public SchemeRatingRes(List<MatchedDevice> list, Double schemeRating, String planName) { |
||||
this.list = list; |
||||
this.schemeRating = schemeRating; |
||||
this.planName = planName; |
||||
} |
||||
|
||||
public List<MatchedDevice> getList() { |
||||
return list; |
||||
} |
||||
|
||||
public void setList(List<MatchedDevice> list) { |
||||
this.list = list; |
||||
} |
||||
|
||||
public Double getSchemeRating() { |
||||
return schemeRating; |
||||
} |
||||
|
||||
public void setSchemeRating(Double schemeRating) { |
||||
this.schemeRating = schemeRating; |
||||
} |
||||
|
||||
public String getPlanName() { |
||||
return planName; |
||||
} |
||||
|
||||
public void setPlanName(String planName) { |
||||
this.planName = planName; |
||||
} |
||||
} |
@ -0,0 +1,42 @@ |
||||
package com.dky.calculate; |
||||
|
||||
import java.text.DecimalFormat; |
||||
|
||||
//方案优势
|
||||
public class MaterialAdvantage { |
||||
|
||||
DecimalFormat decimalFormat = new DecimalFormat("#.00"); |
||||
|
||||
/** |
||||
* 经济性 |
||||
* @param firstInvestFee 初始投资金额 |
||||
* @param yearRunFee 年运行费用 |
||||
* @param lastYearFee 替代前上年运行费用 |
||||
* @return |
||||
*/ |
||||
public String economy(Double firstInvestFee ,Double yearRunFee, Double lastYearFee){ |
||||
// 运行收益 = 上年运行费用(即原设备运行费用)- 今年运行费用
|
||||
Double hsq = Math.round((lastYearFee - yearRunFee) * 100.0)/100.0; |
||||
if (hsq <= 0){ |
||||
return "本技术方案中替代技术相对于原生产设备在经济性上优势不大,但从环保效益上具有较高的优势"; |
||||
} |
||||
// 投资回收期 = 初次投资费用/运行收益
|
||||
Double js = Math.round((firstInvestFee / hsq) * 100.0)/100.0; |
||||
return "本次改造投资回收期为"+js+"年,本改造方案相比较原技术节省年运行费用成本"+decimalFormat.format(hsq)+"元。"; |
||||
} |
||||
|
||||
// 智能性
|
||||
public String safety(){ |
||||
return "精准控温"; |
||||
} |
||||
|
||||
// 智能性
|
||||
public String intelligence() { |
||||
return "以电锅炉替代和实现精准控温。"; |
||||
} |
||||
|
||||
// 环保性
|
||||
public String environment(Double yearReduceCarbon) { |
||||
return "本次改造方案减排" + yearReduceCarbon + "吨"; |
||||
} |
||||
} |
@ -0,0 +1,248 @@ |
||||
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.main(DeviceSubType.Material_Kiln.getDesc(), list); |
||||
List<SysDeviceHeatScene> list2 = GetTargetDeviceList.main(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; |
||||
} |
||||
|
||||
|
||||
} |
@ -1 +0,0 @@ |
||||
industry_code=3200 |
@ -1,169 +0,0 @@ |
||||
package com.dky.generate; |
||||
|
||||
import calculate.MetalKilnScheme; |
||||
import cn.hutool.json.JSONObject; |
||||
import com.dky.calculate.*; |
||||
import com.dky.modelI.DntdModelI; |
||||
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.*; |
||||
|
||||
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.main(DeviceSubType.Material_Kiln.getDesc(), list); |
||||
List<SysDeviceHeatScene> list2 = GetTargetDeviceList.main(DeviceSubType.Metal_Kiln.getDesc(), list); |
||||
List<SysDeviceHeatScene> alternateDeviceList = new ArrayList<>(list1); |
||||
alternateDeviceList.addAll(list2); |
||||
|
||||
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()); |
||||
// 工作容积(单位: m³)【 1 立方米=1000 升 】
|
||||
Double workArea = Double.parseDouble(heatUseNeedInfo.get("workArea").toString()) / 1000; |
||||
// 预计年产量(吨)
|
||||
Double yearOutPut = Double.parseDouble(heatUseNeedInfo.get("yearOutPut").toString()); |
||||
// 温度要求(摄氏度)
|
||||
Double needTemp = Double.parseDouble(heatUseNeedInfo.get("needTemp").toString()); |
||||
// 用户所属行业编码
|
||||
String userIndustry = jsonObject.get("userIndustry").toString(); |
||||
|
||||
// 根据供热需量设备功率计算出不同技术类型下所需要不同功率设备数据
|
||||
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 = CalC.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 + (MaterialKilnModel.calculateAnnualOperatingCost(matchedDevice.getDeviceHeatScene().getDevPower(), matchedDevice.getCount(), matchedDevice.getDeviceHeatScene().getDevSubstituteLaborCost(), matchedDevice.getDeviceHeatScene().getDevAnnualOperationTime())); |
||||
|
||||
allCost = allCost + (MaterialKilnModel.calculateAnnualTotalCost(matchedDevice.getDeviceHeatScene().getDevPower(), matchedDevice.getCount(), matchedDevice.getDeviceHeatScene().getDevSubstituteLaborCost(), |
||||
matchedDevice.getDeviceHeatScene().getDevAnnualOperationTime(), matchedDevice.getDeviceHeatScene().getDevPrice(), matchedDevice.getDeviceHeatScene().getDevServiceLife())); |
||||
|
||||
electric = electric + (MaterialKilnModel.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){ |
||||
energyPrice = GetThisEnergyEmissions.getThisEnergyPrice((Integer) originalDevInfo.get("energyCode")); |
||||
} |
||||
|
||||
try { |
||||
// 替代前年能源用量
|
||||
previousYearEnergyUsage = Double.parseDouble(originalDevInfo.get("previousYearEnergyUsage").toString()); |
||||
} catch (NullPointerException e){ |
||||
lastYearFee = Double.parseDouble(originalDevInfo.get("lastYearFee").toString()); |
||||
previousYearEnergyUsage = lastYearFee / energyPrice; |
||||
} |
||||
|
||||
try { |
||||
// 上年运行费用(元)
|
||||
lastYearFee = Double.parseDouble(originalDevInfo.get("lastYearFee").toString()); |
||||
} catch (NullPointerException e) { |
||||
// e.printStackTrace();
|
||||
System.out.println("计算因子采用默认值"); |
||||
lastYearFee = HeatBoilerModel.calLastYearFee(laborFee1, previousYearEnergyUsage, energyPrice); |
||||
} |
||||
// 替代前上年原设备碳排放量
|
||||
double energyLastYearFactor = HeatBoilerModel.calLastYearFactor(previousYearEnergyUsage, GetThisEnergyEmissions.getThisEnergyEmission((Integer) originalDevInfo.get("energyCode"))); |
||||
// 年减碳量
|
||||
calculateAnnualCarbon = HeatBoilerModel.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", 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)))); |
||||
|
||||
|
||||
return returnJsonObject; |
||||
} |
||||
|
||||
|
||||
} |
@ -1,169 +0,0 @@ |
||||
package com.dky.generate; |
||||
|
||||
import calculate.MetalKilnScheme; |
||||
import cn.hutool.json.JSONObject; |
||||
import com.dky.calculate.*; |
||||
import com.dky.modelI.DntdModelI; |
||||
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 MetalKilnScene 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.Metal_Kiln.getDesc(), list); |
||||
|
||||
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()); |
||||
// 工作容积(单位: m³)【 1 立方米=1000 升 】
|
||||
Double workArea = Double.parseDouble(heatUseNeedInfo.get("workArea").toString()) / 1000; |
||||
// 预计年产量(吨)
|
||||
Double yearOutPut = Double.parseDouble(heatUseNeedInfo.get("yearOutPut").toString()); |
||||
// 温度要求(摄氏度)
|
||||
Double needTemp = Double.parseDouble(heatUseNeedInfo.get("needTemp").toString()); |
||||
// 用户所属行业编码
|
||||
String userIndustry = jsonObject.get("userIndustry").toString(); |
||||
|
||||
// 根据供热需量设备功率计算出不同技术类型下所需要不同功率设备数据
|
||||
List<SysDeviceHeatScene> schemeList = MetalKilnScheme.getSchemeList(userIndustry, needTemp, alternateDeviceList); |
||||
List<MatchedDevice> matchedDeviceGroupList = MetalKilnScheme.calSchemeByTechType(workArea, schemeList); |
||||
|
||||
// 实际可承载容量A = 运行(或合同容量)x0.9 [将运行容量或合同容量折算成容量] x85%
|
||||
double A = runCapacity * COEFFICIENT_1 * COEFFICIENT_2; |
||||
// 根据供热需量设备功率计算每个技术类型下需要的不同功率的设备的数量,然后将不同功率及对应的数量进行计算得出总功率C1,取最大
|
||||
Double C1 = CalC.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 + (MaterialKilnModel.calculateAnnualOperatingCost(matchedDevice.getDeviceHeatScene().getDevPower(), matchedDevice.getCount(), matchedDevice.getDeviceHeatScene().getDevSubstituteLaborCost(), matchedDevice.getDeviceHeatScene().getDevAnnualOperationTime())); |
||||
|
||||
allCost = allCost + (MaterialKilnModel.calculateAnnualTotalCost(matchedDevice.getDeviceHeatScene().getDevPower(), matchedDevice.getCount(), matchedDevice.getDeviceHeatScene().getDevSubstituteLaborCost(), |
||||
matchedDevice.getDeviceHeatScene().getDevAnnualOperationTime(), matchedDevice.getDeviceHeatScene().getDevPrice(), matchedDevice.getDeviceHeatScene().getDevServiceLife())); |
||||
|
||||
electric = electric + (MaterialKilnModel.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){ |
||||
energyPrice = GetThisEnergyEmissions.getThisEnergyPrice((Integer) originalDevInfo.get("energyCode")); |
||||
} |
||||
|
||||
try { |
||||
// 替代前年能源用量
|
||||
previousYearEnergyUsage = Double.parseDouble(originalDevInfo.get("previousYearEnergyUsage").toString()); |
||||
} catch (NullPointerException e){ |
||||
lastYearFee = Double.parseDouble(originalDevInfo.get("lastYearFee").toString()); |
||||
previousYearEnergyUsage = lastYearFee / energyPrice; |
||||
} |
||||
|
||||
try { |
||||
// 上年运行费用(元)
|
||||
lastYearFee = Double.parseDouble(originalDevInfo.get("lastYearFee").toString()); |
||||
} catch (NullPointerException e) { |
||||
// e.printStackTrace();
|
||||
System.out.println("计算因子采用默认值"); |
||||
lastYearFee = HeatBoilerModel.calLastYearFee(laborFee1, previousYearEnergyUsage, energyPrice); |
||||
} |
||||
// 替代前上年原设备碳排放量
|
||||
double energyLastYearFactor = HeatBoilerModel.calLastYearFactor(previousYearEnergyUsage, GetThisEnergyEmissions.getThisEnergyEmission((Integer) originalDevInfo.get("energyCode"))); |
||||
// 年减碳量
|
||||
calculateAnnualCarbon = HeatBoilerModel.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", 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)))); |
||||
|
||||
|
||||
return returnJsonObject; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,6 @@ |
||||
0101=generate.HeatBoilerScene |
||||
0102=generate.MaterialKilnScene |
||||
0201=generate.BuildHeatingScene |
||||
0501=generate.KitchenCookScene |
||||
0805=generate.MetalKilnScene |
||||
0806=stirtpar.StirparModelCalculate |
Loading…
Reference in new issue