|
|
@@ -3,6 +3,7 @@ package com.fs.ipad;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.core.redis.RedisCacheT;
|
|
|
import com.fs.common.exception.base.BaseException;
|
|
|
@@ -17,6 +18,7 @@ import com.fs.qw.domain.QwGroupChat;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.fs.qw.mapper.QwGroupChatMapper;
|
|
|
+import com.fs.qw.mapper.QwUserMapper;
|
|
|
import com.fs.sop.domain.QwSop;
|
|
|
import com.fs.sop.domain.SopUserLogs;
|
|
|
import com.fs.sop.mapper.QwSopMapper;
|
|
|
@@ -53,8 +55,10 @@ public class IpadSendUtils {
|
|
|
private final QwSopMapper qwSopMapper;
|
|
|
private final QwExternalContactMapper qwExternalContactMapper;
|
|
|
private final SopUserLogsMapper sopUserLogsMapper;
|
|
|
+ private final QwUserMapper qwUserMapper;
|
|
|
private final RedisCache redisCacheUrl;
|
|
|
private final String FILE_KEY = "ipad:upload:";
|
|
|
+ private final String USER_KEY = "ipad:user:";
|
|
|
|
|
|
/**
|
|
|
* 发送卡片消息
|
|
|
@@ -241,11 +245,22 @@ public class IpadSendUtils {
|
|
|
* @return 返回的userid
|
|
|
*/
|
|
|
private Long chatIds(BaseVo vo){
|
|
|
+ // 实时查询群聊信息
|
|
|
+ QwGroupChat qwGroupChat = qwGroupChatMapper.selectQwGroupChatByChatId(vo.getExId());
|
|
|
+ if(qwGroupChat == null){
|
|
|
+ throw new BaseException("未找到群聊,检查SOP任务数据");
|
|
|
+ }
|
|
|
+ if(qwGroupChat.getRoomid() != null){
|
|
|
+ return qwGroupChat.getRoomid();
|
|
|
+ }
|
|
|
+ // 找到对应的企业微信
|
|
|
+ QwUser qwUser = qwUserMapper.selectOne(new QueryWrapper<QwUser>().eq("corp_id", qwGroupChat.getCorpId()).eq("ipad_status", 1).last(" limit 1"));
|
|
|
WxWorkChatIdToRoomIdDTO tdo = new WxWorkChatIdToRoomIdDTO();
|
|
|
- tdo.setChatid(vo.getExId());
|
|
|
- tdo.setCorpid(vo.getCorpId());
|
|
|
- tdo.setUuid(vo.getUuid());
|
|
|
- WxWorkResponseDTO<WxWorkChatIdToRoomIdResp> result = wxWorkService.ChatIdToRoomId(tdo, vo.getServerId());
|
|
|
+ // 重新组装数据
|
|
|
+ tdo.setChatid(qwGroupChat.getChatId());
|
|
|
+// tdo.setCorpid(vo.getCorpId());
|
|
|
+ tdo.setUuid(qwUser.getUid());
|
|
|
+ WxWorkResponseDTO<WxWorkChatIdToRoomIdResp> result = wxWorkService.ChatIdToRoomId(tdo, qwUser.getServerId());
|
|
|
if(result.getErrcode() != 0){
|
|
|
throw new BaseException(result.getErrmsg());
|
|
|
}
|
|
|
@@ -254,6 +269,13 @@ public class IpadSendUtils {
|
|
|
log.error("未找到群聊数据,请求数据:{},返回数据:{}", JSON.toJSONString(tdo), JSON.toJSONString(result));
|
|
|
throw new BaseException("未找到群聊:" + vo.getId());
|
|
|
}
|
|
|
+ try {
|
|
|
+ qwGroupChat.setRoomid(data.getRoom_id());
|
|
|
+ qwGroupChatMapper.updateQwGroupChat(qwGroupChat);
|
|
|
+ redisCache.setCacheObject(USER_KEY + vo.getExId(), data.getRoom_id().toString());
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("存储群ID失败", e);
|
|
|
+ }
|
|
|
return data.getRoom_id();
|
|
|
}
|
|
|
|