Commit 8a30d964c4b80b5ecab162c441a0cb0383b18d66
1 parent
08828750ac
Exists in
master
and in
1 other branch
添加自动回复信息-查重,自动回访update
Showing 5 changed files with 308 additions and 341 deletions
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/RegionsController.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsChatInfo.java
- talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushChatInfoTask.java
- talkonlineweb/src/main/resources/mapper/LymsChatInfoMapper.xml
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java
View file @
8a30d96
... | ... | @@ -620,6 +620,62 @@ |
620 | 620 | } |
621 | 621 | return baseResponse; |
622 | 622 | } |
623 | - | |
623 | + /** | |
624 | + * 添加自动回复信息-查重 | |
625 | + * @param type 自动回复类型 | |
626 | + * @param illid 疾病id | |
627 | + * @param id 修改时用 | |
628 | + * @return true 可以使用,false已经存在 | |
629 | + */ | |
630 | + @GetMapping("getChatInfoRepetition") | |
631 | + @TokenRequired | |
632 | + public BaseResponse getChatInfoRepetition(Integer type, Integer illid, @RequestParam(required = false) Integer id){ | |
633 | + BaseResponse baseResponse=new BaseResponse(); | |
634 | + try { | |
635 | + Map<String, Boolean> map= new HashMap<>(); | |
636 | + map.put("type", true);map.put("illid", true); | |
637 | + QueryWrapper<LymsChatInfo> queryWrapper=new QueryWrapper<>(); | |
638 | + queryWrapper.eq("type", type); | |
639 | + queryWrapper.eq("illid", illid); | |
640 | + if(null!=id){//修改的时候判断是否重复 | |
641 | + QueryWrapper<LymsChatInfo> queryWrapper2=new QueryWrapper<>(); | |
642 | + queryWrapper2.eq("id", id); | |
643 | + LymsChatInfo chatInfo2=lymsChatInfoService.getOne(queryWrapper2); | |
644 | + List<LymsChatInfo> chatInfoList=lymsChatInfoService.list(queryWrapper); | |
645 | + if(CollectionUtils.isNotEmpty(chatInfoList)){ | |
646 | + if(null!=type && !chatInfo2.getType().equals(type)){ | |
647 | + for (LymsChatInfo chatInfo : chatInfoList) { | |
648 | + if(chatInfo.getType().equals(type)){ | |
649 | + map.put("type", false); | |
650 | + } | |
651 | + } | |
652 | + } | |
653 | + if(null!=illid && !chatInfo2.getIllid().equals(illid)){ | |
654 | + for (LymsChatInfo chatInfo : chatInfoList) { | |
655 | + if(chatInfo.getIllid().equals(illid)){ | |
656 | + map.put("illid", false); | |
657 | + } | |
658 | + } | |
659 | + } | |
660 | + } | |
661 | + baseResponse.setObject(map); | |
662 | + }else { | |
663 | + LymsChatInfo chatInfo=lymsChatInfoService.getOne(queryWrapper); | |
664 | + if(null!=type && chatInfo.getType().equals(type)){ | |
665 | + map.put("type", false); | |
666 | + } | |
667 | + if(null!=illid && illid.equals(chatInfo.getIllid())){ | |
668 | + map.put("illid", false); | |
669 | + } | |
670 | + baseResponse.setObject(map); | |
671 | + } | |
672 | + baseResponse.setErrormsg("成功"); | |
673 | + } catch (Exception e) { | |
674 | + baseResponse.setErrorcode(1); | |
675 | + baseResponse.setErrormsg("失败"); | |
676 | + e.printStackTrace(); | |
677 | + } | |
678 | + return baseResponse; | |
679 | + } | |
624 | 680 | } |
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/RegionsController.java
View file @
8a30d96
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsChatInfo.java
View file @
8a30d96
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushChatInfoTask.java
View file @
8a30d96
... | ... | @@ -66,355 +66,185 @@ |
66 | 66 | * 每天19点执行回访信息系统回复 |
67 | 67 | */ |
68 | 68 | @Scheduled(cron = "0 0 19 * * ?") |
69 | - @Transactional(rollbackFor = Exception.class) | |
70 | 69 | public void pushChatInfo() { |
71 | 70 | |
72 | 71 | List<Map<String,Object>> PcInfoList=lymsPatientService.getPcInfoList(); |
73 | 72 | for (Map<String, Object> map : PcInfoList) { |
73 | + | |
74 | 74 | try { |
75 | - LymsChatgroup chatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>() | |
76 | - .lambda().eq(LymsChatgroup::getPcid, (Integer)map.get("pcid"))); | |
77 | - LymsPatient patient= lymsPatientService.getOne(new QueryWrapper<LymsPatient>() | |
78 | - .lambda().eq(LymsPatient::getIdno, map.get("idno").toString())); | |
79 | - LymsDoctor doctor= lymsDoctorService.getOne(new QueryWrapper<LymsDoctor>() | |
80 | - .lambda().eq(LymsDoctor::getDlogin, map.get("dlogin").toString())); | |
81 | - if(null==chatgroup){ | |
82 | - //创建聊天群组 | |
83 | - chatgroup=addChatGroup(map,patient,doctor); | |
84 | - } | |
75 | + getPcInfoList( map); | |
76 | + } catch (Exception e) { | |
77 | + e.printStackTrace(); | |
78 | + } | |
85 | 79 | |
86 | - if (null!=chatgroup) { | |
87 | - final List<LymsReturnVisitRecord> returnVisitRecords = lymsReturnVisitRecordService.list(new QueryWrapper<LymsReturnVisitRecord>() | |
88 | - .lambda().eq(LymsReturnVisitRecord::getPcid, (Integer)map.get("pcid"))); | |
89 | - List<LymsDoctor> doctorAminList= lymsDoctorService.list(new QueryWrapper<LymsDoctor>() | |
90 | - .lambda().eq(LymsDoctor::getDpid, doctor.getDpid()) | |
91 | - .in(LymsDoctor::getAdminType, Arrays.asList(1,2)) | |
92 | - .orderByAsc(LymsDoctor::getAdminType)); | |
93 | - int day = DateUtil.daysBetween(DateUtil.parseYMD(map.get("createdtime").toString()),new Date()); | |
94 | - switch (returnVisitRecords.size()) { | |
95 | - case 0: | |
96 | - if (day==2) { | |
97 | - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
98 | - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
99 | - int i=0; | |
100 | - for (LymsIllness lymsIllness : lymsIllnessList) { | |
101 | - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
102 | - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
103 | - .eq(LymsChatInfo::getType, 1)); | |
104 | - //推送回访 | |
105 | - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
106 | - JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), doctor.getDlogin()); | |
107 | - if (null!=jsonObject) { | |
108 | - i++; | |
109 | - //保存发送消息记录 | |
110 | - LymsMessage message=new LymsMessage(); | |
111 | - message.setContent(chatInfo.getConten()); | |
112 | - message.setFromid(doctor.getDlogin()); | |
113 | - message.setTargetid(chatgroup.getHxgroupid()); | |
114 | - message.setMtype("TEXT"); | |
115 | - message.setSendtime(new Date()); | |
116 | - message.setType(1); | |
117 | - lymsMessageService.save(message); | |
118 | - } | |
119 | - } | |
120 | - } | |
121 | - if (i!=0) { | |
122 | - //增加回访记录 | |
123 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
124 | - returnVisitRecord.setDlogin(doctor.getDlogin());//第二天,就诊医生自动回复 | |
125 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
126 | - returnVisitRecord.setIdno(patient.getIdno()); | |
127 | - returnVisitRecord.setType(0); | |
128 | - returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
129 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
130 | - chatgroup.setStat(0); | |
131 | - final boolean b = lymsChatgroupService.updateById(chatgroup); | |
132 | - if (!b) { | |
133 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
134 | - } | |
135 | - //修改同一群组记录的状态 | |
136 | - final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
137 | - .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
138 | - for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
139 | - try { | |
140 | - lymsTkrecord.setStat(0); | |
141 | - final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
142 | - if (!saveOrUpdate) { | |
143 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
144 | - } | |
145 | - } catch (RuntimeException e) { | |
146 | - e.printStackTrace(); | |
147 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
148 | - } | |
149 | - } | |
150 | - } | |
80 | + } | |
81 | + } | |
82 | + | |
83 | + @Transactional(rollbackFor = Exception.class) | |
84 | + public void getPcInfoList(Map<String,Object> map){ | |
85 | + LymsChatgroup chatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>() | |
86 | + .lambda().eq(LymsChatgroup::getPcid, (Integer)map.get("pcid"))); | |
87 | + LymsPatient patient= lymsPatientService.getOne(new QueryWrapper<LymsPatient>() | |
88 | + .lambda().eq(LymsPatient::getIdno, map.get("idno").toString())); | |
89 | + LymsDoctor doctor= lymsDoctorService.getOne(new QueryWrapper<LymsDoctor>() | |
90 | + .lambda().eq(LymsDoctor::getDlogin, map.get("dlogin").toString())); | |
91 | + if(null==chatgroup){ | |
92 | + //创建聊天群组 | |
93 | + chatgroup=addChatGroup(map,patient,doctor); | |
94 | + } | |
95 | + | |
96 | + if (null!=chatgroup) { | |
97 | + final List<LymsReturnVisitRecord> returnVisitRecords = lymsReturnVisitRecordService.list(new QueryWrapper<LymsReturnVisitRecord>() | |
98 | + .lambda().eq(LymsReturnVisitRecord::getPcid, (Integer)map.get("pcid"))); | |
99 | + List<LymsDoctor> doctorAminList= lymsDoctorService.list(new QueryWrapper<LymsDoctor>() | |
100 | + .lambda().eq(LymsDoctor::getDpid, doctor.getDpid()) | |
101 | + .in(LymsDoctor::getAdminType, Arrays.asList(1,2)) | |
102 | + .orderByAsc(LymsDoctor::getAdminType)); | |
103 | + int day = DateUtil.daysBetween(DateUtil.parseYMD(map.get("createdtime").toString()),new Date()); | |
104 | + switch (returnVisitRecords.size()) { | |
105 | + case 0: | |
106 | + if (day==2) { | |
107 | + //就诊医生回复 | |
108 | + final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
109 | + .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
110 | + | |
111 | + for (LymsIllness lymsIllness : lymsIllnessList) { | |
112 | + final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
113 | + .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
114 | + .eq(LymsChatInfo::getType, 1)); | |
115 | + //推送回访 | |
116 | + if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
117 | + //推送回访消息和保存发送记录 | |
118 | + pushOrMessage(null,chatgroup,chatInfo,doctor); | |
119 | + }else { | |
120 | + throw new RuntimeException("参数不符合"); | |
151 | 121 | } |
152 | - break; | |
153 | - case 1: | |
154 | - if (day==5) { | |
155 | - //获取值班护士 | |
156 | - String dlogin=""; | |
157 | - for (LymsDoctor lymsDoctor : doctorAminList) { | |
158 | - if (lymsDoctor.getAdminType()==2) { | |
159 | - dlogin=lymsDoctor.getDlogin(); | |
160 | - return; | |
161 | - } | |
162 | - } | |
163 | - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
164 | - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
165 | - int i=0; | |
166 | - for (LymsIllness lymsIllness : lymsIllnessList) { | |
167 | - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
168 | - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
169 | - .eq(LymsChatInfo::getType, 2)); | |
170 | - //推送回访 | |
171 | - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
172 | - JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
173 | - if (null!=jsonObject) { | |
174 | - i++; | |
175 | - //保存发送消息记录 | |
176 | - LymsMessage message=new LymsMessage(); | |
177 | - message.setContent(chatInfo.getConten()); | |
178 | - message.setFromid(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
179 | - message.setTargetid(chatgroup.getHxgroupid()); | |
180 | - message.setMtype("TEXT"); | |
181 | - message.setSendtime(new Date()); | |
182 | - message.setType(1); | |
183 | - lymsMessageService.save(message); | |
184 | - } | |
185 | - } | |
186 | - } | |
187 | - if (i!=0) { | |
188 | - //增加回访记录 | |
189 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
190 | - returnVisitRecord.setDlogin(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin);//第五天,值班护士自动回复 | |
191 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
192 | - returnVisitRecord.setIdno(patient.getIdno()); | |
193 | - returnVisitRecord.setType(0); | |
194 | - returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
195 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
196 | - chatgroup.setStat(0); | |
197 | - final boolean b = lymsChatgroupService.updateById(chatgroup); | |
198 | - if (!b) { | |
199 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
200 | - } | |
201 | - //修改同一群组记录的状态 | |
202 | - final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
203 | - .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
204 | - for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
205 | - try { | |
206 | - lymsTkrecord.setStat(0); | |
207 | - final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
208 | - if (!saveOrUpdate) { | |
209 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
210 | - } | |
211 | - } catch (RuntimeException e) { | |
212 | - e.printStackTrace(); | |
213 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
214 | - } | |
215 | - } | |
216 | - } | |
122 | + } | |
123 | + //增加回访记录,修改环信群组状态,修改问诊记录状态 | |
124 | + addReturnVisitRecordOrUpdate(null,chatgroup ,patient,doctor); | |
125 | + } | |
126 | + break; | |
127 | + case 1: | |
128 | + if (day==5) { | |
129 | + //获取值班护士回复 | |
130 | + String dlogin=""; | |
131 | + for (LymsDoctor lymsDoctor : doctorAminList) { | |
132 | + if (lymsDoctor.getAdminType()==2) { | |
133 | + dlogin=lymsDoctor.getDlogin(); | |
134 | + return; | |
217 | 135 | } |
218 | - break; | |
219 | - case 2: | |
220 | - if (day==10) { | |
221 | - //获取值班医生 | |
222 | - String dlogin=""; | |
223 | - for (LymsDoctor lymsDoctor : doctorAminList) { | |
224 | - if (lymsDoctor.getAdminType()==1) { | |
225 | - dlogin=lymsDoctor.getDlogin(); | |
226 | - return; | |
227 | - } | |
228 | - } | |
229 | - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
230 | - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
231 | - int i=0; | |
232 | - for (LymsIllness lymsIllness : lymsIllnessList) { | |
233 | - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
234 | - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
235 | - .eq(LymsChatInfo::getType, 3)); | |
236 | - //推送回访 | |
237 | - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
238 | - JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
239 | - if (null!=jsonObject) { | |
240 | - i++; | |
241 | - //保存发送消息记录 | |
242 | - LymsMessage message=new LymsMessage(); | |
243 | - message.setContent(chatInfo.getConten()); | |
244 | - message.setFromid(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
245 | - message.setTargetid(chatgroup.getHxgroupid()); | |
246 | - message.setMtype("TEXT"); | |
247 | - message.setSendtime(new Date()); | |
248 | - message.setType(1); | |
249 | - lymsMessageService.save(message); | |
250 | - } | |
251 | - } | |
252 | - } | |
253 | - if (i!=0) { | |
254 | - //增加回访记录 | |
255 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
256 | - returnVisitRecord.setDlogin(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin);//第十天,值班医生自动回复 | |
257 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
258 | - returnVisitRecord.setIdno(patient.getIdno()); | |
259 | - returnVisitRecord.setType(0); | |
260 | - returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
261 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
262 | - chatgroup.setStat(0); | |
263 | - final boolean b = lymsChatgroupService.updateById(chatgroup); | |
264 | - if (!b) { | |
265 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
266 | - } | |
267 | - //修改同一群组记录的状态 | |
268 | - final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
269 | - .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
270 | - for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
271 | - try { | |
272 | - lymsTkrecord.setStat(0); | |
273 | - final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
274 | - if (!saveOrUpdate) { | |
275 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
276 | - } | |
277 | - } catch (RuntimeException e) { | |
278 | - e.printStackTrace(); | |
279 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
280 | - } | |
281 | - } | |
282 | - } | |
136 | + } | |
137 | + final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
138 | + .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
139 | + for (LymsIllness lymsIllness : lymsIllnessList) { | |
140 | + final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
141 | + .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
142 | + .eq(LymsChatInfo::getType, 2)); | |
143 | + //推送回访 | |
144 | + if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
145 | + //推送回访消息和保存发送记录 | |
146 | + pushOrMessage(dlogin,chatgroup,chatInfo,doctor); | |
147 | + }else { | |
148 | + throw new RuntimeException("参数不符合"); | |
283 | 149 | } |
284 | - break; | |
285 | - case 3: | |
286 | - if (day==20) { | |
287 | - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
288 | - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
289 | - int i=0; | |
290 | - for (LymsIllness lymsIllness : lymsIllnessList) { | |
291 | - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
292 | - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
293 | - .eq(LymsChatInfo::getType, 4)); | |
294 | - //推送回访 | |
295 | - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
296 | - JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), doctor.getDlogin()); | |
297 | - if (null!=jsonObject) { | |
298 | - i++; | |
299 | - //保存发送消息记录 | |
300 | - LymsMessage message=new LymsMessage(); | |
301 | - message.setContent(chatInfo.getConten()); | |
302 | - message.setFromid(doctor.getDlogin()); | |
303 | - message.setTargetid(chatgroup.getHxgroupid()); | |
304 | - message.setMtype("TEXT"); | |
305 | - message.setSendtime(new Date()); | |
306 | - message.setType(1); | |
307 | - lymsMessageService.save(message); | |
308 | - } | |
309 | - } | |
310 | - } | |
311 | - if (i!=0) { | |
312 | - //增加回访记录 | |
313 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
314 | - returnVisitRecord.setDlogin(doctor.getDlogin());//第二十天,就诊医生自动回复 | |
315 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
316 | - returnVisitRecord.setIdno(patient.getIdno()); | |
317 | - returnVisitRecord.setType(0); | |
318 | - returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
319 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
320 | - chatgroup.setStat(0); | |
321 | - final boolean b = lymsChatgroupService.updateById(chatgroup); | |
322 | - if (!b) { | |
323 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
324 | - } | |
325 | - //修改同一群组记录的状态 | |
326 | - final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
327 | - .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
328 | - for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
329 | - try { | |
330 | - lymsTkrecord.setStat(0); | |
331 | - final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
332 | - if (!saveOrUpdate) { | |
333 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
334 | - } | |
335 | - } catch (RuntimeException e) { | |
336 | - e.printStackTrace(); | |
337 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
338 | - } | |
339 | - } | |
340 | - } | |
150 | + } | |
151 | + //增加回访记录,修改环信群组状态,修改问诊记录状态 | |
152 | + addReturnVisitRecordOrUpdate(dlogin,chatgroup ,patient,doctor); | |
153 | + } | |
154 | + break; | |
155 | + case 2: | |
156 | + if (day==10) { | |
157 | + //获取值班医生回复 | |
158 | + String dlogin=""; | |
159 | + for (LymsDoctor lymsDoctor : doctorAminList) { | |
160 | + if (lymsDoctor.getAdminType()==1) { | |
161 | + dlogin=lymsDoctor.getDlogin(); | |
162 | + return; | |
341 | 163 | } |
342 | - break; | |
343 | - case 4: | |
344 | - if (day==30) { | |
345 | - //获取值班医生 | |
346 | - String dlogin=""; | |
347 | - for (LymsDoctor lymsDoctor : doctorAminList) { | |
348 | - if (lymsDoctor.getAdminType()==1) { | |
349 | - dlogin=lymsDoctor.getDlogin(); | |
350 | - return; | |
351 | - } | |
352 | - } | |
353 | - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
354 | - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
355 | - int i=0; | |
356 | - for (LymsIllness lymsIllness : lymsIllnessList) { | |
357 | - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
358 | - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
359 | - .eq(LymsChatInfo::getType, 5)); | |
360 | - //推送回访 | |
361 | - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
362 | - JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
363 | - if (null!=jsonObject) { | |
364 | - i++; | |
365 | - //保存发送消息记录 | |
366 | - LymsMessage message=new LymsMessage(); | |
367 | - message.setContent(chatInfo.getConten()); | |
368 | - message.setFromid(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
369 | - message.setTargetid(chatgroup.getHxgroupid()); | |
370 | - message.setMtype("TEXT"); | |
371 | - message.setSendtime(new Date()); | |
372 | - message.setType(1); | |
373 | - lymsMessageService.save(message); | |
374 | - } | |
375 | - } | |
376 | - } | |
377 | - if (i!=0) { | |
378 | - //增加回访记录 | |
379 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
380 | - returnVisitRecord.setDlogin(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin);//第三十天,值班医生自动回复 | |
381 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
382 | - returnVisitRecord.setIdno(patient.getIdno()); | |
383 | - returnVisitRecord.setType(0); | |
384 | - returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
385 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
386 | - chatgroup.setStat(0); | |
387 | - final boolean b = lymsChatgroupService.updateById(chatgroup); | |
388 | - if (!b) { | |
389 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
390 | - } | |
391 | - //修改同一群组记录的状态 | |
392 | - final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
393 | - .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
394 | - for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
395 | - try { | |
396 | - lymsTkrecord.setStat(0); | |
397 | - final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
398 | - if (!saveOrUpdate) { | |
399 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
400 | - } | |
401 | - } catch (RuntimeException e) { | |
402 | - e.printStackTrace(); | |
403 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
404 | - } | |
405 | - } | |
406 | - } | |
164 | + } | |
165 | + final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
166 | + .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
167 | + int i=0; | |
168 | + for (LymsIllness lymsIllness : lymsIllnessList) { | |
169 | + final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
170 | + .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
171 | + .eq(LymsChatInfo::getType, 3)); | |
172 | + //推送回访 | |
173 | + if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
174 | + //推送回访消息和保存发送记录 | |
175 | + pushOrMessage(dlogin,chatgroup,chatInfo,doctor); | |
176 | + }else { | |
177 | + throw new RuntimeException("参数不符合"); | |
407 | 178 | } |
408 | - break; | |
179 | + } | |
180 | + //增加回访记录,修改环信群组状态,修改问诊记录状态 | |
181 | + addReturnVisitRecordOrUpdate(dlogin,chatgroup ,patient,doctor); | |
409 | 182 | } |
410 | - } | |
411 | - } catch (Exception e) { | |
412 | - e.printStackTrace(); | |
413 | - throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
183 | + break; | |
184 | + case 3: | |
185 | + if (day==20) { | |
186 | + //就诊医生回复 | |
187 | + final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
188 | + .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
189 | + int i=0; | |
190 | + for (LymsIllness lymsIllness : lymsIllnessList) { | |
191 | + final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
192 | + .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
193 | + .eq(LymsChatInfo::getType, 4)); | |
194 | + //推送回访 | |
195 | + if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
196 | + //推送回访消息和保存发送记录 | |
197 | + pushOrMessage(null,chatgroup,chatInfo,doctor); | |
198 | + }else { | |
199 | + throw new RuntimeException("参数不符合"); | |
200 | + } | |
201 | + } | |
202 | + //增加回访记录,修改环信群组状态,修改问诊记录状态 | |
203 | + addReturnVisitRecordOrUpdate(null,chatgroup ,patient,doctor); | |
204 | + } | |
205 | + break; | |
206 | + case 4: | |
207 | + if (day==30) { | |
208 | + //获取值班医生回复 | |
209 | + String dlogin=""; | |
210 | + for (LymsDoctor lymsDoctor : doctorAminList) { | |
211 | + if (lymsDoctor.getAdminType()==1) { | |
212 | + dlogin=lymsDoctor.getDlogin(); | |
213 | + return; | |
214 | + } | |
215 | + } | |
216 | + final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
217 | + .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
218 | + int i=0; | |
219 | + for (LymsIllness lymsIllness : lymsIllnessList) { | |
220 | + final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
221 | + .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
222 | + .eq(LymsChatInfo::getType, 5)); | |
223 | + ///推送回访 | |
224 | + if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
225 | + //推送回访消息和保存发送记录 | |
226 | + pushOrMessage(dlogin,chatgroup,chatInfo,doctor); | |
227 | + }else { | |
228 | + throw new RuntimeException("参数不符合"); | |
229 | + } | |
230 | + } | |
231 | + //增加回访记录,修改环信群组状态,修改问诊记录状态 | |
232 | + addReturnVisitRecordOrUpdate(dlogin,chatgroup ,patient,doctor); | |
233 | + } | |
234 | + break; | |
414 | 235 | } |
415 | 236 | } |
416 | 237 | } |
417 | - public LymsChatgroup addChatGroup(Map<String,Object> map,LymsPatient patient,LymsDoctor doctor) { | |
238 | + | |
239 | + /** | |
240 | + * 创建环信群组 | |
241 | + * @param map | |
242 | + * @param patient | |
243 | + * @param doctor | |
244 | + * @return | |
245 | + */ | |
246 | + @Transactional(rollbackFor = Exception.class) | |
247 | + public LymsChatgroup addChatGroup(Map<String,Object> map,LymsPatient patient,LymsDoctor doctor){ | |
418 | 248 | List<String> adminDlogins=new ArrayList<>(); |
419 | 249 | adminDlogins.add(patient.getIdno()); |
420 | 250 | List<String> groupnames=new ArrayList<>(); |
... | ... | @@ -425,7 +255,12 @@ |
425 | 255 | JSONArray rArr = json.getJSONArray("entities"); |
426 | 256 | if (rArr.size() > 0) { |
427 | 257 | patient.setHxid(rArr.getJSONObject(0).getString("uuid")); |
428 | - lymsPatientService.updateById(patient); | |
258 | + final boolean b = lymsPatientService.updateById(patient); | |
259 | + if (!b) { | |
260 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
261 | + } | |
262 | + }else { | |
263 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
429 | 264 | } |
430 | 265 | } |
431 | 266 | //查询值班医生/值班护士 |
... | ... | @@ -440,7 +275,10 @@ |
440 | 275 | JSONArray rArr = json.getJSONArray("entities"); |
441 | 276 | if (rArr.size() > 0) { |
442 | 277 | lymsDoctor.setHxid(rArr.getJSONObject(0).getString("uuid")); |
443 | - lymsDoctorService.updateById(lymsDoctor); | |
278 | + final boolean b = lymsDoctorService.updateById(lymsDoctor); | |
279 | + if (!b) { | |
280 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
281 | + } | |
444 | 282 | } |
445 | 283 | } |
446 | 284 | adminDlogins.add(lymsDoctor.getDlogin()); |
... | ... | @@ -453,7 +291,10 @@ |
453 | 291 | JSONArray rArr = json.getJSONArray("entities"); |
454 | 292 | if (rArr.size() > 0) { |
455 | 293 | doctor.setHxid(rArr.getJSONObject(0).getString("uuid")); |
456 | - lymsDoctorService.updateById(doctor); | |
294 | + final boolean b = lymsDoctorService.updateById(doctor); | |
295 | + if (!b) { | |
296 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
297 | + } | |
457 | 298 | } |
458 | 299 | } |
459 | 300 | adminDlogins.add(doctor.getDlogin()); |
460 | 301 | |
... | ... | @@ -470,8 +311,77 @@ |
470 | 311 | group.setType(1); |
471 | 312 | group.setStat(0); |
472 | 313 | group.setPcid((Integer)map.get("pcid")); |
473 | - lymsChatgroupService.save(group); | |
314 | + final boolean save = lymsChatgroupService.save(group); | |
315 | + if (!save) { | |
316 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
317 | + } | |
474 | 318 | return group; |
319 | + } | |
320 | + | |
321 | + /** | |
322 | + * 推送回访消息和保存发送记录 | |
323 | + * @param dlogin 发送医生 | |
324 | + * @param chatgroup | |
325 | + * @param chatInfo | |
326 | + * @param doctor | |
327 | + */ | |
328 | + @Transactional(rollbackFor = Exception.class) | |
329 | + public void pushOrMessage(String dlogin,LymsChatgroup chatgroup,LymsChatInfo chatInfo,LymsDoctor doctor) { | |
330 | + JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
331 | + if (null!=jsonObject) { | |
332 | + //保存发送消息记录 | |
333 | + LymsMessage message=new LymsMessage(); | |
334 | + message.setContent(chatInfo.getConten()); | |
335 | + message.setFromid(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
336 | + message.setTargetid(chatgroup.getHxgroupid()); | |
337 | + message.setMtype("TEXT"); | |
338 | + message.setSendtime(new Date()); | |
339 | + message.setType(1); | |
340 | + final boolean save = lymsMessageService.save(message); | |
341 | + if (! save) { | |
342 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
343 | + } | |
344 | + }else { | |
345 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
346 | + } | |
347 | + } | |
348 | + | |
349 | + /** | |
350 | + * 增加回访记录,修改环信群组状态,修改问诊记录状态 | |
351 | + * @param dlogin | |
352 | + * @param chatgroup | |
353 | + * @param patient | |
354 | + * @param doctor | |
355 | + */ | |
356 | + @Transactional(rollbackFor = Exception.class) | |
357 | + public void addReturnVisitRecordOrUpdate(String dlogin,LymsChatgroup chatgroup ,LymsPatient patient,LymsDoctor doctor) { | |
358 | + //增加回访记录 | |
359 | + LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
360 | + returnVisitRecord.setDlogin(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
361 | + returnVisitRecord.setDpid(doctor.getDpid()); | |
362 | + returnVisitRecord.setIdno(patient.getIdno()); | |
363 | + returnVisitRecord.setType(0); | |
364 | + returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
365 | + final boolean save = lymsReturnVisitRecordService.save(returnVisitRecord); | |
366 | + if (!save) { | |
367 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
368 | + } | |
369 | + chatgroup.setType(1); | |
370 | + chatgroup.setStat(0); | |
371 | + final boolean b = lymsChatgroupService.updateById(chatgroup); | |
372 | + if (!b) { | |
373 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
374 | + } | |
375 | + //修改同一群组记录的状态 | |
376 | + final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
377 | + .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
378 | + for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
379 | + lymsTkrecord.setStat(0); | |
380 | + final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
381 | + if (!saveOrUpdate) { | |
382 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
383 | + } | |
384 | + } | |
475 | 385 | } |
476 | 386 | } |
talkonlineweb/src/main/resources/mapper/LymsChatInfoMapper.xml
View file @
8a30d96
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | <id property="id" column="id" jdbcType="INTEGER"/> |
9 | 9 | <result property="conten" column="conten" jdbcType="VARCHAR"/> |
10 | 10 | <result property="type" column="type" jdbcType="INTEGER"/> |
11 | - <result property="illid" column="illid" jdbcType="VARCHAR"/> | |
11 | + <result property="illid" column="illid" jdbcType="INTEGER"/> | |
12 | 12 | <result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/> |
13 | 13 | <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
14 | 14 | </resultMap> |