Commit c7e8c830521973f823cd9ee84781970e9d0d40dd
1 parent
5bf07843b5
Exists in
master
系统自动发回访消息时获取聊天组(前端获取不到聊天组这里后端自己查),自动回访功能update
Showing 3 changed files with 106 additions and 35 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java
View file @
c7e8c83
... | ... | @@ -317,55 +317,56 @@ |
317 | 317 | log.info(res); |
318 | 318 | JSONObject jsonObject= JSON.parseObject(res); |
319 | 319 | JSONArray channel_infos=jsonObject.getJSONArray("channel_infos"); |
320 | - if(channel_infos.size()>0){ | |
320 | + if(channel_infos.size()>0) { | |
321 | 321 | for (int i = 0; i < channel_infos.size(); i++) { |
322 | - JSONObject row=channel_infos.getJSONObject(i); | |
322 | + JSONObject row = channel_infos.getJSONObject(i); | |
323 | 323 | |
324 | - if(row.getJSONObject("meta").size()>0){ | |
325 | - JSONObject payload=row.getJSONObject("meta").getJSONObject("payload"); | |
324 | + if (row.getJSONObject("meta").size() > 0) { | |
325 | + JSONObject payload = row.getJSONObject("meta").getJSONObject("payload"); | |
326 | 326 | System.out.println(payload); |
327 | 327 | |
328 | - payload.put("unread_num",row.get("unread_num")); | |
328 | + payload.put("unread_num", row.get("unread_num")); | |
329 | 329 | |
330 | - String to=payload.getString("to"); | |
331 | - LymsTkrecord tkrecord=new LymsTkrecord(); | |
330 | + String to = payload.getString("to"); | |
331 | + LymsTkrecord tkrecord = new LymsTkrecord(); | |
332 | 332 | tkrecord.setHxgroupid(to); |
333 | - List<LymsTkrecord> rLst=lymsTkrecordService.list(Wrappers.query(tkrecord)); | |
334 | - payload.put("stat",0); | |
335 | - if(rLst.size()>0){ | |
336 | - payload.put("stat",rLst.get(0).getStat()); | |
333 | + List<LymsTkrecord> rLst = lymsTkrecordService.list(Wrappers.query(tkrecord)); | |
334 | + payload.put("stat", 0); | |
335 | + if (rLst.size() > 0) { | |
336 | + payload.put("stat", rLst.get(0).getStat()); | |
337 | 337 | } |
338 | - LymsChatgroup chatgroup=new LymsChatgroup(); | |
338 | + LymsChatgroup chatgroup = new LymsChatgroup(); | |
339 | 339 | chatgroup.setHxgroupid(to); |
340 | - List<LymsChatgroup> cLst=lymsChatgroupService.list(Wrappers.query(chatgroup)); | |
340 | + List<LymsChatgroup> cLst = lymsChatgroupService.list(Wrappers.query(chatgroup)); | |
341 | 341 | |
342 | - if(cLst.size()>0){ | |
343 | - chatgroup=cLst.get(0); | |
344 | - Map<String,Object> param=new HashMap<>(); | |
345 | - param.put("idno",chatgroup.getFromp()); | |
346 | - List<LymsPatient> pLst=lymsPatientService.listByMap(param); | |
347 | - if(pLst.size()>0){ | |
348 | - payload.put("pat",pLst.get(0)); | |
342 | + if (cLst.size() > 0) { | |
343 | + chatgroup = cLst.get(0); | |
344 | + Map<String, Object> param = new HashMap<>(); | |
345 | + param.put("idno", chatgroup.getFromp()); | |
346 | + List<LymsPatient> pLst = lymsPatientService.listByMap(param); | |
347 | + if (pLst.size() > 0) { | |
348 | + payload.put("pat", pLst.get(0)); | |
349 | 349 | } |
350 | 350 | param.clear(); |
351 | - param.put("dlogin",chatgroup.getTarget()); | |
352 | - List<AppgetdoctorlistInfo> dLst=appgetdoctorlistInfoService.listByMap(param); | |
353 | - if(dLst.size()>0){ | |
354 | - payload.put("doc",dLst.get(0)); | |
351 | + param.put("dlogin", chatgroup.getTarget()); | |
352 | + List<AppgetdoctorlistInfo> dLst = appgetdoctorlistInfoService.listByMap(param); | |
353 | + if (dLst.size() > 0) { | |
354 | + payload.put("doc", dLst.get(0)); | |
355 | 355 | } |
356 | - if(CollectionUtils.isEmpty(rLst)){ | |
357 | - if (1==cLst.get(0).getType()) { | |
358 | - payload.put("stat",cLst.get(0).getStat()); | |
356 | + if (CollectionUtils.isEmpty(rLst)) { | |
357 | + if (1 == cLst.get(0).getType()) { | |
358 | + payload.put("stat", cLst.get(0).getStat()); | |
359 | 359 | } |
360 | 360 | } |
361 | 361 | } |
362 | 362 | |
363 | - payload.put("timestamp",row.getJSONObject("meta").get("timestamp")); | |
363 | + payload.put("timestamp", row.getJSONObject("meta").get("timestamp")); | |
364 | 364 | rs.add(payload); |
365 | 365 | } |
366 | - | |
367 | 366 | } |
368 | 367 | } |
368 | + //系统自动发回访消息时获取聊天组(前端获取不到聊天组这里后端自己查) | |
369 | + getChatRecord(rs, jsonObject); | |
369 | 370 | |
370 | 371 | } catch (IOException e) { |
371 | 372 | e.printStackTrace(); |
... | ... | @@ -681,6 +682,73 @@ |
681 | 682 | e.printStackTrace(); |
682 | 683 | } |
683 | 684 | return baseResponse; |
685 | + } | |
686 | + | |
687 | + /** | |
688 | + * 获取聊天群组,组装数据 | |
689 | + * @param rs 最后的结果 | |
690 | + * @param jsonObject 参数集合 | |
691 | + */ | |
692 | + public void getChatRecord(JSONArray rs,JSONObject jsonObject){ | |
693 | + //登录账号 | |
694 | + String user_name=jsonObject.getJSONObject("user_name").toString(); | |
695 | + //1 环信管理员 2 医生 3 患者 | |
696 | + String type=jsonObject.getJSONObject("type").toString(); | |
697 | + LymsChatgroup queryChatgroup=new LymsChatgroup(); | |
698 | + switch (type){ | |
699 | + case "1": | |
700 | + queryChatgroup.setOwnerk(hxuser); | |
701 | + break; | |
702 | + case "2": | |
703 | + queryChatgroup.setTarget(user_name); | |
704 | + break; | |
705 | + case "3": | |
706 | + queryChatgroup.setFromp(user_name); | |
707 | + break; | |
708 | + } | |
709 | + List<LymsChatgroup> chatgroupList=lymsChatgroupService.list(Wrappers.query(queryChatgroup)); | |
710 | + for (LymsChatgroup lymsChatgroup : chatgroupList) { | |
711 | + //组装结果 | |
712 | + JSONObject reusltJsonObject = new JSONObject(); | |
713 | + reusltJsonObject.put("unread_num",0); | |
714 | + reusltJsonObject.put("stat",lymsChatgroup.getStat()); | |
715 | + //患者信息 | |
716 | + LambdaQueryWrapper<LymsPatient> patientQueryWrapper=new QueryWrapper().lambda(); | |
717 | + patientQueryWrapper.ge(LymsPatient::getIdno, lymsChatgroup.getFromp()); | |
718 | + LymsPatient patient = lymsPatientService.getOne(patientQueryWrapper); | |
719 | + if (null==patient) { | |
720 | + continue; | |
721 | + } | |
722 | + reusltJsonObject.put("pat",patient); | |
723 | + //聊天记录 | |
724 | + LambdaQueryWrapper<LymsMessage> messageQueryWrapper=new QueryWrapper().lambda(); | |
725 | + messageQueryWrapper.ge(LymsMessage::getTargetid, lymsChatgroup.getHxgroupid()); | |
726 | + messageQueryWrapper.orderByDesc(LymsMessage::getSendtime); | |
727 | + final List<LymsMessage> lymsMessageList = lymsMessageService.list(messageQueryWrapper); | |
728 | + Map map=new HashMap(); | |
729 | + map.put("msg",lymsMessageList.size()>0?lymsMessageList.get(0).getContent():""); | |
730 | + map.put("type","txt"); | |
731 | + reusltJsonObject.put("bodies",Arrays.asList(map)); | |
732 | + //医生信息 | |
733 | + map.clear(); | |
734 | + map.put("dlogin", lymsChatgroup.getTarget()); | |
735 | + List<AppgetdoctorlistInfo> dLst = appgetdoctorlistInfoService.listByMap(map); | |
736 | + if (dLst.size()==0) { | |
737 | + continue; | |
738 | + } | |
739 | + reusltJsonObject.put("doc",dLst.get(0)); | |
740 | + reusltJsonObject.put("from",lymsChatgroup.getFromp()); | |
741 | + reusltJsonObject.put("to",lymsChatgroup.getHxgroupid()); | |
742 | + reusltJsonObject.put("type","groupchat"); | |
743 | + reusltJsonObject.put("timestamp",lymsMessageList.get(0).getSendtime()); | |
744 | + for (Object r : rs) { | |
745 | + JSONObject rjson= (JSONObject) JSON.toJSON(r); | |
746 | + if (! rjson.get("to").toString().equals(lymsChatgroup.getHxgroupid())) { | |
747 | + rs.add(reusltJsonObject); | |
748 | + } | |
749 | + } | |
750 | + } | |
751 | + | |
684 | 752 | } |
685 | 753 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPatientMapper.java
View file @
c7e8c83
... | ... | @@ -54,8 +54,8 @@ |
54 | 54 | "pc.createdtime " + |
55 | 55 | "FROM " + |
56 | 56 | "lyms_patient p " + |
57 | - "LEFT JOIN lyms_pcase pc ON pc.pid = p.id " + | |
58 | - "LEFT JOIN lyms_doctor dc ON dc.did=pc.dtid ") | |
57 | + "INNER JOIN lyms_pcase pc ON pc.pid = p.id " + | |
58 | + "INNER JOIN lyms_doctor dc ON dc.did=pc.dtid ") | |
59 | 59 | List<Map<String,Object>> getPcInfoList(); |
60 | 60 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushChatInfoTask.java
View file @
c7e8c83
... | ... | @@ -75,7 +75,7 @@ |
75 | 75 | * 第二十天:就诊医生 |
76 | 76 | * 第三十天:值班医生 |
77 | 77 | */ |
78 | -// @Scheduled(cron = "0 0 19 * * ?") | |
78 | + @Scheduled(cron = "0 0 19 * * ?") | |
79 | 79 | public void pushChatInfo() { |
80 | 80 | //用户下的病例信息。每个环信群组代表一个病例,一个病例下有多个疾病种类。 |
81 | 81 | List<Map<String,Object>> PcInfoList=lymsPatientService.getPcInfoList(); |
... | ... | @@ -132,7 +132,7 @@ |
132 | 132 | .in(LymsDoctor::getAdminType, Arrays.asList(1,2)) |
133 | 133 | .orderByAsc(LymsDoctor::getAdminType)); |
134 | 134 | //获取 就诊医生/值班医生/值班护士账号 |
135 | - LymsDoctor doctor2=new LymsDoctor(); | |
135 | + LymsDoctor doctor2=null; | |
136 | 136 | if(adminType!=0) { |
137 | 137 | for (LymsDoctor lymsDoctor : doctorAminList) { |
138 | 138 | if (lymsDoctor.getAdminType() == adminType) { |
... | ... | @@ -140,6 +140,9 @@ |
140 | 140 | break; |
141 | 141 | } |
142 | 142 | } |
143 | + if (null==doctor2){ | |
144 | + doctor2=doctor; | |
145 | + } | |
143 | 146 | }else { |
144 | 147 | doctor2=doctor; |
145 | 148 | } |
... | ... | @@ -217,7 +220,7 @@ |
217 | 220 | group.setOwnerk(hxuser); |
218 | 221 | group.setFromp(patient.getIdno()); |
219 | 222 | group.setHxgroupid(rJson.getJSONObject("data").getString("groupid")); |
220 | - group.setTarget(doctor.getDlogin()); | |
223 | + group.setTarget(doctor2.getDlogin()); | |
221 | 224 | group.setType(1); |
222 | 225 | group.setStat(0); |
223 | 226 | group.setPcid((Integer)map.get("pcid")); |