|
@@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.jfinal.kit.PropKit;
|
|
import com.jfinal.kit.PropKit;
|
|
|
|
+import com.zskk.tools.AESUtils;
|
|
|
|
|
|
import okhttp3.FormBody;
|
|
import okhttp3.FormBody;
|
|
import okhttp3.MediaType;
|
|
import okhttp3.MediaType;
|
|
@@ -37,21 +38,96 @@ public class DataService {
|
|
|
|
|
|
private static final MediaType JSON_TYPE = MediaType.parse("application/json; charset=utf-8");
|
|
private static final MediaType JSON_TYPE = MediaType.parse("application/json; charset=utf-8");
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取云端密钥
|
|
|
|
+ */
|
|
|
|
+ public String getCloudKey() {
|
|
|
|
+ String key = "";
|
|
|
|
+ try {
|
|
|
|
+ key = fileToString("./key.txt");
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(key);
|
|
|
|
+ key = jsonObject.getJSONObject("data").getString("key");
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return key;
|
|
|
|
+ }
|
|
|
|
+ return key;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更新云端密钥
|
|
|
|
+ */
|
|
|
|
+ public void updateCloudKey() {
|
|
|
|
+ Map <String,String> map = new HashMap<String,String>();
|
|
|
|
+ map.put("institution_id", PropKit.get("institution_id"));
|
|
|
|
+ String content = postWithParameters(GET_KEY_URL, map);
|
|
|
|
+ File file = new File("./key.txt");
|
|
|
|
+ try {
|
|
|
|
+ // 使用FileWriter不需要考虑原文件不存在的情况
|
|
|
|
+ // 当该文件不存在时,new FileWriter(file)会自动创建一个真实存在的空文件
|
|
|
|
+ FileWriter fileWriter = new FileWriter(file);
|
|
|
|
+ // 往文件重写内容
|
|
|
|
+ fileWriter.write(content);// 清空
|
|
|
|
+ fileWriter.flush();
|
|
|
|
+ fileWriter.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取未出报告的检查列表
|
|
* 获取未出报告的检查列表
|
|
* @param instutionId
|
|
* @param instutionId
|
|
* @param number
|
|
* @param number
|
|
*/
|
|
*/
|
|
- public String getExamList(String str) {
|
|
|
|
|
|
+ public String getExamList(String jmstr) {
|
|
|
|
+ String cloudjmStr = localjm2cloudjm(jmstr);
|
|
Map <String,String> map = new HashMap<String,String>();
|
|
Map <String,String> map = new HashMap<String,String>();
|
|
map.put("institution_id", "06300009");
|
|
map.put("institution_id", "06300009");
|
|
- map.put("params", str);
|
|
|
|
|
|
+ map.put("params", cloudjmStr);
|
|
String content = postWithParameters(GET_EXAM_URL, map);
|
|
String content = postWithParameters(GET_EXAM_URL, map);
|
|
- return content;
|
|
|
|
|
|
+ String examlistStr = cloudjm2localjm(content);
|
|
|
|
+ return examlistStr;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String localjm2cloudjm(String jmstr) {
|
|
|
|
+ String IV = "0000000000000000";
|
|
|
|
+ //解密内网数据
|
|
|
|
+ String aesDecodeStr = "";
|
|
|
|
+ try {
|
|
|
|
+ aesDecodeStr = AESUtils.aesDecodeStr(jmstr,PropKit.get("nw_key"), IV);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ //加密为云数据
|
|
|
|
+ String aesEncryptStr = AESUtils.aesEncryptStr(aesDecodeStr, getCloudKey(), IV);
|
|
|
|
+ return aesEncryptStr;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public String cloudjm2localjm(String content) {
|
|
|
|
+ String IV = "0000000000000000";
|
|
|
|
+ //解密云端数据
|
|
|
|
+ JSONObject jsonObject = JSON.parseObject(content);
|
|
|
|
+ String aesDecodeSt = "";
|
|
|
|
+ try {
|
|
|
|
+ aesDecodeSt = AESUtils.aesDecodeStr(jsonObject.getString("data"), getCloudKey() ,IV);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ //加密为内网密文
|
|
|
|
+ String aesEncryptStr = AESUtils.aesEncryptStr(aesDecodeSt, PropKit.get("nw_key"),IV);
|
|
|
|
+ return aesEncryptStr;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 写入报告
|
|
* 写入报告
|
|
* @param instutionId
|
|
* @param instutionId
|
|
@@ -59,7 +135,6 @@ public class DataService {
|
|
*/
|
|
*/
|
|
public void saveReport(Map <String,String> map) {
|
|
public void saveReport(Map <String,String> map) {
|
|
postWithParameters(SAVE_REPORT_URL, map);
|
|
postWithParameters(SAVE_REPORT_URL, map);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -125,7 +200,7 @@ public class DataService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public static String fileToString(String path) throws IOException {
|
|
|
|
|
|
+ public String fileToString(String path) throws IOException {
|
|
return Files.readString(Path.of(path));
|
|
return Files.readString(Path.of(path));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -140,30 +215,23 @@ public class DataService {
|
|
// postWithParameters(SAVE_REPORT_URL, map);
|
|
// postWithParameters(SAVE_REPORT_URL, map);
|
|
String content = postWithParameters(GET_KEY_URL, map);
|
|
String content = postWithParameters(GET_KEY_URL, map);
|
|
|
|
|
|
|
|
+ File file = new File("./key.txt");
|
|
|
|
+ try {
|
|
|
|
+ // 使用FileWriter不需要考虑原文件不存在的情况
|
|
|
|
+ // 当该文件不存在时,new FileWriter(file)会自动创建一个真实存在的空文件
|
|
|
|
+ FileWriter fileWriter = new FileWriter(file);
|
|
|
|
+ // 往文件重写内容
|
|
|
|
+ fileWriter.write(content);// 清空
|
|
|
|
+ fileWriter.flush();
|
|
|
|
+ fileWriter.close();
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+// String content = getCloudKey();
|
|
|
|
+// System.out.println(content);
|
|
|
|
|
|
- File file = new File("./123-测试记录.txt");
|
|
|
|
- try {
|
|
|
|
- // 使用FileWriter不需要考虑原文件不存在的情况
|
|
|
|
- // 当该文件不存在时,new FileWriter(file)会自动创建一个真实存在的空文件
|
|
|
|
- FileWriter fileWriter = new FileWriter(file);
|
|
|
|
- // 往文件重写内容
|
|
|
|
- fileWriter.write(content);// 清空
|
|
|
|
- fileWriter.flush();
|
|
|
|
- fileWriter.close();
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- try {
|
|
|
|
- String content2= fileToString("./123-测试记录.txt");
|
|
|
|
-
|
|
|
|
- System.out.println("44"+content2);
|
|
|
|
-
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- // TODO Auto-generated catch block
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|