hwj 1 year ago
parent 9f1fee2e04
commit 2c8102b872
  1. 3
      .idea/misc.xml
  2. 2
      dntd-common/src/main/java/com/dky/utils/ConfigReader.java
  3. 2
      dntd-model-heatboiler/src/main/java/com/dky/calculate/Advantage.java
  4. 2
      dntd-model-heatboiler/src/main/java/com/dky/calculate/RequireDevice.java
  5. 5
      dntd-tool/pom.xml
  6. 2
      dntd-tool/src/main/java/com/dky/Test.java
  7. 19
      dntd-tool/src/main/java/com/dky/generate/HeatBoilerSence.java
  8. 42
      dntd-tool/src/main/java/com/dky/security/GetCpuInfo.java
  9. 16
      dntd-tool/src/main/java/com/dky/security/SM4Utils.java
  10. 1
      doc/modelCode.properties

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
@ -13,7 +14,7 @@
</set>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="corretto-1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -12,6 +12,7 @@ public class ConfigReader {
try {
prop.load(input);
} catch (IOException e) {
System.out.println("未找到场景配置文件");
throw new RuntimeException(e);
}
}else {
@ -19,4 +20,5 @@ public class ConfigReader {
}
return prop.getProperty(key);
}
}

@ -8,7 +8,7 @@ public class Advantage {
//经济性
public String economy(Double firstInvestFee,Double yearTotalFee,Double yearRunFee,Double lastYearFee){
Double hsq = Math.round(firstInvestFee/yearTotalFee*100.0)/100.0;
double js = Math.round(lastYearFee - yearRunFee*100.0)/100.0;
double js = Math.round((lastYearFee - yearRunFee)*100.0)/100.0;
return "本次改造投资回收期为"+hsq+"年,本改造方案相比较原技术节省年运行费用成本"+js+"元。";
}
//智能性

@ -56,6 +56,6 @@ public class RequireDevice {
}
}
return new MatchedDeviceResult(matchedDevices, totalPrice);
return new MatchedDeviceResult(matchedDevices, Math.round(totalPrice*100.0)/100.0);
}
}

@ -43,11 +43,6 @@
<artifactId>dntd-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.dky</groupId>
<artifactId>dntd-model-buildsence</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<resources>

@ -56,7 +56,7 @@ public class Test {
.put("deviceNum", 2)
.put("deviceEnergyType", "1")
.put("lastYearFee", "76.25"));
String key = "vcH5hprSR9VkzneCzkBI3pD0D8plBBmLc927UW8/CY+NmfEi5e0zRH2iU6E8l1HCS/c+EVOzQeOGmgNshVgOpYUFUV5VUaECpWy6O2mE6fLeaeydA5tuGebX9kKp4UH6Oo5TeMC/mjQNpo8d1aho82+eIcOIE1CkVm9Ec875YrijyNz7P7hd9EYlnzJwVsf1Ks4Gzcnl0XRx2n3PN/tvCA==";
String key = "GWnQ4RqqTc8n1Uj59xLoUq0YsJLmzgyVzBvI35uj+DaDjdU0HZoU2fCd33JFsVG+3tWpkuojap/b5eeutSp6d4x4juou3yhCF7yhLBqYs1tdr2DF5QqL8uTsLJuKf1Ys8iufExureFAQw+qjMN+W5UlKE5id39PDi2nsPJGUbwkrvkywf2wqaqwZy+i/QBOl";
JSONObject jsonObject = modelTool.exeModel2Report(param,key);//exeModel2Report
System.out.println(jsonObject.toString());
}

