|
|
@@ -17,6 +17,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;
|
|
|
@@ -56,6 +57,7 @@ public class IpadSendUtils {
|
|
|
private final RedisCache redisCacheUrl;
|
|
|
private final String FILE_KEY = "ipad:upload:";
|
|
|
private final String USER_KEY = "ipad:userid:";
|
|
|
+ private final QwUserMapper qwUserMapper;
|
|
|
|
|
|
/**
|
|
|
* 发送卡片消息
|
|
|
@@ -263,11 +265,25 @@ public class IpadSendUtils {
|
|
|
}catch (Exception e){
|
|
|
log.error("获取群ID失败", e);
|
|
|
}
|
|
|
+ // 实时查询群聊信息
|
|
|
+ QwGroupChat qwGroupChat = qwGroupChatMapper.selectQwGroupChatByChatId(vo.getExId());
|
|
|
+ if(qwGroupChat == null){
|
|
|
+ throw new BaseException("未找到群聊,检查SOP任务数据");
|
|
|
+ }
|
|
|
+ if(qwGroupChat.getRoomid() != null){
|
|
|
+ return qwGroupChat.getRoomid();
|
|
|
+ }
|
|
|
+ // 找到对应的企业微信
|
|
|
+ QwUser qwUser = qwUserMapper.selectQwUserAppKeyAndIdByCorpIdAndUserIdAndIpad(qwGroupChat.getCorpId(), qwGroupChat.getOwner());
|
|
|
+ if(qwUser == null){
|
|
|
+ throw new BaseException("群主离线无法转换");
|
|
|
+ }
|
|
|
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());
|
|
|
}
|
|
|
@@ -277,6 +293,8 @@ public class IpadSendUtils {
|
|
|
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);
|
|
|
@@ -428,9 +446,9 @@ public class IpadSendUtils {
|
|
|
if(result.getErrcode() != 0) throw new BaseException("发送消息错误:" + result.getErrmsg());
|
|
|
}
|
|
|
|
|
|
- public void sendTxtAtMsgVo(WxSendTextAtMsgTwoDTO dto, Long serverId){
|
|
|
+ public void sendTxtAtMsgVo(WxSendTextAtMsgTwoDTO dto, Long serverId ,Long sopUserLogId){
|
|
|
WxWorkResponseDTO<WxSendTextAtMsgVo> result = wxWorkService.sendTextAtMsgTwo(dto, serverId);
|
|
|
- log.info("发送@所有人返回数据:{}", result);
|
|
|
+ log.info("发送@所有人返回数据:{} sop_user_log主键:{}", result, sopUserLogId);
|
|
|
if(result.getErrcode() != 0) throw new BaseException("发送@所有人消息错误:" + result.getErrmsg());
|
|
|
}
|
|
|
|