Commit 9a27d315252ef975ac6eb3f37769d694aa04f17b
1 parent
6bf2af69d0
Exists in
master
修改添加问诊记录接口
Showing 1 changed file with 51 additions and 4 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java
View file @
9a27d31
1 | 1 | package com.lyms.talkonlineweb.controller; |
2 | 2 | |
3 | +import com.alibaba.fastjson.JSONObject; | |
3 | 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
4 | -import com.lyms.talkonlineweb.domain.LymsTkrecord; | |
5 | -import com.lyms.talkonlineweb.domain.TkrecordInfo; | |
5 | +import com.lyms.talkonlineweb.domain.*; | |
6 | 6 | import com.lyms.talkonlineweb.result.BaseResponse; |
7 | -import com.lyms.talkonlineweb.service.LymsTkrecordService; | |
8 | -import com.lyms.talkonlineweb.service.TkrecordInfoService; | |
7 | +import com.lyms.talkonlineweb.service.*; | |
8 | +import com.lyms.talkonlineweb.util.HXService; | |
9 | 9 | import lombok.extern.log4j.Log4j2; |
10 | 10 | import org.springframework.beans.factory.annotation.Autowired; |
11 | 11 | import org.springframework.validation.annotation.Validated; |
12 | 12 | import org.springframework.web.bind.annotation.*; |
13 | 13 | |
14 | +import java.util.List; | |
15 | + | |
14 | 16 | @RestController |
15 | 17 | @RequestMapping("tk") |
16 | 18 | @Log4j2 |
... | ... | @@ -21,6 +23,18 @@ |
21 | 23 | @Autowired |
22 | 24 | private TkrecordInfoService tkrecordInfoService; |
23 | 25 | |
26 | + @Autowired | |
27 | + private LymsTcardService lymsTcardService; | |
28 | + @Autowired | |
29 | + private HXService hxService; | |
30 | + @Autowired | |
31 | + private LymsChatgroupService lymsChatgroupService; | |
32 | + | |
33 | + @Autowired | |
34 | + private LymsDoctorService lymsDoctorService; | |
35 | + @Autowired | |
36 | + private LymsPatientService lymsPatientService; | |
37 | + | |
24 | 38 | /** |
25 | 39 | * 保存问诊记录 |
26 | 40 | * @param tkrecord |
27 | 41 | |
... | ... | @@ -30,7 +44,40 @@ |
30 | 44 | public BaseResponse saveTkRecord(@RequestBody @Validated LymsTkrecord tkrecord){ |
31 | 45 | BaseResponse baseResponse=new BaseResponse(); |
32 | 46 | try { |
47 | + | |
48 | + LymsTcard tcard=new LymsTcard(); | |
49 | + tcard.setPid(tkrecord.getPid()); | |
50 | + tcard.setPcid(tkrecord.getPcid()); | |
51 | +// 获取问诊卡按照先从医院购买的问诊卡消费 | |
52 | + List<LymsTcard> rLst=lymsTcardService.list(Wrappers.query(tcard).notInSql("id","SELECT r.cid FROM lyms_tkrecord r").orderByDesc("fid")); | |
53 | + | |
54 | + if(rLst.size()>0){ | |
55 | + tkrecord.setCid(rLst.get(0).getId()); | |
56 | + }else{ | |
57 | + baseResponse.setErrorcode(1); | |
58 | + baseResponse.setErrormsg("已经没有了问诊卡"); | |
59 | + return baseResponse; | |
60 | + } | |
33 | 61 | lymsTkrecordService.save(tkrecord); |
62 | + | |
63 | + LymsChatgroup group =new LymsChatgroup(); | |
64 | + LymsDoctor doctor=lymsDoctorService.getById(tkrecord.getDid()); | |
65 | + LymsPatient patient=lymsPatientService.getById(tkrecord.getPid()); | |
66 | + | |
67 | + group.setFromp(patient.getIdno()); | |
68 | + group.setTarget(doctor.getDlogin()); | |
69 | + group.setOwnerk("test"); | |
70 | + | |
71 | + log.info("创建环信组:{} from:{} target:{}", group.getOwnerk(), group.getFromp(), group.getTarget()); | |
72 | + JSONObject rJson = hxService.addChatGroups(group.getFromp() + "," + group.getTarget(), group.getOwnerk(), new String[]{group.getFromp(), group.getTarget()}); | |
73 | + log.info("rJson:" + rJson); | |
74 | + group.setHxgroupid(rJson.getJSONObject("data").getString("groupid")); | |
75 | + group.setDescription(group.getFromp() + "," + group.getTarget()); | |
76 | + group.setGroupname(group.getFromp() + "," + group.getTarget()); | |
77 | + lymsChatgroupService.saveOrUpdate(group); | |
78 | + | |
79 | + baseResponse.setObject(group); | |
80 | + | |
34 | 81 | baseResponse.setErrormsg("成功"); |
35 | 82 | } catch (Exception e) { |
36 | 83 | baseResponse.setErrormsg("失败"); |