Commit 69d91d1e468913c1d97ae855a432c33af25c4bb4
1 parent
54f5ebfd79
Exists in
master
PC-医生管理,值班医生/值班护士 添加到现有群组中。
Showing 3 changed files with 106 additions and 17 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/DoctorController.java
View file @
69d91d1
| ... | ... | @@ -13,9 +13,10 @@ |
| 13 | 13 | import com.lyms.talkonlineweb.service.*; |
| 14 | 14 | import com.lyms.talkonlineweb.util.*; |
| 15 | 15 | import lombok.extern.log4j.Log4j2; |
| 16 | +import org.apache.commons.lang3.StringUtils; | |
| 16 | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | +import org.springframework.transaction.annotation.Transactional; | |
| 17 | 19 | import org.springframework.util.DigestUtils; |
| 18 | -import org.springframework.util.StringUtils; | |
| 19 | 20 | import org.springframework.validation.BindingResult; |
| 20 | 21 | import org.springframework.validation.annotation.Validated; |
| 21 | 22 | import org.springframework.web.bind.annotation.*; |
| 22 | 23 | |
| 23 | 24 | |
| ... | ... | @@ -119,29 +120,31 @@ |
| 119 | 120 | if(Objects.nonNull(doctor.getDlogin())){ |
| 120 | 121 | doctor.setDlogin(doctor.getDlogin().toLowerCase()); |
| 121 | 122 | } |
| 123 | + LymsDoctor depart2=new LymsDoctor(); | |
| 124 | + depart2.setDlogin(doctor.getDlogin()); | |
| 125 | + List<LymsDoctor> dLst=lymsDoctorService.list(Wrappers.query(depart2)); | |
| 126 | + if (dLst.size()>0) { | |
| 127 | + baseResponse.setErrormsg("不能创建重复账号"); | |
| 128 | + baseResponse.setErrorcode(1); | |
| 129 | + return baseResponse; | |
| 130 | + } | |
| 122 | 131 | //操作记录标识 |
| 123 | 132 | Integer did=0; |
| 124 | 133 | if(doctor.getDid()==null){ |
| 125 | 134 | doctor.setCreatedtime(new Date()); |
| 126 | - LymsDoctor depart2=new LymsDoctor(); | |
| 127 | - depart2.setDlogin(doctor.getDlogin()); | |
| 128 | - List<LymsDoctor> dLst=lymsDoctorService.list(Wrappers.query(depart2)); | |
| 129 | - if (dLst.size()>0) { | |
| 130 | - baseResponse.setErrormsg("不能创建重复账号"); | |
| 131 | - baseResponse.setErrorcode(1); | |
| 132 | - return baseResponse; | |
| 133 | - } | |
| 134 | -// LymsHdepart hdepart=lymsHdepartService.getById(doctor.getDpid()); | |
| 135 | -// if(doctor.getHxid()==null ){ | |
| 136 | -// JSONObject json=hxService.addUser(doctor.getDlogin(),Constant.COMMON_PASSWD,doctor.getDname()+","+hdepart.getDname()+","+hdepart.getHname()); | |
| 137 | -// JSONArray rArr=json.getJSONArray("entities"); | |
| 138 | -// if(rArr.size()>0){ | |
| 139 | -// doctor.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 140 | -// } | |
| 141 | -// } | |
| 142 | 135 | }else{ |
| 143 | 136 | did=1; |
| 144 | 137 | doctor.setUpdatedTime(new Date()); |
| 138 | + //修改医生状态时。变为就诊医生状态 | |
| 139 | +// if (dLst.size()>0 && null!=doctor.getAdminType() && doctor.getAdminType()==0) { | |
| 140 | +// depart2=dLst.get(0); | |
| 141 | +// //变更前是值班医生/值班护士时,变更环信群组及删除环信群组用户(值班医生/值班护士) | |
| 142 | +// if(depart2.getAdminType()==1 || depart2.getAdminType()==2){ | |
| 143 | +// | |
| 144 | +// } | |
| 145 | +// } | |
| 146 | + | |
| 147 | + | |
| 145 | 148 | } |
| 146 | 149 | if(result.hasErrors()){ |
| 147 | 150 | baseResponse.setErrorcode(1); |
| ... | ... | @@ -457,6 +460,53 @@ |
| 457 | 460 | map.put("visitCount",visitCount); |
| 458 | 461 | map.put("visitRate",visitRate); |
| 459 | 462 | return map; |
| 463 | + } | |
| 464 | + | |
| 465 | + /** | |
| 466 | + * 值班医生/值班护士 添加到现有群组中 | |
| 467 | + * @param doctor | |
| 468 | + * @return | |
| 469 | + */ | |
| 470 | + @PostMapping("addOnDutyDoctor") | |
| 471 | + @TokenRequired | |
| 472 | + public BaseResponse addOnDutyDoctor(@RequestBody LymsDoctor doctor){ | |
| 473 | + BaseResponse baseResponse=new BaseResponse(); | |
| 474 | + try { | |
| 475 | + final List<LymsChatgroup> chatgroupList = lymsChatgroupService.list(new QueryWrapper<LymsChatgroup>().lambda() | |
| 476 | + .eq(LymsChatgroup::getHdepartId, doctor.getDpid())); | |
| 477 | + | |
| 478 | + for (LymsChatgroup lymsChatgroup : chatgroupList) { | |
| 479 | + final List<String> descriptionList = Arrays.asList(lymsChatgroup.getDescription().split(",")); | |
| 480 | + if (!descriptionList.contains(doctor.getDlogin())) { | |
| 481 | + //注册环信 | |
| 482 | + if (StringUtil.isEmpty(doctor.getHxid())) { | |
| 483 | + JSONObject json = hxService.addUser(doctor.getDlogin(), Constant.COMMON_PASSWD, doctor.getDname()); | |
| 484 | + JSONArray rArr = json.getJSONArray("entities"); | |
| 485 | + if (rArr.size() > 0) { | |
| 486 | + doctor.setHxid(rArr.getJSONObject(0).getString("uuid")); | |
| 487 | + lymsDoctorService.updateById(doctor); | |
| 488 | + } | |
| 489 | + } | |
| 490 | + //添加到环信群组中 | |
| 491 | + JSONObject json = hxService.addUserHxGroup(lymsChatgroup.getHxgroupid(), doctor.getDlogin()); | |
| 492 | + JSONObject jsonObject = json.getJSONObject("data"); | |
| 493 | + if (jsonObject.size() > 0 && (boolean) jsonObject.get("result")) { | |
| 494 | + //更新到数据库群组中 | |
| 495 | + lymsChatgroup.setDescription(lymsChatgroup.getDescription() + "," + doctor.getDlogin()); | |
| 496 | + lymsChatgroup.setGroupname(lymsChatgroup.getGroupname() + "," + doctor.getDname()); | |
| 497 | + lymsChatgroupService.updateById(lymsChatgroup); | |
| 498 | + } | |
| 499 | + | |
| 500 | + } | |
| 501 | + } | |
| 502 | + baseResponse.setErrormsg("成功"); | |
| 503 | + } catch (Exception e) { | |
| 504 | + e.printStackTrace(); | |
| 505 | + baseResponse.setErrorcode(1); | |
| 506 | + baseResponse.setErrormsg("失败"); | |
| 507 | + } | |
| 508 | + | |
| 509 | + return baseResponse; | |
| 460 | 510 | } |
| 461 | 511 | |
| 462 | 512 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/util/HXService.java
View file @
69d91d1
| ... | ... | @@ -359,5 +359,42 @@ |
| 359 | 359 | log.info(rs); |
| 360 | 360 | return rs; |
| 361 | 361 | } |
| 362 | + /** | |
| 363 | + * 环信群组增加用户 | |
| 364 | + * @param usernames | |
| 365 | + * @return | |
| 366 | + */ | |
| 367 | + public JSONObject addUserHxGroup(String hxgid,String dlogin) { | |
| 368 | + JSONObject rs=new JSONObject(); | |
| 369 | + Map<String,Object> param=new HashMap<>(); | |
| 370 | + HttpHeaders headers=new HttpHeaders(); | |
| 371 | + | |
| 372 | + headers.add("Authorization","Bearer "+getToken()); | |
| 373 | + | |
| 374 | + HttpEntity entity=new HttpEntity(param,headers); | |
| 375 | + resp=restTemplate.postForEntity(getUrl()+"chatgroups/"+hxgid+"/users/"+dlogin,entity,String.class); | |
| 376 | + if (resp.getStatusCodeValue()==200){ | |
| 377 | + rs= JSON.parseObject(resp.getBody()); | |
| 378 | + } | |
| 379 | + log.info(rs); | |
| 380 | + return rs; | |
| 381 | + } | |
| 382 | + /** | |
| 383 | + * 环信群组移除组用户 | |
| 384 | + * @param usernames | |
| 385 | + * @return | |
| 386 | + */ | |
| 387 | + public JSONObject delUserHxGroup(String hxgid,String dlogin) { | |
| 388 | + JSONObject rs=new JSONObject(); | |
| 389 | + String token=getToken(); | |
| 390 | + HttpHeaders headers=new HttpHeaders(); | |
| 391 | + headers.add("Authorization","Bearer "+token); | |
| 392 | + HttpEntity param=new HttpEntity(headers); | |
| 393 | + resp=restTemplate.exchange(getUrl()+"chatgroups/"+hxgid+"/users/"+dlogin, HttpMethod.DELETE,param,String.class); | |
| 394 | + if (resp.getStatusCodeValue()==200){ | |
| 395 | + rs= JSON.parseObject(resp.getBody()); | |
| 396 | + } | |
| 397 | + return rs; | |
| 398 | + } | |
| 362 | 399 | } |
talkonlineweb/src/main/resources/application-dev.yml
View file @
69d91d1
| ... | ... | @@ -3,7 +3,9 @@ |
| 3 | 3 | spring: |
| 4 | 4 | datasource: |
| 5 | 5 | driver-class-name: com.p6spy.engine.spy.P6SpyDriver |
| 6 | + #测试 | |
| 6 | 7 | url: jdbc:p6spy:mysql://111.206.6.150:3307/talkonline?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8 |
| 8 | + #正式 | |
| 7 | 9 | # url: jdbc:p6spy:mysql://111.206.6.155:3308/talkonline?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8 |
| 8 | 10 | username: platform |
| 9 | 11 | password: Platform@123 |