Commit 12efe23ded52b60069cedfbf32c2f280d91e4d6a
1 parent
72e72880f0
Exists in
master
自动回访功能update
Showing 1 changed file with 312 additions and 280 deletions
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/PushChatInfoTask.java
View file @
12efe23
... | ... | @@ -66,319 +66,351 @@ |
66 | 66 | * 每天19点执行回访信息系统回复 |
67 | 67 | */ |
68 | 68 | @Scheduled(cron = "0 0 19 * * ?") |
69 | + @Transactional(rollbackFor = Exception.class) | |
69 | 70 | public void pushChatInfo() { |
71 | + | |
70 | 72 | List<Map<String,Object>> PcInfoList=lymsPatientService.getPcInfoList(); |
71 | 73 | for (Map<String, Object> map : PcInfoList) { |
72 | - LymsChatgroup chatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>() | |
73 | - .lambda().eq(LymsChatgroup::getPcid, (Integer)map.get("pcid"))); | |
74 | - LymsPatient patient= lymsPatientService.getOne(new QueryWrapper<LymsPatient>() | |
75 | - .lambda().eq(LymsPatient::getIdno, map.get("idno").toString())); | |
76 | - LymsDoctor doctor= lymsDoctorService.getOne(new QueryWrapper<LymsDoctor>() | |
77 | - .lambda().eq(LymsDoctor::getDlogin, map.get("dlogin").toString())); | |
78 | - if(null==chatgroup){ | |
79 | - //创建聊天群组 | |
80 | - chatgroup=addChatGroup(map,patient,doctor); | |
81 | - } | |
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 | + } | |
82 | 85 | |
83 | - if (null!=chatgroup) { | |
84 | - final List<LymsReturnVisitRecord> returnVisitRecords = lymsReturnVisitRecordService.list(new QueryWrapper<LymsReturnVisitRecord>() | |
85 | - .lambda().eq(LymsReturnVisitRecord::getPcid, (Integer)map.get("pcid"))); | |
86 | - List<LymsDoctor> doctorAminList= lymsDoctorService.list(new QueryWrapper<LymsDoctor>() | |
87 | - .lambda().eq(LymsDoctor::getDpid, doctor.getDpid()) | |
88 | - .in(LymsDoctor::getAdminType, Arrays.asList(1,2)) | |
89 | - .orderByAsc(LymsDoctor::getAdminType)); | |
90 | - int day = DateUtil.daysBetween(DateUtil.parseYMD(map.get("createdtime").toString()),new Date()); | |
91 | - switch (returnVisitRecords.size()) { | |
92 | - case 0: | |
93 | - if (day==2) { | |
94 | - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
95 | - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
96 | - int i=0; | |
97 | - for (LymsIllness lymsIllness : lymsIllnessList) { | |
98 | - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
99 | - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
100 | - .eq(LymsChatInfo::getType, 1)); | |
101 | - //推送回访 | |
102 | - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
103 | - JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), doctor.getDlogin()); | |
104 | - if (null!=jsonObject) { | |
105 | - i++; | |
106 | - //保存发送消息记录 | |
107 | - LymsMessage message=new LymsMessage(); | |
108 | - message.setContent(chatInfo.getConten()); | |
109 | - message.setFromid(doctor.getDlogin()); | |
110 | - message.setTargetid(chatgroup.getHxgroupid()); | |
111 | - message.setMtype("TEXT"); | |
112 | - message.setSendtime(new Date()); | |
113 | - message.setType(1); | |
114 | - lymsMessageService.save(message); | |
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 | + } | |
115 | 119 | } |
116 | 120 | } |
117 | - } | |
118 | - if (i!=0) { | |
119 | - //增加回访记录 | |
120 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
121 | - returnVisitRecord.setDlogin(doctor.getDlogin());//第二天,就诊医生自动回复 | |
122 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
123 | - returnVisitRecord.setIdno(patient.getIdno()); | |
124 | - returnVisitRecord.setType(0); | |
125 | - returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
126 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
127 | - chatgroup.setStat(0); | |
128 | - final boolean b = lymsChatgroupService.updateById(chatgroup); | |
129 | - if (!b) { | |
130 | - break; | |
131 | - } | |
132 | - //修改同一群组记录的状态 | |
133 | - final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
134 | - .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
135 | - for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
136 | - lymsTkrecord.setStat(0); | |
137 | - final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
138 | - if (!saveOrUpdate) { | |
139 | - break; | |
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("回滚状态,执行失败,请联系管理员"); | |
140 | 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 | + } | |
141 | 150 | } |
142 | 151 | } |
143 | - } | |
144 | - break; | |
145 | - case 1: | |
146 | - if (day==5) { | |
147 | - //获取值班护士 | |
148 | - String dlogin=""; | |
149 | - for (LymsDoctor lymsDoctor : doctorAminList) { | |
150 | - if (lymsDoctor.getAdminType()==2) { | |
151 | - dlogin=lymsDoctor.getDlogin(); | |
152 | - return; | |
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 | + } | |
153 | 162 | } |
154 | - } | |
155 | - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
156 | - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
157 | - int i=0; | |
158 | - for (LymsIllness lymsIllness : lymsIllnessList) { | |
159 | - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
160 | - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
161 | - .eq(LymsChatInfo::getType, 2)); | |
162 | - //推送回访 | |
163 | - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
164 | - JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
165 | - if (null!=jsonObject) { | |
166 | - i++; | |
167 | - //保存发送消息记录 | |
168 | - LymsMessage message=new LymsMessage(); | |
169 | - message.setContent(chatInfo.getConten()); | |
170 | - message.setFromid(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
171 | - message.setTargetid(chatgroup.getHxgroupid()); | |
172 | - message.setMtype("TEXT"); | |
173 | - message.setSendtime(new Date()); | |
174 | - message.setType(1); | |
175 | - lymsMessageService.save(message); | |
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 | + } | |
176 | 185 | } |
177 | 186 | } |
178 | - } | |
179 | - if (i!=0) { | |
180 | - //增加回访记录 | |
181 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
182 | - returnVisitRecord.setDlogin(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin);//第五天,值班护士自动回复 | |
183 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
184 | - returnVisitRecord.setIdno(patient.getIdno()); | |
185 | - returnVisitRecord.setType(0); | |
186 | - returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
187 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
188 | - chatgroup.setStat(0); | |
189 | - final boolean b = lymsChatgroupService.updateById(chatgroup); | |
190 | - if (!b) { | |
191 | - break; | |
192 | - } | |
193 | - //修改同一群组记录的状态 | |
194 | - final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
195 | - .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
196 | - for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
197 | - lymsTkrecord.setStat(0); | |
198 | - final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
199 | - if (!saveOrUpdate) { | |
200 | - break; | |
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("回滚状态,执行失败,请联系管理员"); | |
201 | 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 | + } | |
202 | 216 | } |
203 | 217 | } |
204 | - } | |
205 | - break; | |
206 | - case 2: | |
207 | - if (day==10) { | |
208 | - //获取值班医生 | |
209 | - String dlogin=""; | |
210 | - for (LymsDoctor lymsDoctor : doctorAminList) { | |
211 | - if (lymsDoctor.getAdminType()==1) { | |
212 | - dlogin=lymsDoctor.getDlogin(); | |
213 | - return; | |
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 | + } | |
214 | 228 | } |
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, 3)); | |
223 | - //推送回访 | |
224 | - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
225 | - JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
226 | - if (null!=jsonObject) { | |
227 | - i++; | |
228 | - //保存发送消息记录 | |
229 | - LymsMessage message=new LymsMessage(); | |
230 | - message.setContent(chatInfo.getConten()); | |
231 | - message.setFromid(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
232 | - message.setTargetid(chatgroup.getHxgroupid()); | |
233 | - message.setMtype("TEXT"); | |
234 | - message.setSendtime(new Date()); | |
235 | - message.setType(1); | |
236 | - lymsMessageService.save(message); | |
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 | + } | |
237 | 251 | } |
238 | 252 | } |
239 | - } | |
240 | - if (i!=0) { | |
241 | - //增加回访记录 | |
242 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
243 | - returnVisitRecord.setDlogin(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin);//第十天,值班医生自动回复 | |
244 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
245 | - returnVisitRecord.setIdno(patient.getIdno()); | |
246 | - returnVisitRecord.setType(0); | |
247 | - returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
248 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
249 | - chatgroup.setStat(0); | |
250 | - final boolean b = lymsChatgroupService.updateById(chatgroup); | |
251 | - if (!b) { | |
252 | - break; | |
253 | - } | |
254 | - //修改同一群组记录的状态 | |
255 | - final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
256 | - .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
257 | - for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
258 | - lymsTkrecord.setStat(0); | |
259 | - final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
260 | - if (!saveOrUpdate) { | |
261 | - break; | |
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("回滚状态,执行失败,请联系管理员"); | |
262 | 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 | + } | |
263 | 282 | } |
264 | 283 | } |
265 | - } | |
266 | - break; | |
267 | - case 3: | |
268 | - if (day==20) { | |
269 | - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
270 | - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
271 | - int i=0; | |
272 | - for (LymsIllness lymsIllness : lymsIllnessList) { | |
273 | - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
274 | - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
275 | - .eq(LymsChatInfo::getType, 4)); | |
276 | - //推送回访 | |
277 | - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
278 | - JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), doctor.getDlogin()); | |
279 | - if (null!=jsonObject) { | |
280 | - i++; | |
281 | - //保存发送消息记录 | |
282 | - LymsMessage message=new LymsMessage(); | |
283 | - message.setContent(chatInfo.getConten()); | |
284 | - message.setFromid(doctor.getDlogin()); | |
285 | - message.setTargetid(chatgroup.getHxgroupid()); | |
286 | - message.setMtype("TEXT"); | |
287 | - message.setSendtime(new Date()); | |
288 | - message.setType(1); | |
289 | - lymsMessageService.save(message); | |
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 | + } | |
290 | 309 | } |
291 | 310 | } |
292 | - } | |
293 | - if (i!=0) { | |
294 | - //增加回访记录 | |
295 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
296 | - returnVisitRecord.setDlogin(doctor.getDlogin());//第二十天,就诊医生自动回复 | |
297 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
298 | - returnVisitRecord.setIdno(patient.getIdno()); | |
299 | - returnVisitRecord.setType(0); | |
300 | - returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
301 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
302 | - chatgroup.setStat(0); | |
303 | - final boolean b = lymsChatgroupService.updateById(chatgroup); | |
304 | - if (!b) { | |
305 | - break; | |
306 | - } | |
307 | - //修改同一群组记录的状态 | |
308 | - final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
309 | - .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
310 | - for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
311 | - lymsTkrecord.setStat(0); | |
312 | - final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
313 | - if (!saveOrUpdate) { | |
314 | - break; | |
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("回滚状态,执行失败,请联系管理员"); | |
315 | 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 | + } | |
316 | 340 | } |
317 | 341 | } |
318 | - } | |
319 | - break; | |
320 | - case 4: | |
321 | - if (day==30) { | |
322 | - //获取值班医生 | |
323 | - String dlogin=""; | |
324 | - for (LymsDoctor lymsDoctor : doctorAminList) { | |
325 | - if (lymsDoctor.getAdminType()==1) { | |
326 | - dlogin=lymsDoctor.getDlogin(); | |
327 | - return; | |
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 | + } | |
328 | 352 | } |
329 | - } | |
330 | - final List<LymsIllness> lymsIllnessList = lymsIllnessService.list(new QueryWrapper<LymsIllness>() | |
331 | - .lambda().eq(LymsIllness::getPcid, (Integer) map.get("pcid"))); | |
332 | - int i=0; | |
333 | - for (LymsIllness lymsIllness : lymsIllnessList) { | |
334 | - final LymsChatInfo chatInfo = lymsChatInfoService.getOne(new QueryWrapper<LymsChatInfo>() | |
335 | - .lambda().eq(LymsChatInfo::getIllid, lymsIllness.getIid()) | |
336 | - .eq(LymsChatInfo::getType, 5)); | |
337 | - //推送回访 | |
338 | - if (null!=chatInfo && StringUtil.isNotEmpty(chatgroup.getHxgroupid()) && null!=doctor) { | |
339 | - JSONObject jsonObject = hxService.sendGroupMsg(new String[]{chatgroup.getHxgroupid()}, chatInfo.getConten(), StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
340 | - if (null!=jsonObject) { | |
341 | - i++; | |
342 | - //保存发送消息记录 | |
343 | - LymsMessage message=new LymsMessage(); | |
344 | - message.setContent(chatInfo.getConten()); | |
345 | - message.setFromid(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin); | |
346 | - message.setTargetid(chatgroup.getHxgroupid()); | |
347 | - message.setMtype("TEXT"); | |
348 | - message.setSendtime(new Date()); | |
349 | - message.setType(1); | |
350 | - lymsMessageService.save(message); | |
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 | + } | |
351 | 375 | } |
352 | 376 | } |
353 | - } | |
354 | - if (i!=0) { | |
355 | - //增加回访记录 | |
356 | - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord(); | |
357 | - returnVisitRecord.setDlogin(StringUtil.isEmpty(dlogin)? doctor.getDlogin():dlogin);//第三十天,值班医生自动回复 | |
358 | - returnVisitRecord.setDpid(doctor.getDpid()); | |
359 | - returnVisitRecord.setIdno(patient.getIdno()); | |
360 | - returnVisitRecord.setType(0); | |
361 | - returnVisitRecord.setHxgroupid(chatgroup.getHxgroupid()); | |
362 | - lymsReturnVisitRecordService.save(returnVisitRecord); | |
363 | - chatgroup.setStat(0); | |
364 | - final boolean b = lymsChatgroupService.updateById(chatgroup); | |
365 | - if (!b) { | |
366 | - break; | |
367 | - } | |
368 | - //修改同一群组记录的状态 | |
369 | - final List<LymsTkrecord> tkrecordList = lymsTkrecordService.list(new QueryWrapper<LymsTkrecord>() | |
370 | - .lambda().eq(LymsTkrecord::getHxgroupid, chatgroup.getHxgroupid())); | |
371 | - for (LymsTkrecord lymsTkrecord : tkrecordList) { | |
372 | - lymsTkrecord.setStat(0); | |
373 | - final boolean saveOrUpdate = lymsTkrecordService.updateById(lymsTkrecord); | |
374 | - if (!saveOrUpdate) { | |
375 | - break; | |
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("回滚状态,执行失败,请联系管理员"); | |
376 | 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 | + } | |
377 | 406 | } |
378 | 407 | } |
379 | - } | |
380 | - break; | |
408 | + break; | |
409 | + } | |
381 | 410 | } |
411 | + } catch (Exception e) { | |
412 | + e.printStackTrace(); | |
413 | + throw new RuntimeException("回滚状态,执行失败,请联系管理员"); | |
382 | 414 | } |
383 | 415 | } |
384 | 416 | } |