|
@@ -3,16 +3,26 @@ package com.fs.im.service.impl;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
+import com.fs.common.exception.ServiceException;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.company.domain.Company;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyMapper;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
+import com.fs.course.domain.FsCourseWatchLog;
|
|
|
+import com.fs.course.domain.FsUserCompanyUser;
|
|
|
+import com.fs.course.domain.FsUserCourse;
|
|
|
+import com.fs.course.dto.BatchSendCourseAllDTO;
|
|
|
+import com.fs.course.dto.BatchSendCourseDTO;
|
|
|
+import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
+import com.fs.course.mapper.FsUserCompanyUserMapper;
|
|
|
+import com.fs.course.mapper.FsUserCourseMapper;
|
|
|
import com.fs.fastGpt.service.AiHookService;
|
|
|
import com.fs.his.domain.FsDoctor;
|
|
|
import com.fs.his.domain.FsFollow;
|
|
@@ -22,10 +32,9 @@ import com.fs.his.mapper.FsDoctorMapper;
|
|
|
import com.fs.his.mapper.FsFollowMapper;
|
|
|
import com.fs.his.mapper.FsUserMapper;
|
|
|
import com.fs.im.config.IMConfig;
|
|
|
-import com.fs.im.dto.OpenImConversationDTO;
|
|
|
-import com.fs.im.dto.OpenImEditConversationDTO;
|
|
|
-import com.fs.im.dto.OpenImMsgDTO;
|
|
|
-import com.fs.im.dto.OpenImResponseDTO;
|
|
|
+import com.fs.im.domain.ImSendLog;
|
|
|
+import com.fs.im.dto.*;
|
|
|
+import com.fs.im.mapper.ImSendLogMapper;
|
|
|
import com.fs.im.service.OpenIMService;
|
|
|
import com.fs.im.vo.OpenImMsgCallBackVO;
|
|
|
import com.fs.im.vo.OpenImResponseDTOTest;
|
|
@@ -33,14 +42,17 @@ import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.github.pagehelper.util.StringUtil;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
-
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -67,6 +79,17 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
@Autowired
|
|
|
@Lazy
|
|
|
private AiHookService aiHookService;
|
|
|
+ @Autowired
|
|
|
+ private FsUserCourseMapper fsUserCourseMapper;
|
|
|
+ @Autowired
|
|
|
+ private FsUserCompanyUserMapper fsUserCompanyUserMapper;
|
|
|
+ @Autowired
|
|
|
+ private FsCourseWatchLogMapper courseWatchLogMapper;
|
|
|
+ @Autowired
|
|
|
+ private ImSendLogMapper imSendLogMapper;
|
|
|
+
|
|
|
+// @Value("${openIM.prefix}")
|
|
|
+// private String openImPrefix;
|
|
|
/*@Autowired
|
|
|
private IFsUserService fsUserService;*/
|
|
|
@Override
|
|
@@ -81,7 +104,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
String adminToken = null;
|
|
|
// 发起 HTTP POST 请求,获取管理员 token
|
|
|
try {
|
|
|
- String response = HttpRequest.post("https://web.im.cdwjyyh.com/api/auth/get_admin_token")
|
|
|
+ String response = HttpRequest.post(IMConfig.URL+"/auth/get_admin_token")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.body(requestBody.toString())
|
|
|
.execute()
|
|
@@ -102,6 +125,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public OpenImResponseDTO AiAutoReply(OpenImMsgCallBackVO openImMsgDTO) throws JsonProcessingException {
|
|
|
try {
|
|
@@ -199,6 +223,106 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private Boolean checkImMsgContent(OpenImMsgCallBackVO openImMsgDTO) {
|
|
|
+ String content = openImMsgDTO.getContent();
|
|
|
+ if (content == null || content.isEmpty() || content.trim().isEmpty()) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ String conversationId = "si_" + openImMsgDTO.getRecvID() + "_" + openImMsgDTO.getSendID();
|
|
|
+ // 三种情况 ①正常聊天 ② 转人工 ③人工之后的聊天
|
|
|
+ // 检测内容是否包含
|
|
|
+ try {
|
|
|
+ //① 存在转人工配置 返回true 跳过自动回复
|
|
|
+ String ex = getIMList(openImMsgDTO.getSendID(),conversationId);
|
|
|
+ if (ex != null && ex.contains("IsArtificial")) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ //② 检查当前语句 是否包含转人工
|
|
|
+ if (content.contains("转人工")) {
|
|
|
+ OpenImEditConversationDTO currentConversation = new OpenImEditConversationDTO();
|
|
|
+ ArrayList<String> userIDs = new ArrayList<>();
|
|
|
+ userIDs.add(openImMsgDTO.getSendID());
|
|
|
+ currentConversation.setUserIDs(userIDs);
|
|
|
+ OpenImConversationDTO openImConversationDTO = new OpenImConversationDTO();
|
|
|
+ openImConversationDTO.setConversationID(conversationId);
|
|
|
+ openImConversationDTO.setConversationType(1);
|
|
|
+ openImConversationDTO.setUserID(openImMsgDTO.getRecvID());
|
|
|
+ // 不存在配置 直接放
|
|
|
+ if (ex == null || StringUtils.isEmpty(ex.trim())) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("IsArtificial", 1);
|
|
|
+ openImConversationDTO.setEx(jsonObject.toString());
|
|
|
+ } else {
|
|
|
+ // 存在配置 添加之后再放
|
|
|
+ JSONObject exJson = new JSONObject(ex);
|
|
|
+ exJson.put("IsArtificial", 1);
|
|
|
+ openImConversationDTO.setEx(exJson.toString());
|
|
|
+ }
|
|
|
+ currentConversation.setConversation(openImConversationDTO);
|
|
|
+ OpenImResponseDTO openImResponseDTO1 = editConversation(currentConversation);
|
|
|
+ log.info("修改回话返回参数:{}", openImResponseDTO1);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ //③正常i情况 直接返回
|
|
|
+ return false;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("openImMsgCallBack,检测内容是否包含转人工失败:", e);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getIMList( String recvID,String conversationId) {
|
|
|
+ int pageNumber = 1;
|
|
|
+ int pageSize = 20;
|
|
|
+ int maxPages = 10; // 最大搜索页数,防止无限循环
|
|
|
+ String adminToken = getAdminToken();
|
|
|
+ try {
|
|
|
+ while (pageNumber <= maxPages) {
|
|
|
+ JSONObject requestBody = new JSONObject();
|
|
|
+ requestBody.put("userID", recvID);
|
|
|
+ JSONObject pagination = new JSONObject();
|
|
|
+ pagination.put("pageNumber", pageNumber);
|
|
|
+ pagination.put("showNumber", pageSize);
|
|
|
+ requestBody.put("pagination", pagination);
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/conversation/get_owner_conversation")
|
|
|
+ .header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
+ .header("token", adminToken)
|
|
|
+ .body(requestBody.toString())
|
|
|
+ .execute()
|
|
|
+ .body();
|
|
|
+ JSONObject jsonResponse = new JSONObject(body);
|
|
|
+ if (jsonResponse.getInt("errCode") == 0) {
|
|
|
+ JSONObject data = jsonResponse.getJSONObject("data");
|
|
|
+ int total = data.getInt("total");
|
|
|
+ if (total > 0) {
|
|
|
+ JSONArray conversations = data.getJSONArray("conversations");
|
|
|
+ // 遍历当前页的所有会话
|
|
|
+ for (int i = 0; i < conversations.length(); i++) {
|
|
|
+ JSONObject conversation = conversations.getJSONObject(i);
|
|
|
+ String convId = conversation.getString("conversationID");
|
|
|
+ // 如果找到目标会话,返回其ex字段
|
|
|
+ if (conversationId.equals(convId)) {
|
|
|
+ return conversation.getString("ex");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果当前页没有找到且已经是最后一页,则退出循环
|
|
|
+ if (conversations.length() < pageSize) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 如果没有数据,直接退出循环
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 移动到下一页
|
|
|
+ pageNumber++;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
//批量修改销售名称,由昵称-公司名,改为昵称
|
|
|
public static void main(String[] args) {
|
|
|
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiJpbUFkbWluIiwiUGxhdGZvcm1JRCI6MTAsImV4cCI6MTc1OTkxMDgwNywiaWF0IjoxNzUyMTM0ODAyfQ.y0akpb-TnOBqJewPUD13tnUeR1iF41A3CcgaXXsjyKE";
|
|
@@ -214,7 +338,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
pagination.put("showNumber", pageSize);
|
|
|
requestPage.put("pagination", pagination);
|
|
|
|
|
|
- String result = HttpRequest.post("https://web.im.cdwjyyh.com/api/user/get_all_users_uid")
|
|
|
+ String result = HttpRequest.post(IMConfig.URL+"/user/get_all_users_uid")
|
|
|
.header("operationID", String.valueOf(time))
|
|
|
.header("token", token)
|
|
|
.body(requestPage.toString())
|
|
@@ -239,7 +363,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
paramMap.put("userIDs", userIds);
|
|
|
|
|
|
String jsonBody = JSONUtil.toJsonStr(paramMap);
|
|
|
- String result1 = HttpRequest.post("https://web.im.cdwjyyh.com/api/user/get_users_info")
|
|
|
+ String result1 = HttpRequest.post(IMConfig.URL+"/user/get_users_info")
|
|
|
.header("operationID", String.valueOf(time))
|
|
|
.header("token", token)
|
|
|
.body(jsonBody)
|
|
@@ -261,7 +385,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
bodyMap.put("userInfo", updateUserInfo);
|
|
|
|
|
|
String jsonBody1 = JSONUtil.toJsonStr(bodyMap);
|
|
|
- String result2 = HttpRequest.post("https://web.im.cdwjyyh.com/api/user/update_user_info_ex")
|
|
|
+ String result2 = HttpRequest.post(IMConfig.URL+"/user/update_user_info_ex")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", token)
|
|
|
.body(jsonBody1)
|
|
@@ -301,7 +425,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
paramMap.put("userIDs", userIDs);
|
|
|
|
|
|
String jsonBody = JSONUtil.toJsonStr(paramMap);
|
|
|
- String result1 = HttpRequest.post("https://web.im.cdwjyyh.com/api/user/get_users_info")
|
|
|
+ String result1 = HttpRequest.post(IMConfig.URL+"/user/get_users_info")
|
|
|
.header("operationID", String.valueOf(time))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonBody)
|
|
@@ -315,14 +439,14 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
}
|
|
|
for (UserInfo user : users) {
|
|
|
updateUserInfo.setUserID(user.getUserID());
|
|
|
- updateUserInfo.setNickname(StringUtils.isNotEmpty(companyUser.getImNickName())?companyUser.getImNickName():companyUser.getNickName());
|
|
|
+ updateUserInfo.setNickname(companyUser.getNickName());
|
|
|
updateUserInfo.setFaceURL(Optional.ofNullable(user.getFaceURL()).orElse(""));
|
|
|
updateUserInfo.setEx(Optional.ofNullable(user.getEx()).orElse(""));
|
|
|
|
|
|
Map<String, Object> bodyMap = new HashMap<>();
|
|
|
bodyMap.put("userInfo", updateUserInfo);
|
|
|
String jsonBody1 = JSONUtil.toJsonStr(bodyMap);
|
|
|
- String result2 = HttpRequest.post("https://web.im.cdwjyyh.com/api/user/update_user_info_ex")
|
|
|
+ String result2 = HttpRequest.post(IMConfig.URL+"/user/update_user_info_ex")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonBody1)
|
|
@@ -358,16 +482,21 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
log.info("进入发消息的方法");
|
|
|
String adminToken = getAdminToken();
|
|
|
JSONObject jsonObject = new JSONObject(openImMsgDTO);
|
|
|
+ String url = IMConfig.URL+"/msg/send_msg";
|
|
|
+ log.info("请求url: {}",url);
|
|
|
log.info("发送消息的请求体:\n{}", jsonObject.toString());
|
|
|
long time = new Date().getTime();
|
|
|
- String result = HttpRequest.post("https://web.im.cdwjyyh.com/api/msg/send_msg")
|
|
|
+
|
|
|
+ log.info("请求header: token={},operationID={}",adminToken,time);
|
|
|
+ String result = HttpRequest.post(url)
|
|
|
.header("operationID", time + "")
|
|
|
.header("token",adminToken)
|
|
|
.body(jsonObject.toString())
|
|
|
.execute()
|
|
|
.body();
|
|
|
+
|
|
|
OpenImResponseDTO responseDTO= JSONUtil.toBean(result,OpenImResponseDTO.class);
|
|
|
- log.info("发送消息返回内容:\n{}", responseDTO);
|
|
|
+ log.info("发送消息返回内容:\n{}", result);
|
|
|
return responseDTO;
|
|
|
}
|
|
|
@Override
|
|
@@ -375,7 +504,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
//userId = 61l;
|
|
|
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // 忽略null字段
|
|
|
- checkAndImportFriendByDianBo(companyUserId,userId.toString(),cropId);
|
|
|
+ checkAndImportFriendByDianBo(companyUserId,userId.toString(),cropId,true);
|
|
|
OpenImMsgDTO.Content content = new OpenImMsgDTO.Content();
|
|
|
OpenImMsgDTO.ImData imData = new OpenImMsgDTO.ImData();
|
|
|
PayloadDTO payload = new PayloadDTO();
|
|
@@ -392,7 +521,8 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
|
|
|
OpenImMsgDTO.OfflinePushInfo offlinePushInfo = new OpenImMsgDTO.OfflinePushInfo();
|
|
|
offlinePushInfo.setDesc(title);
|
|
|
- offlinePushInfo.setTitle("芳华未来");
|
|
|
+ CompanyUser companyUser = companyUserMapper.selectCompanyUserById(companyUserId);
|
|
|
+ offlinePushInfo.setTitle(companyUser.getNickName());
|
|
|
offlinePushInfo.setIOSBadgeCount(true);
|
|
|
offlinePushInfo.setIOSPushSound("");
|
|
|
|
|
@@ -400,19 +530,77 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
openImMsgDTO.setOfflinePushInfo(offlinePushInfo);
|
|
|
openImMsgDTO.setContent(content);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
openImMsgDTO.setSendID("C"+companyUserId);
|
|
|
openImMsgDTO.setRecvID("U"+userId);
|
|
|
openImMsgDTO.setContentType(110);
|
|
|
openImMsgDTO.setSessionType(1);
|
|
|
// 输出格式化JSON日志
|
|
|
- log.info("课程消息:\n{}", objectMapper.writeValueAsString(openImMsgDTO));
|
|
|
+ log.info("课程消息: {}", JSON.toJSONString(openImMsgDTO));
|
|
|
OpenImResponseDTO openImResponseDTO = openIMSendMsg(openImMsgDTO);
|
|
|
openImMsgDTO = null;
|
|
|
content = null;
|
|
|
return openImResponseDTO;
|
|
|
}
|
|
|
+ @Override
|
|
|
+ public OpenImResponseDTO sendPackageUtil(String sendID, String recvID, Integer contentType, String payloadData,String packageName,String packageId){
|
|
|
+ try {
|
|
|
+ OpenImMsgDTO.OfflinePushInfo offlinePushInfo = new OpenImMsgDTO.OfflinePushInfo();
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ OpenImMsgDTO openImMsgDTO = new OpenImMsgDTO();
|
|
|
+ if (sendID.startsWith("C")){
|
|
|
+ CompanyUser company = companyUserMapper.selectCompanyUserByUserId(Long.parseLong(sendID.replace("C", "")));
|
|
|
+ if (null!=company){
|
|
|
+ offlinePushInfo.setTitle(company.getNickName());
|
|
|
+ openImMsgDTO.setSenderFaceURL(company.getAvatar());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ accountCheck(recvID.toString(),"1");
|
|
|
+ openImMsgDTO.setSendID(sendID);
|
|
|
+ openImMsgDTO.setRecvID(recvID);
|
|
|
+ openImMsgDTO.setContentType(contentType);
|
|
|
+ openImMsgDTO.setSenderPlatformID(5);
|
|
|
+ openImMsgDTO.setSessionType(1);
|
|
|
+
|
|
|
+ OpenImMsgDTO.Content content = new OpenImMsgDTO.Content();
|
|
|
+ //content.setContent(ext);
|
|
|
+ PayloadDTO payload = new PayloadDTO();
|
|
|
+ payload.setData(payloadData);
|
|
|
+ PayloadDTO.Extension extension = new PayloadDTO.Extension();
|
|
|
+ //extension.setDiagnose(diagnose);
|
|
|
+ if (StringUtils.isNotEmpty(packageName)){
|
|
|
+ extension.setTitle(packageName);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(packageId)){
|
|
|
+ extension.setPackageId(packageId);
|
|
|
+ }
|
|
|
+ payload.setExtension(extension);
|
|
|
+ OpenImMsgDTO.ImData imData = new OpenImMsgDTO.ImData();
|
|
|
+
|
|
|
+ imData.setPayload(payload);
|
|
|
+
|
|
|
+ String imJson = objectMapper.writeValueAsString(imData);
|
|
|
+ content.setData(imJson);
|
|
|
+ openImMsgDTO.setContent(content);
|
|
|
+ if (contentType == 101){
|
|
|
+ content.setContent(packageName);
|
|
|
+ }
|
|
|
+ //cn.hutool.json.JSONObject jsonObject = new cn.hutool.json.JSONObject(openImMsgDTO);
|
|
|
+
|
|
|
+ //openImMsgDTO.setEx(payload);
|
|
|
+
|
|
|
+ offlinePushInfo.setDesc(packageName);
|
|
|
+
|
|
|
+ offlinePushInfo.setIOSBadgeCount(true);
|
|
|
+ offlinePushInfo.setIOSPushSound("");
|
|
|
+ openImMsgDTO.setOfflinePushInfo(offlinePushInfo);
|
|
|
+ OpenImResponseDTO openImResponseDTO = openIMSendMsg(openImMsgDTO);
|
|
|
+ return openImResponseDTO;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public OpenImResponseDTO sendUtil(String sendID, String recvID, Integer contentType, String payloadData, String diagnose,String title,String followId,String orderId,String ex) throws JsonProcessingException {
|
|
|
try {
|
|
@@ -429,7 +617,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
}else if (sendID.startsWith("C")){
|
|
|
CompanyUser company = companyUserMapper.selectCompanyUserByUserId(Long.parseLong(sendID.replace("C", "")));
|
|
|
if (null!=company&&StringUtils.isNotEmpty(company.getAvatar())){
|
|
|
- offlinePushInfo.setTitle(company.getImNickName());
|
|
|
+ offlinePushInfo.setTitle(company.getNickName());
|
|
|
openImMsgDTO.setSenderFaceURL(company.getAvatar());
|
|
|
}
|
|
|
}
|
|
@@ -495,7 +683,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
OpenImConversationDTO openImConversationDTO = new OpenImConversationDTO();
|
|
|
openImConversationDTO.setConversationID("si_"+sendID+"_"+recvID);
|
|
|
openImConversationDTO.setConversationType(1);
|
|
|
- openImConversationDTO.setUserID(recvID);
|
|
|
+ openImConversationDTO.setUserID(recvID.startsWith("U")?recvID:sendID);
|
|
|
openImConversationDTO.setEx(ex);
|
|
|
log.info("更新到会话的ex的值:{}",ex);
|
|
|
openImEditConversationDTO.setConversation(openImConversationDTO);
|
|
@@ -614,7 +802,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
while (retryCount < maxRetries) {
|
|
|
try {
|
|
|
JSONObject jsonObject = new JSONObject(dto);
|
|
|
- String body = HttpRequest.post("https://web.im.cdwjyyh.com/api/conversation/set_conversations")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/conversation/set_conversations")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonObject.toString())
|
|
@@ -646,7 +834,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("userID1",userID1);
|
|
|
jsonObject.put("userID2",userID2);
|
|
|
- String body = HttpRequest.post("https://web.im.cdwjyyh.com/api/friend/is_friend")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/friend/is_friend")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonObject.toString())
|
|
@@ -683,7 +871,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("ownerUserID",ownerUserID);
|
|
|
jsonObject.put("friendUserIDs",newFriendIds);
|
|
|
- String body = HttpRequest.post("https://web.im.cdwjyyh.com/api/friend/import_friend")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/friend/import_friend")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonObject.toString())
|
|
@@ -720,7 +908,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
requestBody = new JSONObject();
|
|
|
userIds.add(userId);
|
|
|
requestBody.put("checkUserIDs", userIds);
|
|
|
- String body = HttpRequest.post("https://web.im.cdwjyyh.com/api/user/account_check")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/user/account_check")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(requestBody.toString())
|
|
@@ -738,31 +926,38 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
String s = "";
|
|
|
switch (type){
|
|
|
case "2":
|
|
|
- s = userId.replaceFirst("^C", "");
|
|
|
+ s = userId.replaceFirst("^"+"C", "");
|
|
|
CompanyUser companyUser = companyUserMapper.selectCompanyUserByCompanyUserId(Long.parseLong(s));
|
|
|
if (null==companyUser){
|
|
|
- return R.error("用户不存在");
|
|
|
+// return R.error("用户不存在");
|
|
|
+ log.error("异步执行IM注册/添加好友失败,失败原因:{},userId:{},type:{}", "销售用户不存在",userId, type);
|
|
|
+ throw new ServiceException("用户不存在");
|
|
|
}
|
|
|
Company company = companyMapper.selectCompanyById(companyUser.getCompanyId());
|
|
|
map.put("userID",userId);
|
|
|
- map.put("nickname",companyUser.getImNickName());
|
|
|
+ //map.put("nickname",companyUser.getImNickName());
|
|
|
+ map.put("nickname",companyUser.getNickName());
|
|
|
map.put("faceURL",companyUser.getAvatar());
|
|
|
break;
|
|
|
case "1":
|
|
|
- s = userId.replaceFirst("^U", "");
|
|
|
+ s = userId.replaceFirst("^"+"U", "");
|
|
|
FsUser fsUser = fsUserMapper.selectFsUserByUserId(Long.parseLong(s));
|
|
|
if (null==fsUser){
|
|
|
- return R.error("用户不存在");
|
|
|
+// return R.error("用户不存在");
|
|
|
+ log.error("异步执行IM注册/添加好友失败,失败原因:{},userId:{},type:{}", "user用户不存在", userId, type);
|
|
|
+ throw new ServiceException("用户不存在");
|
|
|
}
|
|
|
map.put("userID",userId);
|
|
|
map.put("nickname",StringUtils.isEmpty(fsUser.getNickName())?"微信用户":fsUser.getNickName());
|
|
|
map.put("faceURL",fsUser.getAvatar());
|
|
|
break;
|
|
|
case "3":
|
|
|
- s = userId.replaceFirst("^D", "");
|
|
|
+ s = userId.replaceFirst("^"+"D", "");
|
|
|
FsDoctor fsDoctor = fsDoctorMapper.selectFsDoctorByDoctorId(Long.parseLong(s));
|
|
|
if (null==fsDoctor){
|
|
|
- return R.error("用户不存在");
|
|
|
+// return R.error("用户不存在");
|
|
|
+ log.error("异步执行IM注册/添加好友失败,失败原因:{},userId:{},type:{}", "医生用户不存在", userId, type);
|
|
|
+ throw new ServiceException("用户不存在");
|
|
|
}
|
|
|
map.put("userID",userId);
|
|
|
map.put("nickname",fsDoctor.getDoctorName());
|
|
@@ -774,12 +969,14 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
requestBody = new JSONObject();
|
|
|
userIds.add(userId);
|
|
|
requestBody.put("users", users);
|
|
|
- HttpRequest.post("https://web.im.cdwjyyh.com/api/user/user_register")
|
|
|
+ HttpRequest.post(IMConfig.URL+"/user/user_register")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken).body(requestBody.toString()).execute().body();
|
|
|
}
|
|
|
} else {
|
|
|
- return R.error("返回结果为空");
|
|
|
+// return R.error("返回结果为空");
|
|
|
+ log.error("异步执行IM注册/添加好友失败,失败原因:{},json结果:{}", "返回结果为空", jsonObject);
|
|
|
+ throw new ServiceException("返回结果为空");
|
|
|
}
|
|
|
/* HashMap<String, String> tokenMap = new HashMap<>();
|
|
|
tokenMap.put("platformID","1");
|
|
@@ -787,7 +984,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
requestBody = new JSONObject();
|
|
|
requestBody.put("platformID",5);
|
|
|
requestBody.put("userID",userId);
|
|
|
- String body1 = HttpRequest.post("https://web.im.cdwjyyh.com/api/auth/get_user_token")
|
|
|
+ String body1 = HttpRequest.post(IMConfig.URL+"/auth/get_user_token")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(requestBody.toString()).execute().body();
|
|
@@ -798,31 +995,35 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
String userToken = userData.getString("token");
|
|
|
return R.ok().put("token", userToken);
|
|
|
}
|
|
|
- return R.error("注册失败");
|
|
|
+// return R.error("注册失败");
|
|
|
+ log.error("异步执行IM注册/添加好友失败,errCode:{}", errCode);
|
|
|
+ throw new ServiceException("注册失败");
|
|
|
} else {
|
|
|
- return R.error("获取管理员token失败");
|
|
|
+// return R.error("获取管理员token失败");
|
|
|
+ log.error("异步执行IM注册/添加好友失败,原因:{}, adminToken:{}", "获取管理员token失败", adminToken);
|
|
|
+ throw new ServiceException("获取管理员token失败");
|
|
|
}
|
|
|
}
|
|
|
- @Async
|
|
|
+// @Async
|
|
|
@Override
|
|
|
public void checkAndImportFriend(Long companyUserId,String fsUserId) {
|
|
|
- try {
|
|
|
+// try {
|
|
|
// 注册账号
|
|
|
- accountCheck("C" + companyUserId, "2");
|
|
|
- accountCheck("U"+fsUserId, "1");
|
|
|
+ accountCheck( "C" + companyUserId, "2");
|
|
|
+ accountCheck( "U" + fsUserId, "1");
|
|
|
|
|
|
// 导入好友关系
|
|
|
ArrayList<String> userIds = new ArrayList<>();
|
|
|
userIds.add("U" + fsUserId);
|
|
|
importFriend("C" + companyUserId, userIds);
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("异步执行IM注册/添加好友失败:", e);
|
|
|
- }
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("异步执行IM注册/添加好友失败:", e);
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
@Async
|
|
|
@Override
|
|
|
- public void checkAndImportFriendByDianBo(Long companyUserId,String fsUserId,String cropId) {
|
|
|
+ public void checkAndImportFriendByDianBo(Long companyUserId,String fsUserId,String cropId, boolean isUpdate) {
|
|
|
try {
|
|
|
// 注册账号
|
|
|
accountCheck("C" + companyUserId, "2");
|
|
@@ -832,12 +1033,228 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
ArrayList<String> userIds = new ArrayList<>();
|
|
|
userIds.add("U" + fsUserId);
|
|
|
importFriend("C" + companyUserId, userIds);
|
|
|
- updateFriendByDianBo("C" + companyUserId, userIds,cropId);
|
|
|
+ if(isUpdate){
|
|
|
+ updateFriendByDianBo("C" + companyUserId, userIds,cropId);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.error("异步执行IM注册/添加好友失败:", e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public OpenImResponseDTO openIMBatchSendMsg(OpenImBatchMsgDTO openImBatchMsgDTO) {
|
|
|
+ log.info("========================== 批量发送消息 ==========================");
|
|
|
+ String adminToken = getAdminToken();
|
|
|
+ JSONObject jsonObject = new JSONObject(openImBatchMsgDTO);
|
|
|
+ String url = IMConfig.URL+"/msg/batch_send_msg";
|
|
|
+ log.info("请求url: {},\n请求参数:{}", url, jsonObject);
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
+ log.info("请求header,operationID:{},token:{}", timestamp, adminToken);
|
|
|
+
|
|
|
+ String result = HttpRequest.post(url)
|
|
|
+ .header("operationID", timestamp + "")
|
|
|
+ .header("token",adminToken)
|
|
|
+ .body(jsonObject.toString())
|
|
|
+ .execute()
|
|
|
+ .body();
|
|
|
+ log.info("批量发送消息返回内容:\n{}", result);
|
|
|
+ OpenImResponseDTO responseDTO= JSONUtil.toBean(result, OpenImResponseDTO.class);
|
|
|
+ return responseDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public OpenImResponseDTO batchSendCourse(BatchSendCourseDTO batchSendCourseDTO) throws JsonProcessingException {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // 忽略null字段
|
|
|
+
|
|
|
+ //获取需要发送的人
|
|
|
+ List<String> userIds;
|
|
|
+ if(!batchSendCourseDTO.getUserIds().isEmpty()){
|
|
|
+ userIds = batchSendCourseDTO.getUserIds().stream().map(v -> "U" + v).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ userIds = this.getRecvIds(batchSendCourseDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ //注册和添加好友
|
|
|
+ for (String userId : userIds) {
|
|
|
+ String uId = userId.substring(1);
|
|
|
+ checkAndImportFriendByDianBo(batchSendCourseDTO.getCompanyUserId(), uId,null,false);
|
|
|
+ }
|
|
|
+
|
|
|
+ //组装消息数据
|
|
|
+ PayloadDTO.Extension extension = new PayloadDTO.Extension();
|
|
|
+ extension.setTitle(batchSendCourseDTO.getTitle());
|
|
|
+ extension.setAppRealLink(batchSendCourseDTO.getUrl());
|
|
|
+ extension.setSendTime(new Date());
|
|
|
+ FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(batchSendCourseDTO.getCourseId());
|
|
|
+ Long project = fsUserCourse != null ? fsUserCourse.getProject() : null;
|
|
|
+ extension.setCourseUrl(fsUserCourse != null ? fsUserCourse.getImgUrl() : null);
|
|
|
+
|
|
|
+ PayloadDTO payload = new PayloadDTO();
|
|
|
+ payload.setData("course");
|
|
|
+ payload.setExtension(extension);
|
|
|
+
|
|
|
+ OpenImBatchMsgDTO.ImData imData = new OpenImBatchMsgDTO.ImData();
|
|
|
+ OpenImBatchMsgDTO.Content content = new OpenImBatchMsgDTO.Content();
|
|
|
+ imData.setPayload(payload);
|
|
|
+ String imJson = objectMapper.writeValueAsString(imData);
|
|
|
+ content.setData(imJson);
|
|
|
+
|
|
|
+ OpenImBatchMsgDTO.OfflinePushInfo offlinePushInfo = new OpenImBatchMsgDTO.OfflinePushInfo();
|
|
|
+ offlinePushInfo.setDesc(batchSendCourseDTO.getTitle());
|
|
|
+ CompanyUser companyUser = companyUserMapper.selectCompanyUserById(batchSendCourseDTO.getCompanyUserId());
|
|
|
+ offlinePushInfo.setTitle(companyUser != null ? companyUser.getNickName(): null);
|
|
|
+ offlinePushInfo.setIOSBadgeCount(true);
|
|
|
+ offlinePushInfo.setIOSPushSound("");
|
|
|
+
|
|
|
+ // 设置发送的消息
|
|
|
+ OpenImBatchMsgDTO openImBatchMsgDTO = new OpenImBatchMsgDTO();
|
|
|
+ openImBatchMsgDTO.setSendID("C" + batchSendCourseDTO.getCompanyUserId());
|
|
|
+ openImBatchMsgDTO.setRecvIDs(userIds);
|
|
|
+ openImBatchMsgDTO.setContent(content);
|
|
|
+ openImBatchMsgDTO.setContentType(110);
|
|
|
+ openImBatchMsgDTO.setSessionType(1);
|
|
|
+ openImBatchMsgDTO.setIsOnlineOnly(false);
|
|
|
+ openImBatchMsgDTO.setNotOfflinePush(false);
|
|
|
+ long planSendTimeStamp;
|
|
|
+ if(batchSendCourseDTO.getSendTime() != null && batchSendCourseDTO.getSendTime().compareTo(new Date()) > 0){
|
|
|
+ planSendTimeStamp = batchSendCourseDTO.getSendTime().getTime();
|
|
|
+ } else {
|
|
|
+ planSendTimeStamp = System.currentTimeMillis();
|
|
|
+ }
|
|
|
+ openImBatchMsgDTO.setSendTime(planSendTimeStamp);
|
|
|
+ openImBatchMsgDTO.setOfflinePushInfo(offlinePushInfo);
|
|
|
+ openImBatchMsgDTO.setIsSendAll(false);
|
|
|
+
|
|
|
+ OpenImResponseDTO openImResponseDTO = new OpenImResponseDTO();
|
|
|
+ // 保存发送时间到缓存中
|
|
|
+ if(batchSendCourseDTO.getSendTime() != null && batchSendCourseDTO.getSendTime().compareTo(new Date()) > 0) {
|
|
|
+ // 定时发送
|
|
|
+ for (String userId : userIds) {
|
|
|
+ String redisKey = "openIm:batchSendMsg";
|
|
|
+ Map<String, Object> redisMap = new HashMap<>();
|
|
|
+ BatchSendCourseAllDTO batchSendCourseAllDTO = new BatchSendCourseAllDTO();
|
|
|
+ batchSendCourseAllDTO.setBatchSendCourseDTO(batchSendCourseDTO).setOpenImBatchMsgDTO(openImBatchMsgDTO).setProject(project);
|
|
|
+ redisMap.put(batchSendCourseDTO.getCourseId()+":"+batchSendCourseDTO.getVideoId()+":"+userId+":"+batchSendCourseDTO.getSendTime().getTime()
|
|
|
+ , batchSendCourseAllDTO);
|
|
|
+ redisCache.setCacheMap(redisKey, redisMap);
|
|
|
+ }
|
|
|
+ openImResponseDTO.setErrCode(0);
|
|
|
+ openImResponseDTO.setErrMsg("计划发送创建成功,待消息发送");
|
|
|
+ } else {
|
|
|
+ // 实时发送
|
|
|
+ openImResponseDTO = this.batchSendMsgTask(batchSendCourseDTO, openImBatchMsgDTO, project, 2);
|
|
|
+ openImResponseDTO.setErrMsg("实时发送成功");
|
|
|
+ }
|
|
|
+ return openImResponseDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public OpenImResponseDTO batchSendMsgTask(BatchSendCourseDTO batchSendCourseDTO, OpenImBatchMsgDTO openImBatchMsgDTO, Long project, Integer sendType) {
|
|
|
+
|
|
|
+ log.info("批量发送课程消息: \n{}", JSON.toJSONString(openImBatchMsgDTO));
|
|
|
+ OpenImResponseDTO openImResponseDTO = openIMBatchSendMsg(openImBatchMsgDTO);
|
|
|
+// openImBatchMsgDTO = null;
|
|
|
+// content = null;
|
|
|
+
|
|
|
+ //获取发送消息结果,成功后再生成看课记录和发送记录
|
|
|
+ if(openImResponseDTO.getErrCode() == 0 && openImResponseDTO.getData() != null){
|
|
|
+ Object data = openImResponseDTO.getData();
|
|
|
+ OpenImBatchResponseDataDTO openImBatchResponseDataDTO = JSON.parseObject(JSON.toJSONString(data), OpenImBatchResponseDataDTO.class);
|
|
|
+ List<OpenImBatchResponseDataDTO.Results> results = openImBatchResponseDataDTO.getResults();
|
|
|
+
|
|
|
+ // 生成发送记录
|
|
|
+ this.batchInsertSendLogs(openImBatchMsgDTO, openImResponseDTO, openImBatchResponseDataDTO, sendType);
|
|
|
+
|
|
|
+ // 生成看课记录
|
|
|
+ this.batchInsertWatchLogs(batchSendCourseDTO, results, project);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 生成发送记录
|
|
|
+ this.batchInsertSendLogs(openImBatchMsgDTO, openImResponseDTO, null, sendType);
|
|
|
+ log.error("发送消息失败,结果:{}", openImResponseDTO);
|
|
|
+ throw new ServiceException("发送消息失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ return openImResponseDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> getRecvIds(BatchSendCourseDTO batchSendCourseDTO) {
|
|
|
+ Map<String,Object> param = new HashMap<>();
|
|
|
+ param.put("tagIds", batchSendCourseDTO.getTagIds());
|
|
|
+ param.put("companyUserId", batchSendCourseDTO.getCompanyUserId());
|
|
|
+ List<FsUserCompanyUser> fsUserCompanyUsers = fsUserCompanyUserMapper.selectFsUserCompanyUserByIds(param);
|
|
|
+ if(fsUserCompanyUsers.isEmpty()){
|
|
|
+ log.error("没有消息接收人,参数:{}", batchSendCourseDTO);
|
|
|
+ throw new ServiceException("没有消息接收人");
|
|
|
+ }
|
|
|
+ return fsUserCompanyUsers.stream().map(v -> "U" + v.getUserId()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void batchInsertSendLogs(OpenImBatchMsgDTO openImBatchMsgDTO, OpenImResponseDTO openImResponseDTO, OpenImBatchResponseDataDTO openImBatchResponseDataDTO, Integer sendType) {
|
|
|
+ List<ImSendLog> list = new LinkedList<>();
|
|
|
+ if(openImResponseDTO.getErrCode() != 0){
|
|
|
+ ImSendLog imSendLog = createImsendLog(openImBatchMsgDTO, openImBatchMsgDTO.getSendTime());
|
|
|
+ imSendLog.setStatus(1);
|
|
|
+ imSendLog.setResultMessage(JSON.toJSONString(openImResponseDTO.getErrMsg()));
|
|
|
+ imSendLog.setExceptionInfo(JSON.toJSONString(openImResponseDTO.getErrDlt()));
|
|
|
+ list.add(imSendLog);
|
|
|
+ } else {
|
|
|
+ if(openImBatchResponseDataDTO.getFailedUserIDs() != null) {
|
|
|
+ for (String failedUserID : openImBatchResponseDataDTO.getFailedUserIDs()) {
|
|
|
+ ImSendLog imSendLog = createImsendLog(openImBatchMsgDTO, openImBatchMsgDTO.getSendTime());
|
|
|
+ imSendLog.setRecvId(failedUserID);
|
|
|
+ imSendLog.setStatus(1);
|
|
|
+ imSendLog.setResultMessage(JSON.toJSONString(openImBatchResponseDataDTO));
|
|
|
+ list.add(imSendLog);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (OpenImBatchResponseDataDTO.Results result : openImBatchResponseDataDTO.getResults()) {
|
|
|
+ ImSendLog imSendLog = createImsendLog(openImBatchMsgDTO, openImBatchMsgDTO.getSendTime());
|
|
|
+ imSendLog.setRecvId(result.getRecvID());
|
|
|
+ imSendLog.setActualSendTime(new Date(result.getSendTime()));
|
|
|
+ imSendLog.setSendType(sendType);
|
|
|
+ imSendLog.setStatus(0);
|
|
|
+ imSendLog.setResultMessage(JSON.toJSONString(openImBatchResponseDataDTO));
|
|
|
+ list.add(imSendLog);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ imSendLogMapper.insertImSendLogBatch(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static ImSendLog createImsendLog(OpenImBatchMsgDTO openImBatchMsgDTO, long planSendTimeStamp) {
|
|
|
+ ImSendLog imSendLog = new ImSendLog();
|
|
|
+ imSendLog.setSendId(openImBatchMsgDTO.getSendID());
|
|
|
+ imSendLog.setSendTitle(openImBatchMsgDTO.getOfflinePushInfo() != null ? openImBatchMsgDTO.getOfflinePushInfo().getTitle() : null);
|
|
|
+ imSendLog.setPlanSendTime(new Date(planSendTimeStamp));
|
|
|
+ imSendLog.setParamJson(JSON.toJSONString(openImBatchMsgDTO));
|
|
|
+
|
|
|
+ return imSendLog;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void batchInsertWatchLogs(BatchSendCourseDTO batchSendCourseDTO, List<OpenImBatchResponseDataDTO.Results> results, Long project) {
|
|
|
+ List<FsCourseWatchLog> watchLogsInsertList = new LinkedList<>();
|
|
|
+ for (OpenImBatchResponseDataDTO.Results result : results) {
|
|
|
+ FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
|
|
|
+ BeanUtils.copyProperties(batchSendCourseDTO, fsCourseWatchLog);
|
|
|
+ String userId = result.getRecvID().replaceFirst("^"+"U", "");
|
|
|
+ fsCourseWatchLog.setUserId(Long.parseLong(userId));
|
|
|
+ fsCourseWatchLog.setSendType(1);
|
|
|
+ fsCourseWatchLog.setDuration(0L);
|
|
|
+ fsCourseWatchLog.setCreateTime(new Date());
|
|
|
+ fsCourseWatchLog.setLogType(3);
|
|
|
+ fsCourseWatchLog.setProject(project);
|
|
|
+ watchLogsInsertList.add(fsCourseWatchLog);
|
|
|
+ }
|
|
|
+ courseWatchLogMapper.insertFsCourseWatchLogBatch(watchLogsInsertList);
|
|
|
+ log.info("批量插入FsCourseWatchLog表完成,共插入 {} 条记录", watchLogsInsertList.size());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改好友信息
|
|
|
* @param ownerUserID
|
|
@@ -861,7 +1278,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- List<String> remark = qwExternalContactMapper.selectRemarkByCompanyUserAndFsUser(friendUserIDs.get(0).replaceFirst("^U", ""), ownerUserID.replaceFirst("^C", ""),cropId);
|
|
|
+ List<String> remark = qwExternalContactMapper.selectRemarkByCompanyUserAndFsUser(friendUserIDs.get(0).replaceFirst("^scrmU", ""), ownerUserID.replaceFirst("^scrmC", ""),cropId);
|
|
|
if (CollectionUtils.isEmpty(remark)||remark.size()<=0){
|
|
|
return null;
|
|
|
}
|
|
@@ -870,7 +1287,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
jsonObject.put("ownerUserID",ownerUserID);
|
|
|
jsonObject.put("friendUserIDs",friendUserIDs);
|
|
|
jsonObject.put("remark",remark.get(0));
|
|
|
- String body = HttpRequest.post("https://web.im.cdwjyyh.com/api/friend/update_friends")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/friend/update_friends")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonObject.toString())
|