From 25b36dd0037a320e733c2bcfe98ae7ca7d1388ea Mon Sep 17 00:00:00 2001
From: DESKTOP-6GG29MI\dell <2847338803@qq.com>
Date: Thu, 04 Sep 2025 06:38:39 +0000
Subject: [PATCH] 项目详情页项目进度导出功能添加(补充)
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatRobotServiceImpl.java | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatRobotServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatRobotServiceImpl.java
index 54e493d..7783de2 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatRobotServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/service/impl/WechatRobotServiceImpl.java
@@ -3,6 +3,7 @@
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.temp.service.WechatRobotService;
+import me.zhengjie.utils.weixin.AesException;
import me.zhengjie.utils.weixin.WXBizJsonMsgCrypt;
import org.springframework.stereotype.Service;
@@ -11,13 +12,11 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
-import java.sql.Timestamp;
@Service
@RequiredArgsConstructor
public class WechatRobotServiceImpl implements WechatRobotService {
-// private final String CORP_ID = "wwc0fd49735bfcf0ad";
private final String CORP_ID = "";
private final String TOKEN = "WTAgLRQif";
private final String ENCODING_AES_KEY = "w2FEuoDg2D7DxnmJn4DL6YiD47OSHwB34WXVwa2eriY";
@@ -44,8 +43,9 @@
@Override
public Object handleRobotCallback(String msgSignature, String timestamp, String nonce, HttpServletRequest request, HttpServletResponse response) {
+ WXBizJsonMsgCrypt wxcpt = null;
try {
- WXBizJsonMsgCrypt wxcpt = new WXBizJsonMsgCrypt(TOKEN, ENCODING_AES_KEY, CORP_ID);
+ wxcpt = new WXBizJsonMsgCrypt(TOKEN, ENCODING_AES_KEY, CORP_ID);
// 读取回调数据
StringBuilder sb = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
@@ -57,13 +57,22 @@
String callbackData = sb.toString();
JSONObject jsonObject = JSONObject.parseObject(callbackData);
- String decryptedMessage = wxcpt.DecryptMsg(msgSignature, timestamp, nonce, jsonObject.toString());
+ String decryptedMessage = wxcpt.DecryptRobotMsg(msgSignature, timestamp, nonce, jsonObject.toString());
System.out.println("接收到机器人发送的加密消息:" + jsonObject.toJSONString());
System.out.println("接收到机器人发送的解密后消息:" + decryptedMessage);
-
- return wxcpt.EncryptMsg("消息已收到", "", nonce);
+ JSONObject decryptedMessageJson = JSONObject.parseObject(decryptedMessage);
+ if (decryptedMessageJson.getString("msgtype").equals("text")) {
+ return wxcpt.EncryptRobotMsg("消息已收到", "", nonce);
+ }
} catch (Exception e) {
e.printStackTrace();
+ try {
+ if (wxcpt != null) {
+ return wxcpt.EncryptRobotMsg("消息接收出现异常,请联系管理员处理 o(╥﹏╥o...)", "", nonce);
+ }
+ } catch (AesException aesException) {
+ aesException.printStackTrace();
+ }
}
return null;
--
Gitblit v1.9.3