Commit 985dd0ce9e71c3782959a6541ea82d1a42691b19

Authored by shiyang
1 parent 18fdfc1dff
Exists in master and in 1 other branch dev

自动回访功能update,修改为全局获取环信主账号

Showing 3 changed files with 180 additions and 139 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java View file @ 985dd0c
... ... @@ -22,6 +22,7 @@
22 22 import org.apache.commons.lang3.StringUtils;
23 23 import org.springframework.beans.BeanUtils;
24 24 import org.springframework.beans.factory.annotation.Autowired;
  25 +import org.springframework.beans.factory.annotation.Value;
25 26 import org.springframework.transaction.annotation.Transactional;
26 27 import org.springframework.web.bind.annotation.*;
27 28  
... ... @@ -34,6 +35,8 @@
34 35 @RequestMapping("chat")
35 36 @Log4j2
36 37 public class ChatGroupController {
  38 + @Value("${hx.hxuser}")
  39 + private String hxuser;
37 40 @Autowired
38 41 private LymsChatgroupService lymsChatgroupService;
39 42  
... ... @@ -81,7 +84,7 @@
81 84 String retDlogin=group.getRetDlogin();
82 85 List<LymsChatgroup> gLst = lymsChatgroupService.list(Wrappers.query(group).orderByDesc("id"));
83 86 if (group.getOwnerk() == null) {
84   - group.setOwnerk("test");
  87 + group.setOwnerk(hxuser);
85 88 }
86 89 LymsPatient patient= lymsPatientService.getOne(new QueryWrapper<LymsPatient>()
87 90 .lambda().eq(LymsPatient::getIdno, group.getFromp()));
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/TkRecordController.java View file @ 985dd0c
... ... @@ -14,6 +14,7 @@
14 14 import lombok.extern.log4j.Log4j2;
15 15 import org.apache.commons.lang3.StringUtils;
16 16 import org.springframework.beans.factory.annotation.Autowired;
  17 +import org.springframework.beans.factory.annotation.Value;
17 18 import org.springframework.validation.annotation.Validated;
18 19 import org.springframework.web.bind.annotation.*;
19 20  
... ... @@ -25,7 +26,8 @@
25 26 @RequestMapping("tk")
26 27 @Log4j2
27 28 public class TkRecordController {
28   -
  29 + @Value("${hx.hxuser}")
  30 + private String hxuser;
29 31 @Autowired
30 32 private LymsTkrecordService lymsTkrecordService;
31 33 @Autowired
... ... @@ -90,7 +92,7 @@
90 92 .lambda().eq(LymsChatgroup::getPcid, tkrecord.getPcid()));
91 93 //之前有这个病例的问诊就不用新创建组
92 94 if (0==gLst.size()) {
93   - group.setOwnerk("test");
  95 + group.setOwnerk(hxuser);
94 96 List<String> adminDlogins=new ArrayList<>();
95 97 adminDlogins.add(patient.getIdno());
96 98 List<String> groupnames=new ArrayList<>();
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushChatInfoTask.java View file @ 985dd0c
... ... @@ -63,11 +63,16 @@
63 63 private LymsTkrecordService lymsTkrecordService;
64 64  
65 65 /**
66   - * 每天19点执行回访信息系统回复
  66 + * 每天19点执行自动回访功能
  67 + * 第二天:就诊医生
  68 + * 第五天:值班护士
  69 + * 第十天:值班医生
  70 + * 第二十天:就诊医生
  71 + * 第三十天:值班医生
67 72 */
68 73 @Scheduled(cron = "0 0 19 * * ?")
69 74 public void pushChatInfo() {
70   -
  75 + //用户下的病例信息。每个环信群组代表一个病例,一个病例下有多个疾病种类。
71 76 List<Map<String,Object>> PcInfoList=lymsPatientService.getPcInfoList();
72 77 for (Map<String, Object> map : PcInfoList) {
73 78  
74 79  
75 80  
76 81  
77 82  
78 83  
79 84  
80 85  
81 86  
82 87  
83 88  
84 89  
85 90  
86 91  
87 92  
88 93  
89 94  
... ... @@ -82,158 +87,189 @@
82 87  
83 88 @Transactional(rollbackFor = Exception.class)
84 89 public void getPcInfoList(Map<String,Object> map){
85   - LymsChatgroup chatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>()
86   - .lambda().eq(LymsChatgroup::getPcid, (Integer)map.get("pcid")));
  90 + //患者信息
87 91 LymsPatient patient= lymsPatientService.getOne(new QueryWrapper<LymsPatient>()
88 92 .lambda().eq(LymsPatient::getIdno, map.get("idno").toString()));
  93 + //医生信息
89 94 LymsDoctor doctor= lymsDoctorService.getOne(new QueryWrapper<LymsDoctor>()
90 95 .lambda().eq(LymsDoctor::getDlogin, map.get("dlogin").toString()));
91   - if(null==chatgroup){
92   - //创建聊天群组
93   - chatgroup=addChatGroup(map,patient,doctor);
94   - }
  96 + //值班医生/值班护士信息
  97 + List<LymsDoctor> doctorAminList= lymsDoctorService.list(new QueryWrapper<LymsDoctor>()
  98 + .lambda().eq(LymsDoctor::getDpid, doctor.getDpid())
  99 + .in(LymsDoctor::getAdminType, Arrays.asList(1,2))
  100 + .orderByAsc(LymsDoctor::getAdminType));
  101 + //回访记录
  102 + final List<LymsReturnVisitRecord> returnVisitRecords = lymsReturnVisitRecordService.list(new QueryWrapper<LymsReturnVisitRecord>()
  103 + .lambda().eq(LymsReturnVisitRecord::getPcid, (Integer)map.get("pcid"))
  104 + .eq(LymsReturnVisitRecord::getType, 0));
  105 + //计算(自动回复周期上传病例后- 1:第二天2:第五天3:第十天4:第二十天5:第三十天)
  106 + int day = DateUtil.daysBetween(DateUtil.parseYMD(map.get("createdtime").toString()),new Date());
  107 + switch (returnVisitRecords.size()) {
  108 + case 0:
  109 + if (day==1) {
  110 + //环信聊天群组信息
  111 + LymsChatgroup chatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>()
  112 + .lambda().eq(LymsChatgroup::getPcid, (Integer)map.get("pcid")));
  113 + if(null==chatgroup){
  114 + //创建聊天群组
  115 + chatgroup=addChatGroup(map,patient,doctor);
  116 + }
  117 + //就诊医生回复
  118 + final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>()
  119 + .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid")));
95 120  
96   - if (null!=chatgroup) {
97   - final List<LymsReturnVisitRecord> returnVisitRecords = lymsReturnVisitRecordService.list(new QueryWrapper<LymsReturnVisitRecord>()
98   - .lambda().eq(LymsReturnVisitRecord::getPcid, (Integer)map.get("pcid"))
99   - .eq(LymsReturnVisitRecord::getType, 0));
100   - List<LymsDoctor> doctorAminList= lymsDoctorService.list(new QueryWrapper<LymsDoctor>()
101   - .lambda().eq(LymsDoctor::getDpid, doctor.getDpid())
102   - .in(LymsDoctor::getAdminType, Arrays.asList(1,2))
103   - .orderByAsc(LymsDoctor::getAdminType));
104   - int day = DateUtil.daysBetween(DateUtil.parseYMD(map.get("createdtime").toString()),new Date());
105   - switch (returnVisitRecords.size()) {
106   - case 0:
107   - if (day==1) {
108   - //就诊医生回复
109   - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>()
110   - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid")));
111   -
112   - for (LymsIllness lymsIllness : lymsIllnessList) {
113   - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>()
114   - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid())
115   - .eq(LymsChatInfo::getType, 1));
116   - //推送回访
117   - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) {
118   - //推送回访消息和保存发送记录
119   - pushOrMessage(null,chatgroup,chatInfo,doctor);
120   - }else {
121   - throw new RuntimeException("参数不符合");
122   - }
  121 + for (LymsIllness lymsIllness : lymsIllnessList) {
  122 + final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>()
  123 + .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid())
  124 + .eq(LymsChatInfo::getType, 1));
  125 + //推送回访
  126 + if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) {
  127 + //推送回访消息和保存发送记录
  128 + pushOrMessage(null,chatgroup,chatInfo,doctor);
  129 + }else {
  130 + throw new RuntimeException("参数不符合");
123 131 }
124   - //增加回访记录,修改环信群组状态,修改问诊记录状态
125   - addReturnVisitRecordOrUpdate(null,chatgroup ,patient,doctor);
126 132 }
127   - break;
128   - case 1:
129   - if (day==4) {
130   - //获取值班护士回复
131   - String dlogin="";
132   - for (LymsDoctor lymsDoctor : doctorAminList) {
133   - if (lymsDoctor.getAdminType()==2) {
134   - dlogin=lymsDoctor.getDlogin();
135   - return;
136   - }
  133 + //增加回访记录,修改环信群组状态,修改问诊记录状态
  134 + addReturnVisitRecordOrUpdate(null,chatgroup ,patient,doctor);
  135 + }
  136 + break;
  137 + case 1:
  138 + if (day==4) {
  139 + //环信群组信息
  140 + LymsChatgroup chatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>()
  141 + .lambda().eq(LymsChatgroup::getPcid, (Integer)map.get("pcid")));
  142 + if(null==chatgroup){
  143 + //创建聊天群组
  144 + chatgroup=addChatGroup(map,patient,doctor);
  145 + }
  146 + //获取值班护士回复
  147 + String dlogin="";
  148 + for (LymsDoctor lymsDoctor : doctorAminList) {
  149 + if (lymsDoctor.getAdminType()==2) {
  150 + dlogin=lymsDoctor.getDlogin();
  151 + return;
137 152 }
138   - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>()
139   - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid")));
140   - for (LymsIllness lymsIllness : lymsIllnessList) {
141   - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>()
142   - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid())
143   - .eq(LymsChatInfo::getType, 2));
144   - //推送回访
145   - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) {
146   - //推送回访消息和保存发送记录
147   - pushOrMessage(dlogin,chatgroup,chatInfo,doctor);
148   - }else {
149   - throw new RuntimeException("参数不符合");
150   - }
  153 + }
  154 + final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>()
  155 + .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid")));
  156 + for (LymsIllness lymsIllness : lymsIllnessList) {
  157 + final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>()
  158 + .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid())
  159 + .eq(LymsChatInfo::getType, 2));
  160 + //推送回访
  161 + if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) {
  162 + //推送回访消息和保存发送记录
  163 + pushOrMessage(dlogin,chatgroup,chatInfo,doctor);
  164 + }else {
  165 + throw new RuntimeException("参数不符合");
151 166 }
152   - //增加回访记录,修改环信群组状态,修改问诊记录状态
153   - addReturnVisitRecordOrUpdate(dlogin,chatgroup ,patient,doctor);
154 167 }
155   - break;
156   - case 2:
157   - if (day==9) {
158   - //获取值班医生回复
159   - String dlogin="";
160   - for (LymsDoctor lymsDoctor : doctorAminList) {
161   - if (lymsDoctor.getAdminType()==1) {
162   - dlogin=lymsDoctor.getDlogin();
163   - return;
164   - }
  168 + //增加回访记录,修改环信群组状态,修改问诊记录状态
  169 + addReturnVisitRecordOrUpdate(dlogin,chatgroup ,patient,doctor);
  170 + }
  171 + break;
  172 + case 2:
  173 + if (day==9) {
  174 + //环信群组信息
  175 + LymsChatgroup chatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>()
  176 + .lambda().eq(LymsChatgroup::getPcid, (Integer)map.get("pcid")));
  177 + if(null==chatgroup){
  178 + //创建聊天群组
  179 + chatgroup=addChatGroup(map,patient,doctor);
  180 + }
  181 + //获取值班医生回复
  182 + String dlogin="";
  183 + for (LymsDoctor lymsDoctor : doctorAminList) {
  184 + if (lymsDoctor.getAdminType()==1) {
  185 + dlogin=lymsDoctor.getDlogin();
  186 + return;
165 187 }
166   - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>()
167   - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid")));
168   - int i=0;
169   - for (LymsIllness lymsIllness : lymsIllnessList) {
170   - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>()
171   - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid())
172   - .eq(LymsChatInfo::getType, 3));
173   - //推送回访
174   - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) {
175   - //推送回访消息和保存发送记录
176   - pushOrMessage(dlogin,chatgroup,chatInfo,doctor);
177   - }else {
178   - throw new RuntimeException("参数不符合");
179   - }
  188 + }
  189 + final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>()
  190 + .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid")));
  191 + int i=0;
  192 + for (LymsIllness lymsIllness : lymsIllnessList) {
  193 + final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>()
  194 + .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid())
  195 + .eq(LymsChatInfo::getType, 3));
  196 + //推送回访
  197 + if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) {
  198 + //推送回访消息和保存发送记录
  199 + pushOrMessage(dlogin,chatgroup,chatInfo,doctor);
  200 + }else {
  201 + throw new RuntimeException("参数不符合");
180 202 }
181   - //增加回访记录,修改环信群组状态,修改问诊记录状态
182   - addReturnVisitRecordOrUpdate(dlogin,chatgroup ,patient,doctor);
183 203 }
184   - break;
185   - case 3:
186   - if (day==19) {
187   - //就诊医生回复
188   - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>()
189   - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid")));
190   - int i=0;
191   - for (LymsIllness lymsIllness : lymsIllnessList) {
192   - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>()
193   - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid())
194   - .eq(LymsChatInfo::getType, 4));
195   - //推送回访
196   - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) {
197   - //推送回访消息和保存发送记录
198   - pushOrMessage(null,chatgroup,chatInfo,doctor);
199   - }else {
200   - throw new RuntimeException("参数不符合");
201   - }
  204 + //增加回访记录,修改环信群组状态,修改问诊记录状态
  205 + addReturnVisitRecordOrUpdate(dlogin,chatgroup ,patient,doctor);
  206 + }
  207 + break;
  208 + case 3:
  209 + if (day==19) {
  210 + //环信群组信息
  211 + LymsChatgroup chatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>()
  212 + .lambda().eq(LymsChatgroup::getPcid, (Integer)map.get("pcid")));
  213 + if(null==chatgroup){
  214 + //创建聊天群组
  215 + chatgroup=addChatGroup(map,patient,doctor);
  216 + }
  217 + //就诊医生回复
  218 + final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>()
  219 + .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid")));
  220 + int i=0;
  221 + for (LymsIllness lymsIllness : lymsIllnessList) {
  222 + final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>()
  223 + .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid())
  224 + .eq(LymsChatInfo::getType, 4));
  225 + //推送回访
  226 + if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) {
  227 + //推送回访消息和保存发送记录
  228 + pushOrMessage(null,chatgroup,chatInfo,doctor);
  229 + }else {
  230 + throw new RuntimeException("参数不符合");
202 231 }
203   - //增加回访记录,修改环信群组状态,修改问诊记录状态
204   - addReturnVisitRecordOrUpdate(null,chatgroup ,patient,doctor);
205 232 }
206   - break;
207   - case 4:
208   - if (day==29) {
209   - //获取值班医生回复
210   - String dlogin="";
211   - for (LymsDoctor lymsDoctor : doctorAminList) {
212   - if (lymsDoctor.getAdminType()==1) {
213   - dlogin=lymsDoctor.getDlogin();
214   - return;
215   - }
  233 + //增加回访记录,修改环信群组状态,修改问诊记录状态
  234 + addReturnVisitRecordOrUpdate(null,chatgroup ,patient,doctor);
  235 + }
  236 + break;
  237 + case 4:
  238 + if (day==29) {
  239 + //环信群组信息
  240 + LymsChatgroup chatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>()
  241 + .lambda().eq(LymsChatgroup::getPcid, (Integer)map.get("pcid")));
  242 + if(null==chatgroup){
  243 + //创建聊天群组
  244 + chatgroup=addChatGroup(map,patient,doctor);
  245 + }
  246 + //获取值班医生回复
  247 + String dlogin="";
  248 + for (LymsDoctor lymsDoctor : doctorAminList) {
  249 + if (lymsDoctor.getAdminType()==1) {
  250 + dlogin=lymsDoctor.getDlogin();
  251 + return;
216 252 }
217   - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>()
218   - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid")));
219   - int i=0;
220   - for (LymsIllness lymsIllness : lymsIllnessList) {
221   - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>()
222   - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid())
223   - .eq(LymsChatInfo::getType, 5));
224   - ///推送回访
225   - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) {
226   - //推送回访消息和保存发送记录
227   - pushOrMessage(dlogin,chatgroup,chatInfo,doctor);
228   - }else {
229   - throw new RuntimeException("参数不符合");
230   - }
  253 + }
  254 + final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>()
  255 + .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid")));
  256 + int i=0;
  257 + for (LymsIllness lymsIllness : lymsIllnessList) {
  258 + final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>()
  259 + .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid())
  260 + .eq(LymsChatInfo::getType, 5));
  261 + ///推送回访
  262 + if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) {
  263 + //推送回访消息和保存发送记录
  264 + pushOrMessage(dlogin,chatgroup,chatInfo,doctor);
  265 + }else {
  266 + throw new RuntimeException("参数不符合");
231 267 }
232   - //增加回访记录,修改环信群组状态,修改问诊记录状态
233   - addReturnVisitRecordOrUpdate(dlogin,chatgroup ,patient,doctor);
234 268 }
235   - break;
236   - }
  269 + //增加回访记录,修改环信群组状态,修改问诊记录状态
  270 + addReturnVisitRecordOrUpdate(dlogin,chatgroup ,patient,doctor);
  271 + }
  272 + break;
237 273 }
238 274 }
239 275