2024-03-26 10:58:00 能源消耗测算模型修改

master
魔神煜修罗皇 1 year ago
parent f1df330f69
commit 842b7d096e
  1. 55
      dntd-common/src/main/java/com/dky/utils/entity/SysModelParam.java
  2. 2
      dntd-tool/src/main/java/com/dky/security/SM4Utils.java
  3. 126
      dntd-tool/src/main/java/com/dky/stirtpar/StirparModelCalculate.java
  4. 46
      dntd-tool/src/main/resources/electricConsumeStirpatCoefficient.json
  5. 42
      dntd-tool/src/main/resources/energyConsumeStirpatCoefficient.json

@ -0,0 +1,55 @@
package com.dky.utils.entity;
public class SysModelParam {
/** 序号 */
private Integer id ;
/** 系数名称 */
private String paramName ;
/** 系数值 */
private Double paramValue ;
/** 该系数适用于【0能源, 1电力】 */
private Integer paramModel ;
public SysModelParam() { }
public SysModelParam(Integer id, String paramName, Double paramValue, Integer paramModel) {
this.id = id;
this.paramName = paramName;
this.paramValue = paramValue;
this.paramModel = paramModel;
}
/** 序号 */
public Integer getId(){
return this.id;
}
/** 序号 */
public void setId(Integer id){
this.id=id;
}
/** 系数名称 */
public String getParamName(){
return this.paramName;
}
/** 系数名称 */
public void setParamName(String paramName){
this.paramName=paramName;
}
/** 系数值 */
public Double getParamValue(){
return this.paramValue;
}
/** 系数值 */
public void setParamValue(Double paramValue){
this.paramValue=paramValue;
}
/** 该系数适用于【0能源, 1电力】 */
public Integer getParamModel(){
return this.paramModel;
}
/** 该系数适用于【0能源, 1电力】 */
public void setParamModel(Integer paramModel){
this.paramModel=paramModel;
}
}

@ -17,7 +17,7 @@ public class SM4Utils {
Security.addProvider(new BouncyCastleProvider());
}
public final static String SM4_KEY = "dfd2b0581fc9244e51100c5cf02defc8064a45686eb2e4ddfd44cdab2ef908b2";
public final static String SM4_KEY = "1100fba8ee67ddf1f6f4e37c500dc10eee1bf15827ae3837810e30f402fa0bc6";
private static final String ALGORITHM = "AES/ECB/PKCS5Padding";

@ -1,25 +1,30 @@
package com.dky.stirtpar;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.dky.modelI.DntdModelI;
import com.dky.utils.CalculateUtils;
import com.dky.utils.entity.SysDeviceHeatScene;
import com.dky.utils.entity.SysModelParam;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class StirparModelCalculate implements DntdModelI {
DecimalFormat df = new DecimalFormat("#.00");
static DecimalFormat df = new DecimalFormat("#.00");
/**
* 计算热源消耗总量
* @param provinceCode 省份编码
* @param list 参数列表
* @param peopleNum 人口
* @param averageGdp 人均GDP
* @param U 城市化率
@ -27,16 +32,36 @@ public class StirparModelCalculate implements DntdModelI {
* @param II 工业能源强度
* @return
*/
public static Double energyConsumeStirCoefficient(String provinceCode, Integer peopleNum, Double averageGdp, Double U, Double I, Double II) {
JSONObject jo = (JSONObject) toJSON("energyConsumeStirpatCoefficient.json").get(provinceCode);
Double a = Double.parseDouble(jo.get("a").toString());
Double b1 = Double.parseDouble(jo.get("b1").toString());
Double b2 = Double.parseDouble(jo.get("b2").toString());
Double b3 = Double.parseDouble(jo.get("b3").toString());
Double b4 = Double.parseDouble(jo.get("b4").toString());
Double b5 = Double.parseDouble(jo.get("b5").toString());
Double b6 = Double.parseDouble(jo.get("b6").toString());
Double e = Double.parseDouble(jo.get("e").toString());
public static Double energyConsumeStirCoefficient(List<SysModelParam> list, Integer peopleNum, Double averageGdp, Double U, Double I, Double II) {
List<Map> mapList = getThisModel(0, list);
Double a = 1.0;
Double b1 = 1.0;
Double b2 = 1.0;
Double b3 = 1.0;
Double b4 = 1.0;
Double b5 = 1.0;
Double b6 = 1.0;
Double e = 1.0;
for (Map param : mapList){
if ("a".equals(param.get("key"))) {
a = (Double) param.get("value");
} else if ("b1".equals(param.get("key"))) {
b1 = (Double) param.get("value");
} else if ("b2".equals(param.get("key"))) {
b2 = (Double) param.get("value");
} else if ("b3".equals(param.get("key"))) {
b3 = (Double) param.get("value");
} else if ("b4".equals(param.get("key"))) {
b4 = (Double) param.get("value");
} else if ("b55".equals(param.get("key"))) {
b5 = (Double) param.get("value");
} else if ("b6".equals(param.get("key"))) {
b6 = (Double) param.get("value");
} else if ("e".equals(param.get("key"))) {
e = (Double) param.get("value");
}
}
Double add1 = CalculateUtils.add(a, b1 * Math.log(peopleNum));
Double add2 = CalculateUtils.add(add1, b2 * Math.log(U));
@ -46,12 +71,12 @@ public class StirparModelCalculate implements DntdModelI {
Double add6 = CalculateUtils.add(add5, b6 * Math.log(II));
Double add7 = CalculateUtils.add(add6, e);
return Math.round(Math.exp(add7) * 100) / 100.0;
return Math.exp(add7);
}
/**
* 计算电耗消耗总量
* @param provinceCode 省份编码
* @param list 参数列表
* @param CT 能源消耗量
* @param peopleNum 人口
* @param averageGdp 人均GDP
@ -60,17 +85,39 @@ public class StirparModelCalculate implements DntdModelI {
* @param T 年均温度
* @return
*/
public static Double electricConsumeStirCoefficient(String provinceCode, Double CT, Integer peopleNum, Double averageGdp, Double U, Double PR, Double T) {
JSONObject jo = (JSONObject) toJSON("electricConsumeStirpatCoefficient.json").get(provinceCode);
Double a = Double.parseDouble(jo.get("a").toString());
Double b1 = Double.parseDouble(jo.get("b1").toString());
Double b2 = Double.parseDouble(jo.get("b2").toString());
Double b3 = Double.parseDouble(jo.get("b3").toString());
Double b4 = Double.parseDouble(jo.get("b4").toString());
Double b5 = Double.parseDouble(jo.get("b5").toString());
Double b6 = Double.parseDouble(jo.get("b6").toString());
Double b7 = Double.parseDouble(jo.get("b7").toString());
Double e = Double.parseDouble(jo.get("e").toString());
public static Double electricConsumeStirCoefficient(List<SysModelParam> list, Double CT, Integer peopleNum, Double averageGdp, Double U, Double PR, Double T) {
List<Map> mapList = getThisModel(1, list);
Double a = 1.0;
Double b1 = 1.0;
Double b2 = 1.0;
Double b3 = 1.0;
Double b4 = 1.0;
Double b5 = 1.0;
Double b6 = 1.0;
Double b7 = 1.0;
Double e = 1.0;
for (Map param : mapList){
if ("a".equals(param.get("key"))) {
a = (Double) param.get("value");
} else if ("b1".equals(param.get("key"))) {
b1 = (Double) param.get("value");
} else if ("b2".equals(param.get("key"))) {
b2 = (Double) param.get("value");
} else if ("b3".equals(param.get("key"))) {
b3 = (Double) param.get("value");
} else if ("b4".equals(param.get("key"))) {
b4 = (Double) param.get("value");
} else if ("b55".equals(param.get("key"))) {
b5 = (Double) param.get("value");
} else if ("b6".equals(param.get("key"))) {
b6 = (Double) param.get("value");
} else if ("b7".equals(param.get("key"))) {
b7 = (Double) param.get("value");
} else if ("e".equals(param.get("key"))) {
e = (Double) param.get("value");
}
}
Double add1 = CalculateUtils.add(a, b1 * Math.log(CT));
Double add2 = CalculateUtils.add(add1, b2 * Math.log(peopleNum));
@ -81,7 +128,7 @@ public class StirparModelCalculate implements DntdModelI {
Double add7 = CalculateUtils.add(add6, b7 * Math.log(T));
Double add8 = CalculateUtils.add(add7, e);
return add8;
return Math.exp(add8);
}
@ -127,7 +174,12 @@ public class StirparModelCalculate implements DntdModelI {
e.printStackTrace();
}
String provinceCode = jsonObject.get("provinceCode").toString();
List<SysModelParam> sysParamList = new ArrayList<>();
JSONArray specArray = jsonObject.getJSONArray("sysModelParam");
for (int i = 0; i < specArray.size(); i++) {
SysModelParam devSpec = specArray.getJSONObject(i).toBean(SysModelParam.class);
sysParamList.add(devSpec);
}
Integer peopleNum = Integer.parseInt(new DecimalFormat("#").format(energyInfo.get("peopleNum")));
Double averageGdp = Double.parseDouble(energyInfo.get("averageGdp").toString());
Double U = Double.parseDouble(energyInfo.get("ut").toString());
@ -138,9 +190,25 @@ public class StirparModelCalculate implements DntdModelI {
Double T = Double.parseDouble(electricInfo.get("T").toString());
JSONObject resultJsonObject = new JSONObject();
resultJsonObject.put("CT", df.format(energyConsumeStirCoefficient(provinceCode, peopleNum, averageGdp, U, I, II)));
resultJsonObject.put("CE", df.format(electricConsumeStirCoefficient(provinceCode, CT, peopleNum, averageGdp, U, PR, T)));
resultJsonObject.put("CT", df.format(energyConsumeStirCoefficient(sysParamList, peopleNum, averageGdp, U, I, II)));
resultJsonObject.put("CE", df.format(electricConsumeStirCoefficient(sysParamList, CT, peopleNum, averageGdp, U, PR, T)));
return resultJsonObject;
}
public static List<Map> getThisModel(Integer args, List<SysModelParam> list) {
List<Map> ary = new ArrayList<>();
list.forEach((param) -> {
if (param.getParamModel().equals(args)) {
Map<String, Object> map = new HashMap<>();
map.put("key", param.getParamName());
map.put("value", param.getParamValue());
ary.add(map);
}
});
return ary;
}
}

@ -1,46 +0,0 @@
{
"110000": {
"a": 1,
"b1": 2,
"b2": 3,
"b3": 4,
"b4": 5,
"b5": 6,
"b6": 7,
"b7": 9,
"e": 8
},
"120000": {
"a": 1,
"b1": 2,
"b2": 3,
"b3": 4,
"b4": 5,
"b5": 6,
"b6": 7,
"b7": 9,
"e": 8
},
"310000": {
"a": 1,
"b1": 2,
"b2": 3,
"b3": 4,
"b4": 5,
"b5": 6,
"b6": 7,
"b7": 9,
"e": 8
},
"500000": {
"a": 1,
"b1": 2,
"b2": 3,
"b3": 4,
"b4": 5,
"b5": 6,
"b6": 7,
"b7": 9,
"e": 8
}
}

@ -1,42 +0,0 @@
{
"110000": {
"a": 1,
"b1": 2,
"b2": 3,
"b3": 4,
"b4": 5,
"b5": 6,
"b6": 7,
"e": 8
},
"120000": {
"a": 1,
"b1": 2,
"b2": 3,
"b3": 4,
"b4": 5,
"b5": 6,
"b6": 7,
"e": 8
},
"310000": {
"a": 1,
"b1": 2,
"b2": 3,
"b3": 4,
"b4": 5,
"b5": 6,
"b6": 7,
"e": 8
},
"500000": {
"a": 1,
"b1": 2,
"b2": 3,
"b3": 4,
"b4": 5,
"b5": 6,
"b6": 7,
"e": 8
}
}
Loading…
Cancel
Save