Commit 08f71e7b9bb5931a7c2bf196864a9037e9d85c7c

Authored by changpengfei
1 parent 2243f2fd66
Exists in master

获取专家组\客服人员信息

Showing 1 changed file with 83 additions and 0 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java View file @ 08f71e7
1 1 package com.lyms.talkonlineweb.controller;
2 2  
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONArray;
3 5 import com.alibaba.fastjson.JSONObject;
4 6 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
5 7 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
6 8  
... ... @@ -10,10 +12,14 @@
10 12 import com.lyms.talkonlineweb.service.*;
11 13 import com.lyms.talkonlineweb.util.HXService;
12 14 import lombok.extern.log4j.Log4j2;
  15 +import org.apache.commons.io.IOUtils;
13 16 import org.springframework.beans.BeanUtils;
14 17 import org.springframework.beans.factory.annotation.Autowired;
15 18 import org.springframework.web.bind.annotation.*;
16 19  
  20 +import javax.servlet.http.HttpServletRequest;
  21 +import java.io.IOException;
  22 +import java.nio.charset.Charset;
17 23 import java.util.*;
18 24  
19 25 @RestController
... ... @@ -44,6 +50,9 @@
44 50 @Autowired
45 51 private LymsPatientService lymsPatientService;
46 52  
  53 + @Autowired
  54 + private LymsTkrecordService lymsTkrecordService;
  55 +
47 56 /**
48 57 * 添加或删除聊天组
49 58 *
... ... @@ -171,6 +180,80 @@
171 180 }
172 181  
173 182 baseResponse.setObject(psList);
  183 + return baseResponse;
  184 + }
  185 +
  186 + /**
  187 + * 根据环信传入的会话,获取用户信息
  188 + * @param request
  189 + * @return
  190 + */
  191 + @PostMapping("getSessionListInfo")
  192 + public BaseResponse getSessionListInfo(HttpServletRequest request) {
  193 + BaseResponse baseResponse = new BaseResponse();
  194 + log.info(">>>>>>>>> getSessionListInfo");
  195 + JSONArray rs=new JSONArray();
  196 + try {
  197 + String res=IOUtils.toString(request.getInputStream());
  198 + log.info(res);
  199 + JSONObject jsonObject= JSON.parseObject(res);
  200 + JSONArray channel_infos=jsonObject.getJSONArray("channel_infos");
  201 + if(channel_infos.size()>0){
  202 + for (int i = 0; i < channel_infos.size(); i++) {
  203 + JSONObject row=channel_infos.getJSONObject(i);
  204 +
  205 + if(row.getJSONObject("meta").size()>0){
  206 + JSONObject payload=row.getJSONObject("meta").getJSONObject("payload");
  207 + System.out.println(payload);
  208 + String from =payload.getString("from");
  209 + Map<String,Object> param=new HashMap<>();
  210 + param.put("idno",from);
  211 + List<LymsPatient> pLst=lymsPatientService.listByMap(param);
  212 + if(pLst.size()>0){
  213 + payload.put("pat",pLst.get(0));
  214 + }
  215 + param.clear();
  216 + param.put("dlogin",from);
  217 + List<LymsDoctor> dLst=lymsDoctorService.listByMap(param);
  218 + if(dLst.size()>0){
  219 + payload.put("doc",dLst.get(0));
  220 + }
  221 + payload.put("unread_num",row.get("unread_num"));
  222 + rs.add(payload);
  223 + String to=payload.getString("to");
  224 + LymsTkrecord tkrecord=new LymsTkrecord();
  225 + tkrecord.setHxgroupid(to);
  226 + List<LymsTkrecord> rLst=lymsTkrecordService.list(Wrappers.query(tkrecord));
  227 + payload.put("stat",0);
  228 + if(rLst.size()>0){
  229 + payload.put("stat",rLst.get(0).getStat());
  230 + }
  231 + }
  232 +
  233 + }
  234 + }
  235 +
  236 + } catch (IOException e) {
  237 + e.printStackTrace();
  238 + }
  239 + baseResponse.setObject(rs);
  240 + return baseResponse;
  241 + }
  242 +
  243 + /**
  244 + * 获取专家组\客服人员信息
  245 + * @param request
  246 + * @return
  247 + */
  248 + @GetMapping("getPreMsg")
  249 + public BaseResponse getPreMsg(HttpServletRequest request){
  250 + BaseResponse baseResponse =new BaseResponse();
  251 + Map<String,Object> param=new HashMap<>();
  252 + param.put("vtype",998);
  253 + List<LymsDict> dLst=lymsDictService.listByMap(param);
  254 + if(dLst.size()>0){
  255 + baseResponse.setObject(dLst.get(0));
  256 + }
174 257 return baseResponse;
175 258 }
176 259