| 
					
				 | 
			
			
				@@ -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.baidu.dev2.thirdparty.jackson.databind.ObjectMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.common.annotation.Log; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -29,6 +30,7 @@ import com.fs.framework.security.SecurityUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.framework.service.TokenService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.utils.qrcode.QRCodeUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.his.vo.OptionsVO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.im.service.OpenIMService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qw.domain.QwCompany; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qw.service.IQwCompanyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.qw.vo.CompanyUserQwVO; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -37,6 +39,9 @@ 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.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; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -78,7 +83,8 @@ public class CompanyUserController extends BaseController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private ISysConfigService configService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private RedisCache redisCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private OpenIMService openIMService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     IQwCompanyService iQwCompanyService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -536,4 +542,72 @@ public class CompanyUserController extends BaseController 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public R unBindDoctorId(@RequestBody CompanyUser companyUser){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return companyUserService.bindDoctor(companyUser); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @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("https://web.im.cdwjyyh.com/api/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.getImNickName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    map.put("faceURL",companyUser.getAvatar()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    users.add(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    requestBody = new JSONObject(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    userIds.add(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    requestBody.put("users", users); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    HttpRequest.post("https://web.im.cdwjyyh.com/api/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("https://web.im.cdwjyyh.com/api/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失败"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |