Commit 37b8415994450e8625ebcebd6b357a91da8e4216
1 parent
c8f57c4be5
Exists in
master
and in
6 other branches
提升短信
Showing 3 changed files with 268 additions and 4 deletions
platform-common/src/main/java/com/lyms/platform/common/enums/WxTempleteIdEnums.java
View file @
37b8415
| ... | ... | @@ -22,8 +22,8 @@ | 
| 22 | 22 | CHAN_YI_BAN_ZHI_DAO("H2_ucLqVEbsZAv-EZcmUDpD1Zul5NGqMoJktHT0u4gw","产妇一般指导"),//产妇 | 
| 23 | 23 | BABY_YI_BAN_ZHI_DAO("dqvyESU8UXx1V3cIMQDqj4PLxI6T9-sgihQcs3ZGL9E","儿童一般指导"),//儿童 | 
| 24 | 24 | |
| 25 | - YI_SHENG_ZHI_DAO("OggqiSHitLkCgSLCaCH72reCZzaw5NyG8iO56InQiQg","医生指导"),//指导 | |
| 26 | - WEI_JI_ZHI_DAO("fNkkLSp_gS-YWvzji6gwgdTddl4XBlk8SNP7FRksrfk","危急值提醒");//危急值提醒 | |
| 25 | + YI_SHENG_ZHI_DAO("OggqiSHitLkCgSLCaCH72reCZzaw5NyG8iO56InQiQg","医生指导");//指导 | |
| 26 | +// WEI_JI_ZHI_DAO("fNkkLSp_gS-YWvzji6gwgdTddl4XBlk8SNP7FRksrfk","危急值提醒");//危急值提醒 | |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | 
platform-msg-generate/src/main/java/com/lyms/platform/msg/service/impl/MsgGenerateServiceImpl.java
View file @
37b8415
| ... | ... | @@ -9,11 +9,15 @@ | 
| 9 | 9 | import com.lyms.platform.msg.worker.TempleteMsgGenerateWorker; | 
| 10 | 10 | import com.lyms.platform.msg.worker.YunAmsMsgGenerateWorker; | 
| 11 | 11 | |
| 12 | +import com.lyms.platform.permission.service.BabyPatientExtendEarFollowUpService; | |
| 13 | +import com.lyms.platform.permission.service.BabyPatientExtendEarHearingDiagnoseService; | |
| 14 | +import com.lyms.platform.permission.service.BabyPatientExtendEarScreenService; | |
| 12 | 15 | import com.lyms.platform.pojo.SmsConfigModel; | 
| 13 | 16 | import org.apache.commons.collections.CollectionUtils; | 
| 14 | 17 | import org.slf4j.Logger; | 
| 15 | 18 | import org.slf4j.LoggerFactory; | 
| 16 | 19 | import org.springframework.beans.factory.annotation.Autowired; | 
| 20 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
| 17 | 21 | import org.springframework.stereotype.Service; | 
| 18 | 22 | |
| 19 | 23 | import java.util.*; | 
| 20 | 24 | |
| ... | ... | @@ -38,12 +42,24 @@ | 
| 38 | 42 | private IBaseService baseService; | 
| 39 | 43 | |
| 40 | 44 | @Autowired | 
| 45 | + private MongoTemplate mongoTemplate; | |
| 46 | + | |
| 47 | + @Autowired | |
| 41 | 48 | private YunBookbuildingService yunBookbuildingService; | 
| 42 | 49 | |
| 43 | 50 | @Autowired | 
| 44 | 51 | private SmsTemplateService smsTemplateService; | 
| 45 | 52 | |
| 46 | 53 | @Autowired | 
| 54 | + private BabyPatientExtendEarScreenService babyPatientExtendEarScreenService; | |
| 55 | + | |
| 56 | + @Autowired | |
| 57 | + private BabyPatientExtendEarHearingDiagnoseService hearingDiagnoseService; | |
| 58 | + | |
| 59 | + @Autowired | |
| 60 | + private BabyPatientExtendEarFollowUpService babyPatientExtendEarFollowUpService; | |
| 61 | + | |
| 62 | + @Autowired | |
| 47 | 63 | private HighRiskService highRiskService; | 
| 48 | 64 | |
| 49 | 65 | @Autowired | 
| ... | ... | @@ -147,7 +163,15 @@ | 
| 147 | 163 | end = configModels.size(); | 
| 148 | 164 | } | 
| 149 | 165 | TempleteMsgGenerateWorker worker = new TempleteMsgGenerateWorker(configModels.subList(i,end), | 
| 150 | - baseService,yunBookbuildingService,smsTemplateService,babyBookbuildingService,postReviewService); | |
| 166 | + baseService, | |
| 167 | + yunBookbuildingService, | |
| 168 | + smsTemplateService, | |
| 169 | + babyBookbuildingService, | |
| 170 | + postReviewService, | |
| 171 | + mongoTemplate, | |
| 172 | + babyPatientExtendEarScreenService, | |
| 173 | + hearingDiagnoseService, | |
| 174 | + babyPatientExtendEarFollowUpService); | |
| 151 | 175 | pool.execute(worker); | 
| 152 | 176 | } | 
| 153 | 177 | 
platform-msg-generate/src/main/java/com/lyms/platform/msg/worker/TempleteMsgGenerateWorker.java
View file @
37b8415
| ... | ... | @@ -8,11 +8,19 @@ | 
| 8 | 8 | import com.lyms.platform.msg.service.IBaseService; | 
| 9 | 9 | import com.lyms.platform.msg.utils.DateUtils; | 
| 10 | 10 | import com.lyms.platform.msg.utils.HelperUtils; | 
| 11 | +import com.lyms.platform.permission.model.*; | |
| 12 | +import com.lyms.platform.permission.service.BabyPatientExtendEarFollowUpService; | |
| 13 | +import com.lyms.platform.permission.service.BabyPatientExtendEarHearingDiagnoseService; | |
| 14 | +import com.lyms.platform.permission.service.BabyPatientExtendEarScreenService; | |
| 11 | 15 | import com.lyms.platform.pojo.*; | 
| 12 | 16 | import com.lyms.platform.query.*; | 
| 13 | 17 | import org.apache.commons.collections.CollectionUtils; | 
| 14 | 18 | import org.slf4j.Logger; | 
| 15 | 19 | import org.slf4j.LoggerFactory; | 
| 20 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 21 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
| 22 | +import org.springframework.data.mongodb.core.query.Criteria; | |
| 23 | +import org.springframework.data.mongodb.core.query.Query; | |
| 16 | 24 | |
| 17 | 25 | import java.util.*; | 
| 18 | 26 | import java.util.concurrent.ExecutorService; | 
| 19 | 27 | |
| 20 | 28 | |
| ... | ... | @@ -33,18 +41,29 @@ | 
| 33 | 41 | |
| 34 | 42 | private YunBookbuildingService yunBookbuildingService; | 
| 35 | 43 | |
| 44 | + private MongoTemplate mongoTemplate; | |
| 36 | 45 | |
| 37 | 46 | private SmsTemplateService smsTemplateService; | 
| 38 | 47 | |
| 39 | 48 | private BabyBookbuildingService babyBookbuildingService; | 
| 40 | 49 | |
| 50 | + private BabyPatientExtendEarScreenService babyPatientExtendEarScreenService; | |
| 51 | + | |
| 52 | + private BabyPatientExtendEarHearingDiagnoseService hearingDiagnoseService; | |
| 53 | + | |
| 54 | + private BabyPatientExtendEarFollowUpService babyPatientExtendEarFollowUpService; | |
| 55 | + | |
| 41 | 56 | private PostReviewService postReviewService; | 
| 42 | 57 | |
| 43 | 58 | public TempleteMsgGenerateWorker(List<SmsConfigModel> configs, IBaseService baseService, | 
| 44 | 59 | YunBookbuildingService yunBookbuildingService, | 
| 45 | 60 | SmsTemplateService smsTemplateService, | 
| 46 | 61 | BabyBookbuildingService babyBookbuildingService, | 
| 47 | - PostReviewService postReviewService) | |
| 62 | + PostReviewService postReviewService, | |
| 63 | + MongoTemplate mongoTemplate, | |
| 64 | + BabyPatientExtendEarScreenService babyPatientExtendEarScreenService, | |
| 65 | + BabyPatientExtendEarHearingDiagnoseService hearingDiagnoseService, | |
| 66 | + BabyPatientExtendEarFollowUpService babyPatientExtendEarFollowUpService) | |
| 48 | 67 | { | 
| 49 | 68 | this.configs = configs; | 
| 50 | 69 | this.baseService = baseService; | 
| ... | ... | @@ -52,6 +71,10 @@ | 
| 52 | 71 | this.smsTemplateService = smsTemplateService; | 
| 53 | 72 | this.babyBookbuildingService = babyBookbuildingService; | 
| 54 | 73 | this.postReviewService = postReviewService; | 
| 74 | + this.mongoTemplate = mongoTemplate; | |
| 75 | + this.babyPatientExtendEarScreenService = babyPatientExtendEarScreenService; | |
| 76 | + this.hearingDiagnoseService = hearingDiagnoseService; | |
| 77 | + this.babyPatientExtendEarFollowUpService = babyPatientExtendEarFollowUpService; | |
| 55 | 78 | } | 
| 56 | 79 | |
| 57 | 80 | @Override | 
| ... | ... | @@ -537,6 +560,223 @@ | 
| 537 | 560 | } | 
| 538 | 561 | } | 
| 539 | 562 | } | 
| 563 | + } | |
| 564 | + //儿童眼保键预约提醒 | |
| 565 | + else if (smsType == SmsServiceEnums.YBYYTX.getId()) | |
| 566 | + { | |
| 567 | + //发送短信集合 | |
| 568 | + MsgListRequest list = new MsgListRequest(); | |
| 569 | + List<MsgRequest> messages = new ArrayList<>(); | |
| 570 | + | |
| 571 | + Date orderDate = DateUtils.addDay(new Date(), sendTimeType); | |
| 572 | + orderDate = DateUtils.formatDate(orderDate,DateUtils.Y_M_D); | |
| 573 | + | |
| 574 | + List<BabyEyeCheck> checkModels = mongoTemplate.find(Query.query(Criteria.where("nextCheckTime").is(orderDate) | |
| 575 | + .and("yn").ne("0").and("hospitalId").is(tempHid)), BabyEyeCheck.class); | |
| 576 | + if (CollectionUtils.isNotEmpty(checkModels)) | |
| 577 | + { | |
| 578 | + for(BabyEyeCheck eyecheck : checkModels) | |
| 579 | + { | |
| 580 | + | |
| 581 | + BabyModelQuery query = new BabyModelQuery(); | |
| 582 | + query.setYn(YnEnums.YES.getId()); | |
| 583 | + query.setId(eyecheck.getBabyId()); | |
| 584 | + | |
| 585 | + //查询符合条件儿童 | |
| 586 | + List<BabyModel> babyModels = babyBookbuildingService.queryBabyBuildByCond(query); | |
| 587 | + if (CollectionUtils.isNotEmpty(babyModels)) | |
| 588 | + { | |
| 589 | + for (BabyModel model : babyModels) | |
| 590 | + { | |
| 591 | + //短信前缀 | |
| 592 | + String messagePrefix = baseService.getSmsPrefix(config, model.getBuildDoctor(),ServiceObjEnums.BABYOBJ.getId()); | |
| 593 | + String messageContent = "【"+messagePrefix+"】"+template.getContent(); | |
| 594 | + messageContent = HelperUtils.replaceEL(model.getName(), orderDate, messageContent); | |
| 595 | + | |
| 596 | + String itemName = "儿童保健"; | |
| 597 | + String nextCheckTime = DateUtils.getDateStr(orderDate,DateUtils.Y_M_D); | |
| 598 | + | |
| 599 | + MsgRequest request = HelperUtils.getMessageRequest(messageContent, model.getMphone(), | |
| 600 | + ServiceObjEnums.BABYOBJ.getId(), template.getSmsType(), | |
| 601 | + model.getHospitalId(), template.getId(), model.getId(), itemName, nextCheckTime, "", | |
| 602 | + WxTempleteIdEnums.ER_TONG_TI_XING.getId(),service); | |
| 603 | + | |
| 604 | + messages.add(request); | |
| 605 | + } | |
| 606 | + } | |
| 607 | + } | |
| 608 | + } | |
| 609 | + | |
| 610 | + list.setMessages(messages); | |
| 611 | + HelperUtils.sendMsg(list); | |
| 612 | + } | |
| 613 | + //儿童听力筛查预约提醒 | |
| 614 | + else if (smsType == SmsServiceEnums.TSYYTX.getId()) | |
| 615 | + { | |
| 616 | + //发送短信集合 | |
| 617 | + MsgListRequest list = new MsgListRequest(); | |
| 618 | + List<MsgRequest> messages = new ArrayList<>(); | |
| 619 | + | |
| 620 | + Date orderDate = DateUtils.addDay(new Date(), sendTimeType); | |
| 621 | + orderDate = DateUtils.formatDate(orderDate,DateUtils.Y_M_D); | |
| 622 | + | |
| 623 | + | |
| 624 | + BabyPatientExtendEarScreenQuery screenQuery = new BabyPatientExtendEarScreenQuery(); | |
| 625 | + screenQuery.setNextStartTime(DateUtils.getDateStr(orderDate, DateUtils.Y_M_D)); | |
| 626 | + screenQuery.setNextEndTime(DateUtils.getDateStr(orderDate,DateUtils.Y_M_D)); | |
| 627 | + screenQuery.setCheckHospitalId(tempHid); | |
| 628 | + screenQuery.setStatus(0); | |
| 629 | + screenQuery.setSort("screen_date"); | |
| 630 | + screenQuery.setNeed("y"); | |
| 631 | + | |
| 632 | + List<BabyPatientExtendEarScreen> babyPatientExtendEarScreens = babyPatientExtendEarScreenService.queryEarScreenList(screenQuery); | |
| 633 | + if (CollectionUtils.isNotEmpty(babyPatientExtendEarScreens)) | |
| 634 | + { | |
| 635 | + for(BabyPatientExtendEarScreen ear : babyPatientExtendEarScreens) | |
| 636 | + { | |
| 637 | + | |
| 638 | + BabyModelQuery query = new BabyModelQuery(); | |
| 639 | + query.setYn(YnEnums.YES.getId()); | |
| 640 | + query.setId(ear.getBabyId()); | |
| 641 | + | |
| 642 | + //查询符合条件儿童 | |
| 643 | + List<BabyModel> babyModels = babyBookbuildingService.queryBabyBuildByCond(query); | |
| 644 | + if (CollectionUtils.isNotEmpty(babyModels)) | |
| 645 | + { | |
| 646 | + for (BabyModel model : babyModels) | |
| 647 | + { | |
| 648 | + //短信前缀 | |
| 649 | + String messagePrefix = baseService.getSmsPrefix(config, model.getBuildDoctor(),ServiceObjEnums.BABYOBJ.getId()); | |
| 650 | + String messageContent = "【"+messagePrefix+"】"+template.getContent(); | |
| 651 | + messageContent = HelperUtils.replaceEL(model.getName(), orderDate, messageContent); | |
| 652 | + | |
| 653 | + String itemName = "儿童保健"; | |
| 654 | + String nextCheckTime = DateUtils.getDateStr(orderDate,DateUtils.Y_M_D); | |
| 655 | + | |
| 656 | + MsgRequest request = HelperUtils.getMessageRequest(messageContent, model.getMphone(), | |
| 657 | + ServiceObjEnums.BABYOBJ.getId(), template.getSmsType(), | |
| 658 | + model.getHospitalId(), template.getId(), model.getId(), itemName, nextCheckTime, "", | |
| 659 | + WxTempleteIdEnums.ER_TONG_TI_XING.getId(),service); | |
| 660 | + | |
| 661 | + messages.add(request); | |
| 662 | + } | |
| 663 | + } | |
| 664 | + } | |
| 665 | + } | |
| 666 | + | |
| 667 | + list.setMessages(messages); | |
| 668 | + HelperUtils.sendMsg(list); | |
| 669 | + } | |
| 670 | + //儿童听力诊断预约提醒 | |
| 671 | + else if (smsType == SmsServiceEnums.TYZDYYTX.getId()) | |
| 672 | + { | |
| 673 | + //发送短信集合 | |
| 674 | + MsgListRequest list = new MsgListRequest(); | |
| 675 | + List<MsgRequest> messages = new ArrayList<>(); | |
| 676 | + | |
| 677 | + Date orderDate = DateUtils.addDay(new Date(), sendTimeType); | |
| 678 | + orderDate = DateUtils.formatDate(orderDate,DateUtils.Y_M_D); | |
| 679 | + | |
| 680 | + BabyPatientExtendEarHearingDiagnoseQuery diagnoseQuery = new BabyPatientExtendEarHearingDiagnoseQuery(); | |
| 681 | + diagnoseQuery.setDiagnNextStartTime(orderDate); | |
| 682 | + diagnoseQuery.setDiagnNextEndTime(orderDate); | |
| 683 | + diagnoseQuery.setHospitalId(tempHid); | |
| 684 | + diagnoseQuery.setSort("diagnose_time desc"); | |
| 685 | + | |
| 686 | + //已经诊断的数据 | |
| 687 | + List<BabyPatientExtendEarHearingDiagnose> hearingDiagnoseList = hearingDiagnoseService.getHdAndScreen(diagnoseQuery); | |
| 688 | + if (CollectionUtils.isNotEmpty(hearingDiagnoseList)) | |
| 689 | + { | |
| 690 | + for(BabyPatientExtendEarHearingDiagnose diagnose : hearingDiagnoseList) | |
| 691 | + { | |
| 692 | + | |
| 693 | + BabyModelQuery query = new BabyModelQuery(); | |
| 694 | + query.setYn(YnEnums.YES.getId()); | |
| 695 | + query.setId(diagnose.getBabyId()); | |
| 696 | + | |
| 697 | + //查询符合条件儿童 | |
| 698 | + List<BabyModel> babyModels = babyBookbuildingService.queryBabyBuildByCond(query); | |
| 699 | + if (CollectionUtils.isNotEmpty(babyModels)) | |
| 700 | + { | |
| 701 | + for (BabyModel model : babyModels) | |
| 702 | + { | |
| 703 | + //短信前缀 | |
| 704 | + String messagePrefix = baseService.getSmsPrefix(config, model.getBuildDoctor(),ServiceObjEnums.BABYOBJ.getId()); | |
| 705 | + String messageContent = "【"+messagePrefix+"】"+template.getContent(); | |
| 706 | + messageContent = HelperUtils.replaceEL(model.getName(), orderDate, messageContent); | |
| 707 | + | |
| 708 | + String itemName = "儿童保健"; | |
| 709 | + String nextCheckTime = DateUtils.getDateStr(orderDate,DateUtils.Y_M_D); | |
| 710 | + | |
| 711 | + MsgRequest request = HelperUtils.getMessageRequest(messageContent, model.getMphone(), | |
| 712 | + ServiceObjEnums.BABYOBJ.getId(), template.getSmsType(), | |
| 713 | + model.getHospitalId(), template.getId(), model.getId(), itemName, nextCheckTime, "", | |
| 714 | + WxTempleteIdEnums.ER_TONG_TI_XING.getId(),service); | |
| 715 | + | |
| 716 | + messages.add(request); | |
| 717 | + } | |
| 718 | + } | |
| 719 | + } | |
| 720 | + } | |
| 721 | + | |
| 722 | + list.setMessages(messages); | |
| 723 | + HelperUtils.sendMsg(list); | |
| 724 | + } | |
| 725 | + //儿童听力随访预约提醒 | |
| 726 | + else if (smsType == SmsServiceEnums.TLZDYYTX.getId()) | |
| 727 | + { | |
| 728 | + //发送短信集合 | |
| 729 | + MsgListRequest list = new MsgListRequest(); | |
| 730 | + List<MsgRequest> messages = new ArrayList<>(); | |
| 731 | + | |
| 732 | + Date orderDate = DateUtils.addDay(new Date(), sendTimeType); | |
| 733 | + orderDate = DateUtils.formatDate(orderDate,DateUtils.Y_M_D); | |
| 734 | + | |
| 735 | + | |
| 736 | + //查询条件 | |
| 737 | + BabyPatientExtendEarFollowUpQuery followUpQuery = new BabyPatientExtendEarFollowUpQuery(); | |
| 738 | + followUpQuery.setIfdel(0); | |
| 739 | + followUpQuery.setNextStartTime(DateUtils.getDateStr(orderDate,DateUtils.Y_M_D)); | |
| 740 | + followUpQuery.setNextEndTime(DateUtils.getDateStr(orderDate,DateUtils.Y_M_D)); | |
| 741 | + followUpQuery.setHospitalId(tempHid); | |
| 742 | + | |
| 743 | + List<BabyPatientExtendEarFollowUp> BabyPatientExtendEarFollowUpList = babyPatientExtendEarFollowUpService.queryBabyPatientExtendEarFollowUp(followUpQuery); | |
| 744 | + if (CollectionUtils.isNotEmpty(BabyPatientExtendEarFollowUpList)) | |
| 745 | + { | |
| 746 | + for(BabyPatientExtendEarFollowUp follow : BabyPatientExtendEarFollowUpList) | |
| 747 | + { | |
| 748 | + | |
| 749 | + BabyModelQuery query = new BabyModelQuery(); | |
| 750 | + query.setYn(YnEnums.YES.getId()); | |
| 751 | + query.setId(follow.getBabyId()); | |
| 752 | + | |
| 753 | + //查询符合条件儿童 | |
| 754 | + List<BabyModel> babyModels = babyBookbuildingService.queryBabyBuildByCond(query); | |
| 755 | + if (CollectionUtils.isNotEmpty(babyModels)) | |
| 756 | + { | |
| 757 | + for (BabyModel model : babyModels) | |
| 758 | + { | |
| 759 | + //短信前缀 | |
| 760 | + String messagePrefix = baseService.getSmsPrefix(config, model.getBuildDoctor(),ServiceObjEnums.BABYOBJ.getId()); | |
| 761 | + String messageContent = "【"+messagePrefix+"】"+template.getContent(); | |
| 762 | + messageContent = HelperUtils.replaceEL(model.getName(), orderDate, messageContent); | |
| 763 | + | |
| 764 | + String itemName = "儿童保健"; | |
| 765 | + String nextCheckTime = DateUtils.getDateStr(orderDate,DateUtils.Y_M_D); | |
| 766 | + | |
| 767 | + MsgRequest request = HelperUtils.getMessageRequest(messageContent, model.getMphone(), | |
| 768 | + ServiceObjEnums.BABYOBJ.getId(), template.getSmsType(), | |
| 769 | + model.getHospitalId(), template.getId(), model.getId(), itemName, nextCheckTime, "", | |
| 770 | + WxTempleteIdEnums.ER_TONG_TI_XING.getId(),service); | |
| 771 | + | |
| 772 | + messages.add(request); | |
| 773 | + } | |
| 774 | + } | |
| 775 | + } | |
| 776 | + } | |
| 777 | + | |
| 778 | + list.setMessages(messages); | |
| 779 | + HelperUtils.sendMsg(list); | |
| 540 | 780 | } | 
| 541 | 781 | } | 
| 542 | 782 |