|
|
@@ -1,8 +1,10 @@
|
|
|
package com.kede.wechat.service.impl;
|
|
|
|
|
|
+import com.kede.common.model.ChatMsgUser;
|
|
|
import com.kede.common.utils.DateUtils;
|
|
|
import com.kede.common.utils.HttpUtils;
|
|
|
import com.kede.common.utils.RSAEncrypt;
|
|
|
+import com.kede.common.utils.StringUtils;
|
|
|
import com.kede.wechat.bo.InputChatMsg;
|
|
|
import com.kede.wechat.service.ConversationContentService;
|
|
|
import com.tencent.wework.Finance;
|
|
|
@@ -13,6 +15,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import com.kede.common.dao.ChatMsgUserMapper;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
@@ -23,6 +26,8 @@ public class ConversationContentServiceImpl implements ConversationContentServic
|
|
|
Logger logger = LoggerFactory.getLogger(ConversationContentServiceImpl.class);
|
|
|
@Resource
|
|
|
private RedisTemplate redisTemplate;
|
|
|
+ @Resource
|
|
|
+ private ChatMsgUserMapper chatMsgUserMapper;
|
|
|
|
|
|
|
|
|
@Value(value = "${conversationContent.corpid}")
|
|
|
@@ -173,33 +178,44 @@ public class ConversationContentServiceImpl implements ConversationContentServic
|
|
|
System.out.println(result.getString("errcode"));
|
|
|
System.out.println("获取会话内容存档成员列表失败");
|
|
|
}
|
|
|
- getChatName(result.toJSONString());
|
|
|
+ pushGetChatName(result.toJSONString());
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String getChatName(String msg) {
|
|
|
-// msg="{\"msgid\":\"1634016854685227651_1749628622146_external\",\"action\":\"send\"," +
|
|
|
-// "\"from\":\"wopeIoCwAArS1POCA5Fiw6VidWWqkwVA\",\"tolist\":[\"KaKa\"],\"roomid\":\"\",\"msgtime\":1749628618742,\"msgtype\":\"text\",\"" +
|
|
|
-// "text\":{\"content\":\"您好,请详细描述您的问题,以便更快得到解答!\"}}";
|
|
|
-// com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(msg);
|
|
|
-// //直接转成对象
|
|
|
-// InputChatMsg chatMsg = new InputChatMsg(jsonObject);
|
|
|
- String msgIdSub = msg.substring(0, 2);
|
|
|
- String url=null;
|
|
|
- if (msgIdSub.equals("wb")){
|
|
|
- url=String.format("https://qyapi.weixin.qq.com/cgi-bin/msgaudit/get_robot_info??access_token=%s&robot_id=%s",getAccessToken(),msg);
|
|
|
- }else if (msgIdSub.equals("wo")){
|
|
|
- // https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid=EXTERNAL_USERID&cursor=CURSOR
|
|
|
- url=String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=%s&external_userid=%s",getAccessToken(),msg);
|
|
|
- }else if (msgIdSub.equals("wm")){
|
|
|
- url=String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=%s&external_userid=%s",getAccessToken(),msg);
|
|
|
+ public String pushGetChatName(String userId) {
|
|
|
+ ChatMsgUser chatMsgUser = chatMsgUserMapper.selectByUserId(userId);
|
|
|
+ if (chatMsgUser != null){
|
|
|
+ return chatMsgUser.getName();
|
|
|
}else {
|
|
|
- url=String.format("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=%s&userid=%s",getAccessToken(),msg);
|
|
|
+ String msgIdSub = userId.substring(0, 2);
|
|
|
+ String url=null;
|
|
|
+ Integer type=0;
|
|
|
+ if (msgIdSub.equals("wb")){
|
|
|
+ url=String.format("https://qyapi.weixin.qq.com/cgi-bin/msgaudit/get_robot_info??access_token=%s&robot_id=%s",getAccessToken(),userId);
|
|
|
+ }else if (msgIdSub.equals("wo")){
|
|
|
+ // https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=ACCESS_TOKEN&external_userid=EXTERNAL_USERID&cursor=CURSOR
|
|
|
+ url=String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=%s&external_userid=%s",getAccessToken(),userId);
|
|
|
+ type=1;
|
|
|
+ }else if (msgIdSub.equals("wm")){
|
|
|
+ url=String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=%s&external_userid=%s",getAccessToken(),userId);
|
|
|
+ type=1;
|
|
|
+ }else {
|
|
|
+ url=String.format("https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=%s&userid=%s",getAccessToken(),userId);
|
|
|
+ type=2;
|
|
|
+ }
|
|
|
+ String userName = getUserName(url);
|
|
|
+ System.out.println(userId+"="+userName);
|
|
|
+ if (StringUtils.isNotBlank(userName)){
|
|
|
+ chatMsgUser = new ChatMsgUser();
|
|
|
+ chatMsgUser.setUserId(userId);
|
|
|
+ chatMsgUser.setName(userName);
|
|
|
+ chatMsgUser.setType(type);
|
|
|
+ chatMsgUser.setCreateTime(new Date());
|
|
|
+ chatMsgUserMapper.insert(chatMsgUser);
|
|
|
+ }
|
|
|
+ return userName;
|
|
|
}
|
|
|
- String userName = getUserName(url);
|
|
|
- System.out.println(msg+"="+userName);
|
|
|
- return userName;
|
|
|
}
|
|
|
|
|
|
|