|
|
@@ -34,6 +34,7 @@ public class IpadSendUtils {
|
|
|
private final RedisCacheT<String> redisCache;
|
|
|
private final RedisCache redisCacheUrl;
|
|
|
private final String FILE_KEY = "ipad:upload:";
|
|
|
+ private final String USER_KEY = "ipad:userid:";
|
|
|
|
|
|
/**
|
|
|
* 发送卡片消息
|
|
|
@@ -200,6 +201,14 @@ public class IpadSendUtils {
|
|
|
if(vo.isRoom()){
|
|
|
return chatIds(vo);
|
|
|
}
|
|
|
+ try {
|
|
|
+ String idStr = redisCache.getCacheObject(USER_KEY + vo.getExId());
|
|
|
+ if(StringUtils.isNotEmpty(idStr)){
|
|
|
+ return Long.parseLong(idStr);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("获取外部联系人ID失败", e);
|
|
|
+ }
|
|
|
WxWorkUserId2VidDTO wxWorkUserId2VidDTO = new WxWorkUserId2VidDTO();
|
|
|
wxWorkUserId2VidDTO.setOpenid(Collections.singletonList(vo.getExId()));
|
|
|
wxWorkUserId2VidDTO.setCorpid(vo.getCorpId());
|
|
|
@@ -211,6 +220,11 @@ public class IpadSendUtils {
|
|
|
log.error("未找到用户数据,基础数据:{},请求数据:{},返回数据:{}", vo, JSON.toJSONString(wxWorkUserId2VidDTO), JSON.toJSONString(WxWorkVid2UserIdRespDTO));
|
|
|
throw new BaseException("未找到用户:" + vo.getId());
|
|
|
}
|
|
|
+ try {
|
|
|
+ redisCache.setCacheObject(USER_KEY + vo.getExId(), data.get(0).getUser_id().toString());
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("存储获外部联系人ID失败", e);
|
|
|
+ }
|
|
|
return data.get(0).getUser_id();
|
|
|
}
|
|
|
|
|
|
@@ -220,6 +234,14 @@ public class IpadSendUtils {
|
|
|
* @return 返回的userid
|
|
|
*/
|
|
|
private Long chatIds(BaseVo vo){
|
|
|
+ try {
|
|
|
+ String idStr = redisCache.getCacheObject(USER_KEY + vo.getExId());
|
|
|
+ if(StringUtils.isNotEmpty(idStr)){
|
|
|
+ return Long.parseLong(idStr);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("获取群ID失败", e);
|
|
|
+ }
|
|
|
WxWorkChatIdToRoomIdDTO tdo = new WxWorkChatIdToRoomIdDTO();
|
|
|
tdo.setChatid(vo.getExId());
|
|
|
tdo.setCorpid(vo.getCorpId());
|
|
|
@@ -233,6 +255,11 @@ public class IpadSendUtils {
|
|
|
log.error("未找到群聊数据,请求数据:{},返回数据:{}", JSON.toJSONString(tdo), JSON.toJSONString(result));
|
|
|
throw new BaseException("未找到群聊:" + vo.getId());
|
|
|
}
|
|
|
+ try {
|
|
|
+ redisCache.setCacheObject(USER_KEY + vo.getExId(), data.getRoom_id().toString());
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("存储群ID失败", e);
|
|
|
+ }
|
|
|
return data.getRoom_id();
|
|
|
}
|
|
|
|