Commit 30dfcca6b9bee266a8f7658c06ef86c9c0b01b15

Authored by zhangchao
1 parent 010564087b
Exists in dev

#fix 新增医生回复消息提醒、增加自动同步his病例、新增工作通知模块

Showing 27 changed files with 956 additions and 342 deletions

talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/ChatGroupController.java View file @ 30dfcca
Diff suppressed. Click to show
... ... @@ -12,13 +12,11 @@
12 12 import com.lyms.talkonlineweb.constants.ErrorCodeConstants;
13 13 import com.lyms.talkonlineweb.domain.*;
14 14 import com.lyms.talkonlineweb.enums.MessageEnum;
  15 +import com.lyms.talkonlineweb.param.DataEntity;
15 16 import com.lyms.talkonlineweb.request.MsgDelParam;
16 17 import com.lyms.talkonlineweb.result.BaseResponse;
17 18 import com.lyms.talkonlineweb.service.*;
18   -import com.lyms.talkonlineweb.util.Constant;
19   -import com.lyms.talkonlineweb.util.DateUtil;
20   -import com.lyms.talkonlineweb.util.HXService;
21   -import com.lyms.talkonlineweb.util.StringUtil;
  19 +import com.lyms.talkonlineweb.util.*;
22 20 import lombok.extern.log4j.Log4j2;
23 21 import org.apache.commons.io.IOUtils;
24 22 import org.apache.commons.lang3.StringUtils;
... ... @@ -33,6 +31,7 @@
33 31 import java.io.IOException;
34 32 import java.nio.charset.Charset;
35 33 import java.util.*;
  34 +import java.util.concurrent.*;
