Commit d8e403a8b1c8fa64b4920afd5785cbc8a6c0603d
1 parent
a9d2db70ad
Exists in
master
and in
1 other branch
统一在触发聊天时注册环信用户
Showing 4 changed files with 74 additions and 29 deletions
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/DoctorController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java
View file @
d8e403a
| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | import com.lyms.talkonlineweb.domain.*; |
| 14 | 14 | import com.lyms.talkonlineweb.result.BaseResponse; |
| 15 | 15 | import com.lyms.talkonlineweb.service.*; |
| 16 | +import com.lyms.talkonlineweb.util.Constant; | |
| 16 | 17 | import com.lyms.talkonlineweb.util.DateUtil; |
| 17 | 18 | import com.lyms.talkonlineweb.util.HXService; |
| 18 | 19 | import com.lyms.talkonlineweb.util.StringUtil; |
| ... | ... | @@ -79,6 +80,26 @@ |
| 79 | 80 | LymsChatgroup group2 = gLst.get(0); |
| 80 | 81 | group = group2; |
| 81 | 82 | } else { |
| 83 | + LymsPatient patient= lymsPatientService.getOne(new QueryWrapper<LymsPatient>().lambda().eq(LymsPatient::getIdno, group.getFromp())); | |
| 84 | + LymsDoctor doctor= lymsDoctorService.getOne(new QueryWrapper<LymsDoctor>().lambda().eq(LymsDoctor::getDlogin, group.getTarget())); | |
| 85 | + //患者注册环信 | |
| 86 | + if (StringUtil.isEmpty(patient.getHxid())) { | |
| 87 | + JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname()); | |
| 88 | + JSONArray rArr = json.getJSONArray("entities"); | |
| 89 | + if (rArr.size() > 0) { | |
| 90 | + patient.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 91 | + lymsPatientService.updateById(patient); | |
| 92 | + } | |
| 93 | + } | |
| 94 | + //医生注册环信 | |
| 95 | + if (StringUtil.isEmpty(doctor.getHxid())) { | |
| 96 | + JSONObject json = hxService.addUser(doctor.getDlogin(), Constant.COMMON_PASSWD, doctor.getDname()); | |
| 97 | + JSONArray rArr = json.getJSONArray("entities"); | |
| 98 | + if (rArr.size() > 0) { | |
| 99 | + doctor.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 100 | + lymsDoctorService.updateById(doctor); | |
| 101 | + } | |
| 102 | + } | |
| 82 | 103 | log.info("创建环信组:{} from:{} target:{}", group.getOwnerk(), group.getFromp(), group.getTarget()); |
| 83 | 104 | JSONObject rJson = hxService.addChatGroups(group.getFromp() + "," + group.getTarget(), group.getOwnerk(), new String[]{group.getFromp(), group.getTarget()}); |
| 84 | 105 | log.info("rJson:" + rJson); |
| ... | ... | @@ -86,8 +107,6 @@ |
| 86 | 107 | group.setDescription(group.getFromp() + "," + group.getTarget()); |
| 87 | 108 | // group.setGroupname(group.getFromp() + "," + group.getTarget()); |
| 88 | 109 | //环信群组名称更改为姓名串-用于PC端问诊展示 |
| 89 | - LymsPatient patient= lymsPatientService.getOne(new QueryWrapper<LymsPatient>().lambda().eq(LymsPatient::getIdno, group.getFromp())); | |
| 90 | - LymsDoctor doctor= lymsDoctorService.getOne(new QueryWrapper<LymsDoctor>().lambda().eq(LymsDoctor::getDlogin, group.getTarget())); | |
| 91 | 110 | group.setGroupname(patient.getPname() + "," + doctor.getDdname()); |
| 92 | 111 | |
| 93 | 112 | group.setCtime(new Date()); |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/DoctorController.java
View file @
d8e403a
| ... | ... | @@ -126,15 +126,14 @@ |
| 126 | 126 | baseResponse.setErrorcode(1); |
| 127 | 127 | return baseResponse; |
| 128 | 128 | } |
| 129 | - LymsHdepart hdepart=lymsHdepartService.getById(doctor.getDpid()); | |
| 130 | - if(doctor.getHxid()==null ){ | |
| 131 | - JSONObject json=hxService.addUser(doctor.getDlogin(),Constant.COMMON_PASSWD,doctor.getDname()+","+hdepart.getDname()+","+hdepart.getHname()); | |
| 132 | - JSONArray rArr=json.getJSONArray("entities"); | |
| 133 | - if(rArr.size()>0){ | |
| 134 | - doctor.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 135 | - } | |
| 136 | -// lymsDoctorService.saveOrUpdate(doctor); | |
| 137 | - } | |
| 129 | +// LymsHdepart hdepart=lymsHdepartService.getById(doctor.getDpid()); | |
| 130 | +// if(doctor.getHxid()==null ){ | |
| 131 | +// JSONObject json=hxService.addUser(doctor.getDlogin(),Constant.COMMON_PASSWD,doctor.getDname()+","+hdepart.getDname()+","+hdepart.getHname()); | |
| 132 | +// JSONArray rArr=json.getJSONArray("entities"); | |
| 133 | +// if(rArr.size()>0){ | |
| 134 | +// doctor.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 135 | +// } | |
| 136 | +// } | |
| 138 | 137 | }else{ |
| 139 | 138 | did=1; |
| 140 | 139 | doctor.setUpdatedTime(new Date()); |
| ... | ... | @@ -197,16 +196,16 @@ |
| 197 | 196 | Map<String,Object> map=new HashMap<>(); |
| 198 | 197 | map.put("doctor",doctor); |
| 199 | 198 | map.put("token",jwt); |
| 200 | - if (StringUtil.isEmpty(doctor.getHxid())) { | |
| 201 | - JSONObject json = hxService.addUser(doctor.getDlogin(), Constant.COMMON_PASSWD, doctor.getDname()); | |
| 202 | - JSONArray rArr = json.getJSONArray("entities"); | |
| 203 | - if (rArr.size() > 0) { | |
| 204 | - LymsDoctor doctor2=new LymsDoctor(); | |
| 205 | - doctor2.setDid(doctor.getDid()); | |
| 206 | - doctor2.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 207 | - lymsDoctorService.updateById(doctor2); | |
| 208 | - } | |
| 209 | - } | |
| 199 | +// if (StringUtil.isEmpty(doctor.getHxid())) { | |
| 200 | +// JSONObject json = hxService.addUser(doctor.getDlogin(), Constant.COMMON_PASSWD, doctor.getDname()); | |
| 201 | +// JSONArray rArr = json.getJSONArray("entities"); | |
| 202 | +// if (rArr.size() > 0) { | |
| 203 | +// LymsDoctor doctor2=new LymsDoctor(); | |
| 204 | +// doctor2.setDid(doctor.getDid()); | |
| 205 | +// doctor2.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 206 | +// lymsDoctorService.updateById(doctor2); | |
| 207 | +// } | |
| 208 | +// } | |
| 210 | 209 | baseResponse.setErrorcode(0); |
| 211 | 210 | baseResponse.setObject(map); |
| 212 | 211 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PatientController.java
View file @
d8e403a
| ... | ... | @@ -194,6 +194,13 @@ |
| 194 | 194 | if (!StringUtils.isEmpty(patient.getCode())) { |
| 195 | 195 | patient.setOpenid(WeiXinUtil.getWxOpenId(patient.getCode())); |
| 196 | 196 | } |
| 197 | +// if (StringUtil.isEmpty(patient.getHxid())) { | |
| 198 | +// JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname()); | |
| 199 | +// JSONArray rArr = json.getJSONArray("entities"); | |
| 200 | +// if (rArr.size() > 0) { | |
| 201 | +// patient.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 202 | +// } | |
| 203 | +// } | |
| 197 | 204 | |
| 198 | 205 | boolean f = lymsPatientService.saveOrUpdate(patient); |
| 199 | 206 | |
| ... | ... | @@ -373,13 +380,13 @@ |
| 373 | 380 | |
| 374 | 381 | if (StringUtils.isEmpty(patient2.getHxid()) || StringUtils.isEmpty(patient2.getOpenid())) { |
| 375 | 382 | |
| 376 | - if (patient2.getHxid() == null) { | |
| 377 | - JSONObject json = hxService.addUser(patient2.getIdno(), Constant.COMMON_PASSWD, patient2.getPname()); | |
| 378 | - JSONArray rArr = json.getJSONArray("entities"); | |
| 379 | - if (rArr.size() > 0) { | |
| 380 | - patient2.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 381 | - } | |
| 382 | - } | |
| 383 | +// if (patient2.getHxid() == null) { | |
| 384 | +// JSONObject json = hxService.addUser(patient2.getIdno(), Constant.COMMON_PASSWD, patient2.getPname()); | |
| 385 | +// JSONArray rArr = json.getJSONArray("entities"); | |
| 386 | +// if (rArr.size() > 0) { | |
| 387 | +// patient2.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 388 | +// } | |
| 389 | +// } | |
| 383 | 390 | if (StringUtils.isEmpty(patient2.getOpenid())) { |
| 384 | 391 | patient2.setOpenid(WeiXinUtil.getWxOpenId(patient.getCode())); |
| 385 | 392 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java
View file @
d8e403a
| 1 | 1 | package com.lyms.talkonlineweb.controller; |
| 2 | 2 | |
| 3 | +import com.alibaba.fastjson.JSONArray; | |
| 3 | 4 | import com.alibaba.fastjson.JSONObject; |
| 4 | 5 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| 5 | 6 | import com.lyms.talkonlineweb.annotation.TokenRequired; |
| 6 | 7 | import com.lyms.talkonlineweb.domain.*; |
| 7 | 8 | import com.lyms.talkonlineweb.result.BaseResponse; |
| 8 | 9 | import com.lyms.talkonlineweb.service.*; |
| 10 | +import com.lyms.talkonlineweb.util.Constant; | |
| 9 | 11 | import com.lyms.talkonlineweb.util.HXService; |
| 12 | +import com.lyms.talkonlineweb.util.StringUtil; | |
| 10 | 13 | import lombok.extern.log4j.Log4j2; |
| 11 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | 15 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -77,7 +80,24 @@ |
| 77 | 80 | LymsChatgroup group =new LymsChatgroup(); |
| 78 | 81 | LymsDoctor doctor=lymsDoctorService.getById(tkrecord.getDid()); |
| 79 | 82 | LymsPatient patient=lymsPatientService.getById(tkrecord.getPid()); |
| 80 | - | |
| 83 | + //患者注册环信 | |
| 84 | + if (StringUtil.isEmpty(patient.getHxid())) { | |
| 85 | + JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname()); | |
| 86 | + JSONArray rArr = json.getJSONArray("entities"); | |
| 87 | + if (rArr.size() > 0) { | |
| 88 | + patient.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 89 | + lymsPatientService.updateById(patient); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + //医生注册环信 | |
| 93 | + if (StringUtil.isEmpty(doctor.getHxid())) { | |
| 94 | + JSONObject json = hxService.addUser(doctor.getDlogin(), Constant.COMMON_PASSWD, doctor.getDname()); | |
| 95 | + JSONArray rArr = json.getJSONArray("entities"); | |
| 96 | + if (rArr.size() > 0) { | |
| 97 | + doctor.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 98 | + lymsDoctorService.updateById(doctor); | |
| 99 | + } | |
| 100 | + } | |
| 81 | 101 | group.setFromp(patient.getIdno()); |
| 82 | 102 | group.setTarget(doctor.getDlogin()); |
| 83 | 103 | group.setOwnerk("test"); |