Commit fd920c93121094e965e599dd7ac47c90fa001dd8
1 parent
38b951eae3
Exists in
master
and in
6 other branches
1
Showing 2 changed files with 123 additions and 3 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/SmsConfigController.java
View file @
fd920c9
| ... | ... | @@ -414,8 +414,10 @@ |
| 414 | 414 | |
| 415 | 415 | @RequestMapping(value = "/sms/build/send", method = RequestMethod.GET) |
| 416 | 416 | @ResponseBody |
| 417 | - public String querySmsConfAndTemplate(@RequestParam("patientId")String patientId){ | |
| 418 | - examinationFacade.createSendMsg(patientId); | |
| 417 | + public String querySmsConfAndTemplate(@RequestParam("patientId")String patientId, | |
| 418 | + @RequestParam("hospitalId")String hospitalId, | |
| 419 | + @RequestParam("doctorId")String doctorId){ | |
| 420 | + examinationFacade.createdSengMsg1(hospitalId,patientId,doctorId); | |
| 419 | 421 | return "0"; |
| 420 | 422 | } |
| 421 | 423 | @Autowired |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java
View file @
fd920c9
| ... | ... | @@ -363,7 +363,7 @@ |
| 363 | 363 | //发送推送消息 |
| 364 | 364 | patients.setSendMsgTime(new Date()); |
| 365 | 365 | } |
| 366 | - if(antExamModel.getSendMsg() != null || StringUtils.isNotEmpty(antExAddRequest.getVcCardNo())){ | |
| 366 | + if (antExamModel.getSendMsg() != null || StringUtils.isNotEmpty(antExAddRequest.getVcCardNo())) { | |
| 367 | 367 | patientsService.updatePatient(patients); |
| 368 | 368 | } |
| 369 | 369 | } |
| ... | ... | @@ -681,6 +681,124 @@ |
| 681 | 681 | updateChuAutoData(antExChuModel,excAddRequest, hospitalId, userId); |
| 682 | 682 | |
| 683 | 683 | return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); |
| 684 | + } | |
| 685 | + | |
| 686 | + /** | |
| 687 | + * | |
| 688 | + * @param hospitalId 院内系统的医院id | |
| 689 | + * @param patientId | |
| 690 | + * @param doctorId | |
| 691 | + */ | |
| 692 | + public void createdSengMsg1(String hospitalId,String patientId,String doctorId){ | |
| 693 | + Patients patient = patientsService.findOnePatientById(patientId); | |
| 694 | + //判断医院是否启动和对应的服务项是否启用 | |
| 695 | + SmsConfigModel configModel = new SmsConfigModel(); | |
| 696 | + int startType = smsConfigFacade.hospitalIsStart(hospitalId, configModel, SmsServiceEnums.FWDGTX.getId()); | |
| 697 | + if (startType == 0) { | |
| 698 | + return; | |
| 699 | + } | |
| 700 | + boolean isHightRisk = false; | |
| 701 | + if (patient.getRiskScore() != null) { | |
| 702 | + if (patient.getRiskScore() > 0) {//高危评分大于0 | |
| 703 | + if (CollectionUtils.isNotEmpty(patient.getRiskFactorId())) { | |
| 704 | + if (!"d42eec03-aa86-45b8-a4e0-78a0ff365fb6".equals(patient.getRiskFactorId().get(0))) { | |
| 705 | + isHightRisk = true; | |
| 706 | + } | |
| 707 | + } | |
| 708 | + } | |
| 709 | + } | |
| 710 | + SmsTemplateQuery query = new SmsTemplateQuery(); | |
| 711 | + query.setYn(YnEnums.YES.getId()); | |
| 712 | + query.setStatus(1); | |
| 713 | + query.setHospitalId(patient.getHospitalId()); | |
| 714 | + query.setServiceObj(ServiceObjEnums.YUNOBJ.getId()); | |
| 715 | + | |
| 716 | + //健康类型 0健康 1高危 | |
| 717 | + if (isHightRisk) {//高危孕妇 | |
| 718 | + query.setHealthType(1); | |
| 719 | + } else {//健康 | |
| 720 | + query.setHealthType(0); | |
| 721 | + } | |
| 722 | + | |
| 723 | + List<SmsTemplateModel> temps = smsTemplateService.querySmsTemplates(query); | |
| 724 | + | |
| 725 | + Integer serviceType = 0; | |
| 726 | + Integer serviceStatus = 0; | |
| 727 | + //根据服务状态和服务类型获取可以发送的模板 | |
| 728 | + List<SmsTemplateModel> sendList = smsConfigFacade.getSendTemplateByServiceStatus(temps, serviceType, serviceStatus); | |
| 729 | + | |
| 730 | + if (CollectionUtils.isNotEmpty(temps)) { | |
| 731 | + if (CollectionUtils.isNotEmpty(sendList)) { | |
| 732 | + //短信前缀 | |
| 733 | + String messagePrefix = smsConfigFacade.getMsgPrefix(configModel, doctorId, ServiceObjEnums.YUNOBJ.getId()); | |
| 734 | + for (SmsTemplateModel templateModel : sendList) { | |
| 735 | + if (templateModel != null && templateModel.getStatus() == 1) { | |
| 736 | + | |
| 737 | + //推送类型模板 | |
| 738 | + if (templateModel.getTemplateType() == null || templateModel.getTemplateType() == 0) { | |
| 739 | + //发送推送类模板建档 | |
| 740 | + if (startType == 3) { | |
| 741 | + continue; | |
| 742 | + } | |
| 743 | + } | |
| 744 | + //发送短信类模板建档 | |
| 745 | + else if (templateModel.getTemplateType() == 1 && startType == 1) { | |
| 746 | + continue; | |
| 747 | + } | |
| 748 | + | |
| 749 | + List<MsgRequest> messages = new ArrayList<>(); | |
| 750 | + MsgRequest mr = new MsgRequest(); | |
| 751 | + | |
| 752 | + String doctorName = ""; | |
| 753 | + try { | |
| 754 | + Users users = usersService.getUsers(Integer.parseInt(doctorId)); | |
| 755 | + if (users != null && users.getYn() == YnEnums.YES.getId()) { | |
| 756 | + doctorName = users.getName(); | |
| 757 | + mr.setKeyword1(doctorName); | |
| 758 | + } | |
| 759 | + } catch (Exception e) { | |
| 760 | + System.out.print(e + doctorId); | |
| 761 | + } | |
| 762 | + | |
| 763 | + String content = ""; | |
| 764 | + if (isHightRisk) { | |
| 765 | + //风险名称 | |
| 766 | + String riskNmae = queryRiskNameStr(patient.getRiskFactorId()); | |
| 767 | + content = com.lyms.platform.common.utils.StringUtils.replaceNameRisk(patient.getUsername(), riskNmae, templateModel.getContent(), doctorName); | |
| 768 | + } else { | |
| 769 | + content = com.lyms.platform.common.utils.StringUtils.replaceName(patient.getUsername(), templateModel.getContent(), doctorName); | |
| 770 | + } | |
| 771 | + | |
| 772 | + mr.setFirst("【" + messagePrefix + "】" + content); | |
| 773 | + mr.setObjType(ServiceObjEnums.YUNOBJ.getId()); | |
| 774 | + mr.setPhone(patient.getPhone()); | |
| 775 | + mr.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); | |
| 776 | + mr.setPlanTime(DateUtil.getyyyy_MM_dd_hms(new Date())); | |
| 777 | + mr.setSubTypeId(SmsServiceEnums.FWDGTX.getId()); | |
| 778 | + mr.setStatus(SmsStatusEnums.WFS.getId()); | |
| 779 | + mr.setHospitalId(hospitalId); | |
| 780 | + mr.setTempId(templateModel.getId()); | |
| 781 | + mr.setPatientId(patient.getId()); | |
| 782 | + mr.setSmsStatus(SmsStatusEnums.WFS.getId()); | |
| 783 | + mr.setServiceType((templateModel.getTemplateType() == null || templateModel.getTemplateType() == 0) ? 1 : 3); //判断发送类型 | |
| 784 | + | |
| 785 | + mr.setTypeId(templateModel.getHealthType()); | |
| 786 | + System.out.println("patient.getLastCheckEmployeeId()=" +doctorId); | |
| 787 | + | |
| 788 | + | |
| 789 | + mr.setKeyword2(DateUtil.getymd()); | |
| 790 | + mr.setRemark(doctorId); | |
| 791 | + mr.setCreated(DateUtil.getyyyy_MM_dd_hms(new Date())); | |
| 792 | + | |
| 793 | + mr.setWxTempId(WxTempleteIdEnums.FU_WU_DING_GOU_TX.getId()); | |
| 794 | + messages.add(mr); | |
| 795 | + if (CollectionUtils.isNotEmpty(messages)) { | |
| 796 | + smsConfigFacade.saveMsg(messages, hospitalId); | |
| 797 | + } | |
| 798 | + } | |
| 799 | + } | |
| 800 | + } | |
| 801 | + } | |
| 684 | 802 | } |
| 685 | 803 | |
| 686 | 804 | /** |