Commit 18c1524f authored by ZWT's avatar ZWT

feat(零碳): 长庆演示系统新增功能

1.新建油田配置表同时生成相关代码及mapper文件,修改部分第三方数据抽取定时任务,增加针对不同井场开关控制逻辑,同时修改首页页面展示逻辑,通过油田配置功能区分不同首页展示功能;
2.新建定时任务配置表同时生成相关代码及mapper文件,定时任务模块增加mybatis配置,用以操作数据库,修改部分第三方数据抽取定时任务,修改使用方式使其脱离框架方便动态控制;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 28cdca4d
package pps.core.common.utils;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
/**
* @author lixueyan
* @date 2022/1/12 0012 10:46
*/
public class AESUtil {
private static String KEY = "abcdef0123456789"; // 长度必须是 16
private static String IV = "abcdef0123456789"; // 长度必须是 16
public static void main(String args[]) throws Exception {
String content = "dddddddddd";
//加密
String encrypted = encrypt(content, KEY, IV);
//解密
String decrypted = decrypt(encrypted, KEY, IV);
System.out.println("加密前:" + content);
System.out.println("加密后:" + encrypted);
System.out.println("解密后:" + decrypted);
}
public static String encrypt(String content) throws Exception {
return encrypt(content, KEY, IV);
}
/**
* 加密返回的数据转换成 String 类型
*
* @param content 明文
* @param key 秘钥
* @param iv 初始化向量是16位长度的字符串
* @return
* @throws Exception
*/
public static String encrypt(String content, String key, String iv) throws Exception {
// 将返回的加密过的 byte[] 转换成Base64编码字符串 !!!!很关键
return base64ToString(AES_CBC_Encrypt(content.getBytes(), key.getBytes(), iv.getBytes()));
}
public static String decrypt(String content) {
try {
return decrypt(content, KEY, IV);
} catch (Exception e) {
System.out.println("exception:" + e.toString());
}
return null;
}
/**
* 将解密返回的数据转换成 String 类型
*
* @param content Base64编码的密文
* @param key 秘钥
* @param iv 初始化向量是16位长度的字符串
* @return
* @throws Exception
*/
public static String decrypt(String content, String key, String iv) throws Exception {
// stringToBase64() 将 Base64编码的字符串转换成 byte[] !!!与base64ToString()配套使用
return new String(AES_CBC_Decrypt(stringToBase64(content), key.getBytes(), iv.getBytes()));
}
private static byte[] AES_CBC_Encrypt(byte[] content, byte[] keyBytes, byte[] iv) {
try {
SecretKeySpec key = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv));
byte[] result = cipher.doFinal(content);
return result;
} catch (Exception e) {
System.out.println("exception:" + e.toString());
}
return null;
}
private static byte[] AES_CBC_Decrypt(byte[] content, byte[] keyBytes, byte[] iv) {
try {
SecretKeySpec key = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv));
byte[] result = cipher.doFinal(content);
return result;
} catch (Exception e) {
System.out.println("exception:" + e.toString());
}
return null;
}
/**
* 字符串装换成 Base64
*/
public static byte[] stringToBase64(String key) throws Exception {
return Base64.decodeBase64(key.getBytes());
}
/**
* Base64装换成字符串
*/
public static String base64ToString(byte[] key) throws Exception {
return new Base64().encodeToString(key);
}
}
...@@ -6,6 +6,7 @@ import org.jxls.transform.Transformer; ...@@ -6,6 +6,7 @@ import org.jxls.transform.Transformer;
import org.jxls.util.JxlsHelper; import org.jxls.util.JxlsHelper;
import java.io.*; import java.io.*;
import java.nio.file.Files;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -22,7 +23,7 @@ public class ExportExcelUtils { ...@@ -22,7 +23,7 @@ public class ExportExcelUtils {
if (!file.getParentFile().exists()) { if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
OutputStream out = new FileOutputStream(file); OutputStream out = Files.newOutputStream(file.toPath());
try { try {
out.write(fileBuff); out.write(fileBuff);
out.flush(); out.flush();
...@@ -53,7 +54,7 @@ public class ExportExcelUtils { ...@@ -53,7 +54,7 @@ public class ExportExcelUtils {
JxlsHelper jxlsHelper = JxlsHelper.getInstance(); JxlsHelper jxlsHelper = JxlsHelper.getInstance();
Transformer transformer = jxlsHelper.createTransformer(inputStream, buff); Transformer transformer = jxlsHelper.createTransformer(inputStream, buff);
JexlExpressionEvaluator evaluator = (JexlExpressionEvaluator) transformer.getTransformationConfig().getExpressionEvaluator(); JexlExpressionEvaluator evaluator = (JexlExpressionEvaluator) transformer.getTransformationConfig().getExpressionEvaluator();
Map<String, Object> funcs = new HashMap<String, Object>(); Map<String, Object> funcs = new HashMap<>();
funcs.put("utils", new JxlsUtils()); //添加自定义功能 funcs.put("utils", new JxlsUtils()); //添加自定义功能
evaluator.getJexlEngine().setFunctions(funcs); evaluator.getJexlEngine().setFunctions(funcs);
jxlsHelper.processTemplate(context, transformer); jxlsHelper.processTemplate(context, transformer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment