Browse Source

发送通知换成秘钥

xiaochan 10 months ago
parent
commit
eb662506dd

+ 1 - 0
src/main/java/thyyxxk/webserver/config/envionment/Other.java

@@ -12,4 +12,5 @@ import org.springframework.stereotype.Component;
 public class Other {
     private String mobileAddress;
     private Integer mobileAgentid;
+    private String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCDN7dqjx3C71g7P6qlcMHsnxawNSdgx7C0nHreDzAk0GFUO2xAkhxrYT9P2KQTPWzFQOje/DaxhWhJHssRQc8Q9lnaDZXta3wZvIvkLhW/NfJQNMLpOhYS6wyfTHrppSw/52TcxttmzmAEsza2ekkZbSvTwyVU4rIpKHyYt9r7bQIDAQAB";
 }

+ 1 - 1
src/main/java/thyyxxk/webserver/service/ca/CaServer.java

@@ -476,7 +476,7 @@ public class CaServer implements Assertion {
         if (StrUtil.isBlank(value.getUuid())) {
             value.setUuid(IdUtil.simpleUUID());
             redisServer.delData(redisKey);
-            redisData.setPdf(emrServer.getPdfBase(value.getDocumentId()));
+            redisData.setPdf(EmrServer.getPdfBase(value.getDocumentId()));
         } else {
             redisData = redisServer.getData(redisKey);
             if (redisData == null) {

+ 24 - 8
src/main/java/thyyxxk/webserver/service/jcptmobile/JcptMobileService.java

@@ -1,5 +1,8 @@
 package thyyxxk.webserver.service.jcptmobile;
 
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.crypto.asymmetric.KeyType;
+import cn.hutool.crypto.asymmetric.RSA;
 import com.dtflys.forest.Forest;
 import com.dtflys.forest.http.ForestRequest;
 import com.dtflys.forest.utils.ForestDataType;
@@ -7,28 +10,41 @@ import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.envionment.Other;
 import thyyxxk.webserver.utils.TokenUtil;
 
+
 @Service
 public class JcptMobileService {
     private final Other other;
+    private final RSA rsa;
 
     public JcptMobileService(Other other) {
         this.other = other;
+        rsa = new RSA(null, other.getPublicKey());
     }
 
-    public ForestRequest<?> get(String url) {
-        return Forest.get(url)
-                .addHeader("token", TokenUtil.getInstance().getUserToken())
+    public ForestRequest<?> request(String url, String request) {
+        ForestRequest<?> forestRequest;
+        if ("get".equals(request)) {
+            forestRequest = Forest.get(url);
+        } else {
+            forestRequest = Forest.post(url);
+        }
+
+        String token = TokenUtil.getInstance().getTokenUserId() + "_" + DateUtil.now();
+        String encrypted = rsa.encryptBase64(token, KeyType.PublicKey);
+
+        forestRequest.addHeader("token", encrypted)
                 .bodyType(ForestDataType.JSON)
                 .addHeader("content-type", "application/json")
                 .basePath(other.getMobileAddress() + "/thyy/moveEmr/api");
+        return forestRequest;
+    }
+
+    public ForestRequest<?> get(String url) {
+        return request(url, "get");
     }
 
     public ForestRequest<?> post(String url) {
-        return Forest.post(url)
-                .addHeader("token", TokenUtil.getInstance().getUserToken())
-                .addHeader("content-type", "application/json")
-                .bodyType(ForestDataType.JSON)
-                .basePath(other.getMobileAddress() + "/thyy/moveEmr/api");
+        return request(url, "post");
     }
 
 }

+ 4 - 2
src/main/java/thyyxxk/webserver/service/zhuyuanyisheng/emr/EmrControlRuleSever.java

@@ -1,5 +1,7 @@
 package thyyxxk.webserver.service.zhuyuanyisheng.emr;
 
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.format.FastDateFormat;
 import cn.hutool.core.text.StrFormatter;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
@@ -78,8 +80,8 @@ public class EmrControlRuleSever {
             return String.join("|", yiWuBuUser);
         });
 
-        DateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分", Locale.CHINA);
-        String date = DateUtil.formatDate(param.getApplicationTime(), df);
+        String date = FastDateFormat.getInstance("yyyy年MM月dd日 HH时mm分")
+                .format(param.getApplicationTime());
 
         String description = StrFormatter.format("<div class=\"gray\">{}</div> <div class=\"normal\">理由:{}</div><div class=\"highlight\">解锁:【{}】</div>", date, param.getRequestRemarks(), param.getUnlockJson());
         JSONObject js = getMessageJson(data, description);

+ 2 - 1
src/main/resources/application-cytest.yml

@@ -186,7 +186,8 @@ thyy:
       return-url: "https://emr.hnthyy.cn:9222/caTest/thyyca/hBoardSignReturnUrl"
   archive:
     path: "Z:\\"
-#    archive-url: "http://172.16.32.167:20921/thyy/api/archive"
+  #    archive-url: "http://172.16.32.167:20921/thyy/api/archive"
   other:
     mobile-address: "https://emr.hnthyy.cn:8081"
     mobile-agentid: 1000051
+    public-key: "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCDN7dqjx3C71g7P6qlcMHsnxawNSdgx7C0nHreDzAk0GFUO2xAkhxrYT9P2KQTPWzFQOje/DaxhWhJHssRQc8Q9lnaDZXta3wZvIvkLhW/NfJQNMLpOhYS6wyfTHrppSw/52TcxttmzmAEsza2ekkZbSvTwyVU4rIpKHyYt9r7bQIDAQAB"