From 9526971c403417c1c007804f24884c443b9e6cd7 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 04 九月 2024 00:34:40 +0800
Subject: [PATCH] 代码提交
---
ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java | 237 +++++++++++++++++++++++++++++++++++++++-------------------
1 files changed, 158 insertions(+), 79 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java b/ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java
index c216a11..d9d78bd 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/test/MQTest.java
@@ -1,94 +1,173 @@
package com.ruoyi.web.test;
-import com.ruoyi.web.task.PhoneTask;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.smartor.domain.ThiedInhospInfo;
import org.junit.Test;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
-import javax.crypto.BadPaddingException;
-import javax.crypto.Cipher;
-import javax.crypto.IllegalBlockSizeException;
-import javax.crypto.NoSuchPaddingException;
-import java.security.*;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.util.Base64;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import java.lang.reflect.Type;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
//@SpringBootTest
//@RunWith(SpringRunner.class)
public class MQTest {
- @Autowired
- private RabbitTemplate rabbitTemplate;
- @Test
- public void testSend() {
- try {
- // 鐢熸垚RSA瀵嗛挜瀵�
- KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
- keyPairGenerator.initialize(2048);
- KeyPair keyPair = keyPairGenerator.generateKeyPair();
-
- // 鑾峰彇鍏挜鍜岀閽�
- PublicKey publicKey = keyPair.getPublic();
- PrivateKey privateKey = keyPair.getPrivate();
- String publicKeyString = Base64.getEncoder().encodeToString(privateKey.getEncoded());
- System.out.println(publicKeyString);
- // 鏄庢枃
- String plainText = "Hello, World!";
-
- // 鍔犲瘑
- Cipher encryptCipher = Cipher.getInstance("RSA");
- encryptCipher.init(Cipher.ENCRYPT_MODE, publicKey);
- byte[] encryptedBytes = encryptCipher.doFinal(plainText.getBytes());
-
- // 灏嗗姞瀵嗗悗鐨勬暟鎹浆鎹负Base64缂栫爜鐨勫瓧绗︿覆
- String encryptedText = Base64.getEncoder().encodeToString(encryptedBytes);
- System.out.println("鍔犲瘑鍚庣殑鏁版嵁锛�" + encryptedText);
-
- // 瑙e瘑
- Cipher decryptCipher = Cipher.getInstance("RSA");
- decryptCipher.init(Cipher.DECRYPT_MODE, privateKey);
- byte[] decryptedBytes = decryptCipher.doFinal(Base64.getDecoder().decode(encryptedBytes));
-
- // 鏄庢枃
- String decryptedText = new String(decryptedBytes);
- System.out.println("瑙e瘑鍚庣殑鏁版嵁锛�" + decryptedText);
- } catch (Exception e) {
-
- }
-
-// String str = "absdf";
-// String c = Character.toUpperCase(str.charAt(0)) + str.substring(1);
-// System.out.println(c);
- "鎮ㄥソ锛屾垜鏄禉浜屽尰闄㈠紶鍖荤敓锛屾偍鏄�${name}鍚楋紵杩樻槸瀹跺睘?".replaceAll("$$*variable", "AA");
-// Pattern pattern = Pattern.compile("^(?!.*(濂絴澶ソ)).*$");
-// Matcher matcher = pattern.matcher("鐫$湢涓嶅ソ");
-// System.out.println(matcher.matches());
- // 鍒涘缓鍥哄畾澶у皬鐨勭嚎绋嬫睜
-// ExecutorService executorService = Executors.newFixedThreadPool(10);
-//
-// executorService.submit(new PhoneTask());
- }
-
+ String result="{\n" +
+ " \"code\": \"0\",\n" +
+ " \"message\": \"success\",\n" +
+ " \"data\": {\n" +
+ " \"result\": ["+
+ " {\n" +
+ " \"admissDeptName\": \"娴嬭瘯绉戝\",\n" +
+ " \"patiTypeId\": \"22\",\n" +
+ " \"companyTelNum\": \"\",\n" +
+ " \"currDeptCode\": \"1024\",\n" +
+ " \"currWardCode\": \"1331\",\n" +
+ " \"patiIdCardNo\": \"\",\n" +
+ " \"PatiHomeAddr\": \"娴欐睙鐪佹澀宸炲競鎷卞鍖篭",\n" +
+ " \"patiMediaId\": \"69674\",\n" +
+ " \"admissBedNo\": \"\",\n" +
+ " \"patiBirthday\": \"2009-03-03 00:00:00\",\n" +
+ " \"Education\": null,\n" +
+ " \"nationalityAddr\": \"\",\n" +
+ " \"admissWardCode\": \"1331\",\n" +
+ " \"doctId\": \"6af3708533e645edb10a655cabead79f\",\n" +
+ " \"inpatientId\": \"2403000055\",\n" +
+ " \"ProfessionId\": \"\",\n" +
+ " \"admissWardId\": \"7f95c670151746bca580c866ae56cfeb\",\n" +
+ " \"doctName\": \"娴嬭瘯鍖荤敓\",\n" +
+ " \"currBedId\": \"7aeeb24077b1434d8f2b6ccb204f9159\",\n" +
+ " \"diagName\": \"鍍礬",\n" +
+ " \"currWardName\": \"娴嬭瘯鐥呭尯\",\n" +
+ " \"totalAmount\": 0.00,\n" +
+ " \"admissWardName\": \"娴嬭瘯鐥呭尯\",\n" +
+ " \"contactPersonName\": null,\n" +
+ " \"patiMediaNo\": \"024000070\",\n" +
+ " \"patiIndex\": \"024000070\",\n" +
+ " \"diagIcd10\": \"M20.200\",\n" +
+ " \"admissDeptCode\": \"1024\",\n" +
+ " \"patiRecordGender\": \"濂砛",\n" +
+ " \"patiNatureId\": \"22\",\n" +
+ " \"treateAge\": 15,\n" +
+ " \"suggestAmount\": \"\",\n" +
+ " \"contactPersonAddr\": null,\n" +
+ " \"contactPersonPhone\": null,\n" +
+ " \"admissBedId\": \"\",\n" +
+ " \"treatAgeunit\": \"宀乗",\n" +
+ " \"currBedNo\": \"T-003\",\n" +
+ " \"PatiNation\": \"姹夋棌\",\n" +
+ " \"patiRecordName\": \"鏃㈠線3-5\",\n" +
+ " \"currDeptId\": \"416a047536b411e7bff40242ac103005\",\n" +
+ " \"outWayName\": null,\n" +
+ " \"RelationShip\": \"\",\n" +
+ " \"admitFormId\": null,\n" +
+ " \"patiNatureName\": \"闈炶璐﹀尰淇漒",\n" +
+ " \"PatiNationality\": \"涓浗\",\n" +
+ " \"outDate\": null,\n" +
+ " \"admissDeptId\": \"416a047536b411e7bff40242ac103005\",\n" +
+ " \"admissDate\": \"2024-03-05 14:33:00\",\n" +
+ " \"currStatus\": 2,\n" +
+ " \"DocName\": \"\",\n" +
+ " \"patiTypeName\": \"闈炶璐﹀尰淇漒",\n" +
+ " \"currDeptName\": \"娴嬭瘯绉戝\",\n" +
+ " \"currWardId\": \"7f95c670151746bca580c866ae56cfeb\",\n" +
+ " \"areaId\": \"\",\n" +
+ " \"PatiMaritalStatus\": null,\n" +
+ " \"PatiHomePhone\": \"\",\n" +
+ " \"preoutDate\": null,\n" +
+ " \"outWayId\": null,\n" +
+ " \"inhospitalTimes\": 3,\n" +
+ " \"patiRecordId\": \"69409\",\n" +
+ " \"age\": \"15宀乗",\n" +
+ " \"diagId\": \"314216\"\n" +
+ " },\n" +
+ " {\n" +
+ " \"admissDeptName\": \"娴嬭瘯绉戝\",\n" +
+ " \"patiTypeId\": \"22\",\n" +
+ " \"companyTelNum\": \"\",\n" +
+ " \"currDeptCode\": \"1024\",\n" +
+ " \"currWardCode\": \"1331\",\n" +
+ " \"patiIdCardNo\": \"330106198001030057\",\n" +
+ " \"PatiHomeAddr\": \"娴欐睙鐪佹澀宸炲競瑗挎箹鍖篭",\n" +
+ " \"patiMediaId\": \"69675\",\n" +
+ " \"admissBedNo\": \"\",\n" +
+ " \"patiBirthday\": \"1980-01-03 00:00:00\",\n" +
+ " \"Education\": null,\n" +
+ " \"nationalityAddr\": \"\",\n" +
+ " \"admissWardCode\": \"1331\",\n" +
+ " \"doctId\": \"7d3f0eaaec304bbfad8a8471998e38e4\",\n" +
+ " \"inpatientId\": \"2403000056\",\n" +
+ " \"ProfessionId\": \"\",\n" +
+ " \"admissWardId\": \"7f95c670151746bca580c866ae56cfeb\",\n" +
+ " \"doctName\": \"浣忛櫌鐥呭巻\",\n" +
+ " \"currBedId\": \"377f94ca047e4786aef56a1ac22678b7\",\n" +
+ " \"diagName\": \"鐦熺梾\",\n" +
+ " \"currWardName\": \"娴嬭瘯鐥呭尯\",\n" +
+ " \"totalAmount\": 0.00,\n" +
+ " \"admissWardName\": \"娴嬭瘯鐥呭尯\",\n" +
+ " \"contactPersonName\": \"\",\n" +
+ " \"patiMediaNo\": \"024000071\",\n" +
+ " \"patiIndex\": \"024000071\",\n" +
+ " \"diagIcd10\": \"A01.03.01.\",\n" +
+ " \"admissDeptCode\": \"1024\",\n" +
+ " \"patiRecordGender\": \"鐢穃",\n" +
+ " \"patiNatureId\": \"22\",\n" +
+ " \"treateAge\": 44,\n" +
+ " \"suggestAmount\": \"\",\n" +
+ " \"contactPersonAddr\": \"\",\n" +
+ " \"contactPersonPhone\": \"\",\n" +
+ " \"admissBedId\": \"\",\n" +
+ " \"treatAgeunit\": \"宀乗",\n" +
+ " \"currBedNo\": \"T-006\",\n" +
+ " \"PatiNation\": \"姹夋棌\",\n" +
+ " \"patiRecordName\": \"鎷呬繚閲戦01\",\n" +
+ " \"currDeptId\": \"416a047536b411e7bff40242ac103005\",\n" +
+ " \"outWayName\": null,\n" +
+ " \"RelationShip\": \"\",\n" +
+ " \"admitFormId\": null,\n" +
+ " \"patiNatureName\": \"闈炶璐﹀尰淇漒",\n" +
+ " \"PatiNationality\": \"涓浗\",\n" +
+ " \"outDate\": null,\n" +
+ " \"admissDeptId\": \"416a047536b411e7bff40242ac103005\",\n" +
+ " \"admissDate\": \"2024-03-07 14:04:00\",\n" +
+ " \"currStatus\": 2,\n" +
+ " \"DocName\": \"\",\n" +
+ " \"patiTypeName\": \"闈炶璐﹀尰淇漒",\n" +
+ " \"currDeptName\": \"娴嬭瘯绉戝\",\n" +
+ " \"currWardId\": \"7f95c670151746bca580c866ae56cfeb\",\n" +
+ " \"areaId\": \"\",\n" +
+ " \"PatiMaritalStatus\": null,\n" +
+ " \"PatiHomePhone\": \"\",\n" +
+ " \"preoutDate\": null,\n" +
+ " \"outWayId\": null,\n" +
+ " \"inhospitalTimes\": 1,\n" +
+ " \"patiRecordId\": \"69410\",\n" +
+ " \"age\": \"44宀乗",\n" +
+ " \"diagId\": \"1000040\"\n" +
+ " }\n" +
+ " ],\n" +
+ " \"hasNext\": false\n" +
+ " }\n" +
+ "}";
@Test
public void testSend22() {
- try {
- byte[] privateKeyBytes = Base64.getDecoder().decode("");
- PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(privateKeyBytes);
- KeyFactory keyFactory = KeyFactory.getInstance("RSA");
- PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
+ Gson gson = new Gson();
+ JsonObject jsonObject = gson.fromJson(result, JsonObject.class);
+ JsonArray resultArray = jsonObject.getAsJsonObject("data").getAsJsonArray("result");
- // 浣跨敤绉侀挜瑙e瘑鏁版嵁
- Cipher decryptCipher = Cipher.getInstance("RSA");
- decryptCipher.init(Cipher.DECRYPT_MODE, privateKey);
- byte[] decryptedBytes = decryptCipher.doFinal(Base64.getDecoder().decode(""));
-
- // 瑙e瘑鍚庣殑鏁版嵁
- String decryptedData = new String(decryptedBytes);
- System.out.println("瑙e瘑鍚庣殑鏁版嵁锛�" + decryptedData);
- } catch (Exception e) {
- }
+ // 瀹氫箟 ResultItem 鐨勭被鍨�
+ Type resultType = new TypeToken<List<ThiedInhospInfo>>() {}.getType();
+ List<ThiedInhospInfo> resultList = gson.fromJson(resultArray, resultType);
+ System.out.println(resultList);
}
+
+
}
--
Gitblit v1.9.3