Commit 8bb0170de8e273d28327a7fc7df586a7f371bf36
1 parent
ff99c97d24
Exists in
master
and in
1 other branch
update
Showing 1 changed file with 18 additions and 21 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java
View file @
8bb0170
| ... | ... | @@ -691,23 +691,15 @@ |
| 691 | 691 | */ |
| 692 | 692 | public void getChatRecord(JSONArray rs,JSONObject jsonObject){ |
| 693 | 693 | JSONArray rsrjson=new JSONArray(); |
| 694 | - //登录账号 | |
| 695 | - String user_name=null!=jsonObject.get("user_name")?jsonObject.get("user_name").toString():""; | |
| 696 | - //1 环信管理员 2 医生 3 患者 | |
| 697 | - String type=jsonObject.get("type").toString(); | |
| 698 | - LymsChatgroup queryChatgroup=new LymsChatgroup(); | |
| 699 | - switch (type){ | |
| 700 | - case "1": | |
| 701 | - queryChatgroup.setOwnerk(hxuser); | |
| 702 | - break; | |
| 703 | - case "2": | |
| 704 | - queryChatgroup.setTarget(user_name); | |
| 705 | - break; | |
| 706 | - case "3": | |
| 707 | - queryChatgroup.setFromp(user_name); | |
| 708 | - break; | |
| 694 | + //环信组id | |
| 695 | + JSONArray groupData=jsonObject.getJSONArray("groupData"); | |
| 696 | + List<String> groupidList=new ArrayList<>(); | |
| 697 | + for (Object groupDatum : groupData) { | |
| 698 | + groupidList.add(((JSONObject) JSON.toJSON(groupDatum)).get("groupid").toString()); | |
| 709 | 699 | } |
| 710 | - List<LymsChatgroup> chatgroupList=lymsChatgroupService.list(Wrappers.query(queryChatgroup)); | |
| 700 | + LambdaQueryWrapper<LymsChatgroup> chatgroupQueryWrapper=new QueryWrapper().lambda(); | |
| 701 | + chatgroupQueryWrapper.in(LymsChatgroup::getHxgroupid,groupidList); | |
| 702 | + List<LymsChatgroup> chatgroupList=lymsChatgroupService.list(chatgroupQueryWrapper); | |
| 711 | 703 | for (LymsChatgroup lymsChatgroup : chatgroupList) { |
| 712 | 704 | //组装结果 |
| 713 | 705 | JSONObject reusltJsonObject = new JSONObject(); |
| 714 | 706 | |
| ... | ... | @@ -741,13 +733,18 @@ |
| 741 | 733 | reusltJsonObject.put("from",lymsChatgroup.getFromp()); |
| 742 | 734 | reusltJsonObject.put("to",lymsChatgroup.getHxgroupid()); |
| 743 | 735 | reusltJsonObject.put("type","groupchat"); |
| 744 | - reusltJsonObject.put("timestamp",lymsMessageList.size()>0?lymsMessageList.get(0).getSendtime():null); | |
| 745 | - for (Object r : rs) { | |
| 746 | - JSONObject rjson= (JSONObject) JSON.toJSON(r); | |
| 747 | - if (! rjson.get("to").toString().equals(lymsChatgroup.getHxgroupid())) { | |
| 748 | - rsrjson.add(reusltJsonObject); | |
| 736 | + reusltJsonObject.put("timestamp",lymsMessageList.size()>0?lymsMessageList.get(0).getSendtime().getTime():""); | |
| 737 | + if (CollectionUtils.isEmpty(rs)) { | |
| 738 | + rsrjson.add(reusltJsonObject); | |
| 739 | + }else { | |
| 740 | + for (Object r : rs) { | |
| 741 | + JSONObject rjson = (JSONObject) JSON.toJSON(r); | |
| 742 | + if (!rjson.get("to").toString().equals(lymsChatgroup.getHxgroupid())) { | |
| 743 | + rsrjson.add(reusltJsonObject); | |
| 744 | + } | |
| 749 | 745 | } |
| 750 | 746 | } |
| 747 | + | |
| 751 | 748 | } |
| 752 | 749 | //结果集中添加 |
| 753 | 750 | for (Object o : rsrjson) { |