Browse Source

im发课同步

15376779826 1 tháng trước cách đây
mục cha
commit
db5bd24430

+ 5 - 0
fs-company/src/main/java/com/fs/company/controller/company/CompanyProfileController.java

@@ -15,6 +15,7 @@ import com.fs.company.service.ICompanyUserService;
 import com.fs.framework.security.LoginUser;
 import com.fs.framework.security.SecurityUtils;
 import com.fs.framework.service.TokenService;
+import com.fs.im.service.OpenIMService;
 import com.fs.system.service.ISysConfigService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -39,6 +40,8 @@ public class CompanyProfileController extends BaseController
     @Autowired
     private RedisCache redisCache;
 
+    @Autowired
+    private OpenIMService openIMService;
     /**
      * 个人信息
      */
@@ -67,6 +70,8 @@ public class CompanyProfileController extends BaseController
 
         if (userService.updateUserProfile(user) > 0)
         {
+            //修改im用户信息
+            openIMService.updateUserInfo(user);
             LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
             // 更新缓存用户信息
             loginUser.getUser().setNickName(user.getNickName());

+ 74 - 0
fs-company/src/main/java/com/fs/company/controller/company/CompanyUserController.java

@@ -1,6 +1,7 @@
 package com.fs.company.controller.company;
 
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.http.HttpRequest;
 import cn.hutool.json.JSONUtil;
 import com.fs.common.annotation.Log;
 import com.fs.common.constant.UserConstants;
@@ -26,13 +27,18 @@ import com.fs.framework.security.LoginUser;
 import com.fs.framework.security.SecurityUtils;
 import com.fs.framework.service.TokenService;
 import com.fs.his.vo.OptionsVO;
+import com.fs.im.config.IMConfig;
+import com.fs.im.service.OpenIMService;
 import com.fs.qw.vo.CompanyUserQwVO;
 import com.fs.qw.vo.QwUserVO;
 import com.fs.system.service.ISysConfigService;
 import com.fs.voice.utils.StringUtil;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import io.swagger.annotations.ApiOperation;
 import org.apache.ibatis.annotations.Param;
+import org.json.JSONArray;
+import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -69,6 +75,8 @@ public class CompanyUserController extends BaseController
     private ICompanyUserDelayTimeService companyUserDelayTimeService;
     @Autowired
     private ISysConfigService configService;
+    @Autowired
+    private OpenIMService openIMService;
     /**
      * 获取用户列表
      */
@@ -118,6 +126,72 @@ public class CompanyUserController extends BaseController
         }
         return getDataTable(list);
     }
+    @ApiOperation("校验客服是否注册新的im")
+    @PostMapping("/accountCheck")
+    public R accountCheck(@RequestBody Map<String, String> userIdMap){
+        //获取管理员token
+        String userId = userIdMap.get("userId");
+        String adminToken = openIMService.getAdminToken();
+        JSONObject requestBody = new JSONObject();
+        // 解析响应
+        if (StringUtils.isNotEmpty(adminToken)) {
+            //查询用户是否注册
+            ArrayList<String> userIds = new ArrayList<>();
+            requestBody = new JSONObject();
+            userIds.add(userId);
+            requestBody.put("checkUserIDs", userIds);
+            String body = HttpRequest.post(IMConfig.URL+"/user/account_check")
+                    .header("operationID", String.valueOf(System.currentTimeMillis()))
+                    .header("token", adminToken)
+                    .body(requestBody.toString())
+                    .execute()
+                    .body();
+            JSONObject jsonObject = new JSONObject(body);
+            JSONArray results = jsonObject.getJSONObject("data").getJSONArray("results");
+            if (results != null && results.length() > 0) {
+                JSONObject resultObj = results.getJSONObject(0);
+                int accountStatus = resultObj.getInt("accountStatus");
+                //未注册自动注册
+                if (accountStatus==0){
+                    String s = userId.replaceFirst("^C", "");
+                    CompanyUser companyUser = companyUserService.selectCompanyUserById(Long.parseLong(s));
+                    if (null==companyUser){
+                        return R.error("用户不存在");
+                    }
+                    ArrayList<Object> users = new ArrayList<>();
+                    HashMap<String, String> map = new HashMap<>();
+                    map.put("userID",userId);
+                    map.put("nickname",companyUser.getNickName());
+                    map.put("faceURL",companyUser.getAvatar());
+                    users.add(map);
+                    requestBody = new JSONObject();
+                    userIds.add(userId);
+                    requestBody.put("users", users);
+                    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("返回结果为空");
+            }
+           /* HashMap<String, String> tokenMap = new HashMap<>();
+            tokenMap.put("platformID","1");
+            tokenMap.put("userID",userId);*/
+            requestBody = new JSONObject();
+            requestBody.put("platformID",5);
+            requestBody.put("userID",userId);
+            String body1 = HttpRequest.post(IMConfig.URL+"/auth/get_user_token")
+                    .header("operationID", String.valueOf(System.currentTimeMillis()))
+                    .header("token", adminToken)
+                    .body(requestBody.toString()).execute().body();
+            JSONObject userJson = new JSONObject(body1);
+            JSONObject userData = userJson.getJSONObject("data");
+            String userToken = userData.getString("token");
+            return R.ok().put("token", userToken);
+        } else {
+            return R.error("获取管理员token失败");
+        }
+    }
     @Log(title = "用户管理", businessType = BusinessType.EXPORT)
     @PreAuthorize("@ss.hasPermi('company:user:export')")
     @GetMapping("/export")

+ 1 - 1
fs-doctor-app/src/main/java/com/fs/app/controller/DoctorController.java

@@ -158,7 +158,7 @@ public class DoctorController extends  AppBaseController {
             requestBody = new JSONObject();
             requestBody.put("platformID",5);
             requestBody.put("userID",userId);
-            String body1 = HttpRequest.post(IMConfig.URL+"/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();

+ 2 - 2
fs-doctor-app/src/main/resources/application.yml

@@ -5,5 +5,5 @@ server:
 # Spring配置
 spring:
   profiles:
-#    active: dev
-    active: druid-jnmy
+    active: dev
+#    active: druid-jnmy

+ 2 - 1
fs-service/src/main/java/com/fs/im/service/impl/OpenIMServiceImpl.java

@@ -420,7 +420,8 @@ public class OpenIMServiceImpl implements OpenIMService {
         for (UserInfo user : users) {
             updateUserInfo.setUserID(user.getUserID());
             updateUserInfo.setNickname(companyUser.getNickName());
-            updateUserInfo.setFaceURL(Optional.ofNullable(user.getFaceURL()).orElse(""));
+            //updateUserInfo.setFaceURL(Optional.ofNullable(user.getFaceURL()).orElse("http://company.muyi88.com/profile/avatar/2025/09/10/35ed3564-aad9-4580-a746-5da01e24d2ab.jpeg"));
+            updateUserInfo.setFaceURL("http://company.muyi88.com/prod-api/profile/avatar/2025/04/08/aa418999-6738-492d-9856-491916f714d9.jpeg");
             updateUserInfo.setEx(Optional.ofNullable(user.getEx()).orElse(""));
 
             Map<String, Object> bodyMap = new HashMap<>();

+ 2 - 2
fs-service/src/main/resources/application-common.yml

@@ -142,5 +142,5 @@ image:
 openIM:
   secret: openIM123
   userID: imAdmin
-  url: https://web.im.cdwjyyh.com/api
-  prefix: scrm
+  url: https://web.im.fbylive.com/api
+  prefix: