15376779826 преди 1 месец
родител
ревизия
bae1fa0448

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

@@ -1,6 +1,7 @@
 package com.fs.app.controller;
 
 
+import cn.hutool.http.HttpRequest;
 import cn.hutool.json.JSONUtil;
 import com.fs.app.annotation.Login;
 import com.fs.app.param.DoctorEditParam;
@@ -20,13 +21,17 @@ import com.fs.his.param.FsDoctorExtractListSParam;
 import com.fs.his.service.*;
 import com.fs.his.vo.FsDoctorBillListSVO;
 import com.fs.his.vo.FsDoctorExtractListSVO;
+import com.fs.im.service.OpenIMService;
 import com.fs.sms.service.SmsService;
 import com.fs.system.service.ISysConfigService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.github.pagehelper.util.StringUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+import org.json.JSONArray;
+import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
@@ -34,10 +39,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 
@@ -59,7 +61,8 @@ public class DoctorController extends  AppBaseController {
     private IFsDoctorExtractService doctorExtractService;
     @Autowired
     private ISysConfigService configService;
-
+    @Autowired
+    private OpenIMService openIMService;
     @Autowired
     private SmsService smsService;
     @ApiOperation("登录")
@@ -100,7 +103,72 @@ public class DoctorController extends  AppBaseController {
             return R.ok(map);
         }
     }
-
+    @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 (StringUtil.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("^D", "");
+                    FsDoctor fsDoctor = doctorService.selectFsDoctorByDoctorId(Long.parseLong(s));
+                    if (null==fsDoctor){
+                        return R.error("用户不存在");
+                    }
+                    ArrayList<Object> users = new ArrayList<>();
+                    HashMap<String, String> map = new HashMap<>();
+                    map.put("userID",userId);
+                    map.put("nickname",fsDoctor.getDoctorName());
+                    map.put("faceURL",fsDoctor.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失败");
+        }
+    }
     @ApiOperation("登录")
     @PostMapping("/loginByWeb")
     public R loginByWeb(@Validated @RequestBody DoctorLoginParam param) {

+ 1 - 0
fs-service/src/main/java/com/fs/his/config/AgreementConfig.java

@@ -11,4 +11,5 @@ public class AgreementConfig implements Serializable {
     String userHealth;
     String vipService;
     String vipAutomaticService;
+    String userRemoveService;
 }

+ 3 - 0
fs-service/src/main/java/com/fs/his/mapper/FsUserMapper.java

@@ -408,4 +408,7 @@ public interface FsUserMapper
     List<FsUser> selectFsUserListLimit(FsUser fsUser);
 
     List<FindUsersByDTO> findUsersByParam(FindUserByParam param);
+
+    @Update("update fs_user set status = 0,phone = null,union_id = null,is_del = 1 where user_id = #{userId}")
+    void removeUser(Long userId);
 }

+ 2 - 0
fs-service/src/main/java/com/fs/his/service/IFsUserService.java

@@ -221,4 +221,6 @@ public interface IFsUserService
     List<FsUser> getUserListLimit(FsUser fsUser);
 
     void handleFsUserWx(FsUser user, LoginMaWxParam param, WxMaJscode2SessionResult session);
+
+    R removeUser(Long id);
 }

+ 6 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsUserServiceImpl.java

@@ -1275,4 +1275,10 @@ public class FsUserServiceImpl implements IFsUserService
         }
     }
 
+    @Override
+    public R removeUser(Long id) {
+        fsUserMapper.removeUser(id);
+        return R.ok();
+    }
+
 }

+ 11 - 0
fs-user-app/src/main/java/com/fs/app/controller/H5Controller.java

@@ -75,5 +75,16 @@ public class H5Controller
         return mv;
     }
 
+    @GetMapping("/userRemoveService")
+    public ModelAndView userRemoveService( )
+    {
+        String json=configService.selectConfigByKey("his.agreementConfig");
+        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
+        ModelAndView mv=new ModelAndView();
+        mv.addObject("userRemoveService", config.getUserRemoveService());
+        mv.setViewName("userRemoveService");
+        return mv;
+    }
+
 
 }

+ 6 - 0
fs-user-app/src/main/java/com/fs/app/controller/UserController.java

@@ -348,4 +348,10 @@ public class UserController extends  AppBaseController {
         }
     }
 
+    @Login
+    @ApiOperation("注销用户")
+    @PostMapping("/removeUser/{id}")
+    public R removeUser(@PathVariable("id") Long id ){
+        return userService.removeUser(id);
+    }
 }

+ 21 - 0
fs-user-app/src/main/resources/templates/userRemoveService.html

@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml"
+      xmlns:th="http://www.thymeleaf.org">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+    <title >用户注销协议</title>
+    <link  rel="stylesheet"/>
+    <style>
+        body{
+            background-color:#F8F8F8;
+        }
+    </style>
+<body>
+<div th:utext="${userRemoveService}" ></div>
+<script th:inline="javascript">
+
+</script>
+
+</body>
+</html>