@ -34,19 +34,20 @@ public class HeatBoilerSence implements DntdModelI {
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 deviceNum = "";*/
//单位(元/台、元/套)
String unit = "";
Set<String> devTypeSet = new HashSet<>();
for (MatchedDevice matchedDevice : matchedDeviceResult.getMatchedDevices()) {
/* for (MatchedDevice matchedDevice : matchedDeviceResult.getMatchedDevices()) {
devTypeSet.add(matchedDevice.getDevSpec().getDevType());
deviceSpec = deviceSpec + matchedDevice.getDevSpec().getDevType() + ":"+matchedDevice.getDevSpec().getCapacity()+"蒸吨、";
deviceNum = deviceNum + matchedDevice.getCount() + "台/"+matchedDevice.getDevSpec().getDevType()+";";
@ -57,10 +58,10 @@ public class HeatBoilerSence implements DntdModelI {
break;
}
}
}
for (String s : devTypeSet) {
}*/
/* for (String s : devTypeSet) {
deviceType = deviceType + s + "、";
}
}*/
Advantage advantage = new Advantage();
//总价
String totalPrice = matchedDeviceResult.getTotalPriceInTenThousand()+"万元";
@ -70,9 +71,9 @@ public class HeatBoilerSence implements DntdModelI {
jsonReport.put("yearReduceCarbon", yearReduceCarbon);
jsonReport.put("replaceEnergy", replaceEnergy);
jsonReport.put("reportDetail", reportDetail);
jsonReport.put("deviceType", deviceType);
jsonReport.put("deviceSpec", deviceSpec);
jsonReport.put("deviceNum", deviceNum);
/*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());

@ -14,11 +14,11 @@ public class GetCpuInfo {
// 获取当前操作系统名称
String os = System.getProperty("os.name");
os = os.toUpperCase();
System.out.println("当前操作系统:"+os);
// linux系统用Runtime.getRuntime().exec()执行 dmidecode -t processor 查询cpu序列
// windows系统用 wmic cpu get ProcessorId 查看cpu序列
if ("LINUX".equals(os)) {
cpuId = getLinuxCpuId("dmidecode -t processor | grep 'ID'", "ID", ":");
cpuId = getLinuxCpuId("dmidecode -t processor | grep 'ID' | head -n 1", "ID", ":");
} else {
cpuId = getWindowsCpuId();
}
@ -31,6 +31,7 @@ public class GetCpuInfo {
*/
public static String getLinuxCpuId(String cmd, String record, String symbol) throws Exception {
String execResult = executeLinuxCmd(cmd);
System.out.println("获取命令执行结果:"+execResult);
String[] infos = execResult.split("\n");
for (String info : infos) {
info = info.trim();
@ -43,20 +44,31 @@ public class GetCpuInfo {
return null;
}
public static String executeLinuxCmd(String cmd) throws Exception {
Runtime run = Runtime.getRuntime();
Process process;
process = run.exec(cmd);
InputStream in = process.getInputStream();
BufferedReader bs = new BufferedReader(new InputStreamReader(in));
StringBuffer out = new StringBuffer();
byte[] b = new byte[8192];
for (int n; (n = in.read(b)) != -1; ) {
out.append(new String(b, 0, n));
public static String executeLinuxCmd(String cmd){
try {
Runtime run = Runtime.getRuntime();
Process process = null;
process = run.exec(cmd);
System.out.println(process.toString());
if (process == null){
System.out.println("未获取到执行结果");
}else {
System.out.println("读取执行结果");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line); // 打印每一行输出
break;
}
reader.close();
process.destroy();
return line;
}
}catch (Exception e) {
e.printStackTrace();
}
in.close();
process.destroy();
return out.toString();
return null;
}
/**

@ -30,7 +30,7 @@ public class SM4Utils {
public static Map<String, String> decrypt(String encrypted) throws Exception {
Cipher cipher = Cipher.getInstance(ALGORITHM, "BC");
SecretKeySpec secretKey = new SecretKeySpec(SM4_KEY.getBytes(StandardCharsets.UTF_8), "SM4");
SecretKeySpec secretKey = new SecretKeySpec(SM4_KEY.getBytes(StandardCharsets.UTF_8), "AES");
cipher.init(Cipher.DECRYPT_MODE, secretKey);
byte[] decoded = Base64.getDecoder().decode(encrypted);
byte[] decrypted = cipher.doFinal(decoded);
@ -58,17 +58,7 @@ public class SM4Utils {
}
public static void main(String[] args) throws Exception {
Map map = new HashMap<>();
ArrayList<String> cpuIds = new ArrayList<>();
cpuIds.add("duahduejdiejidi");
cpuIds.add("ddnfjuufhurhffr");
cpuIds.add("frfrjfirjfirjfir");
cpuIds.add("BFEBFBFF000506E3");
cpuIds.add("BFEBFBFF000806EA");
map.put("name", "模型1工具");
map.put("cpuIds", cpuIds.toString());
map.put("expireTime","2024-12-16 00:00:00");
String encrypted = encrypt(map);
System.out.println(encrypted);
Map<String, String> decrypt = decrypt("GWnQ4RqqTc8n1Uj59xLoUq0YsJLmzgyVzBvI35uj+DaDjdU0HZoU2fCd33JFsVG+3tWpkuojap/b5eeutSp6d4x4juou3yhCF7yhLBqYs1tdr2DF5QqL8uTsLJuKf1Ys8iufExureFAQw+qjMN+W5UlKE5id39PDi2nsPJGUbwkrvkywf2wqaqwZy+i/QBOl");
System.out.println(decrypt.toString());
}
}

@ -0,0 +1 @@
0101=generate.HeatBoilerSence
Loading…
Cancel
Save