|
@@ -67,8 +67,6 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
@Autowired
|
|
|
@Lazy
|
|
|
private AiHookService aiHookService;
|
|
|
- private static final String OPEN_IM_URL = "https://web.im.cdwjyyh.com/api";
|
|
|
- private static final String PREFIX = "scrm";
|
|
|
/*@Autowired
|
|
|
private IFsUserService fsUserService;*/
|
|
|
@Override
|
|
@@ -83,7 +81,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
String adminToken = null;
|
|
|
// 发起 HTTP POST 请求,获取管理员 token
|
|
|
try {
|
|
|
- String response = HttpRequest.post(OPEN_IM_URL+"/auth/get_admin_token")
|
|
|
+ String response = HttpRequest.post(IMConfig.URL+"/auth/get_admin_token")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.body(requestBody.toString())
|
|
|
.execute()
|
|
@@ -267,7 +265,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
pagination.put("pageNumber", pageNumber);
|
|
|
pagination.put("showNumber", pageSize);
|
|
|
requestBody.put("pagination", pagination);
|
|
|
- String body = HttpRequest.post(OPEN_IM_URL+"/conversation/get_owner_conversation")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/conversation/get_owner_conversation")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(requestBody.toString())
|
|
@@ -320,7 +318,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
pagination.put("showNumber", pageSize);
|
|
|
requestPage.put("pagination", pagination);
|
|
|
|
|
|
- String result = HttpRequest.post(OPEN_IM_URL+"/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())
|
|
@@ -337,7 +335,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
|
|
|
// 过滤出以C开头的用户ID
|
|
|
List<String> userIds = userIDs.stream()
|
|
|
- .filter(uid -> uid.startsWith(PREFIX+"C"))
|
|
|
+ .filter(uid -> uid.startsWith(IMConfig.PREFIX+"C"))
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(userIds)) {
|
|
@@ -345,7 +343,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
paramMap.put("userIDs", userIds);
|
|
|
|
|
|
String jsonBody = JSONUtil.toJsonStr(paramMap);
|
|
|
- String result1 = HttpRequest.post(OPEN_IM_URL+"/user/get_users_info")
|
|
|
+ String result1 = HttpRequest.post(IMConfig.URL+"/user/get_users_info")
|
|
|
.header("operationID", String.valueOf(time))
|
|
|
.header("token", token)
|
|
|
.body(jsonBody)
|
|
@@ -367,7 +365,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
bodyMap.put("userInfo", updateUserInfo);
|
|
|
|
|
|
String jsonBody1 = JSONUtil.toJsonStr(bodyMap);
|
|
|
- String result2 = HttpRequest.post(OPEN_IM_URL+"/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)
|
|
@@ -403,11 +401,11 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
OpenImResponseDTO responseDTO = null;
|
|
|
Map<String, Object> paramMap = new HashMap<>();
|
|
|
ArrayList<String> userIDs = new ArrayList<>();
|
|
|
- userIDs.add(PREFIX+"C"+companyUser.getUserId());
|
|
|
+ userIDs.add(IMConfig.PREFIX+"C"+companyUser.getUserId());
|
|
|
paramMap.put("userIDs", userIDs);
|
|
|
|
|
|
String jsonBody = JSONUtil.toJsonStr(paramMap);
|
|
|
- String result1 = HttpRequest.post(OPEN_IM_URL+"/user/get_users_info")
|
|
|
+ String result1 = HttpRequest.post(IMConfig.URL+"/user/get_users_info")
|
|
|
.header("operationID", String.valueOf(time))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonBody)
|
|
@@ -428,7 +426,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
Map<String, Object> bodyMap = new HashMap<>();
|
|
|
bodyMap.put("userInfo", updateUserInfo);
|
|
|
String jsonBody1 = JSONUtil.toJsonStr(bodyMap);
|
|
|
- String result2 = HttpRequest.post(OPEN_IM_URL+"/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)
|
|
@@ -466,7 +464,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
JSONObject jsonObject = new JSONObject(openImMsgDTO);
|
|
|
log.info("发送消息的请求体:\n{}", jsonObject.toString());
|
|
|
long time = new Date().getTime();
|
|
|
- String result = HttpRequest.post(OPEN_IM_URL+"/msg/send_msg")
|
|
|
+ String result = HttpRequest.post(IMConfig.URL+"/msg/send_msg")
|
|
|
.header("operationID", time + "")
|
|
|
.header("token",adminToken)
|
|
|
.body(jsonObject.toString())
|
|
@@ -509,8 +507,8 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
|
|
|
|
|
|
|
|
|
- openImMsgDTO.setSendID(PREFIX+"C"+companyUserId);
|
|
|
- openImMsgDTO.setRecvID(PREFIX+"U"+userId);
|
|
|
+ openImMsgDTO.setSendID(IMConfig.PREFIX+"C"+companyUserId);
|
|
|
+ openImMsgDTO.setRecvID(IMConfig.PREFIX+"U"+userId);
|
|
|
openImMsgDTO.setContentType(110);
|
|
|
openImMsgDTO.setSessionType(1);
|
|
|
// 输出格式化JSON日志
|
|
@@ -526,8 +524,8 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
OpenImMsgDTO.OfflinePushInfo offlinePushInfo = new OpenImMsgDTO.OfflinePushInfo();
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
OpenImMsgDTO openImMsgDTO = new OpenImMsgDTO();
|
|
|
- if (sendID.startsWith(PREFIX+"C")){
|
|
|
- CompanyUser company = companyUserMapper.selectCompanyUserByUserId(Long.parseLong(sendID.replace(PREFIX+"C", "")));
|
|
|
+ if (sendID.startsWith(IMConfig.PREFIX+"C")){
|
|
|
+ CompanyUser company = companyUserMapper.selectCompanyUserByUserId(Long.parseLong(sendID.replace(IMConfig.PREFIX+"C", "")));
|
|
|
if (null!=company){
|
|
|
offlinePushInfo.setTitle(company.getNickName());
|
|
|
openImMsgDTO.setSenderFaceURL(company.getAvatar());
|
|
@@ -585,15 +583,15 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
OpenImMsgDTO.OfflinePushInfo offlinePushInfo = new OpenImMsgDTO.OfflinePushInfo();
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
OpenImMsgDTO openImMsgDTO = new OpenImMsgDTO();
|
|
|
- if (sendID.startsWith(PREFIX+"D")){
|
|
|
- FsDoctor fsDoctor = fsDoctorMapper.selectFsDoctorByDoctorId(Long.parseLong(sendID.replace(PREFIX+"D","")));
|
|
|
+ if (sendID.startsWith(IMConfig.PREFIX+"D")){
|
|
|
+ FsDoctor fsDoctor = fsDoctorMapper.selectFsDoctorByDoctorId(Long.parseLong(sendID.replace(IMConfig.PREFIX+"D","")));
|
|
|
//FsUser fsUser = fsUserService.selectFsUserByUserId(sendID);
|
|
|
if (null!=fsDoctor&&StringUtils.isNotEmpty(fsDoctor.getAvatar())){
|
|
|
offlinePushInfo.setTitle(fsDoctor.getDoctorName());
|
|
|
openImMsgDTO.setSenderFaceURL(fsDoctor.getAvatar());
|
|
|
}
|
|
|
- }else if (sendID.startsWith(PREFIX+"C")){
|
|
|
- CompanyUser company = companyUserMapper.selectCompanyUserByUserId(Long.parseLong(sendID.replace(PREFIX+"C", "")));
|
|
|
+ }else if (sendID.startsWith(IMConfig.PREFIX+"C")){
|
|
|
+ CompanyUser company = companyUserMapper.selectCompanyUserByUserId(Long.parseLong(sendID.replace(IMConfig.PREFIX+"C", "")));
|
|
|
if (null!=company&&StringUtils.isNotEmpty(company.getAvatar())){
|
|
|
offlinePushInfo.setTitle(company.getNickName());
|
|
|
openImMsgDTO.setSenderFaceURL(company.getAvatar());
|
|
@@ -680,9 +678,9 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
try {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
OpenImMsgDTO openImMsgDTO = new OpenImMsgDTO();
|
|
|
- if (sendID.startsWith(PREFIX+"U")){
|
|
|
+ if (sendID.startsWith(IMConfig.PREFIX+"U")){
|
|
|
//FsDoctor fsDoctor = fsDoctorMapper.selectFsDoctorByDoctorId(Long.parseLong(sendID.replace("D","")));
|
|
|
- FsUser fsUser = fsUserMapper.selectFsUserByUserId(Long.parseLong(sendID.replace(PREFIX+"U","")));
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserByUserId(Long.parseLong(sendID.replace(IMConfig.PREFIX+"U","")));
|
|
|
if (null!=fsUser&&StringUtils.isNotEmpty(fsUser.getAvatar())){
|
|
|
openImMsgDTO.setSenderFaceURL(fsUser.getAvatar());
|
|
|
}
|
|
@@ -780,7 +778,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
while (retryCount < maxRetries) {
|
|
|
try {
|
|
|
JSONObject jsonObject = new JSONObject(dto);
|
|
|
- String body = HttpRequest.post(OPEN_IM_URL+"/conversation/set_conversations")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/conversation/set_conversations")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonObject.toString())
|
|
@@ -812,7 +810,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("userID1",userID1);
|
|
|
jsonObject.put("userID2",userID2);
|
|
|
- String body = HttpRequest.post(OPEN_IM_URL+"/friend/is_friend")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/friend/is_friend")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonObject.toString())
|
|
@@ -849,7 +847,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("ownerUserID",ownerUserID);
|
|
|
jsonObject.put("friendUserIDs",newFriendIds);
|
|
|
- String body = HttpRequest.post(OPEN_IM_URL+"/friend/import_friend")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/friend/import_friend")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonObject.toString())
|
|
@@ -886,7 +884,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
requestBody = new JSONObject();
|
|
|
userIds.add(userId);
|
|
|
requestBody.put("checkUserIDs", userIds);
|
|
|
- String body = HttpRequest.post(OPEN_IM_URL+"/user/account_check")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/user/account_check")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(requestBody.toString())
|
|
@@ -941,7 +939,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
requestBody = new JSONObject();
|
|
|
userIds.add(userId);
|
|
|
requestBody.put("users", users);
|
|
|
- HttpRequest.post(OPEN_IM_URL+"/user/user_register")
|
|
|
+ HttpRequest.post(IMConfig.URL+"/user/user_register")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken).body(requestBody.toString()).execute().body();
|
|
|
}
|
|
@@ -954,7 +952,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
requestBody = new JSONObject();
|
|
|
requestBody.put("platformID",5);
|
|
|
requestBody.put("userID",userId);
|
|
|
- String body1 = HttpRequest.post(OPEN_IM_URL+"/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();
|
|
@@ -975,13 +973,13 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
public void checkAndImportFriend(Long companyUserId,String fsUserId) {
|
|
|
try {
|
|
|
// 注册账号
|
|
|
- accountCheck(PREFIX+"C" + companyUserId, "2");
|
|
|
- accountCheck(PREFIX+"U"+fsUserId, "1");
|
|
|
+ accountCheck(IMConfig.PREFIX+"C" + companyUserId, "2");
|
|
|
+ accountCheck(IMConfig.PREFIX+"U"+fsUserId, "1");
|
|
|
|
|
|
// 导入好友关系
|
|
|
ArrayList<String> userIds = new ArrayList<>();
|
|
|
- userIds.add(PREFIX+"U" + fsUserId);
|
|
|
- importFriend(PREFIX+"C" + companyUserId, userIds);
|
|
|
+ userIds.add(IMConfig.PREFIX+"U" + fsUserId);
|
|
|
+ importFriend(IMConfig.PREFIX+"C" + companyUserId, userIds);
|
|
|
} catch (Exception e) {
|
|
|
log.error("异步执行IM注册/添加好友失败:", e);
|
|
|
}
|
|
@@ -992,14 +990,14 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
public void checkAndImportFriendByDianBo(Long companyUserId,String fsUserId,String cropId) {
|
|
|
try {
|
|
|
// 注册账号
|
|
|
- accountCheck(PREFIX+"C" + companyUserId, "2");
|
|
|
- accountCheck(PREFIX+"U"+fsUserId, "1");
|
|
|
+ accountCheck(IMConfig.PREFIX+"C" + companyUserId, "2");
|
|
|
+ accountCheck(IMConfig.PREFIX+"U"+fsUserId, "1");
|
|
|
|
|
|
// 导入好友关系
|
|
|
ArrayList<String> userIds = new ArrayList<>();
|
|
|
- userIds.add(PREFIX+"U" + fsUserId);
|
|
|
- importFriend(PREFIX+"C" + companyUserId, userIds);
|
|
|
- updateFriendByDianBo(PREFIX+"C" + companyUserId, userIds,cropId);
|
|
|
+ userIds.add(IMConfig.PREFIX+"U" + fsUserId);
|
|
|
+ importFriend(IMConfig.PREFIX+"C" + companyUserId, userIds);
|
|
|
+ updateFriendByDianBo(IMConfig.PREFIX+"C" + companyUserId, userIds,cropId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("异步执行IM注册/添加好友失败:", e);
|
|
|
}
|
|
@@ -1037,7 +1035,7 @@ public class OpenIMServiceImpl implements OpenIMService {
|
|
|
jsonObject.put("ownerUserID",ownerUserID);
|
|
|
jsonObject.put("friendUserIDs",friendUserIDs);
|
|
|
jsonObject.put("remark",remark.get(0));
|
|
|
- String body = HttpRequest.post(OPEN_IM_URL+"/friend/update_friends")
|
|
|
+ String body = HttpRequest.post(IMConfig.URL+"/friend/update_friends")
|
|
|
.header("operationID", String.valueOf(System.currentTimeMillis()))
|
|
|
.header("token", adminToken)
|
|
|
.body(jsonObject.toString())
|