36 35  
37 36 @RestController
38 37 @RequestMapping("chat")
39 38  
40 39  
41 40  
42 41  
... ... @@ -84,25 +83,25 @@
84 83 @TokenRequired
85 84 public BaseResponse saveChatGroup(@RequestBody LymsChatgroup group) {
86 85 BaseResponse baseResponse = new BaseResponse();
87   - String retDlogin=group.getRetDlogin();
  86 + String retDlogin = group.getRetDlogin();
88 87 List<LymsChatgroup> gLst = lymsChatgroupService.list(Wrappers.query(group).orderByDesc("id"));
89 88 if (group.getOwnerk() == null) {
90 89 group.setOwnerk(hxuser);
91 90 }
92   - LymsPatient patient= lymsPatientService.getOne(new QueryWrapper<LymsPatient>()
  91 + LymsPatient patient = lymsPatientService.getOne(new QueryWrapper<LymsPatient>()
93 92 .lambda().eq(LymsPatient::getIdno, group.getFromp()));
94   - LymsDoctor doctor= lymsDoctorService.getOne(new QueryWrapper<LymsDoctor>()
  93 + LymsDoctor doctor = lymsDoctorService.getOne(new QueryWrapper<LymsDoctor>()
95 94 .lambda().eq(LymsDoctor::getDlogin, group.getTarget()));
96 95 if (gLst.size() > 0) {
97 96 LymsChatgroup group2 = gLst.get(0);
98 97 group = group2;
99 98 //回访的状态才去执行(上次关闭了再次点击会开启)
100   - if (1==group.getType()&&group.getStat()==1) {
  99 + if (1 == group.getType() && group.getStat() == 1) {
101 100 group.setStat(0);
102 101 //修改群组状态
103 102 lymsChatgroupService.updateById(group);
104 103 //添加回访记录
105   - LymsReturnVisitRecord returnVisitRecord=new LymsReturnVisitRecord();
  104 + LymsReturnVisitRecord returnVisitRecord = new LymsReturnVisitRecord();
106 105 returnVisitRecord.setDlogin(retDlogin);//前端传的当前登录医生账号
107 106 returnVisitRecord.setDpid(doctor.getDpid());
108 107 returnVisitRecord.setIdno(patient.getIdno());
... ... @@ -112,7 +111,7 @@
112 111 lymsReturnVisitRecordService.save(returnVisitRecord);
113 112 }
114 113 //患者消费问诊卡 咨询结束后
115   - if(0==group.getType()){
  114 + if (0 == group.getType()) {
116 115  
117 116 group.setType(1);
118 117 lymsChatgroupService.updateById(group);
119 118  
120 119  
121 120  
122 121  
123 122  
... ... @@ -127,28 +126,28 @@
127 126 lymsReturnVisitRecordService.save(returnVisitRecord2);
128 127 }
129 128 } else {
130   - List<String> adminDlogins=new ArrayList<>();
  129 + List<String> adminDlogins = new ArrayList<>();
131 130 adminDlogins.add(group.getFromp());
132   - List<String> groupnames=new ArrayList<>();
  131 + List<String> groupnames = new ArrayList<>();
133 132 groupnames.add(patient.getPname());
134 133 //患者注册环信
135 134 if (StringUtil.isEmpty(patient.getHxid())) {
136 135 patient = lymsPatientService.addPatientHxId(patient);
137 136 }
138 137 //查询值班医生
139   - List<LymsDoctor> doctorAminList= lymsDoctorService.list(new QueryWrapper<LymsDoctor>()
  138 + List<LymsDoctor> doctorAminList = lymsDoctorService.list(new QueryWrapper<LymsDoctor>()
140 139 .lambda().eq(LymsDoctor::getDpid, doctor.getDpid())
141   - .in(LymsDoctor::getAdminType, new int[]{1,2})
  140 + .in(LymsDoctor::getAdminType, new int[]{1, 2})
142 141 .orderByAsc(LymsDoctor::getAdminType));
143 142 //科室值班医生注册环信
144 143 for (LymsDoctor lymsDoctor : doctorAminList) {
145   - if(StringUtil.isEmpty(lymsDoctor.getHxid())) {
  144 + if (StringUtil.isEmpty(lymsDoctor.getHxid())) {
146 145 lymsDoctorService.addDoctorHxId(lymsDoctor);
147 146 }
148 147 adminDlogins.add(lymsDoctor.getDlogin());
149 148 groupnames.add(lymsDoctor.getDname());
150 149 }
151   - if ( ! adminDlogins.contains(doctor.getDlogin())) {
  150 + if (!adminDlogins.contains(doctor.getDlogin())) {
152 151 //医生注册环信
153 152 if (StringUtil.isEmpty(doctor.getHxid())) {
154 153 lymsDoctorService.addDoctorHxId(doctor);
... ... @@ -191,6 +190,7 @@
191 190  
192 191 /**
193 192 * 查询聊天历史记录(本地)
  193 + *
194 194 * @param targetId 分组ID
195 195 * @param current
196 196 * @param size
197 197  
198 198  
199 199  
200 200  
... ... @@ -198,17 +198,17 @@
198 198 */
199 199 @GetMapping("getHistoryLogs")
200 200 @TokenRequired
201   - public BaseResponse getHistoryLogs(String targetId,Integer current, Integer size){
  201 + public BaseResponse getHistoryLogs(String targetId, Integer current, Integer size) {
202 202  
203   - if (StringUtil.isEmpty(targetId)){
  203 + if (StringUtil.isEmpty(targetId)) {
204 204 return BaseResponse.error("聊天组ID不能为空");
205 205 }
206 206 BaseResponse baseResponse = new BaseResponse();
207   - Page<LymsMessage> page = new Page(current,size);
  207 + Page<LymsMessage> page = new Page(current, size);
208 208 QueryWrapper<LymsMessage> query = new QueryWrapper();
209   - query.eq("targetid",targetId);
  209 + query.eq("targetid", targetId);
210 210 query.orderByDesc("sendtime");
211   - page=lymsMessageService.page(page,query);
  211 + page = lymsMessageService.page(page, query);
212 212 baseResponse.setObject(page);
213 213 baseResponse.setErrorcode(0);
214 214 baseResponse.setErrormsg("成功");
215 215  
... ... @@ -221,12 +221,12 @@
221 221  
222 222  
223 223 boolean b = hxService.recallMsg(msgDelParam);
224   - if(b){
  224 + if (b) {
225 225 QueryWrapper<LymsMessage> queryWrapper = new QueryWrapper<>();
226   - queryWrapper.eq("hx_msg_id",msgDelParam.getMsg_id());
227   - queryWrapper.eq("yn",1);
228   - LymsMessage lymsMessage = lymsMessageService.getOne(queryWrapper,false);
229   - if(lymsMessage != null){
  226 + queryWrapper.eq("hx_msg_id", msgDelParam.getMsg_id());
  227 + queryWrapper.eq("yn", 1);
  228 + LymsMessage lymsMessage = lymsMessageService.getOne(queryWrapper, false);
  229 + if (lymsMessage != null) {
230 230 LymsMessage m = new LymsMessage();
231 231 m.setId(lymsMessage.getId());
232 232 m.setYn(0);
... ... @@ -239,6 +239,7 @@
239 239  
240 240 /**
241 241 * 根据群组ID获取患者和医生信息
  242 + *
242 243 * @param chatgroup
243 244 * @return
244 245 */
245 246  
... ... @@ -249,11 +250,11 @@
249 250 BaseResponse baseResponse = new BaseResponse();
250 251 Map<String, Object> rs = new HashMap<>();
251 252 //不作为条件查询
252   - Integer type=chatgroup.getType();
  253 + Integer type = chatgroup.getType();
253 254 chatgroup.setType(null);
254 255 List<LymsChatgroup> gLst = lymsChatgroupService.list(Wrappers.query(chatgroup).orderByDesc("id"));
255 256  
256   - if (gLst.size()>0){
  257 + if (gLst.size() > 0) {
257 258 chatgroup = gLst.get(0);
258 259 }
259 260 LymsDoctor doctor = new LymsDoctor();
260 261  
261 262  
262 263  
263 264  
264 265  
... ... @@ -266,25 +267,25 @@
266 267  
267 268 List<Map<String, Object>> tmpList = lymsChatgroupService.getPinfoBySesson(null, doctor.getDid().toString(), chatgroup.getHxgroupid());
268 269 if (tmpList.size() > 0) {
269   - if(null==type) {
  270 + if (null == type) {
270 271 rs.put("sess", tmpList.get(0));
271   - }else {
  272 + } else {
272 273 //修改为恢复聊天状态
273   - LymsTkrecord tkrecord=new LymsTkrecord();
  274 + LymsTkrecord tkrecord = new LymsTkrecord();
274 275 tkrecord.setId((Integer) tmpList.get(0).get("rid"));
275 276 tkrecord.setStat(0);
276 277 lymsTkrecordService.updateById(tkrecord);
277   - if (chatgroup.getId()!=null){
  278 + if (chatgroup.getId() != null) {
278 279 chatgroup.setStat(0);
279 280 lymsChatgroupService.updateById(chatgroup);
280 281 }
281 282 tmpList.get(0).put("stat", 0);
282 283 rs.put("sess", tmpList.get(0));
283 284 }
284   - }else {
  285 + } else {
285 286 //防止重复创建组
286   - if(null!=type && 1==type && CollectionUtils.isNotEmpty(gLst)){
287   - Map<String, Object> map=new HashMap<>();
  287 + if (null != type && 1 == type && CollectionUtils.isNotEmpty(gLst)) {
  288 + Map<String, Object> map = new HashMap<>();
288 289 map.put("stat", 0);
289 290 rs.put("sess", tmpList.add(map));
290 291 }
... ... @@ -321,8 +322,8 @@
321 322 /**
322 323 * 医生端--回话会话列表获取患者信息
323 324 *
324   - * @param froms 发送人员ID
325   - * @param did 问诊医生ID
  325 + * @param froms 发送人员ID
  326 + * @param did 问诊医生ID
326 327 * @param groupid 群组ID
327 328 * @return
328 329 */
329 330  
330 331  
331 332  
332 333  
333 334  
... ... @@ -345,27 +346,27 @@
345 346 @PostMapping("getChatList")
346 347 @TokenRequired
347 348 public BaseResponse getSessionListInfoNew(HttpServletRequest request) {
348   - JSONArray rs=new JSONArray();
349   - try{
  349 + JSONArray rs = new JSONArray();
  350 + try {
350 351 request.setCharacterEncoding("utf-8");
351   - String res=IOUtils.toString(request.getInputStream(),Charset.forName("UTF-8"));
352   - JSONObject jsonObject= JSON.parseObject(res);
353   - JSONArray conversations =jsonObject.getJSONArray("conversations");
354   - if(conversations == null || conversations.size()==0) {
  352 + String res = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8"));
  353 + JSONObject jsonObject = JSON.parseObject(res);
  354 + JSONArray conversations = jsonObject.getJSONArray("conversations");
  355 + if (conversations == null || conversations.size() == 0) {
355 356 return BaseResponse.error("参数错误");
356 357 }
357 358  
358   - for(int i = 0,size = conversations.size();i< size;i++){
  359 + for (int i = 0, size = conversations.size(); i < size; i++) {
359 360 JSONObject conversation = conversations.getJSONObject(i);
360 361 JSONObject lastMessage = conversation.getJSONObject("lastMessage");
361   - lastMessage.put("unReadCount",conversation.getInteger("unReadCount"));
  362 + lastMessage.put("unReadCount", conversation.getInteger("unReadCount"));
362 363 String hxgroupid = lastMessage.getString("to");
363 364  
364 365 QueryWrapper<LymsChatgroup> groupQuery = new QueryWrapper<>();
365   - groupQuery.eq("hxgroupid",hxgroupid);
366   - LymsChatgroup chatgroup = lymsChatgroupService.getOne(groupQuery);
  366 + groupQuery.eq("hxgroupid", hxgroupid);
  367 + LymsChatgroup chatgroup = lymsChatgroupService.getOne(groupQuery);
367 368 //如果环信有聊天组信息,本地数据库中没有,则不显示(该情况可能是本地测试删除了数据)
368   - if(chatgroup == null){
  369 + if (chatgroup == null) {
369 370 continue;
370 371 }
371 372  
... ... @@ -398,8 +399,8 @@
398 399  
399 400 }
400 401  
401   - }catch (Exception e){
402   - log.error("",e);
  402 + } catch (Exception e) {
  403 + log.error("", e);
403 404 }
404 405 return BaseResponse.ok(rs);
405 406 }
406 407  
407 408  
408 409  
409 410  
410 411  
411 412  
412 413  
413 414  
414 415  
415 416  
416 417  
417 418  
418 419  
... ... @@ -408,58 +409,58 @@
408 409 @TokenRequired
409 410 public BaseResponse getChatgroupListInfoNew(@RequestParam("excludeGroups") List<String> excludeGroups, int current, int size) {
410 411 List<JSONObject> rs = new ArrayList<>();
411   - LambdaQueryWrapper<LymsChatgroup> chatgroupQueryWrapper=new QueryWrapper().lambda();
412   - if(CollectionUtils.isNotEmpty(excludeGroups)){
413   - chatgroupQueryWrapper.notIn(LymsChatgroup::getHxgroupid,excludeGroups);
  412 + LambdaQueryWrapper<LymsChatgroup> chatgroupQueryWrapper = new QueryWrapper().lambda();
  413 + if (CollectionUtils.isNotEmpty(excludeGroups)) {
  414 + chatgroupQueryWrapper.notIn(LymsChatgroup::getHxgroupid, excludeGroups);
414 415 }
415   - chatgroupQueryWrapper.eq(LymsChatgroup::getYn,1)
  416 + chatgroupQueryWrapper.eq(LymsChatgroup::getYn, 1)
416 417 .orderByDesc(LymsChatgroup::getCtime);
417   - Page<LymsChatgroup> chatGroupPage = new Page<>(current,size);
  418 + Page<LymsChatgroup> chatGroupPage = new Page<>(current, size);
418 419 chatGroupPage = lymsChatgroupService.page(chatGroupPage, chatgroupQueryWrapper);
419   - for(LymsChatgroup lymsChatgroup : chatGroupPage.getRecords() ){
  420 + for (LymsChatgroup lymsChatgroup : chatGroupPage.getRecords()) {
420 421 //患者信息
421   - LambdaQueryWrapper<LymsPatient> patientQueryWrapper=new QueryWrapper().lambda();
  422 + LambdaQueryWrapper<LymsPatient> patientQueryWrapper = new QueryWrapper().lambda();
422 423 patientQueryWrapper.eq(LymsPatient::getIdno, lymsChatgroup.getFromp());
423 424 LymsPatient patient = lymsPatientService.getOne(patientQueryWrapper);
424   - if (null==patient) {
  425 + if (null == patient) {
425 426 continue;
426 427 }
427 428 //医生信息
428   - LambdaQueryWrapper<AppgetdoctorlistInfo> appgetdoctorlistInfoQueryWrapper=new QueryWrapper().lambda();
  429 + LambdaQueryWrapper<AppgetdoctorlistInfo> appgetdoctorlistInfoQueryWrapper = new QueryWrapper().lambda();
429 430 appgetdoctorlistInfoQueryWrapper.eq(AppgetdoctorlistInfo::getDlogin, lymsChatgroup.getTarget());
430 431 List<AppgetdoctorlistInfo> dLst = appgetdoctorlistInfoService.list(appgetdoctorlistInfoQueryWrapper);
431   - if (dLst.size()==0) {
  432 + if (dLst.size() == 0) {
432 433 continue;
433 434 }
434 435  
435 436 //聊天记录
436   - LambdaQueryWrapper<LymsMessage> messageQueryWrapper=new QueryWrapper().lambda();
  437 + LambdaQueryWrapper<LymsMessage> messageQueryWrapper = new QueryWrapper().lambda();
437 438 messageQueryWrapper.eq(LymsMessage::getTargetid, lymsChatgroup.getHxgroupid())
438   - .eq(LymsMessage::getYn,1)
  439 + .eq(LymsMessage::getYn, 1)
439 440 .orderByDesc(LymsMessage::getSendtime)
440 441 .last(" limit 1");
441 442 final List<LymsMessage> lymsMessageList = lymsMessageService.list(messageQueryWrapper);
442   - if(lymsMessageList.size() == 0){
  443 + if (lymsMessageList.size() == 0) {
443 444 continue;
444 445 }
445 446  
446 447 LymsMessage lymsMessage = lymsMessageList.get(0);
447 448  
448 449 JSONObject reusltJsonObject = new JSONObject();
449   - reusltJsonObject.put("unReadCount",0);
450   - reusltJsonObject.put("stat",lymsChatgroup.getStat());
451   - reusltJsonObject.put("pat",patient);
452   - reusltJsonObject.put("msg",lymsMessage.getContent());
  450 + reusltJsonObject.put("unReadCount", 0);
  451 + reusltJsonObject.put("stat", lymsChatgroup.getStat());
  452 + reusltJsonObject.put("pat", patient);
  453 + reusltJsonObject.put("msg", lymsMessage.getContent());
453 454 reusltJsonObject.put("type", MessageEnum.getName(lymsMessage.getMtype()));
454   - reusltJsonObject.put("doc",dLst.get(0));
455   - reusltJsonObject.put("from",lymsChatgroup.getFromp());
456   - reusltJsonObject.put("to",lymsChatgroup.getHxgroupid());
457   - reusltJsonObject.put("chatType","groupchat");
458   - reusltJsonObject.put("time",lymsMessage.getSendtime().getTime());
  455 + reusltJsonObject.put("doc", dLst.get(0));
  456 + reusltJsonObject.put("from", lymsChatgroup.getFromp());
  457 + reusltJsonObject.put("to", lymsChatgroup.getHxgroupid());
  458 + reusltJsonObject.put("chatType", "groupchat");
  459 + reusltJsonObject.put("time", lymsMessage.getSendtime().getTime());
459 460 rs.add(reusltJsonObject);
460 461 }
461 462  
462   - Page<JSONObject> returnPage = new Page(current,size);
  463 + Page<JSONObject> returnPage = new Page(current, size);
463 464 returnPage.setTotal(chatGroupPage.getTotal());
464 465 returnPage.setRecords(rs);
465 466 return BaseResponse.ok(returnPage);
... ... @@ -467,6 +468,7 @@
467 468  
468 469 /**
469 470 * 根据环信传入的会话,获取用户信息
  471 + *
470 472 * @param request
471 473 * @return
472 474 */
473 475  
474 476  
... ... @@ -475,14 +477,14 @@
475 477 public BaseResponse getSessionListInfo(HttpServletRequest request) {
476 478 BaseResponse baseResponse = new BaseResponse();
477 479 log.info(">>>>>>>>> getSessionListInfo 根据环信传入的会话,获取用户信息");
478   - JSONArray rs=new JSONArray();
  480 + JSONArray rs = new JSONArray();
479 481 try {
480 482 request.setCharacterEncoding("utf-8");
481   - String res=IOUtils.toString(request.getInputStream(),Charset.forName("UTF-8"));
  483 + String res = IOUtils.toString(request.getInputStream(), Charset.forName("UTF-8"));
482 484 log.info(res);
483   - JSONObject jsonObject= JSON.parseObject(res);
484   - JSONArray channel_infos=jsonObject.getJSONArray("channel_infos");
485   - if(channel_infos.size()>0) {
  485 + JSONObject jsonObject = JSON.parseObject(res);
  486 + JSONArray channel_infos = jsonObject.getJSONArray("channel_infos");
  487 + if (channel_infos.size() > 0) {
486 488 for (int i = 0; i < channel_infos.size(); i++) {
487 489 JSONObject row = channel_infos.getJSONObject(i);
488 490  
... ... @@ -505,7 +507,7 @@
505 507 List<LymsChatgroup> cLst = lymsChatgroupService.list(Wrappers.query(chatgroup));
506 508  
507 509 //如果环信有聊天组信息,本地数据库中没有,则不显示(该情况可能是本地测试删除了数据)
508   - if(CollectionUtils.isEmpty(cLst)){
  510 + if (CollectionUtils.isEmpty(cLst)) {
509 511 continue;
510 512 }
511 513  
... ... @@ -539,7 +541,7 @@
539 541 getChatRecord(rs, jsonObject);
540 542  
541 543 } catch (IOException e) {
542   - log.error("getSessionListInfo exception",e);
  544 + log.error("getSessionListInfo exception", e);
543 545 }
544 546 baseResponse.setObject(rs);
545 547 return baseResponse;
546 548  
547 549  
548 550  
549 551  
550 552  
551 553  
552 554  
553 555  
554 556  
555 557  
556 558  
557 559  
558 560  
559 561  
560 562  
561 563  
562 564  
563 565  
564 566  
565 567  
566 568  
567 569  
568 570  
569 571  
570 572  
571 573  
572 574  
573 575  
... ... @@ -547,125 +549,129 @@
547 549  
548 550 /**
549 551 * 获取聊天群组,组装数据
550   - * @param rs 最后的结果
  552 + *
  553 + * @param rs 最后的结果
551 554 * @param jsonObject 参数集合
552 555 */
553   - public void getChatRecord(JSONArray rs,JSONObject jsonObject){
  556 + public void getChatRecord(JSONArray rs, JSONObject jsonObject) {
554 557 //环信组id
555   - JSONArray groupData=jsonObject.getJSONArray("groupData");
556   - List<String> groupidList=new ArrayList<>();
  558 + JSONArray groupData = jsonObject.getJSONArray("groupData");
  559 + List<String> groupidList = new ArrayList<>();
557 560 for (Object groupDatum : groupData) {
558 561 groupidList.add(((JSONObject) JSON.toJSON(groupDatum)).get("groupid").toString());
559 562 }
560 563  
561 564 //如果结果集中包含了该聊天组,过滤掉
562   - for (int i=0;i< rs.size(); i++) {
  565 + for (int i = 0; i < rs.size(); i++) {
563 566 JSONObject rjson = (JSONObject) JSON.toJSON(rs.get(i));
564   - if(groupidList.contains(rjson.get("to").toString())){
  567 + if (groupidList.contains(rjson.get("to").toString())) {
565 568 groupidList.remove(rjson.get("to").toString());
566 569 }
567 570 }
568   - if(groupidList.size() == 0){
  571 + if (groupidList.size() == 0) {
569 572 return;
570 573 }
571 574  
572   - LambdaQueryWrapper<LymsChatgroup> chatgroupQueryWrapper=new QueryWrapper().lambda();
573   - chatgroupQueryWrapper.in(LymsChatgroup::getHxgroupid,groupidList);
574   - List<LymsChatgroup> chatgroupList=lymsChatgroupService.list(chatgroupQueryWrapper);
  575 + LambdaQueryWrapper<LymsChatgroup> chatgroupQueryWrapper = new QueryWrapper().lambda();
  576 + chatgroupQueryWrapper.in(LymsChatgroup::getHxgroupid, groupidList);
  577 + List<LymsChatgroup> chatgroupList = lymsChatgroupService.list(chatgroupQueryWrapper);
575 578 for (LymsChatgroup lymsChatgroup : chatgroupList) {
576 579 //组装结果
577 580 JSONObject reusltJsonObject = new JSONObject();
578   - reusltJsonObject.put("unread_num",0);
579   - reusltJsonObject.put("stat",lymsChatgroup.getStat());
  581 + reusltJsonObject.put("unread_num", 0);
  582 + reusltJsonObject.put("stat", lymsChatgroup.getStat());
580 583 //患者信息
581   - LambdaQueryWrapper<LymsPatient> patientQueryWrapper=new QueryWrapper().lambda();
  584 + LambdaQueryWrapper<LymsPatient> patientQueryWrapper = new QueryWrapper().lambda();
582 585 patientQueryWrapper.eq(LymsPatient::getIdno, lymsChatgroup.getFromp());
583 586 LymsPatient patient = lymsPatientService.getOne(patientQueryWrapper);
584   - if (null==patient) {
  587 + if (null == patient) {
585 588 continue;
586 589 }
587   - reusltJsonObject.put("pat",patient);
  590 + reusltJsonObject.put("pat", patient);
588 591 //聊天记录
589   - LambdaQueryWrapper<LymsMessage> messageQueryWrapper=new QueryWrapper().lambda();
  592 + LambdaQueryWrapper<LymsMessage> messageQueryWrapper = new QueryWrapper().lambda();
590 593 messageQueryWrapper.eq(LymsMessage::getTargetid, lymsChatgroup.getHxgroupid());
591   - messageQueryWrapper.eq(LymsMessage::getYn,1);
  594 + messageQueryWrapper.eq(LymsMessage::getYn, 1);
592 595 messageQueryWrapper.orderByDesc(LymsMessage::getSendtime).last(" limit 1");
593 596 final List<LymsMessage> lymsMessageList = lymsMessageService.list(messageQueryWrapper);
594   - Map map=new HashMap();
595   - map.put("msg",lymsMessageList.size()>0?lymsMessageList.get(0).getContent():"");
596   - map.put("type","txt");
597   - reusltJsonObject.put("bodies",Arrays.asList(map));
  597 + Map map = new HashMap();
  598 + map.put("msg", lymsMessageList.size() > 0 ? lymsMessageList.get(0).getContent() : "");
  599 + map.put("type", "txt");
  600 + reusltJsonObject.put("bodies", Arrays.asList(map));
598 601 //医生信息
599   - LambdaQueryWrapper<AppgetdoctorlistInfo> appgetdoctorlistInfoQueryWrapper=new QueryWrapper().lambda();
  602 + LambdaQueryWrapper<AppgetdoctorlistInfo> appgetdoctorlistInfoQueryWrapper = new QueryWrapper().lambda();
600 603 appgetdoctorlistInfoQueryWrapper.eq(AppgetdoctorlistInfo::getDlogin, lymsChatgroup.getTarget());
601 604 List<AppgetdoctorlistInfo> dLst = appgetdoctorlistInfoService.list(appgetdoctorlistInfoQueryWrapper);
602   - if (dLst.size()==0) {
  605 + if (dLst.size() == 0) {
603 606 continue;
604 607 }
605   - reusltJsonObject.put("doc",dLst.get(0));
606   - reusltJsonObject.put("from",lymsChatgroup.getFromp());
607   - reusltJsonObject.put("to",lymsChatgroup.getHxgroupid());
608   - reusltJsonObject.put("type","groupchat");
609   - reusltJsonObject.put("timestamp",lymsMessageList.size()>0?lymsMessageList.get(0).getSendtime().getTime():"");
  608 + reusltJsonObject.put("doc", dLst.get(0));
  609 + reusltJsonObject.put("from", lymsChatgroup.getFromp());
  610 + reusltJsonObject.put("to", lymsChatgroup.getHxgroupid());
  611 + reusltJsonObject.put("type", "groupchat");
  612 + reusltJsonObject.put("timestamp", lymsMessageList.size() > 0 ? lymsMessageList.get(0).getSendtime().getTime() : "");
610 613 rs.add(reusltJsonObject);
611 614 }
612 615  
613 616 }
614 617  
615 618 /**
616   - * 获取专家组\客服人员信息
  619 + * 获取专家组\客服人员信息
  620 + *
617 621 * @param request
618 622 * @return
619 623 */
620 624 @GetMapping("getPreMsg")
621 625 @TokenRequired
622   - public BaseResponse getPreMsg(HttpServletRequest request){
623   - BaseResponse baseResponse =new BaseResponse();
624   - Map<String,Object> param=new HashMap<>();
625   - param.put("vtype",998);
626   - List<LymsDict> dLst=lymsDictService.listByMap(param);
627   - if(dLst.size()>0){
  626 + public BaseResponse getPreMsg(HttpServletRequest request) {
  627 + BaseResponse baseResponse = new BaseResponse();
  628 + Map<String, Object> param = new HashMap<>();
  629 + param.put("vtype", 998);
  630 + List<LymsDict> dLst = lymsDictService.listByMap(param);
  631 + if (dLst.size() > 0) {
628 632 baseResponse.setObject(dLst.get(0));
629 633 }
630 634 return baseResponse;
631 635 }
  636 +
632 637 /**
633   - * 医生端获取自己的患者列表
634   - * @param doctorId 医生id
635   - * @param current 页数
636   - * @param size 条数
  638 + * 医生端获取自己的患者列表
  639 + *
  640 + * @param doctorId 医生id
  641 + * @param current 页数
  642 + * @param size 条数
637 643 * @param synthesisQuery 综合筛选条件
638   - * @param did 科室id 值班医生/值班护士 时需要传。doctorId 就不能传
  644 + * @param did 科室id 值班医生/值班护士 时需要传。doctorId 就不能传
639 645 * @return
640 646 */
641 647 @GetMapping("getDoctorPatient")
642 648 @TokenRequired
643   - public BaseResponse getDoctorPatient(Integer doctorId,Integer current, Integer size,String synthesisQuery,
644   - Integer did){
645   - BaseResponse baseResponse =new BaseResponse();
646   - if((null==doctorId && null==did)||(null!=doctorId && null!=did)){
  649 + public BaseResponse getDoctorPatient(Integer doctorId, Integer current, Integer size, String synthesisQuery,
  650 + Integer did) {
  651 + BaseResponse baseResponse = new BaseResponse();
  652 + if ((null == doctorId && null == did) || (null != doctorId && null != did)) {
647 653 baseResponse.setErrorcode(ErrorCodeConstants.PARAMETER_ERROR);
648 654 baseResponse.setErrormsg("参数错误");
649 655 return baseResponse;
650 656 }
651   - Page<Map<String,Object>> page=new Page<>(current,size);
652   - QueryWrapper queryWrapper=new QueryWrapper<>();
653   - if(null!=did){
  657 + Page<Map<String, Object>> page = new Page<>(current, size);
  658 + QueryWrapper queryWrapper = new QueryWrapper<>();
  659 + if (null != did) {
654 660 //科室下的患者
655 661 queryWrapper.eq("pc.did", did);
656   - }else {
  662 + } else {
657 663 //医生下的患者
658 664 queryWrapper.eq("pc.dtid", doctorId);
659 665 }
660   - if (StringUtil.isNotEmpty(synthesisQuery)){
  666 + if (StringUtil.isNotEmpty(synthesisQuery)) {
661 667 queryWrapper.like("p.pname", synthesisQuery);
662 668 }
663   - List<Map<String,Object>> list=lymsChatgroupService.getDoctorPatient(page,queryWrapper);
  669 + List<Map<String, Object>> list = lymsChatgroupService.getDoctorPatient(page, queryWrapper);
664 670 for (Map<String, Object> map : list) {
665   - if(map.get("sex")!=null) {
666   - map.put("sex",(int)map.get("sex")==1?"男":"女");
  671 + if (map.get("sex") != null) {
  672 + map.put("sex", (int) map.get("sex") == 1 ? "男" : "女");
667 673 }
668   - if(map.get("birth")!=null){
  674 + if (map.get("birth") != null) {
669 675 map.put("birth", DateUtil.getAge(DateUtil.parseYMD(map.get("birth").toString())));
670 676 }
671 677 }
672 678  
... ... @@ -675,14 +681,15 @@
675 681 }
676 682  
677 683 /**
678   - * 前端3秒执行一次调用。聊天室状态(患者、医生分别查询)
  684 + * 前端3秒执行一次调用。聊天室状态(患者、医生分别查询)
  685 + *
679 686 * @param groupId
680 687 * @return
681 688 */
682 689 @GetMapping("getChatStat")
683 690 //@TokenRequired
684   - public BaseResponse getChatStat(String groupId){
685   - BaseResponse baseResponse =new BaseResponse();
  691 + public BaseResponse getChatStat(String groupId) {
  692 + BaseResponse baseResponse = new BaseResponse();
686 693 try {
687 694 final LymsChatgroup chatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>()
688 695 .lambda().eq(LymsChatgroup::getHxgroupid, groupId));
689 696  
690 697  
691 698  
692 699  
693 700  
694 701  
695 702  
696 703  
697 704  
698 705  
699 706  
700 707  
701 708  
... ... @@ -691,66 +698,72 @@
691 698 .lambda().eq(LymsTkrecord::getHxgroupid, groupId)
692 699 .groupBy(LymsTkrecord::getHxgroupid));*/
693 700 final LymsTkrecord tkrecord = lymsTkrecordService.getLeastRecordByHxgroupId(groupId);
694   - Map<String,Object> map= new LinkedHashMap<>();
695   - map.put("groupStat",null==chatgroup?"":chatgroup.getStat());
696   - map.put("tkrecordStat",null==tkrecord?"":tkrecord.getStat());
  701 + Map<String, Object> map = new LinkedHashMap<>();
  702 + map.put("groupStat", null == chatgroup ? "" : chatgroup.getStat());
  703 + map.put("tkrecordStat", null == tkrecord ? "" : tkrecord.getStat());
697 704 baseResponse.setObject(map);
698 705 } catch (Exception e) {
699 706 e.printStackTrace();
700 707 }
701 708 return baseResponse;
702 709 }
  710 +
703 711 /**
704   - * 添加/修改 回访聊天信息自动回复话术
  712 + * 添加/修改 回访聊天信息自动回复话术
  713 + *
705 714 * @param chatInfo
706 715 * @return
707 716 */
708 717 @PostMapping("addOrUpdateLymsChatInfo")
709 718 @TokenRequired
710   - public BaseResponse addOrUpdateLymsChatInfo(@RequestBody LymsChatInfo chatInfo){
711   - BaseResponse baseResponse =new BaseResponse();
  719 + public BaseResponse addOrUpdateLymsChatInfo(@RequestBody LymsChatInfo chatInfo) {
  720 + BaseResponse baseResponse = new BaseResponse();
712 721 try {
713 722 final boolean b = lymsChatInfoService.saveOrUpdate(chatInfo);
714   - baseResponse.setErrorcode(b?0:1);
715   - baseResponse.setErrormsg(b?"成功":"失败");
  723 + baseResponse.setErrorcode(b ? 0 : 1);
  724 + baseResponse.setErrormsg(b ? "成功" : "失败");
716 725 } catch (Exception e) {
717 726 e.printStackTrace();
718 727 }
719 728 return baseResponse;
720 729 }
  730 +
721 731 /**
722   - * 删除 回访聊天信息自动回复话术
  732 + * 删除 回访聊天信息自动回复话术
  733 + *
723 734 * @param id
724 735 * @return
725 736 */
726 737 @DeleteMapping("delLymsChatInfo")
727 738 @TokenRequired
728   - public BaseResponse delLymsChatInfo(Integer id){
729   - BaseResponse baseResponse =new BaseResponse();
  739 + public BaseResponse delLymsChatInfo(Integer id) {
  740 + BaseResponse baseResponse = new BaseResponse();
730 741 try {
731 742 final boolean b = lymsChatInfoService.removeById(id);
732   - baseResponse.setErrorcode(b?0:1);
733   - baseResponse.setErrormsg(b?"成功":"失败");
  743 + baseResponse.setErrorcode(b ? 0 : 1);
  744 + baseResponse.setErrormsg(b ? "成功" : "失败");
734 745 } catch (Exception e) {
735 746 e.printStackTrace();
736 747 }
737 748 return baseResponse;
738 749 }
  750 +
739 751 /**
740   - * 查询列表 回访聊天信息自动回复话术
  752 + * 查询列表 回访聊天信息自动回复话术
  753 + *
741 754 * @param chatInfo
742   - * @param current 页数
743   - * @param size 条数
  755 + * @param current 页数
  756 + * @param size 条数
744 757 * @return
745 758 */
746 759 @GetMapping("getLymsChatInfo")
747 760 @TokenRequired
748   - public BaseResponse getLymsChatInfo(LymsChatInfo chatInfo, int current, int size){
749   - BaseResponse baseResponse =new BaseResponse();
  761 + public BaseResponse getLymsChatInfo(LymsChatInfo chatInfo, int current, int size) {
  762 + BaseResponse baseResponse = new BaseResponse();
750 763 try {
751 764 QueryWrapper<LymsChatInfo> queryWrapper = Wrappers.query(chatInfo);
752 765 Page<LymsChatInfo> page = new Page<>(current, size);
753   - Page<LymsChatInfo> patientPagePage = lymsChatInfoService.page(page,queryWrapper);
  766 + Page<LymsChatInfo> patientPagePage = lymsChatInfoService.page(page, queryWrapper);
754 767 baseResponse.setObject(patientPagePage);
755 768 baseResponse.setErrorcode(0);
756 769 baseResponse.setErrormsg("成功");
757 770  
758 771  
759 772  
... ... @@ -759,21 +772,23 @@
759 772 }
760 773 return baseResponse;
761 774 }
  775 +
762 776 /**
763   - * 患者点咨询。查询是否有回访。有就直接进入聊天。不消耗问诊卡
  777 + * 患者点咨询。查询是否有回访。有就直接进入聊天。不消耗问诊卡
  778 + *
764 779 * @param chatgroup
765 780 * @return
766 781 */
767 782 @GetMapping("getYnReturnVisit")
768 783 @TokenRequired
769   - public BaseResponse getYnReturnVisit(LymsChatgroup chatgroup){
770   - BaseResponse baseResponse =new BaseResponse();
  784 + public BaseResponse getYnReturnVisit(LymsChatgroup chatgroup) {
  785 + BaseResponse baseResponse = new BaseResponse();
771 786 try {
772 787 final LymsChatgroup lymsChatgroup = lymsChatgroupService.getOne(new QueryWrapper<LymsChatgroup>()
773 788 .lambda().eq(LymsChatgroup::getFromp, chatgroup.getFromp())
774 789 .eq(LymsChatgroup::getTarget, chatgroup.getTarget())
775 790 .eq(LymsChatgroup::getPcid, chatgroup.getPcid()));
776   - if (null!=lymsChatgroup) {
  791 + if (null != lymsChatgroup) {
777 792 baseResponse.setObject(lymsChatgroup);
778 793 }
779 794 baseResponse.setErrorcode(0);
780 795  
781 796  
782 797  
783 798  
784 799  
785 800  
786 801  
787 802  
... ... @@ -783,41 +798,43 @@
783 798 }
784 799 return baseResponse;
785 800 }
  801 +
786 802 /**
787   - * 有回访记录时。患者消耗问诊卡修改环信组状态 并加问诊记录,开启聊天
  803 + * 有回访记录时。患者消耗问诊卡修改环信组状态 并加问诊记录,开启聊天
  804 + *
788 805 * @param chatgroup
789 806 * @return
790 807 */
791 808 @PostMapping("updateGroupStat")
792 809 @TokenRequired
793 810 @Transactional(rollbackFor = Exception.class)
794   - public BaseResponse updateGroupStat(@RequestBody LymsChatgroup chatgroup){
795   - BaseResponse baseResponse =new BaseResponse();
  811 + public BaseResponse updateGroupStat(@RequestBody LymsChatgroup chatgroup) {
  812 + BaseResponse baseResponse = new BaseResponse();
796 813 try {
797 814 final boolean b = lymsChatgroupService.updateById(chatgroup);
798   - if(!b){
  815 + if (!b) {
799 816 baseResponse.setErrorcode(1);
800   - log.error("updateGroupStat回滚LymsChatgroup失败,{}",chatgroup);
  817 + log.error("updateGroupStat回滚LymsChatgroup失败,{}", chatgroup);
801 818 throw new RuntimeException("回滚状态,执行失败,请联系管理员");
802 819 }
803 820 final List<PatientInfo> patientInfos = patientInfoService.list(new QueryWrapper<PatientInfo>()
804 821 .lambda().eq(PatientInfo::getCid, chatgroup.getPcid()).last(" limit 1"));
805 822 if (CollectionUtils.isEmpty(patientInfos)) {
806 823 baseResponse.setErrorcode(1);
807   - log.error("updateGroupStat回滚查询患者信息失败,{}",chatgroup);
  824 + log.error("updateGroupStat回滚查询患者信息失败,{}", chatgroup);
808 825 throw new RuntimeException("回滚状态,执行失败,请联系管理员");
809 826 }
810 827 PatientInfo patientInfo = patientInfos.get(0);
811   - LymsTkrecord tkrecord=new LymsTkrecord();
  828 + LymsTkrecord tkrecord = new LymsTkrecord();
812 829 LymsTcard tcard = new LymsTcard();
813 830 tcard.setPid(patientInfo.getId());
814 831 tcard.setPcid(patientInfo.getCid());
815 832 // 获取问诊卡按照先从医院购买的问诊卡消费
816   - List<LymsTcard> rLst = lymsTcardService.queryUnused(tcard);
  833 + List<LymsTcard> rLst = lymsTcardService.queryUnused(tcard);
817 834 if (rLst.size() > 0) {
818 835 tkrecord.setCid(rLst.get(0).getId());
819 836 tkrecord.setFid((byte) 2);
820   - }else{
  837 + } else {
821 838 //小程序购买的问诊卡
822 839 tcard.setPcid(null);
823 840 tcard.setFid(1);
824 841  
... ... @@ -825,10 +842,10 @@
825 842 if (xLst.size() > 0) {
826 843 tkrecord.setCid(xLst.get(0).getId());
827 844 tkrecord.setFid((byte) 1);
828   - }else{
  845 + } else {
829 846 baseResponse.setErrorcode(1);
830 847 baseResponse.setErrormsg("已经没有咨询卡,请联系客服购买!");
831   - return baseResponse;
  848 + return baseResponse;
832 849 }
833 850 }
834 851  
... ... @@ -843,7 +860,7 @@
843 860 final boolean save = lymsTkrecordService.save(tkrecord);
844 861 if (!save) {
845 862 baseResponse.setErrorcode(1);
846   - log.error("updateGroupStat回滚保存tkrecode失败,{}",chatgroup);
  863 + log.error("updateGroupStat回滚保存tkrecode失败,{}", chatgroup);
847 864 throw new RuntimeException("回滚状态,执行失败,请联系管理员");
848 865 }
849 866 //修改同一群组记录的状态
850 867  
851 868  
852 869  
853 870  
854 871  
855 872  
856 873  
857 874  
858 875  
859 876  
860 877  
... ... @@ -857,58 +874,61 @@
857 874 baseResponse.setErrormsg("成功");
858 875 } catch (Exception e) {
859 876 baseResponse.setErrorcode(1);
860   - log.error("updateGroupStat异常",e);
  877 + log.error("updateGroupStat异常", e);
861 878 //这里想触发事务回滚需抛运行时异常
862 879 throw new RuntimeException("回滚状态,执行失败,请联系管理员");
863 880 }
864 881 return baseResponse;
865 882 }
  883 +
866 884 /**
867 885 * 添加自动回复信息-查重
868   - * @param type 自动回复类型
869   - * @param illid 疾病id
870   - * @param id 修改时用
  886 + *
  887 + * @param type 自动回复类型
  888 + * @param illid 疾病id
  889 + * @param id 修改时用
871 890 * @return true 可以使用,false已经存在
872 891 */
873 892 @GetMapping("getChatInfoRepetition")
874 893 @TokenRequired
875   - public BaseResponse getChatInfoRepetition(Integer type, Integer illid, @RequestParam(required = false) Integer id){
876   - BaseResponse baseResponse=new BaseResponse();
  894 + public BaseResponse getChatInfoRepetition(Integer type, Integer illid, @RequestParam(required = false) Integer id) {
  895 + BaseResponse baseResponse = new BaseResponse();
877 896 try {
878   - Map<String, Boolean> map= new HashMap<>();
879   - map.put("type", true);map.put("illid", true);
880   - QueryWrapper<LymsChatInfo> queryWrapper=new QueryWrapper<>();
  897 + Map<String, Boolean> map = new HashMap<>();
  898 + map.put("type", true);
  899 + map.put("illid", true);
  900 + QueryWrapper<LymsChatInfo> queryWrapper = new QueryWrapper<>();
881 901 queryWrapper.eq("type", type);
882 902 queryWrapper.eq("illid", illid);
883   - if(null!=id){//修改的时候判断是否重复
884   - QueryWrapper<LymsChatInfo> queryWrapper2=new QueryWrapper<>();
  903 + if (null != id) {//修改的时候判断是否重复
  904 + QueryWrapper<LymsChatInfo> queryWrapper2 = new QueryWrapper<>();
885 905 queryWrapper2.eq("id", id);
886   - LymsChatInfo chatInfo2=lymsChatInfoService.getOne(queryWrapper2);
887   - List<LymsChatInfo> chatInfoList=lymsChatInfoService.list(queryWrapper);
888   - if(CollectionUtils.isNotEmpty(chatInfoList)){
889   - if(null!=type && !chatInfo2.getType().equals(type)){
  906 + LymsChatInfo chatInfo2 = lymsChatInfoService.getOne(queryWrapper2);
  907 + List<LymsChatInfo> chatInfoList = lymsChatInfoService.list(queryWrapper);
  908 + if (CollectionUtils.isNotEmpty(chatInfoList)) {
  909 + if (null != type && !chatInfo2.getType().equals(type)) {
890 910 for (LymsChatInfo chatInfo : chatInfoList) {
891   - if(chatInfo.getType().equals(type)){
  911 + if (chatInfo.getType().equals(type)) {
892 912 map.put("type", false);
893 913 }
894 914 }
895 915 }
896   - if(null!=illid && !chatInfo2.getIllid().equals(illid)){
  916 + if (null != illid && !chatInfo2.getIllid().equals(illid)) {
897 917 for (LymsChatInfo chatInfo : chatInfoList) {
898   - if(chatInfo.getIllid().equals(illid)){
  918 + if (chatInfo.getIllid().equals(illid)) {
899 919 map.put("illid", false);
900 920 }
901 921 }
902 922 }
903 923 }
904 924 baseResponse.setObject(map);
905   - }else {
906   - LymsChatInfo chatInfo=lymsChatInfoService.getOne(queryWrapper);
907   - if (null!=chatInfo) {
908   - if(null!=type && chatInfo.getType().equals(type)){
  925 + } else {
  926 + LymsChatInfo chatInfo = lymsChatInfoService.getOne(queryWrapper);
  927 + if (null != chatInfo) {
  928 + if (null != type && chatInfo.getType().equals(type)) {
909 929 map.put("type", false);
910 930 }
911   - if(null!=illid && illid.equals(chatInfo.getIllid())){
  931 + if (null != illid && illid.equals(chatInfo.getIllid())) {
912 932 map.put("illid", false);
913 933 }
914 934 }
... ... @@ -923,6 +943,86 @@
923 943 return baseResponse;
924 944 }
925 945  
  946 + @Value("${getAccessToken.on_off}")
  947 + public boolean on_off;//配置yml 微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突)
  948 +
  949 + @Autowired
  950 + private LymsPatientWechatService lymsPatientWechatService;
  951 +
  952 + private static final ScheduledExecutorService executor = Executors.newScheduledThreadPool(5);
  953 + /**
  954 + ** 患者如果有未读消息发送微信公众号消息给患者
  955 + **
  956 + ** @return
  957 + */
  958 + @GetMapping("sendPatientWeChatMsg")
  959 + @TokenRequired
  960 + public BaseResponse sendPatientWeChatMsg(String idCard) {
  961 + if (!on_off) {
  962 + return BaseResponse.ok();
  963 + }
  964 + QueryWrapper<LymsPatientWechat> queryWrapper = new QueryWrapper<>();
  965 + queryWrapper.eq("idcard", idCard);
  966 + queryWrapper.eq("status", 0);
  967 + LymsPatientWechat lymsPatientWechat = lymsPatientWechatService.getOne(queryWrapper);
  968 + if (lymsPatientWechat == null) {
  969 + lymsPatientWechat = new LymsPatientWechat();
  970 + lymsPatientWechat.setCreated(new Date());
  971 + lymsPatientWechat.setIdCard(idCard);
  972 + lymsPatientWechat.setStatus(0);
  973 + lymsPatientWechatService.save(lymsPatientWechat);
  974 + // 设置延迟时间(单位:毫秒)
  975 + long delayTimeInMillis = TimeUnit.MINUTES.toMillis(30);
  976 + // 创建一个Runnable对象作为需要延迟执行的任务
  977 + PushTask pushTask = new PushTask() {
  978 + String idno = idCard;
  979 + @Override
  980 + public void run() {
  981 + log.info("开始执行患者未读消息推送 idno: {}",idno);
  982 + QueryWrapper<LymsPatient> qw = new QueryWrapper();
  983 + qw.eq("idno", idno);
  984 + LymsPatient lymsPatient = lymsPatientService.getOne(qw);
  985 +
  986 + if (lymsPatient == null || StringUtil.isEmpty(lymsPatient.getGzopenid())) {
  987 + log.error("患者消息提醒,未获取到公众号openid:{}", lymsPatient);
  988 + return;
  989 + }
  990 + Map<String, Object> mapTemplate = new HashMap<>();
  991 + mapTemplate.put("first", "患者消息提醒");
  992 + mapTemplate.put("keyword1", new DataEntity("尊敬的患者:" + lymsPatient.getPname(), "#173177"));
  993 + mapTemplate.put("keyword2", new DataEntity("您对医生的回复满意吗?", "#173177"));
  994 + mapTemplate.put("remark", "请点击下方进入小程序,查看医生回访信息。");
  995 + Map<String, Object> map = new HashMap<>();
  996 + map.put("plogin", lymsPatient.getEnrolmentPhone());
  997 + map.put("passwd", lymsPatient.getPpasswd());
  998 + try {
  999 + Integer code = WeiXinUtil.DoctorSendWeChatMsg(lymsPatient.getGzopenid(), Constant.GZ_TEMPLATE_ID_DOCTOR_VISIT, mapTemplate, map);
  1000 + log.info("患者消息提醒,code:{},{}", code, lymsPatient);
  1001 + if (code==0){
  1002 + QueryWrapper<LymsPatientWechat> query = new QueryWrapper<>();
  1003 + query.eq("idcard", idno);
  1004 + query.eq("status", 0);
  1005 + LymsPatientWechat patientWechat = lymsPatientWechatService.getOne(query);
  1006 + if (patientWechat!=null){
  1007 + patientWechat.setStatus(1);
  1008 + lymsPatientWechatService.updateById(patientWechat);
  1009 + }
  1010 + }
  1011 + } catch (Exception e) {
  1012 + log.error("患者消息提醒异常,{}", lymsPatient, e);
  1013 + }
  1014 + }
  1015 + @Override
  1016 + public PushTask setParam(String param) {
  1017 + idno = param;
  1018 + return this;
  1019 + }
  1020 + };
  1021 + // 将任务提交到线程池并指定延迟时间
  1022 + executor.schedule(pushTask, delayTimeInMillis, TimeUnit.MILLISECONDS);
  1023 + }
  1024 + return BaseResponse.ok();
  1025 + }
926 1026  
927 1027 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsHisInfoController.java View file @ 30dfcca
1 1 package com.lyms.talkonlineweb.controller;
2 2  
3   -import com.baomidou.mybatisplus.core.conditions.Wrapper;
  3 +import cn.afterturn.easypoi.excel.ExcelExportUtil;
  4 +import cn.afterturn.easypoi.excel.entity.ExportParams;
4 5 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5   -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
6 6 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7 7 import com.lyms.talkonlineweb.annotation.Resubmit;
8 8 import com.lyms.talkonlineweb.annotation.TokenRequired;
9   -import com.lyms.talkonlineweb.domain.LymsDict;
10 9 import com.lyms.talkonlineweb.domain.LymsHisInfo;
11   -import com.lyms.talkonlineweb.domain.LymsUser;
12 10 import com.lyms.talkonlineweb.result.BaseResponse;
13   -import com.lyms.talkonlineweb.result.CheckResult;
14 11 import com.lyms.talkonlineweb.service.LymsHisInfoService;
15   -import com.lyms.talkonlineweb.service.LymsUserService;
16   -import com.lyms.talkonlineweb.util.JwtUtils;
17 12 import com.lyms.talkonlineweb.util.StringUtil;
  13 +import org.apache.poi.ss.usermodel.Workbook;
18 14 import org.springframework.beans.factory.annotation.Autowired;
19   -import org.springframework.validation.BindingResult;
20 15 import org.springframework.validation.annotation.Validated;
21 16 import org.springframework.web.bind.annotation.*;
22 17  
23   -import javax.servlet.http.HttpServletRequest;
24   -import java.util.Date;
  18 +import javax.servlet.ServletOutputStream;
  19 +import javax.servlet.http.HttpServletResponse;
  20 +import java.net.URLEncoder;
25 21 import java.util.List;
26 22  
27 23 /**
... ... @@ -33,8 +29,6 @@
33 29  
34 30 @Autowired
35 31 private LymsHisInfoService lymsHisInfoService;
36   - @Autowired
37   - private LymsUserService lymsUserService;
38 32  
39 33 /**
40 34 * 获取医院患者His列表
... ... @@ -60,6 +54,9 @@
60 54 .or().eq("phone", hisInfo.getSynthesisQuery())
61 55 .or().eq("idCard", hisInfo.getSynthesisQuery()));
62 56 }
  57 + if (StringUtil.isNotEmpty(hisInfo.getDept())){
  58 + query.eq("dept", hisInfo.getDept());
  59 + }
63 60 if(StringUtil.isNotEmpty(hisInfo.getStartCreatedtime())){
64 61 query.ge("created", hisInfo.getStartCreatedtime());
65 62 }
66 63  
... ... @@ -78,12 +75,13 @@
78 75 */
79 76 @PostMapping("upHisInfo")
80 77 @TokenRequired
  78 + @Resubmit
81 79 public BaseResponse upHisInfo( @RequestBody @Validated LymsHisInfo lymsHisInfo){
82 80 BaseResponse baseResponse=new BaseResponse();
83 81 try {
84 82 baseResponse.setErrorcode(0);
85 83 baseResponse.setErrormsg("患者上传成功");
86   - String result = lymsHisInfoService.upHisInfo(lymsHisInfo);
  84 + String result = lymsHisInfoService.upHisInfo(lymsHisInfo,1);
87 85 if(StringUtil.isNotEmpty(result)){
88 86 baseResponse.setErrorcode(1);
89 87 baseResponse.setErrormsg(result);
... ... @@ -101,7 +99,7 @@
101 99 * @return
102 100 */
103 101 @PostMapping("upAllHisInfo")
104   - @TokenRequired
  102 + // @TokenRequired
105 103 @Resubmit
106 104 public BaseResponse upAllHisInfo(){
107 105 BaseResponse baseResponse=new BaseResponse();
108 106  
... ... @@ -151,8 +149,26 @@
151 149 }
152 150 return baseResponse;
153 151 }
  152 + @PostMapping("/export")
  153 + @TokenRequired
  154 + public void export( HttpServletResponse response) throws Exception{
  155 + QueryWrapper<LymsHisInfo> query=new QueryWrapper();
  156 + query.eq("up_type",2);
  157 + List<LymsHisInfo> list= lymsHisInfoService.list(query);
154 158  
155   -
156   -
  159 + Workbook result = ExcelExportUtil.exportExcel(
  160 + new ExportParams("his病例上传失败列表", "his病例上传失败列表"),
  161 + LymsHisInfo.class, list);
  162 + //写出
  163 + ServletOutputStream outputStream = response.getOutputStream();
  164 + //设置请求头,解决文件名中文乱码问题
  165 + response.setContentType("application/vnd.ms-excel");
  166 + response.setCharacterEncoding("utf-8");
  167 + response.setHeader("Content-disposition",
  168 + "attachment;filename=" + URLEncoder.encode("his病例上传失败列表","utf-8") + ".xls");
  169 + result.write(outputStream);
  170 + outputStream.close();
  171 + result.close();
  172 + }
157 173 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/LymsWorkMessageController.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.controller;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4 +import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5 +import com.lyms.talkonlineweb.annotation.TokenRequired;
  6 +import com.lyms.talkonlineweb.domain.LymsHisInfo;
  7 +import com.lyms.talkonlineweb.result.BaseResponse;
  8 +import com.lyms.talkonlineweb.util.StringUtil;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.http.ResponseEntity;
  11 +import org.springframework.web.bind.annotation.*;
  12 +import com.lyms.talkonlineweb.domain.LymsWorkMessage;
  13 +import com.lyms.talkonlineweb.service.LymsWorkMessageService;
  14 +
  15 +/**
  16 + * ;(lyms_work_message)表控制层
  17 + * @author : http://www.chiner.pro
  18 + * @date : 2024-2-6
  19 + */
  20 +@RestController
  21 +@RequestMapping("/workMessage")
  22 +public class LymsWorkMessageController{
  23 + @Autowired
  24 + private LymsWorkMessageService lymsWorkMessageService;
  25 +
  26 + @GetMapping("getList")
  27 + @TokenRequired
  28 + public BaseResponse getList( int current, int size,Integer hospitalId
  29 + ,String dept,Integer type,String startTime,String endTime){
  30 + BaseResponse baseResponse=new BaseResponse();
  31 + Page<LymsWorkMessage> page=new Page<>(current,size);
  32 + QueryWrapper<LymsWorkMessage> query=new QueryWrapper();
  33 + if(hospitalId!=null) {
  34 + query.eq("hospital_id", hospitalId);
  35 + }
  36 + if(null!=type){
  37 + query.eq("type", type);
  38 + }
  39 + if(StringUtil.isNotEmpty(startTime)&&StringUtil.isNotEmpty(endTime)){
  40 + query.ge("created", startTime+" 00:00:00");
  41 + query.le("created", endTime+" 23:59:59");
  42 + }
  43 + if (StringUtil.isNotEmpty(dept)){
  44 + query.eq("dept", dept);
  45 + }
  46 + Page<LymsWorkMessage> messagePage=lymsWorkMessageService.page(page,query);
  47 + baseResponse.setObject(messagePage);
  48 + return baseResponse;
  49 + }
  50 + @GetMapping("getInfo")
  51 + @TokenRequired
  52 + public BaseResponse getInfo(Integer id){
  53 + BaseResponse baseResponse=new BaseResponse();
  54 + LymsWorkMessage lymsWorkMessage= lymsWorkMessageService.getById(id);
  55 + lymsWorkMessage.setIsRead(1);
  56 + lymsWorkMessageService.updateById(lymsWorkMessage);
  57 + baseResponse.setObject(lymsWorkMessage);
  58 + return baseResponse;
  59 + }
  60 + @GetMapping("getReadList")
  61 + @TokenRequired
  62 + public BaseResponse getReadList(Integer type){
  63 + BaseResponse baseResponse=new BaseResponse();
  64 + QueryWrapper<LymsWorkMessage> query=new QueryWrapper();
  65 + if (type!=null){
  66 + query.eq("type",type);
  67 + }
  68 + query.eq("is_read",0);
  69 + baseResponse.setObject(lymsWorkMessageService.list(query));
  70 + return baseResponse;
  71 + }
  72 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/PushMessageController.java View file @ 30dfcca
1 1 package com.lyms.talkonlineweb.controller;
2 2  
  3 +import cn.afterturn.easypoi.excel.ExcelExportUtil;
  4 +import cn.afterturn.easypoi.excel.entity.ExportParams;
3 5 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 6 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 7 import com.lyms.talkonlineweb.annotation.TokenRequired;
6 8  
7 9  
... ... @@ -8,11 +10,13 @@
8 10 import com.lyms.talkonlineweb.service.LymsPushMessageService;
9 11 import com.lyms.talkonlineweb.util.StringUtil;
10 12 import lombok.RequiredArgsConstructor;
  13 +import org.apache.poi.ss.usermodel.Workbook;
11 14 import org.springframework.beans.factory.annotation.Autowired;
12   -import org.springframework.web.bind.annotation.GetMapping;
13   -import org.springframework.web.bind.annotation.PathVariable;
14   -import org.springframework.web.bind.annotation.RestController;
  15 +import org.springframework.web.bind.annotation.*;
15 16  
  17 +import javax.servlet.ServletOutputStream;
  18 +import javax.servlet.http.HttpServletResponse;
  19 +import java.net.URLEncoder;
16 20 import java.util.ArrayList;
17 21 import java.util.List;
18 22  
... ... @@ -65,5 +69,8 @@
65 69 lymsPushMessageService.updateById(lymsPushMessage);
66 70 return BaseResponse.ok();
67 71 }
  72 +
  73 +
  74 +
68 75 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsHisInfo.java View file @ 30dfcca
1 1 package com.lyms.talkonlineweb.domain;
2 2  
  3 +import cn.afterturn.easypoi.excel.annotation.Excel;
  4 +import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
3 5 import com.baomidou.mybatisplus.annotation.*;
4 6  
5 7 import java.io.Serializable;
... ... @@ -15,6 +17,7 @@
15 17 */
16 18 @TableName(value ="lyms_his_info")
17 19 @Data
  20 +@ExcelTarget("lyms_his_info")
18 21 public class LymsHisInfo implements Serializable {
19 22 /**
20 23 *
... ... @@ -28,6 +31,7 @@
28 31 */
29 32 @TableField(value = "vcCardNo")
30 33 @NotNull(message = "vccardno不能为空")
  34 + @Excel(name = "编号", width = 10,orderNum = "0")
31 35 private String vccardno;
32 36  
33 37 /**
... ... @@ -35,6 +39,7 @@
35 39 */
36 40 @TableField(value = "name")
37 41 @NotNull(message = "name不能为空")
  42 + @Excel(name = "患者姓名", width = 20,orderNum = "1")
38 43 private String name;
39 44  
40 45 /**
... ... @@ -56,6 +61,7 @@
56 61 */
57 62 @TableField(value = "phone")
58 63 @NotNull(message = "phone不能为空")
  64 + @Excel(name = "电话", width = 25,orderNum = "2")
59 65 private String phone;
60 66  
61 67 /**
... ... @@ -63,6 +69,7 @@
63 69 */
64 70 @TableField(value = "idCard")
65 71 //@NotNull(message = "idcard不能为空")
  72 + @Excel(name = "身份证号", width = 30,orderNum = "3")
66 73 private String idcard;
67 74  
68 75 /**
... ... @@ -70,6 +77,7 @@
70 77 */
71 78 @TableField(value = "dept")
72 79 @NotNull(message = "dept不能为空")
  80 + @Excel(name = "科室名称", width = 20,orderNum = "4")
73 81 private String dept;
74 82  
75 83 /**
... ... @@ -77,6 +85,7 @@
77 85 */
78 86 @TableField(value = "diagnose")
79 87 @NotNull(message = "diagnose不能为空")
  88 + @Excel(name = "疾病名称", width = 20,orderNum = "5")
80 89 private String diagnose;
81 90  
82 91 /**
... ... @@ -84,6 +93,7 @@
84 93 */
85 94 @TableField(value = "doctor")
86 95 @NotNull(message = "doctor不能为空")
  96 + @Excel(name = "医生姓名", width = 20,orderNum = "6")
87 97 private String doctor;
88 98 /**
89 99 * 医院id
90 100  
... ... @@ -124,7 +134,11 @@
124 134 * 失败原因
125 135 */
126 136 @TableField(value = "remark")
  137 + @Excel(name = "失败原因", width = 50,orderNum = "8")
127 138 private String remark;
  139 +
  140 + @TableField(value = "is_open")
  141 + private Integer isOpen;
128 142  
129 143 /**
130 144 * 筛选开始时间
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsPatientWechat.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.domain;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.IdType;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.Data;
  8 +
  9 +import java.util.Date;
  10 +
  11 +@Data
  12 +@TableName(value ="lyms_patient_wechat")
  13 +public class LymsPatientWechat {
  14 + /**
  15 + * id
  16 + */
  17 + @TableId(value = "id", type = IdType.AUTO)
  18 + private Integer id;
  19 + @TableField(value = "idcard")
  20 + private String idCard;
  21 + @TableField(value = "status")
  22 + private Integer status;
  23 + @TableField(value = "created")
  24 + private Date created;
  25 +
  26 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/domain/LymsWorkMessage.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.domain;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.IdType;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import lombok.Data;
  8 +
  9 +import java.io.Serializable;
  10 +import java.util.Date;
  11 +
  12 + /**
  13 + * ;
  14 + * @author : http://www.chiner.pro
  15 + * @date : 2024-2-6
  16 + */
  17 + @TableName(value ="lyms_work_message")
  18 + @Data
  19 +public class LymsWorkMessage implements Serializable{
  20 +
  21 + @TableField(exist = false)
  22 + private static final long serialVersionUID = 1L;
  23 +
  24 + /** ID */
  25 + @TableId(value = "id", type = IdType.AUTO)
  26 + private Integer id ;
  27 + /** his病例ID */
  28 + @TableField(value = "his_info_id")
  29 + private Integer hisInfoId ;
  30 + /** 姓名 */
  31 + private String username ;
  32 + /** 医院ID */
  33 + @TableField(value = "hospital_id")
  34 + private Integer hospitalId ;
  35 + /** 医院名称 */
  36 + private String hospital ;
  37 + /** 科室 */
  38 + private String dept ;
  39 + /** 手机号 */
  40 + private String phone ;
  41 + /** */
  42 + private String content ;
  43 + /** 失败原因 */
  44 + private String remark ;
  45 + /** 岗位类型 1为客服 2为编辑 3为学术经理 */
  46 + private Integer type ;
  47 + /** 0为未读 1为已读 */
  48 + @TableField(value = "is_read")
  49 + private Integer isRead ;
  50 + /** 创建时间 */
  51 + private Date created ;
  52 +
  53 +
  54 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/enums/ChatEnum.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.enums;
  2 +
  3 +import lombok.Getter;
  4 +
  5 +@Getter
  6 +public enum ChatEnum {
  7 + TWO(1,"第二天"),
  8 + FIVE(2,"第五天"),
  9 + TEN(3,"第十天"),
  10 + TWENTY(4,"第二十天"),
  11 + THIRTY(5,"第三十天");
  12 +
  13 + private Integer code;
  14 + private String name;
  15 +
  16 + ChatEnum(Integer code,String name){
  17 + this.code = code;
  18 + this.name = name;
  19 + }
  20 + public static String getName(Integer code) {
  21 + MessageEnum[] values = MessageEnum.values();
  22 + for (MessageEnum value : values) {
  23 + if (value.getCode().equals(code)) {
  24 + return value.getName();
  25 + }
  26 + }
  27 + return "";
  28 + }
  29 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsDoctorWorktimeMapper.java View file @ 30dfcca
... ... @@ -14,6 +14,7 @@
14 14 public interface LymsDoctorWorktimeMapper extends BaseMapper<LymsDoctorWorkTime> {
15 15  
16 16 List<DoctorChatCount> selectDoctorChatCount(@Param("startTime") String startTime);
  17 + List<DoctorChatCount> selectDoctorChat();
17 18  
18 19 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsHisInfoMapper.java View file @ 30dfcca
... ... @@ -2,11 +2,16 @@
2 2  
3 3 import com.lyms.talkonlineweb.domain.LymsHisInfo;
4 4 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +import org.apache.ibatis.annotations.Param;
5 6  
  7 +import java.util.Date;
  8 +import java.util.List;
  9 +
6 10 /**
7 11 * @Entity com.lyms.talkonlineweb.domain.LymsHisInfo
8 12 */
9 13 public interface LymsHisInfoMapper extends BaseMapper<LymsHisInfo> {
10 14  
  15 + List<LymsHisInfo> selectByOrder(@Param("endTime") Date endTime);
11 16 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsPatientWechatMapper.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.mapper;
  2 +
  3 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import com.lyms.talkonlineweb.domain.LymsHisInfo;
  5 +import com.lyms.talkonlineweb.domain.LymsPatientWechat;
  6 +
  7 +public interface LymsPatientWechatMapper extends BaseMapper<LymsPatientWechat> {
  8 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsWorkMessageMapper.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.mapper;
  2 +
  3 +
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +import org.apache.ibatis.annotations.Mapper;
  6 +import com.lyms.talkonlineweb.domain.LymsWorkMessage;
  7 +
  8 + /**
  9 + * ;(lyms_work_message)表数据库访问层
  10 + * @author : http://www.chiner.pro
  11 + * @date : 2024-2-6
  12 + */
  13 +public interface LymsWorkMessageMapper extends BaseMapper<LymsWorkMessage> {
  14 +
  15 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsDoctorWorktimeService.java View file @ 30dfcca
... ... @@ -13,5 +13,6 @@
13 13 */
14 14 public interface LymsDoctorWorktimeService extends IService<LymsDoctorWorkTime> {
15 15 List<DoctorChatCount> selectDoctorChatCount(String startTime);
  16 + List<DoctorChatCount> selectDoctorChat();
16 17 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsHisInfoService.java View file @ 30dfcca
... ... @@ -9,7 +9,7 @@
9 9 */
10 10 public interface LymsHisInfoService extends IService<LymsHisInfo> {
11 11  
12   - String upHisInfo(LymsHisInfo lymsHisInfo) throws Exception;
  12 + String upHisInfo(LymsHisInfo lymsHisInfo,Integer upType) throws Exception;
13 13  
14 14 void upAllHisInfo();
15 15  
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsPatientWechatService.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.lyms.talkonlineweb.domain.LymsPatientWechat;
  5 +
  6 +public interface LymsPatientWechatService extends IService<LymsPatientWechat> {
  7 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/LymsWorkMessageService.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.lyms.talkonlineweb.domain.LymsWorkMessage;
  5 +
  6 + /**
  7 + * ;(lyms_work_message)表服务接口
  8 + * @author : http://www.chiner.pro
  9 + * @date : 2024-2-6
  10 + */
  11 +public interface LymsWorkMessageService extends IService<LymsWorkMessage> {
  12 +
  13 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/PushTask.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.service;
  2 +
  3 +public interface PushTask extends Runnable {
  4 + PushTask setParam(String param);
  5 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsDoctorWorktimeServiceImpl.java View file @ 30dfcca
... ... @@ -27,5 +27,10 @@
27 27 public List<DoctorChatCount> selectDoctorChatCount(String startTime) {
28 28 return doctorWorktimeMapper.selectDoctorChatCount(startTime);
29 29 }
  30 +
  31 + @Override
  32 + public List<DoctorChatCount> selectDoctorChat() {
  33 + return doctorWorktimeMapper.selectDoctorChat();
  34 + }
30 35 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsHisInfoServiceImpl.java View file @ 30dfcca
... ... @@ -7,6 +7,7 @@
7 7 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8 8 import com.lyms.talkonlineweb.domain.*;
9 9 import com.lyms.talkonlineweb.enums.ChargeWay;
  10 +import com.lyms.talkonlineweb.enums.ChatEnum;
10 11 import com.lyms.talkonlineweb.param.DataEntity;
11 12 import com.lyms.talkonlineweb.result.BaseResponse;
12 13 import com.lyms.talkonlineweb.result.Diagnose;
... ... @@ -19,6 +20,7 @@
19 20 import com.lyms.talkonlineweb.util.WeiXinUtil;
20 21 import lombok.extern.log4j.Log4j2;
21 22 import org.springframework.beans.factory.annotation.Autowired;
  23 +import org.springframework.beans.factory.annotation.Value;
22 24 import org.springframework.stereotype.Service;
23 25 import org.springframework.transaction.annotation.Transactional;
24 26 import org.springframework.util.DigestUtils;
... ... @@ -31,6 +33,7 @@
31 33 */
32 34 @Service
33 35 @Log4j2
  36 +@Transactional
34 37 public class LymsHisInfoServiceImpl extends ServiceImpl<LymsHisInfoMapper, LymsHisInfo>
35 38 implements LymsHisInfoService{
36 39  
37 40  
38 41  
... ... @@ -64,12 +67,18 @@
64 67 private LymsChatInfoService lymsChatInfoService;
65 68 @Autowired
66 69 private LymsPushMessageService lymsPushMessageService;
  70 + @Autowired
  71 + private LymsHisInfoMapper lymsHisInfoMapper;
  72 + @Autowired
  73 + private LymsWorkMessageService lymsWorkMessageService;
67 74  
  75 + @Value("${getAccessToken.on_off}")
  76 + public boolean on_off;//配置yml 微信公众号获取access_token(测试环境部署不要开启。会与线上环境冲突)
68 77  
69 78 @Override
70 79 @Transactional(rollbackFor = {Exception.class,RuntimeException.class})
71   - public String upHisInfo(LymsHisInfo lymsHisInfo) throws Exception,RuntimeException {
72   - String result=collateData(lymsHisInfo);
  80 + public String upHisInfo(LymsHisInfo lymsHisInfo,Integer upType) throws Exception,RuntimeException {
  81 + String result=collateData(lymsHisInfo,upType);
73 82 Integer type;
74 83 if(StringUtil.isEmpty(result)){
75 84 type=1;
76 85  
77 86  
78 87  
79 88  
80 89  
81 90  
82 91  
83 92  
... ... @@ -84,86 +93,88 @@
84 93 throw new Exception("更新HIS患者信息返回值失败状态!");
85 94 }
86 95 if (type==1){
87   - new Thread(new Runnable() {
88   - @Override
89   - public void run() {
90   - try {
91   - Thread.sleep(3000);
92   - LymsPatient patient =null;
93   - String idCard = lymsHisInfo.getIdcard();
94   - if (StringUtil.isEmpty(idCard)) {
95   - QueryWrapper<LymsPatient> queryWrapper = new QueryWrapper<>();
96   - queryWrapper.eq("pname",lymsHisInfo.getName());
97   - queryWrapper.eq("enrolment_phone",lymsHisInfo.getPhone());
98   - List<LymsPatient> list = lymsPatientService.list(queryWrapper);
99   - if(CollectionUtils.isNotEmpty(list)){
100   - patient=list.get(0);
  96 + if (on_off) {
  97 + new Thread(new Runnable() {
  98 + @Override
  99 + public void run() {
  100 + try {
  101 + Thread.sleep(3000);
  102 + LymsPatient patient =null;
  103 + String idCard = lymsHisInfo.getIdcard();
  104 + if (StringUtil.isEmpty(idCard)) {
  105 + QueryWrapper<LymsPatient> queryWrapper = new QueryWrapper<>();
  106 + queryWrapper.eq("pname",lymsHisInfo.getName());
  107 + queryWrapper.eq("enrolment_phone",lymsHisInfo.getPhone());
  108 + List<LymsPatient> list = lymsPatientService.list(queryWrapper);
  109 + if(CollectionUtils.isNotEmpty(list)){
  110 + patient=list.get(0);
  111 + }
  112 + }else {
  113 + //判断患者是否存在
  114 + LymsPatient patientQuery = new LymsPatient();
  115 + patientQuery.setIdno(idCard.toLowerCase());
  116 + patient = lymsPatientService.getOne(Wrappers.query(patientQuery));
101 117 }
102   - }else {
103   - //判断患者是否存在
104   - LymsPatient patientQuery = new LymsPatient();
105   - patientQuery.setIdno(idCard.toLowerCase());
106   - patient = lymsPatientService.getOne(Wrappers.query(patientQuery));
107   - }
108   - if (patient!=null){
109   - List<PushOrderResult> orderList= lymsOrderService.selectPushOrder(patient.getId());
110   - log.info("SendWeChatMsg--->orderList,"+orderList.toString());
111   - if (CollectionUtils.isNotEmpty(orderList)){
112   - LymsPushMessage lymsPushMessage=new LymsPushMessage();
113   - PushOrderResult order= orderList.get(0);
114   - lymsPushMessage.setIdno(patient.getIdno());
115   - lymsPushMessage.setHospital(order.getHname());
116   - lymsPushMessage.setDept(order.getDname());
117   - lymsPushMessage.setCid(order.getCid());
118   - lymsPushMessage.setDiagnose(order.getIname());
119   - lymsPushMessage.setMessageType(3);
120   - lymsPushMessage.setPushType(1);
121   - lymsPushMessage.setTitle("通知:您有一条服务内容推送消息,请点击此处及时查看。");
122   - lymsPushMessage.setName(patient.getPname());
123   - lymsPushMessage.setPushTime(new Date());
124   - lymsPushMessage.setType(0);
125   - //推送微信公众号
126   - Map<String,Object> map=new HashMap<>();
127   - map.put("keyword1",new DataEntity(order.getPname(),"#173177"));
128   - map.put("keyword2",new DataEntity(order.getHname(),"#173177"));
129   - map.put("keyword3",new DataEntity(order.getDname()+"【点击此提醒可查看服务具体内容】","#173177"));
  118 + if (patient!=null){
  119 + List<PushOrderResult> orderList= lymsOrderService.selectPushOrder(patient.getId());
  120 + log.info("SendWeChatMsg--->orderList,"+orderList.toString());
  121 + if (CollectionUtils.isNotEmpty(orderList)){
  122 + LymsPushMessage lymsPushMessage=new LymsPushMessage();
  123 + PushOrderResult order= orderList.get(0);
  124 + lymsPushMessage.setIdno(patient.getIdno());
  125 + lymsPushMessage.setHospital(order.getHname());
  126 + lymsPushMessage.setDept(order.getDname());
  127 + lymsPushMessage.setCid(order.getCid());
  128 + lymsPushMessage.setDiagnose(order.getIname());
  129 + lymsPushMessage.setMessageType(3);
  130 + lymsPushMessage.setPushType(1);
  131 + lymsPushMessage.setTitle("通知:您有一条服务内容推送消息,请点击此处及时查看。");
  132 + lymsPushMessage.setName(patient.getPname());
  133 + lymsPushMessage.setPushTime(new Date());
  134 + lymsPushMessage.setType(0);
  135 + //推送微信公众号
  136 + Map<String,Object> map=new HashMap<>();
  137 + map.put("keyword1",new DataEntity(order.getPname(),"#173177"));
  138 + map.put("keyword2",new DataEntity(order.getHname(),"#173177"));
  139 + map.put("keyword3",new DataEntity(order.getDname()+"【点击此提醒可查看服务具体内容】","#173177"));
130 140  
131   - //公众号跳转小程序需要的登录信息
132   - Map<String,Object> mapInfo =lymsUserService.pLoginInfo(order.getPid(),3);
133   - try {
134   - log.info("SendWeChatMsg--->startup");
135   - Integer code= WeiXinUtil.SendWeChatMsg(order.getGzopenid(),Constant.GZ_TEMPLATE_ID,map,mapInfo);
136   - log.info("SendWeChatMsg--->code, "+code);
137   - if (null == code || code != 0) {
138   - lymsPushMessage.setStatus(0);
139   - lymsPushMessage.setRemark(String.valueOf(code));
140   - }else {
141   - lymsPushMessage.setStatus(1);
  141 + //公众号跳转小程序需要的登录信息
  142 + Map<String,Object> mapInfo =lymsUserService.pLoginInfo(order.getPid(),3);
  143 + try {
  144 + log.info("SendWeChatMsg--->startup");
  145 + Integer code= WeiXinUtil.SendWeChatMsg(order.getGzopenid(),Constant.GZ_TEMPLATE_ID,map,mapInfo);
  146 + log.info("SendWeChatMsg--->code, "+code);
  147 + if (null == code || code != 0) {
  148 + lymsPushMessage.setStatus(0);
  149 + lymsPushMessage.setRemark(String.valueOf(code));
  150 + }else {
  151 + lymsPushMessage.setStatus(1);
  152 + }
  153 + lymsPushMessageService.save(lymsPushMessage);
  154 + } catch (Exception e) {
  155 + log.error("serviceContent Exception,"+e.getMessage());
142 156 }
143   - lymsPushMessageService.save(lymsPushMessage);
144   - } catch (Exception e) {
145   - log.error("serviceContent Exception,"+e.getMessage());
146 157 }
147 158 }
  159 + }catch (Exception e){
  160 + log.error("upHisInfo---> Thread Exception"+e.getMessage());
148 161 }
149   - }catch (Exception e){
150   - log.error("upHisInfo---> Thread Exception"+e.getMessage());
151 162 }
152   - }
153   - }).start();
  163 + }).start();
  164 + }
  165 +
154 166 }
155 167 return result;
156 168 }
157 169  
158 170 @Override
159 171 public void upAllHisInfo() {
160   - LambdaQueryWrapper<LymsHisInfo> query = new QueryWrapper<LymsHisInfo>()
161   - .lambda().eq(LymsHisInfo::getUpType, 0);
162   - List<LymsHisInfo> list = this.list(query);
  172 +
  173 + List<LymsHisInfo> list = lymsHisInfoMapper.selectByOrder(new Date());
163 174 if (CollectionUtils.isNotEmpty(list)){
164 175 for(LymsHisInfo hisInfo : list){
165 176 try{
166   - String result = upHisInfo(hisInfo);
  177 + String result = upHisInfo(hisInfo,2);
167 178 if(StringUtil.isNotEmpty(result)){
168 179 log.error("upAllHisInfo--->his患者上传失败,result={},info={}",result,hisInfo);
169 180 }
170 181  
171 182  
172 183  
173 184  
... ... @@ -212,23 +223,47 @@
212 223  
213 224 /**
214 225 * 处理数据,执行
215   -// * @param lymsHisInfo
  226 + * @param lymsHisInfo
  227 + *@param type 1 为手动上传 2为一键上传
216 228 */
217   - private String collateData(LymsHisInfo lymsHisInfo){
  229 + public String collateData(LymsHisInfo lymsHisInfo,Integer type){
218 230 if(null!=lymsHisInfo) {
  231 +
  232 + QueryWrapper<LymsPatient> wrapper = new QueryWrapper<>();
  233 + wrapper.eq("pname",lymsHisInfo.getName());
  234 + wrapper.eq("enrolment_phone",lymsHisInfo.getPhone());
  235 + List<LymsPatient> listPatient = lymsPatientService.list(wrapper);
  236 + LymsPatient patient=CollectionUtils.isNotEmpty(listPatient) ? listPatient.get(0) : null;
  237 + Boolean b=false;
  238 + Map<Integer,String> params=new HashMap<>();
219 239 //姓名
220 240 String name = lymsHisInfo.getName();
221 241 if (StringUtil.isEmpty(name)){
222   - String remark= "患者姓名不能为空,请补全信息后再上传。";
223   - lymsHisInfo.setRemark(remark);
224   - return remark;
  242 + if(patient!=null&&StringUtil.isNotEmpty(patient.getPname())) {
  243 + b=true;
  244 + String pname = patient.getPname();
  245 + lymsHisInfo.setName(pname);
  246 + // this.updateById(lymsHisInfo);
  247 + }else {
  248 + String remark= "患者姓名不能为空,请补全信息后再上传。";
  249 + // lymsHisInfo.setRemark(remark);
  250 + params.put(1,remark);
  251 +
  252 + }
225 253 }
226 254 //性别
227 255 Integer sex = null;
228 256 if (StringUtil.isEmpty(lymsHisInfo.getSex())){
229   - String remark= "患者性别不能为空,请补全信息后再上传。";
230   - lymsHisInfo.setRemark(remark);
231   - return remark;
  257 + if(patient!=null&&patient.getSex()!=null) {
  258 + b=true;
  259 + lymsHisInfo.setSex(patient.getSex()==1?"男":"女");
  260 + // this.updateById(lymsHisInfo);
  261 + }else {
  262 + String remark= "患者性别不能为空,请补全信息后再上传。";
  263 + //lymsHisInfo.setRemark(remark);
  264 + params.put(2,remark);
  265 +
  266 + }
232 267 }
233 268 if("男".equals(lymsHisInfo.getSex())){
234 269 sex=1;
235 270  
236 271  
237 272  
238 273  
239 274  
240 275  
241 276  
... ... @@ -238,47 +273,66 @@
238 273 //生日
239 274 String birthday = lymsHisInfo.getBirthday();
240 275 if (StringUtil.isEmpty(birthday)){
241   - String remark= "患者生日不能为空,请补全信息后再上传。";
242   - lymsHisInfo.setRemark(remark);
243   - return remark;
  276 + if(patient!=null&&StringUtil.isNotEmpty(patient.getBirth())) {
  277 + b=true;
  278 + String birth = patient.getBirth();
  279 + lymsHisInfo.setBirthday(birth);
  280 + //this.updateById(lymsHisInfo);
  281 + }else {
  282 + String remark= "患者生日不能为空,请补全信息后再上传。";
  283 + //lymsHisInfo.setRemark(remark);
  284 + params.put(3,remark);
  285 +
  286 + }
  287 +
244 288 }
245 289 //电话
246 290 String phone = lymsHisInfo.getPhone();
247 291 if (StringUtil.isEmpty(phone)){
248   - String remark= "患者电话不能为空,请补全信息后再上传。";
249   - lymsHisInfo.setRemark(remark);
250   - return remark;
  292 + if(patient!=null) {
  293 + b=true;
  294 + String enrolmentPhone = patient.getEnrolmentPhone();
  295 + lymsHisInfo.setPhone(enrolmentPhone);
  296 + // this.updateById(lymsHisInfo);
  297 + }else {
  298 + String remark= "患者电话不能为空,请补全信息后再上传。";
  299 + //lymsHisInfo.setRemark(remark);
  300 + params.put(4,remark);
  301 +
  302 + }
  303 +
251 304 }
252 305 //患者(身份证)
253 306 String idCard = lymsHisInfo.getIdcard();
254 307 if (StringUtil.isEmpty(idCard)) {
255   - QueryWrapper<LymsPatient> queryWrapper = new QueryWrapper<>();
256   - queryWrapper.eq("pname",lymsHisInfo.getName());
257   - queryWrapper.eq("enrolment_phone",lymsHisInfo.getPhone());
258   - List<LymsPatient> list = lymsPatientService.list(queryWrapper);
259   - if(CollectionUtils.isNotEmpty(list)){
260   - String idno = list.get(0).getIdno();
  308 + if(CollectionUtils.isNotEmpty(listPatient)){
  309 + b=true;
  310 + String idno = patient.getIdno();
261 311 lymsHisInfo.setIdcard(idno);
262   - this.updateById(lymsHisInfo);
  312 + // this.updateById(lymsHisInfo);
263 313 }else{
264 314 String remark= "患者身份证号不存在,请等待患者注册补全身份证信息后再上传。";
265   - lymsHisInfo.setRemark(remark);
266   - return remark;
  315 + //lymsHisInfo.setRemark(remark);
  316 + params.put(5,remark);
  317 +
267 318 }
268 319 }
269 320  
270   - //判断患者是否存在
271   - LymsPatient patientQuery = new LymsPatient();
272   - patientQuery.setIdno(idCard.toLowerCase());
273   - LymsPatient patient = lymsPatientService.getOne(Wrappers.query(patientQuery));
274 321  
  322 +
  323 +
  324 +
  325 + /* patientQuery.setIdno(idCard.toLowerCase());
  326 + LymsPatient patient = lymsPatientService.getOne(Wrappers.query(patientQuery));*/
  327 +
275 328 //判断医院是否平台收费,是否存在订单
276 329 LymsHospital lymsHospital = lymsHospitalService.getById(Integer.valueOf(lymsHisInfo.getHospitalId()));
277 330 if(ChargeWay.PLATFORM.getCode()==lymsHospital.getChargeWay()){
278 331 if(patient == null){
279 332 String remark= "患者还没有缴费,暂时不能上传";
280   - lymsHisInfo.setRemark(remark);
281   - return remark;
  333 + // lymsHisInfo.setRemark(remark);
  334 + params.put(6,remark);
  335 +
282 336 }
283 337 QueryWrapper<LymsOrder> queryWrapper = new QueryWrapper<>();
284 338 queryWrapper.eq("pid",patient.getId());
... ... @@ -287,8 +341,10 @@
287 341 List<LymsOrder> list = lymsOrderService.list(queryWrapper);
288 342 if(CollectionUtils.isEmpty(list)){
289 343 String remark= "患者还没有缴费,暂时不能上传";
290   - lymsHisInfo.setRemark(remark);
291   - return remark;
  344 + // lymsHisInfo.setRemark(remark);
  345 + params.put(6,remark);
  346 + }else {
  347 + lymsHisInfo.setIsOpen(1);
292 348 }
293 349 }
294 350  
... ... @@ -303,8 +359,9 @@
303 359 deptId = lymsHdeparts.getDid();
304 360 }else {
305 361 String remark="医院科室不存在,请增加"+deptName;
306   - lymsHisInfo.setRemark(remark);
307   - return remark;
  362 + //lymsHisInfo.setRemark(remark);
  363 + params.put(7,remark);
  364 +
308 365 }
309 366 //医生
310 367 Integer doctorId = null;//医生id
... ... @@ -318,8 +375,8 @@
318 375 doctorId = lymsDoctors.get(0).getDid();
319 376 }else {
320 377 String remark= "医生不存在,请在"+deptName+"下面增加"+doctorName+"医生!";
321   - lymsHisInfo.setRemark(remark);
322   - return remark;
  378 + //lymsHisInfo.setRemark(remark);
  379 + params.put(8,remark);
323 380 }
324 381  
325 382 //疾病
326 383  
327 384  
... ... @@ -330,17 +387,18 @@
330 387 Diagnose diagnose = this.getDiagnoseByName(diagnoseName);
331 388 if(diagnose == null){
332 389 String remark= "疾病["+diagnoseName+"]不存在,请在设置-字典管理中添加疾病或在疾病映射中添加映射关系。";
333   - lymsHisInfo.setRemark(remark);
334   - return remark;
  390 + //lymsHisInfo.setRemark(remark);
  391 + params.put(9,remark);
  392 + }else {
  393 + diagnoseIds.add(diagnose.getDiagnoseCode()!=null?diagnose.getDiagnoseCode().toString():"");
  394 + diagnoseMap.put(diagnoseName,diagnose);
335 395 }
336   - diagnoseIds.add(diagnose.getDiagnoseCode().toString());
337   - diagnoseMap.put(diagnoseName,diagnose);
338 396 }
339 397  
340 398 if (diagnoseIds.size()>1){
341 399 String remark= "该患者存在多种疾病,请手动上传";
342   - lymsHisInfo.setRemark(remark);
343   - return remark;
  400 + //lymsHisInfo.setRemark(remark);
  401 + params.put(10,remark);
344 402 }
345 403 /*
346 404 List<String> diagnoseOrmIds = new ArrayList<>();//疾病映射ids
347 405  
348 406  
349 407  
350 408  
... ... @@ -377,25 +435,78 @@
377 435 }
378 436 }*/
379 437  
380   - if(!"产科".equals(deptName)){
  438 + //手动上传不卡条件,自动上传的时候才卡
  439 + if (type==2){
381 440 //知识库
382   - List<ArticleInfo> articleList= articleInfoService.list(new QueryWrapper<ArticleInfo>()
383   - .in("iid",diagnoseIds));
384   - if (CollectionUtils.isEmpty(articleList)||articleList.size()<18){
385   - String remark= "该患者疾病文章不足18篇";
386   - lymsHisInfo.setRemark(remark);
387   - return remark;
  441 + if (diagnoseIds.size()>0){
  442 + List<ArticleInfo> articleList= articleInfoService.list(new QueryWrapper<ArticleInfo>()
  443 + .in("iid",diagnoseIds));
  444 + if (CollectionUtils.isEmpty(articleList)||articleList.size()<18){
  445 + String remark= "该患者疾病文章不足18篇,(缺少"+(18-articleList.size())+"篇)";
  446 + //lymsHisInfo.setRemark(remark);
  447 + params.put(11,remark);
  448 + }
388 449 }
  450 + }
  451 + //当前科室不为产科并且是自动上传时才卡
  452 + if(!deptName.contains("产科")&&type==2){
389 453 //回访
390   - List<LymsChatInfo> chatList= lymsChatInfoService.list(new QueryWrapper<LymsChatInfo>().in("illid",diagnoseIds));
391   - if (CollectionUtils.isEmpty(chatList) ||
392   - chatList.stream().collect(Collectors.groupingBy(LymsChatInfo::getType)).size()<5){
393   - String remark= "该患者疾病回访内容不足5种类型";
394   - lymsHisInfo.setRemark(remark);
395   - return remark;
  454 + if (diagnoseIds.size()>0){
  455 + List<LymsChatInfo> chatList= lymsChatInfoService.list(new QueryWrapper<LymsChatInfo>().in("illid",diagnoseIds));
  456 + Map<Integer,List<LymsChatInfo>> map= chatList.stream().collect(Collectors.groupingBy(LymsChatInfo::getType));
  457 + if (CollectionUtils.isEmpty(chatList) ||
  458 + map.size()<5){
  459 + //1:第二天2:第五天3:第十天4:第二十天5:第三十天
  460 + String str="";
  461 + for (int i = 1; i <6 ; i++) {
  462 + if (!map.containsKey(i)){
  463 + str+= ChatEnum.getName(i)+" ";
  464 + }
  465 + }
  466 + String remark= "该患者疾病回访内容不足5种类型(缺少 "+str+")";
  467 + //lymsHisInfo.setRemark(remark);
  468 + params.put(12,remark);
  469 + }
396 470 }
397 471 }
398 472  
  473 + if (CollectionUtils.isNotEmpty(params)){
  474 + //自动同步his用户基本信息
  475 + if (b){
  476 + this.updateById(lymsHisInfo);
  477 + }
  478 + List<LymsWorkMessage> workMessageList=new ArrayList<>();
  479 + StringBuffer sb=new StringBuffer();
  480 + params.entrySet().stream().forEach(entry -> {
  481 + LymsWorkMessage lymsWorkMessage=new LymsWorkMessage();
  482 + Integer key = entry.getKey();
  483 + String value = entry.getValue();
  484 + if (key==9 ||key==10 ){
  485 + lymsWorkMessage.setType(1);
  486 + }else if (key==11 ||key==12){
  487 + lymsWorkMessage.setType(2);
  488 + }else {
  489 + lymsWorkMessage.setType(3);
  490 + }
  491 + sb.append(value).append(",");
  492 + lymsWorkMessage.setRemark(value);
  493 + lymsWorkMessage.setCreated(new Date());
  494 + lymsWorkMessage.setDept(deptName);
  495 + lymsWorkMessage.setHisInfoId(lymsHisInfo.getId());
  496 + lymsWorkMessage.setHospital(lymsHospital.getHname());
  497 + lymsWorkMessage.setHospitalId(lymsHospital.getHid());
  498 + lymsWorkMessage.setPhone(phone);
  499 + lymsWorkMessage.setUsername(name);
  500 + workMessageList.add(lymsWorkMessage);
  501 + });
  502 + if (CollectionUtils.isNotEmpty(workMessageList)){
  503 + lymsWorkMessageService.saveBatch(workMessageList);
  504 + lymsHisInfo.setRemark(sb.toString().substring(0,sb.length()-1));
  505 + }
  506 + return params.toString();
  507 + }
  508 +
  509 +
399 510 if (null != patient) {
400 511 QueryWrapper<LymsPcase> queryWrapper = new QueryWrapper<>();
401 512 queryWrapper.eq("pid", patient.getId());
... ... @@ -447,6 +558,7 @@
447 558 }
448 559 return null;
449 560 }
  561 +
450 562  
451 563 //添加修改患者方法
452 564 @Transactional
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsPatientWechatServiceImpl.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.lyms.talkonlineweb.domain.LymsPatientWechat;
  5 +import com.lyms.talkonlineweb.mapper.LymsPatientWechatMapper;
  6 +import com.lyms.talkonlineweb.service.LymsPatientWechatService;
  7 +import org.springframework.stereotype.Service;
  8 +import org.springframework.transaction.annotation.Transactional;
  9 +
  10 +@Transactional
  11 +@Service
  12 +public class LymsPatientWechatServiceImpl extends ServiceImpl<LymsPatientWechatMapper, LymsPatientWechat>
  13 + implements LymsPatientWechatService {
  14 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsWorkMessageServiceImpl.java View file @ 30dfcca
  1 +package com.lyms.talkonlineweb.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.lyms.talkonlineweb.domain.LymsUser;
  5 +import com.lyms.talkonlineweb.mapper.LymsUserMapper;
  6 +import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +import com.lyms.talkonlineweb.domain.LymsWorkMessage;
  10 +import com.lyms.talkonlineweb.mapper.LymsWorkMessageMapper;
  11 +import com.lyms.talkonlineweb.service.LymsWorkMessageService;
  12 + /**
  13 + * ;(lyms_work_message)表服务实现类
  14 + * @author : http://www.chiner.pro
  15 + * @date : 2024-2-6
  16 + */
  17 +@Service
  18 +public class LymsWorkMessageServiceImpl extends ServiceImpl<LymsWorkMessageMapper, LymsWorkMessage> implements LymsWorkMessageService{
  19 +
  20 +
  21 +
  22 +}
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/DoctorMsgNotifyTask.java View file @ 30dfcca
1 1 package com.lyms.talkonlineweb.task;
2 2  
3 3 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4 +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
4 5 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 6 import com.lyms.talkonlineweb.domain.DoctorChatCount;
6 7 import com.lyms.talkonlineweb.domain.LymsDoctor;
7 8  
8 9  
9 10  
... ... @@ -66,8 +67,43 @@
66 67  
67 68 }
68 69  
  70 + }
69 71  
  72 + /**
  73 + * 每天上午11点和下午16点给医生推送未读消息
  74 + */
  75 + @Scheduled(cron = "0 0 11,16 * * ?")
  76 + public void doctorMsgTask(){
  77 + if(!on_off){
  78 + return;
  79 + }
  80 + String startTime = DateUtil.getDateTime(new Date(),"HH:mm");
  81 + log.info("医生消息提醒,时间:{}",startTime);
  82 + List<DoctorChatCount> doctorChatCounts = doctorWorktimeService.selectDoctorChat();
  83 + if (CollectionUtils.isNotEmpty(doctorChatCounts)){
  84 + for(DoctorChatCount doctor: doctorChatCounts) {
  85 + if(StringUtil.isEmpty(doctor.getGzopenid())){
  86 + log.warn("医生消息提醒,未获取到公众号openid:{}",doctor);
  87 + continue;
  88 + }
  89 + Map<String,Object> mapTemplate=new HashMap<>();
  90 + mapTemplate.put("first","医生消息提醒");
  91 + mapTemplate.put("keyword1",new DataEntity("尊敬的医生:"+doctor.getDname(),"#173177"));
  92 + mapTemplate.put("keyword2",new DataEntity("您有患者消息"+doctor.getCount()+"条,请及时查看","#173177"));
  93 + mapTemplate.put("remark","请点击下方进入小程序,根据病例点咨询查看医生回访信息。");
  94 + Map<String,Object> map=new HashMap<>();
  95 + map.put("plogin", doctor.getDlogin());
  96 + map.put("passwd", doctor.getDpasswd());
  97 + try {
  98 + Integer code= WeiXinUtil.DoctorSendWeChatMsg(doctor.getGzopenid(), Constant.GZ_TEMPLATE_ID_DOCTOR_VISIT,mapTemplate,map);
  99 + log.info("医生消息提醒,code:{},{}",code,doctor);
  100 + } catch (Exception e) {
  101 + log.error("医生消息提醒异常,{}",doctor,e);
  102 + }
70 103  
  104 + }
  105 + }
71 106 }
  107 +
72 108 }
talkonlineweb/src/main/java/com/lyms/talkonlineweb/task/HisPatientsAutoUploadTask.java View file @ 30dfcca
... ... @@ -35,17 +35,14 @@
35 35 @Autowired
36 36 private LymsHisInfoService lymsHisInfoService;
37 37  
38   - @Autowired
39   - private LymsHospitalService lymsHospitalService; //医院
40   -
41   - // @Scheduled(cron = "0 0 13,21 * * ?")
  38 + @Scheduled(cron = "0 0 0 * * ?")
42 39 public void hisPatientsAutoUploadTask(){
43 40 if(!on_off){
44 41 return;
45 42 }
46 43 log.info("his患者信息自动上传任务开始...");
47 44 //查询3天内未上传的数据
48   - LambdaQueryWrapper<LymsHisInfo> query = new QueryWrapper<LymsHisInfo>()
  45 + /* LambdaQueryWrapper<LymsHisInfo> query = new QueryWrapper<LymsHisInfo>()
49 46 .lambda().eq(LymsHisInfo::getUpType, 0)
50 47 .ge(LymsHisInfo::getCreatedtime, DateUtil.addDay(new Date(),-3));
51 48 List<LymsHisInfo> list = lymsHisInfoService.list(query);
... ... @@ -53,7 +50,7 @@
53 50 if (CollectionUtils.isNotEmpty(list)){
54 51 for(LymsHisInfo hisInfo : list){
55 52 try{
56   - String result = lymsHisInfoService.upHisInfo(hisInfo);
  53 + String result = lymsHisInfoService.upHisInfo(hisInfo,2);
57 54 if(StringUtil.isNotEmpty(result)){
58 55 log.error("his患者上传失败,result={},info={}",result,hisInfo);
59 56 }
... ... @@ -62,7 +59,8 @@
62 59 log.error("his患者信息自动上传任务异常",e);
63 60 }
64 61 }
65   - }
  62 + }*/
  63 + lymsHisInfoService.upAllHisInfo();
66 64  
67 65 log.info("his患者信息自动上传任务结束...");
68 66  
talkonlineweb/src/main/resources/mapper/LymsDoctorWorktimeMapper.xml View file @ 30dfcca
... ... @@ -35,5 +35,20 @@
35 35  
36 36 </select>
37 37  
  38 + <select id="selectDoctorChat" resultType="com.lyms.talkonlineweb.domain.DoctorChatCount">
  39 + SELECT
  40 + d.did,
  41 + d.dlogin,
  42 + d.dpasswd,
  43 + d.dname,
  44 + d.mobile,
  45 + d.gzopenid,
  46 + c.count
  47 +FROM
  48 + lyms_doctor d
  49 +INNER JOIN lyms_doctor_worktime w ON d.did = w.did
  50 +INNER JOIN v_doctor_chat_count c ON d.did = c.did
  51 +AND c.count > 0
  52 + </select>
38 53 </mapper>
talkonlineweb/src/main/resources/mapper/LymsHisInfoMapper.xml View file @ 30dfcca
... ... @@ -29,5 +29,15 @@
29 29 doctor,up_type,up_time,created,
30 30 createdtime
31 31 </sql>
  32 + <select id="selectByOrder" resultMap="BaseResultMap">
  33 + SELECT
  34 + hi.*
  35 +FROM
  36 + lyms_order o
  37 +INNER JOIN lyms_patient p ON p.id=o.pid and o.`status`=1
  38 +INNER JOIN lyms_his_info hi ON p.idno=hi.idCard and hi.up_type=0
  39 +INNER JOIN lyms_hospital h ON h.hid=hi.hospitalId and charge_way=1
  40 +where <![CDATA[o.service_end_time>=#{endTime}]]>
  41 + </select>
32 42 </mapper>
talkonlineweb/src/main/resources/mapper/LymsPatientWechatMapper.xml View file @ 30dfcca
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsPatientWechatMapper">
  4 + <resultMap type="com.lyms.talkonlineweb.domain.LymsPatientWechat" id="LymsPatientWechatMap">
  5 + <result property="id" column="id" jdbcType="INTEGER"/>
  6 + <result property="idCard" column="idcard" jdbcType="INTEGER"/>
  7 + <result property="status" column="status" jdbcType="INTEGER"/>
  8 + <result property="created" column="created" jdbcType="TIMESTAMP"/>
  9 + </resultMap>
  10 +</mapper>
talkonlineweb/src/main/resources/mapper/LymsWorkMessageMapper.xml View file @ 30dfcca
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="com.lyms.talkonlineweb.mapper.LymsWorkMessageMapper">
  4 + <resultMap type="com.lyms.talkonlineweb.domain.LymsWorkMessage" id="LymsWorkMessageMap">
  5 + <result property="id" column="id" jdbcType="INTEGER"/>
  6 + <result property="hisInfoId" column="his_info_id" jdbcType="INTEGER"/>
  7 + <result property="username" column="username" jdbcType="VARCHAR"/>
  8 + <result property="hospitalId" column="hospital_id" jdbcType="INTEGER"/>
  9 + <result property="hospital" column="hospital" jdbcType="VARCHAR"/>
  10 + <result property="dept" column="dept" jdbcType="VARCHAR"/>
  11 + <result property="phone" column="phone" jdbcType="VARCHAR"/>
  12 + <result property="content" column="content" jdbcType="VARCHAR"/>
  13 + <result property="remark" column="remark" jdbcType="VARCHAR"/>
  14 + <result property="type" column="type" jdbcType="INTEGER"/>
  15 + <result property="isRead" column="is_read" jdbcType="INTEGER"/>
  16 + <result property="created" column="created" jdbcType="TIMESTAMP"/>
  17 + </resultMap>
  18 +</mapper>