Commit 561c9723cd7e57b6a241d6a96535c484e14ca7b0
1 parent
02e1d2c1be
Exists in
master
and in
1 other branch
保存问诊卡功能修改,修改环信查询用户404错误返回null
Showing 6 changed files with 143 additions and 74 deletions
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsTcardMapper.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsTcardService.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsTcardServiceImpl.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/HXService.java
- talkonlineweb/src/main/resources/mapper/LymsTcardMapper.xml
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java
View file @
561c972
| ... | ... | @@ -62,43 +62,52 @@ |
| 62 | 62 | tcard.setPid(tkrecord.getPid()); |
| 63 | 63 | tcard.setPcid(tkrecord.getPcid()); |
| 64 | 64 | // 获取问诊卡按照先从医院购买的问诊卡消费 |
| 65 | - List<LymsTcard> rLst = lymsTcardService.list(Wrappers.query(tcard).notInSql("id", "SELECT r.cid FROM lyms_tkrecord r").orderByDesc("fid")); | |
| 66 | - | |
| 67 | -// 小程序购买的问诊卡 | |
| 68 | - tcard.setPcid(null); | |
| 69 | - tcard.setFid(1); | |
| 70 | - List<LymsTcard> xLst = lymsTcardService.list(Wrappers.query(tcard).notInSql("id", "SELECT r.cid FROM lyms_tkrecord r").orderByDesc("fid")); | |
| 71 | - | |
| 72 | - if (rLst.size() > 0 || xLst.size() > 0) { | |
| 73 | - if (rLst.size() > 0) { | |
| 74 | - tkrecord.setCid(rLst.get(0).getId()); | |
| 75 | - tkrecord.setFid((byte) 2); | |
| 76 | - } else { | |
| 65 | + //List<LymsTcard> rLst = lymsTcardService.list(Wrappers.query(tcard).notInSql("id", "SELECT r.cid FROM lyms_tkrecord r").orderByDesc("fid")); | |
| 66 | + List<LymsTcard> rLst = lymsTcardService.queryUnused(tcard); | |
| 67 | + if (rLst.size() > 0) { | |
| 68 | + tkrecord.setCid(rLst.get(0).getId()); | |
| 69 | + tkrecord.setFid((byte) 2); | |
| 70 | + }else{ | |
| 71 | + //小程序购买的问诊卡 | |
| 72 | + tcard.setPcid(null); | |
| 73 | + tcard.setFid(1); | |
| 74 | + List<LymsTcard> xLst = lymsTcardService.queryUnused(tcard);//lymsTcardService.list(Wrappers.query(tcard).notInSql("id", "SELECT r.cid FROM lyms_tkrecord r").orderByDesc("fid")); | |
| 75 | + if (xLst.size() > 0) { | |
| 77 | 76 | tkrecord.setCid(xLst.get(0).getId()); |
| 78 | 77 | tkrecord.setFid((byte) 1); |
| 78 | + }else{ | |
| 79 | + baseResponse.setErrorcode(1); | |
| 80 | + baseResponse.setErrormsg("已经没有了问诊卡"); | |
| 81 | + return baseResponse; | |
| 79 | 82 | } |
| 80 | - | |
| 81 | - } else { | |
| 82 | - baseResponse.setErrorcode(1); | |
| 83 | - baseResponse.setErrormsg("已经没有了问诊卡"); | |
| 84 | - return baseResponse; | |
| 85 | 83 | } |
| 84 | + | |
| 86 | 85 | } |
| 87 | 86 | LymsChatgroup group =new LymsChatgroup(); |
| 88 | - LymsDoctor doctor=lymsDoctorService.getById(tkrecord.getDid()); | |
| 89 | - LymsPatient patient=lymsPatientService.getById(tkrecord.getPid()); | |
| 90 | 87 | |
| 88 | + | |
| 91 | 89 | List<LymsChatgroup> gLst = lymsChatgroupService.list(new QueryWrapper<LymsChatgroup>() |
| 92 | 90 | .lambda().eq(LymsChatgroup::getPcid, tkrecord.getPcid())); |
| 93 | 91 | //之前有这个病例的问诊就不用新创建组 |
| 94 | - if (0==gLst.size()) { | |
| 95 | - group.setOwnerk(hxuser); | |
| 96 | - List<String> adminDlogins=new ArrayList<>(); | |
| 97 | - adminDlogins.add(patient.getIdno()); | |
| 98 | - List<String> groupnames=new ArrayList<>(); | |
| 99 | - groupnames.add(patient.getPname()); | |
| 100 | - //患者注册环信 | |
| 101 | - if (StringUtil.isEmpty(patient.getHxid())) { | |
| 92 | + if(gLst.size() > 0){ | |
| 93 | + group=gLst.get(0); | |
| 94 | + tkrecord.setHxgroupid(group.getHxgroupid()); | |
| 95 | + lymsTkrecordService.save(tkrecord); | |
| 96 | + baseResponse.setObject(group); | |
| 97 | + baseResponse.setErrormsg("成功"); | |
| 98 | + return baseResponse; | |
| 99 | + } | |
| 100 | + | |
| 101 | + LymsDoctor doctor=lymsDoctorService.getById(tkrecord.getDid()); | |
| 102 | + LymsPatient patient=lymsPatientService.getById(tkrecord.getPid()); | |
| 103 | + | |
| 104 | + //患者注册环信 | |
| 105 | + if (StringUtil.isEmpty(patient.getHxid())) { | |
| 106 | + JSONObject hxUserJSON = hxService.getUser(patient.getIdno()); | |
| 107 | + if(hxUserJSON != null && hxUserJSON.getJSONArray("entities") != null && hxUserJSON.getJSONArray("entities").size() > 0){ | |
| 108 | + patient.setHxid(hxUserJSON.getJSONArray("entities").getJSONObject(0).getString("uuid")); | |
| 109 | + lymsPatientService.updateById(patient); | |
| 110 | + }else{ | |
| 102 | 111 | JSONObject json = hxService.addUser(patient.getIdno(), Constant.COMMON_PASSWD, patient.getPname()); |
| 103 | 112 | JSONArray rArr = json.getJSONArray("entities"); |
| 104 | 113 | if (rArr.size() > 0) { |
| ... | ... | @@ -106,14 +115,27 @@ |
| 106 | 115 | lymsPatientService.updateById(patient); |
| 107 | 116 | } |
| 108 | 117 | } |
| 109 | - //查询值班医生/值班护士 | |
| 110 | - List<LymsDoctor> doctorAminList= lymsDoctorService.list(new QueryWrapper<LymsDoctor>() | |
| 111 | - .lambda().eq(LymsDoctor::getDpid, doctor.getDpid()) | |
| 112 | - .in(LymsDoctor::getAdminType, Arrays.asList(1,2)) | |
| 113 | - .orderByAsc(LymsDoctor::getAdminType)); | |
| 114 | - //科室值班医生注册环信 | |
| 115 | - for (LymsDoctor lymsDoctor : doctorAminList) { | |
| 116 | - if(StringUtil.isEmpty(lymsDoctor.getHxid())) { | |
| 118 | + | |
| 119 | + } | |
| 120 | + | |
| 121 | + group.setOwnerk(hxuser); | |
| 122 | + List<String> adminDlogins=new ArrayList<>(); | |
| 123 | + adminDlogins.add(patient.getIdno()); | |
| 124 | + List<String> groupnames=new ArrayList<>(); | |
| 125 | + groupnames.add(patient.getPname()); | |
| 126 | + //查询值班医生/值班护士 | |
| 127 | + List<LymsDoctor> doctorAminList= lymsDoctorService.list(new QueryWrapper<LymsDoctor>() | |
| 128 | + .lambda().eq(LymsDoctor::getDpid, doctor.getDpid()) | |
| 129 | + .in(LymsDoctor::getAdminType, Arrays.asList(1,2)) | |
| 130 | + .orderByAsc(LymsDoctor::getAdminType)); | |
| 131 | + //科室值班医生注册环信 | |
| 132 | + for (LymsDoctor lymsDoctor : doctorAminList) { | |
| 133 | + if (StringUtil.isEmpty(lymsDoctor.getHxid())) { | |
| 134 | + JSONObject hxDockerUserJSON = hxService.getUser(lymsDoctor.getDlogin()); | |
| 135 | + if (hxDockerUserJSON != null && hxDockerUserJSON.getJSONArray("entities") != null && hxDockerUserJSON.getJSONArray("entities").size() > 0) { | |
| 136 | + lymsDoctor.setHxid(hxDockerUserJSON.getJSONArray("entities").getJSONObject(0).getString("uuid")); | |
| 137 | + lymsDoctorService.updateById(lymsDoctor); | |
| 138 | + } else { | |
| 117 | 139 | JSONObject json = hxService.addUser(lymsDoctor.getDlogin(), Constant.COMMON_PASSWD, lymsDoctor.getDname()); |
| 118 | 140 | JSONArray rArr = json.getJSONArray("entities"); |
| 119 | 141 | if (rArr.size() > 0) { |
| ... | ... | @@ -124,9 +146,16 @@ |
| 124 | 146 | adminDlogins.add(lymsDoctor.getDlogin()); |
| 125 | 147 | groupnames.add(lymsDoctor.getDname()); |
| 126 | 148 | } |
| 127 | - if ( ! adminDlogins.contains(doctor.getDlogin())) { | |
| 128 | - //医生注册环信 | |
| 129 | - if (StringUtil.isEmpty(doctor.getHxid())) { | |
| 149 | + } | |
| 150 | + | |
| 151 | + if ( ! adminDlogins.contains(doctor.getDlogin())) { | |
| 152 | + //医生注册环信 | |
| 153 | + if (StringUtil.isEmpty(doctor.getHxid())) { | |
| 154 | + JSONObject hxDockerJSON = hxService.getUser(doctor.getDlogin()); | |
| 155 | + if (hxDockerJSON != null && hxDockerJSON.getJSONArray("entities") != null && hxDockerJSON.getJSONArray("entities").size() > 0) { | |
| 156 | + doctor.setHxid(hxDockerJSON.getJSONArray("entities").getJSONObject(0).getString("uuid")); | |
| 157 | + lymsDoctorService.updateById(doctor); | |
| 158 | + }else { | |
| 130 | 159 | JSONObject json = hxService.addUser(doctor.getDlogin(), Constant.COMMON_PASSWD, doctor.getDname()); |
| 131 | 160 | JSONArray rArr = json.getJSONArray("entities"); |
| 132 | 161 | if (rArr.size() > 0) { |
| 133 | 162 | |
| 134 | 163 | |
| 135 | 164 | |
| 136 | 165 | |
| 137 | 166 | |
| ... | ... | @@ -134,51 +163,46 @@ |
| 134 | 163 | lymsDoctorService.updateById(doctor); |
| 135 | 164 | } |
| 136 | 165 | } |
| 137 | - adminDlogins.add(doctor.getDlogin()); | |
| 138 | - groupnames.add(doctor.getDname()); | |
| 139 | 166 | } |
| 167 | + adminDlogins.add(doctor.getDlogin()); | |
| 168 | + groupnames.add(doctor.getDname()); | |
| 169 | + } | |
| 140 | 170 | |
| 141 | 171 | |
| 142 | - log.info("创建环信组:{} description:{}", group.getOwnerk(), StringUtils.join(adminDlogins.toArray(), ",")); | |
| 143 | - JSONObject rJson = hxService.addChatGroups(StringUtils.join(adminDlogins.toArray(), ","), group.getOwnerk(), adminDlogins.toArray(new String[adminDlogins.size()])); | |
| 144 | - log.info("rJson:" + rJson); | |
| 145 | - group.setHxgroupid(rJson.getJSONObject("data").getString("groupid")); | |
| 146 | - group.setDescription(StringUtils.join(adminDlogins.toArray(), ",")); | |
| 147 | - //环信群组名称更改为姓名串-用于PC端问诊展示 | |
| 148 | - group.setGroupname(StringUtils.join(groupnames.toArray(), ",")); | |
| 149 | - group.setFromp(patient.getIdno()); | |
| 150 | - group.setTarget(doctor.getDlogin()); | |
| 151 | - group.setPcid(tkrecord.getPcid()); | |
| 152 | - group.setHdepartId(doctor.getDpid()); | |
| 153 | - if(null==tkrecord.getType()) { | |
| 154 | - lymsChatgroupService.saveOrUpdate(group); | |
| 155 | - tkrecord.setHxgroupid(group.getHxgroupid()); | |
| 156 | - lymsTkrecordService.save(tkrecord); | |
| 157 | - }else { | |
| 158 | - group.setType(1); | |
| 159 | - lymsChatgroupService.saveOrUpdate(group); | |
| 160 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
| 161 | - returnVisitRecord.setDlogin(tkrecord.getRetDlogin());//前端传的当前登录医生账号 | |
| 162 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
| 163 | - returnVisitRecord.setIdno(patient.getIdno()); | |
| 164 | - returnVisitRecord.setType(1); | |
| 165 | - returnVisitRecord.setPcid(tkrecord.getPcid()); | |
| 166 | - returnVisitRecord.setHxgroupid(group.getHxgroupid()); | |
| 167 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
| 168 | - } | |
| 169 | - }else { | |
| 170 | - group=gLst.get(0); | |
| 172 | + log.info("创建环信组:{} description:{}", group.getOwnerk(), StringUtils.join(adminDlogins.toArray(), ",")); | |
| 173 | + JSONObject rJson = hxService.addChatGroups(StringUtils.join(adminDlogins.toArray(), ","), group.getOwnerk(), adminDlogins.toArray(new String[adminDlogins.size()])); | |
| 174 | + log.info("rJson:" + rJson); | |
| 175 | + group.setHxgroupid(rJson.getJSONObject("data").getString("groupid")); | |
| 176 | + group.setDescription(StringUtils.join(adminDlogins.toArray(), ",")); | |
| 177 | + //环信群组名称更改为姓名串-用于PC端问诊展示 | |
| 178 | + group.setGroupname(StringUtils.join(groupnames.toArray(), ",")); | |
| 179 | + group.setFromp(patient.getIdno()); | |
| 180 | + group.setTarget(doctor.getDlogin()); | |
| 181 | + group.setPcid(tkrecord.getPcid()); | |
| 182 | + group.setHdepartId(doctor.getDpid()); | |
| 183 | + if(null==tkrecord.getType()) { | |
| 184 | + lymsChatgroupService.saveOrUpdate(group); | |
| 171 | 185 | tkrecord.setHxgroupid(group.getHxgroupid()); |
| 172 | 186 | lymsTkrecordService.save(tkrecord); |
| 187 | + }else { | |
| 188 | + group.setType(1); | |
| 189 | + lymsChatgroupService.saveOrUpdate(group); | |
| 190 | + LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
| 191 | + returnVisitRecord.setDlogin(tkrecord.getRetDlogin());//前端传的当前登录医生账号 | |
| 192 | + returnVisitRecord.setDpid(doctor.getDpid()); | |
| 193 | + returnVisitRecord.setIdno(patient.getIdno()); | |
| 194 | + returnVisitRecord.setType(1); | |
| 195 | + returnVisitRecord.setPcid(tkrecord.getPcid()); | |
| 196 | + returnVisitRecord.setHxgroupid(group.getHxgroupid()); | |
| 197 | + lymsReturnVisitRecordService.save(returnVisitRecord); | |
| 173 | 198 | } |
| 174 | 199 | |
| 175 | 200 | baseResponse.setObject(group); |
| 176 | - | |
| 177 | 201 | baseResponse.setErrormsg("成功"); |
| 178 | 202 | } catch (Exception e) { |
| 179 | 203 | baseResponse.setErrorcode(1); |
| 180 | 204 | baseResponse.setErrormsg("失败"); |
| 181 | - e.printStackTrace(); | |
| 205 | + log.error("保存问诊记录异常",e); | |
| 182 | 206 | } |
| 183 | 207 | |
| 184 | 208 | return baseResponse; |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsTcardMapper.java
View file @
561c972
| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | import org.apache.ibatis.annotations.Param; |
| 6 | 6 | import org.apache.ibatis.annotations.Select; |
| 7 | 7 | |
| 8 | +import java.util.List; | |
| 8 | 9 | import java.util.Map; |
| 9 | 10 | |
| 10 | 11 | /** |
| ... | ... | @@ -14,5 +15,7 @@ |
| 14 | 15 | |
| 15 | 16 | @Select("SELECT IFNULL(a.ccnt,0) ccnt,IFNULL(b.cnt,0) cnt FROM (SELECT SUM(ccnt) ccnt FROM lyms_patient ${pSql} ) a,(SELECT SUM(cnt) cnt FROM lyms_tcard ${cSql} ) b") |
| 16 | 17 | Map<String, Object> cardStat(@Param("pSql") String pSql,@Param("cSql") String cSql); |
| 18 | + | |
| 19 | + List<LymsTcard> queryUnused(LymsTcard lymsTcard); | |
| 17 | 20 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsTcardService.java
View file @
561c972
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | import com.lyms.talkonlineweb.domain.LymsTcard; |
| 4 | 4 | import com.baomidou.mybatisplus.extension.service.IService; |
| 5 | 5 | |
| 6 | +import java.util.List; | |
| 6 | 7 | import java.util.Map; |
| 7 | 8 | |
| 8 | 9 | /** |
| ... | ... | @@ -11,5 +12,12 @@ |
| 11 | 12 | public interface LymsTcardService extends IService<LymsTcard> { |
| 12 | 13 | |
| 13 | 14 | Map<String, Object> cardStat(String pSql, String cSql); |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 查询未使用的问诊卡 | |
| 18 | + * @param lymsTcard | |
| 19 | + * @return | |
| 20 | + */ | |
| 21 | + List<LymsTcard> queryUnused(LymsTcard lymsTcard); | |
| 14 | 22 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsTcardServiceImpl.java
View file @
561c972
| ... | ... | @@ -7,6 +7,7 @@ |
| 7 | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | 8 | import org.springframework.stereotype.Service; |
| 9 | 9 | |
| 10 | +import java.util.List; | |
| 10 | 11 | import java.util.Map; |
| 11 | 12 | |
| 12 | 13 | /** |
| ... | ... | @@ -21,6 +22,11 @@ |
| 21 | 22 | @Override |
| 22 | 23 | public Map<String, Object> cardStat(String pSql, String cSql) { |
| 23 | 24 | return lymsTcardMapper.cardStat(pSql,cSql); |
| 25 | + } | |
| 26 | + | |
| 27 | + @Override | |
| 28 | + public List<LymsTcard> queryUnused(LymsTcard lymsTcard) { | |
| 29 | + return lymsTcardMapper.queryUnused(lymsTcard); | |
| 24 | 30 | } |
| 25 | 31 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/HXService.java
View file @
561c972
| ... | ... | @@ -86,9 +86,16 @@ |
| 86 | 86 | HttpHeaders headers=new HttpHeaders(); |
| 87 | 87 | headers.add("Authorization","Bearer "+token); |
| 88 | 88 | HttpEntity param=new HttpEntity(headers); |
| 89 | - resp=restTemplate.exchange(getUrl()+"users/"+username, HttpMethod.GET,param,String.class); | |
| 90 | - if (resp.getStatusCodeValue()==200){ | |
| 91 | - user= JSON.parseObject(resp.getBody()); | |
| 89 | + ResponseEntity<String> getUserResponse = null; | |
| 90 | + try{ | |
| 91 | + getUserResponse=restTemplate.exchange(getUrl()+"users/"+username, HttpMethod.GET,param,String.class); | |
| 92 | + }catch (Exception e){ | |
| 93 | + log.error("调用环信查询接口异常",e); | |
| 94 | + return null; | |
| 95 | + } | |
| 96 | + | |
| 97 | + if (getUserResponse.getStatusCodeValue()==200){ | |
| 98 | + user= JSON.parseObject(getUserResponse.getBody()); | |
| 92 | 99 | } |
| 93 | 100 | return user; |
| 94 | 101 | } |
talkonlineweb/src/main/resources/mapper/LymsTcardMapper.xml
View file @
561c972
| ... | ... | @@ -21,5 +21,26 @@ |
| 21 | 21 | cnt,price,createdby, |
| 22 | 22 | createdtime,updatedby,updated_time |
| 23 | 23 | </sql> |
| 24 | + | |
| 25 | + <select id="queryUnused" parameterType="com.lyms.talkonlineweb.domain.LymsTcard" resultMap="BaseResultMap"> | |
| 26 | + | |
| 27 | + select | |
| 28 | + <include refid="Base_Column_List"></include> | |
| 29 | + from lyms_tcard card | |
| 30 | + where 1 = 1 | |
| 31 | + <if test="pid != null"> | |
| 32 | + and card.pid = #{pid} | |
| 33 | + </if> | |
| 34 | + <if test="pcid != null"> | |
| 35 | + and card.pcid = #{pcid} | |
| 36 | + </if> | |
| 37 | + <if test="fid != null"> | |
| 38 | + and card.fid = #{fid} | |
| 39 | + </if> | |
| 40 | + and not EXISTS ( SELECT r.cid FROM lyms_tkrecord r where r.cid = card.id ) | |
| 41 | + order by | |
| 42 | + card.fid desc,card.createdtime ASC | |
| 43 | + | |
| 44 | + </select> | |
| 24 | 45 | </mapper> |