Commit 71a6ee543b4508085a4020e3c859319732b06a4c
1 parent
fb74a679ac
Exists in
master
and in
8 other branches
code update
Showing 10 changed files with 268 additions and 236 deletions
- platform-common/src/main/java/com/lyms/platform/common/enums/SmsTimeTypeEnums.java
- platform-data-api/src/main/java/com/lyms/platform/data/pojo/MessageRequest.java
- platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBookbuildingController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SmsConfigFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/MessageRequest.java
platform-common/src/main/java/com/lyms/platform/common/enums/SmsTimeTypeEnums.java
View file @
71a6ee5
1 | +package com.lyms.platform.common.enums; | |
2 | + | |
3 | +public enum SmsTimeTypeEnums { | |
4 | + | |
5 | + ONTIME(1, "及时短信"), NO_ONTIME(2, "非及时短信"), ; | |
6 | + | |
7 | + private SmsTimeTypeEnums(int id, String title) { | |
8 | + this.id = id; | |
9 | + this.title = title; | |
10 | + } | |
11 | + | |
12 | + private int id; | |
13 | + | |
14 | + private String title; | |
15 | + | |
16 | + public SmsTimeTypeEnums getEnum(int id) { | |
17 | + for (SmsTimeTypeEnums yn : values()) { | |
18 | + if (yn.getId() == id) { | |
19 | + return yn; | |
20 | + } | |
21 | + } | |
22 | + return null; | |
23 | + } | |
24 | + | |
25 | + public int getId() { | |
26 | + return id; | |
27 | + } | |
28 | + | |
29 | + public String getTitle() { | |
30 | + return title; | |
31 | + } | |
32 | +} |
platform-data-api/src/main/java/com/lyms/platform/data/pojo/MessageRequest.java
View file @
71a6ee5
... | ... | @@ -30,6 +30,16 @@ |
30 | 30 | //患者ID |
31 | 31 | private String ext3; |
32 | 32 | |
33 | + //1 及时短信 2非及时短信 | |
34 | + private Integer timeType; | |
35 | + | |
36 | + public Integer getTimeType() { | |
37 | + return timeType; | |
38 | + } | |
39 | + | |
40 | + public void setTimeType(Integer timeType) { | |
41 | + this.timeType = timeType; | |
42 | + } | |
33 | 43 | |
34 | 44 | public Integer getStatus() { |
35 | 45 | return status; |
platform-data-api/src/main/java/com/lyms/platform/data/service/impl/SmsServiceImpl.java
View file @
71a6ee5
... | ... | @@ -2112,6 +2112,7 @@ |
2112 | 2112 | request.setServiceType(SmsProviderEnums.ALDY.getId()); |
2113 | 2113 | request.setSubTypeId(smsType); |
2114 | 2114 | request.setStatus(SmsStatusEnums.WFS.getId()); |
2115 | + request.setTimeType(SmsTimeTypeEnums.NO_ONTIME.getId()); | |
2115 | 2116 | |
2116 | 2117 | //医院ID ext1 |
2117 | 2118 | //模板ID ext2; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BabyBookbuildingController.java
View file @
71a6ee5
... | ... | @@ -100,14 +100,14 @@ |
100 | 100 | */ |
101 | 101 | @RequestMapping(value = "/queryBabyBuildRecord", method = RequestMethod.GET) |
102 | 102 | @ResponseBody |
103 | -// @TokenRequired | |
103 | + @TokenRequired | |
104 | 104 | public BaseObjectResponse queryBabyBuildRecord(HttpServletRequest request,@RequestParam(required = false)String cardNo,@RequestParam(required = false)String vcCardNo,@RequestParam(required = false)String hospitalId){ |
105 | 105 | BookbuildingQueryRequest param = new BookbuildingQueryRequest(); |
106 | 106 | param.setCardNo(cardNo); |
107 | 107 | param.setVcCardNo(vcCardNo); |
108 | 108 | param.setHospitalId(hospitalId); |
109 | -// LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
110 | - return babyBookbuildingFacade.queryBabyBuildRecord(param,null); | |
109 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
110 | + return babyBookbuildingFacade.queryBabyBuildRecord(param,loginState.getId()); | |
111 | 111 | } |
112 | 112 | |
113 | 113 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
View file @
71a6ee5
... | ... | @@ -155,9 +155,10 @@ |
155 | 155 | */ |
156 | 156 | @RequestMapping(value = "/sendPGuildSms", method = RequestMethod.POST) |
157 | 157 | @ResponseBody |
158 | - public BaseResponse patientGuildSms(@RequestBody @Valid PatientGuideSmsRequest patientGuideSmsRequest){ | |
159 | - | |
160 | - return patientFacade.patientGuildSms(patientGuideSmsRequest); | |
158 | + @TokenRequired | |
159 | + public BaseResponse patientGuildSms(@RequestBody @Valid PatientGuideSmsRequest patientGuideSmsRequest,HttpServletRequest request1){ | |
160 | + LoginContext loginState = (LoginContext) request1.getAttribute("loginContext"); | |
161 | + return patientFacade.patientGuildSms(patientGuideSmsRequest,loginState.getId()); | |
161 | 162 | } |
162 | 163 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyBookbuildingFacade.java
View file @
71a6ee5
... | ... | @@ -69,8 +69,10 @@ |
69 | 69 | @Autowired |
70 | 70 | private UsersService usersService; |
71 | 71 | |
72 | + | |
73 | + | |
72 | 74 | @Autowired |
73 | - private SmsConfigService smsConfigService; | |
75 | + private SmsConfigFacade smsConfigFacade; | |
74 | 76 | |
75 | 77 | |
76 | 78 | public BaseResponse getBabyBase(String babyId){ |
... | ... | @@ -463,7 +465,7 @@ |
463 | 465 | |
464 | 466 | if (model == null || model.getId() == null) { |
465 | 467 | br.setErrorcode(ErrorCodeConstants.SYSTEM_ERROR); |
466 | - br.setErrormsg("失败"); | |
468 | + br.setErrormsg("保存失败"); | |
467 | 469 | return br; |
468 | 470 | } |
469 | 471 | //创建建档短信 |
470 | 472 | |
471 | 473 | |
... | ... | @@ -484,47 +486,14 @@ |
484 | 486 | private void createBuildSms(BabyModel babyModel) |
485 | 487 | { |
486 | 488 | |
487 | - OrganizationQuery orgQuery = new OrganizationQuery(); | |
488 | - orgQuery.setYn(YnEnums.YES.getId()); | |
489 | - orgQuery.setId(Integer.parseInt(babyModel.getHospitalId())); | |
490 | - List<Organization> list = organizationService.queryOrganization(orgQuery); | |
491 | - boolean isRunning = false; | |
492 | - if (CollectionUtils.isNotEmpty(list)) | |
489 | + //判断医院是否启动和对应的服务项是否启用 | |
490 | + SmsConfigModel configModel = null; | |
491 | + BaseResponse response = smsConfigFacade.hospitalIsStart(babyModel.getHospitalId(),configModel); | |
492 | + if (response != null) | |
493 | 493 | { |
494 | - Organization org = list.get(0); | |
495 | - if (org != null) | |
496 | - { | |
497 | - Integer status = org.getStatus(); | |
498 | - if (status != null && (status == HospitalStatusEnums.SYX.getId() || status == HospitalStatusEnums.ZSYX.getId())) | |
499 | - { | |
500 | - isRunning = true; | |
501 | - } | |
502 | - } | |
503 | - } | |
504 | - if (!isRunning) | |
505 | - { | |
506 | 494 | return; |
507 | 495 | } |
508 | 496 | |
509 | - SmsConfigQuery configQuery = new SmsConfigQuery(); | |
510 | - configQuery.setYn(YnEnums.YES.getId()); | |
511 | - configQuery.setHospitalId(babyModel.getHospitalId()); | |
512 | - //查询出对应医院配置 | |
513 | - List<SmsConfigModel> configs = smsConfigService.querySmsConfig(configQuery); | |
514 | - boolean isStart = false; | |
515 | - if (CollectionUtils.isNotEmpty(configs)) | |
516 | - { | |
517 | - String serviceStr = configs.get(0).getSmsService(); | |
518 | - if (StringUtils.isNotEmpty(serviceStr)) | |
519 | - { | |
520 | - isStart = isStartService(SmsServiceEnums.FWKT.getId(), serviceStr); | |
521 | - } | |
522 | - } | |
523 | - if (!isStart) | |
524 | - { | |
525 | - return; | |
526 | - } | |
527 | - | |
528 | 497 | SmsTemplateQuery query = new SmsTemplateQuery(); |
529 | 498 | query.setYn(YnEnums.YES.getId()); |
530 | 499 | query.setStatus(1); |
531 | 500 | |
... | ... | @@ -629,14 +598,14 @@ |
629 | 598 | { |
630 | 599 | |
631 | 600 | //短信前缀 |
632 | - String messagePrefix = getSmsPrefix(configs.get(0),babyModel.getBuildDoctor()); | |
601 | + String messagePrefix = smsConfigFacade.getSmsPrefix(configModel, babyModel.getBuildDoctor()); | |
633 | 602 | for (SmsTemplateModel templateModel : sendList) |
634 | 603 | { |
635 | 604 | if (templateModel != null && templateModel.getStatus() == 1) { |
636 | 605 | MessageListRequest smsList = new MessageListRequest(); |
637 | 606 | List<MessageRequest> messages = new ArrayList<>(); |
638 | 607 | MessageRequest mr = new MessageRequest(); |
639 | - mr.setContent("【"+messagePrefix+"】"+templateModel.getContent()); | |
608 | + mr.setContent("【" + messagePrefix + "】" + templateModel.getContent()); | |
640 | 609 | mr.setObjType(ServiceObjEnums.BABYOBJ.getId()); |
641 | 610 | mr.setPhone(babyModel.getMphone()); |
642 | 611 | //短信商 |
... | ... | @@ -645,6 +614,7 @@ |
645 | 614 | mr.setPlanTime(DateUtil.getyyyy_MM_dd_hms(new Date())); |
646 | 615 | mr.setSubTypeId(SmsServiceEnums.FWKT.getId()); |
647 | 616 | mr.setStatus(SmsStatusEnums.WFS.getId()); |
617 | + mr.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); | |
648 | 618 | |
649 | 619 | mr.setExt1(babyModel.getHospitalId()); |
650 | 620 | mr.setExt2(templateModel.getId()); |
651 | 621 | |
... | ... | @@ -667,97 +637,8 @@ |
667 | 637 | |
668 | 638 | |
669 | 639 | |
670 | - /** | |
671 | - * 获取发送短信的前缀 如果配置为发送科室前缀 就通过医生查询到医生所在科室 | |
672 | - * 然后取对应科室前缀 如果为空就取医院前缀 | |
673 | - * @return | |
674 | - */ | |
675 | - public String getSmsPrefix(SmsConfigModel config,String doctorId) | |
676 | - { | |
677 | - String messagePrefix = config.getHospitalPrefix(); | |
678 | - //前缀类型 0医院前缀 1科室前缀 | |
679 | - if (config.getPrefixType() != null && config.getPrefixType() == 1) | |
680 | - { | |
681 | - String res = getDeptPrefix(doctorId, config.getDeptPrefix()); | |
682 | - messagePrefix = res == "" ? messagePrefix : res; | |
683 | - } | |
684 | - return messagePrefix; | |
685 | - } | |
686 | 640 | |
687 | 641 | /** |
688 | - * /通过医生查询科室前缀 | |
689 | - * @param doctorId | |
690 | - * @param detpPrefixStr | |
691 | - * @return | |
692 | - */ | |
693 | - private String getDeptPrefix(String doctorId,String detpPrefixStr) | |
694 | - { | |
695 | - | |
696 | - if (StringUtils.isEmpty(doctorId) || StringUtils.isEmpty(detpPrefixStr)) | |
697 | - { | |
698 | - return ""; | |
699 | - } | |
700 | - Integer userId = null; | |
701 | - try { | |
702 | - userId = Integer.valueOf(doctorId); | |
703 | - }catch (Exception e) | |
704 | - { | |
705 | - System.out.println(doctorId); | |
706 | - return ""; | |
707 | - } | |
708 | - | |
709 | - //通过建档医生查询用户信息 | |
710 | - Users user = usersService.getUsers(userId); | |
711 | - if (user != null) | |
712 | - { | |
713 | - //得到医生对应的部门id | |
714 | - Integer deptId = user.getDeptId(); | |
715 | - if (StringUtils.isNotEmpty(detpPrefixStr)) | |
716 | - { | |
717 | - List<Map> detpPrefixs = JsonUtil.toList(detpPrefixStr, Map.class); | |
718 | - if (CollectionUtils.isNotEmpty(detpPrefixs)) | |
719 | - { | |
720 | - for (Map map : detpPrefixs) | |
721 | - { | |
722 | - Integer preDeptId = Integer.valueOf(String.valueOf(map.get("deptId"))); | |
723 | - if (preDeptId == deptId) | |
724 | - { | |
725 | - return String.valueOf(map.get("deptPrefix")); | |
726 | - } | |
727 | - } | |
728 | - } | |
729 | - } | |
730 | - } | |
731 | - return ""; | |
732 | - } | |
733 | - | |
734 | - /** | |
735 | - * 判断对应服务是否启动 | |
736 | - */ | |
737 | - private boolean isStartService(Integer smsType,String serviceStr) | |
738 | - { | |
739 | - if (StringUtils.isEmpty(serviceStr)) | |
740 | - { | |
741 | - return false; | |
742 | - } | |
743 | - //消息服务启动 | |
744 | - List<Map> smsServices = JsonUtil.toList(serviceStr, Map.class); | |
745 | - | |
746 | - if (CollectionUtils.isNotEmpty(smsServices)) | |
747 | - { | |
748 | - for (Map map : smsServices) | |
749 | - { | |
750 | - String status = String.valueOf(map.get(String.valueOf(smsType))); | |
751 | - if ("true".equals(status)) | |
752 | - { | |
753 | - return true; | |
754 | - } | |
755 | - } | |
756 | - } | |
757 | - return false; | |
758 | - } | |
759 | - | |
760 | - /** | |
761 | 642 | * 准备修改和添加的孕妇建档数据 |
762 | 643 | * |
763 | 644 | * @param request |
... | ... | @@ -1257,10 +1138,6 @@ |
1257 | 1138 | buildRecords.put("buildHospital", ""); |
1258 | 1139 | } |
1259 | 1140 | |
1260 | -// result.setId(build.getId()); | |
1261 | -// result.setCardNo(build.getCardNo()); | |
1262 | -// result.setName(build.getName()); | |
1263 | -// result.setMonthAge(DateUtil.getBabyMonthAge(build.getBirth(), new Date())); | |
1264 | 1141 | list.add(buildRecords); |
1265 | 1142 | } |
1266 | 1143 | |
... | ... | @@ -1326,6 +1203,7 @@ |
1326 | 1203 | buildRecords.put("id", build.getId()); |
1327 | 1204 | buildRecords.put("buildDate", DateUtil.getyyyy_MM_dd(build.getBuildDate())); |
1328 | 1205 | |
1206 | + buildRecords.put("hospitalId",build.getHospitalId()); | |
1329 | 1207 | //查询建档医院 |
1330 | 1208 | Organization org = organizationService.getOrganization(Integer.valueOf(build.getHospitalId())); |
1331 | 1209 | if (org != null) { |
1332 | 1210 | |
1333 | 1211 | |
1334 | 1212 | |
1335 | 1213 | |
... | ... | @@ -1671,55 +1549,15 @@ |
1671 | 1549 | } |
1672 | 1550 | } |
1673 | 1551 | |
1674 | - OrganizationQuery orgQuery = new OrganizationQuery(); | |
1675 | - orgQuery.setYn(YnEnums.YES.getId()); | |
1676 | - orgQuery.setId(Integer.parseInt(hospitalId)); | |
1677 | - List<Organization> list = organizationService.queryOrganization(orgQuery); | |
1678 | - boolean isRunning = false; | |
1679 | - if (CollectionUtils.isNotEmpty(list)) | |
1552 | + //判断医院是否启动和对应的服务项是否启用 | |
1553 | + SmsConfigModel configModel = null; | |
1554 | + BaseResponse response = smsConfigFacade.hospitalIsStart(hospitalId,configModel); | |
1555 | + if (response != null) | |
1680 | 1556 | { |
1681 | - Organization org = list.get(0); | |
1682 | - if (org != null) | |
1683 | - { | |
1684 | - Integer status = org.getStatus(); | |
1685 | - if (status != null && (status == HospitalStatusEnums.SYX.getId() || status == HospitalStatusEnums.ZSYX.getId())) | |
1686 | - { | |
1687 | - isRunning = true; | |
1688 | - } | |
1689 | - } | |
1557 | + return response; | |
1690 | 1558 | } |
1691 | - if (!isRunning) | |
1692 | - { | |
1693 | - BaseResponse objectResponse = new BaseResponse(); | |
1694 | - objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
1695 | - objectResponse.setErrormsg("暂无发送权限"); | |
1696 | - return objectResponse; | |
1697 | - } | |
1698 | 1559 | |
1699 | - SmsConfigQuery configQuery = new SmsConfigQuery(); | |
1700 | - configQuery.setYn(YnEnums.YES.getId()); | |
1701 | - configQuery.setHospitalId(hospitalId); | |
1702 | - //查询出对应医院配置 | |
1703 | - List<SmsConfigModel> configs = smsConfigService.querySmsConfig(configQuery); | |
1704 | - boolean isStart = false; | |
1705 | - if (CollectionUtils.isNotEmpty(configs)) | |
1706 | - { | |
1707 | - String serviceStr = configs.get(0).getSmsService(); | |
1708 | - if (StringUtils.isNotEmpty(serviceStr)) | |
1709 | - { | |
1710 | - isStart = isStartService(SmsServiceEnums.FWKT.getId(), serviceStr); | |
1711 | - } | |
1712 | 1560 | |
1713 | - } | |
1714 | - if (!isStart) | |
1715 | - { | |
1716 | - BaseResponse objectResponse = new BaseResponse(); | |
1717 | - objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
1718 | - objectResponse.setErrormsg("暂无发送权限"); | |
1719 | - return objectResponse; | |
1720 | - } | |
1721 | - | |
1722 | - | |
1723 | 1561 | MessageListRequest smsList = new MessageListRequest(); |
1724 | 1562 | List<MessageRequest> messages = new ArrayList<>(); |
1725 | 1563 | |
1726 | 1564 | |
... | ... | @@ -1747,8 +1585,10 @@ |
1747 | 1585 | if (CollectionUtils.isNotEmpty(sendModels)) { |
1748 | 1586 | for (BabyModel model : sendModels) { |
1749 | 1587 | if (model != null && StringUtils.isNotEmpty(model.getMphone())) { |
1588 | + //短信前缀 | |
1589 | + String messagePrefix = smsConfigFacade.getSmsPrefix(configModel, model.getBuildDoctor()); | |
1750 | 1590 | MessageRequest mr = new MessageRequest(); |
1751 | - mr.setContent(request.getSmsContent()); | |
1591 | + mr.setContent("【"+messagePrefix+"】"+request.getSmsContent()); | |
1752 | 1592 | mr.setObjType(ServiceObjEnums.BABYOBJ.getId()); |
1753 | 1593 | mr.setPhone(model.getMphone()); |
1754 | 1594 | //短信商 |
... | ... | @@ -1756,6 +1596,9 @@ |
1756 | 1596 | mr.setTypeId(ProjectTypeEnums.YNXT.getId()); |
1757 | 1597 | mr.setPlanTime(DateUtil.getyyyy_MM_dd_hms(new Date())); |
1758 | 1598 | mr.setSubTypeId(SmsServiceEnums.YSGXHZD.getId()); |
1599 | + mr.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); | |
1600 | + | |
1601 | + mr.setStatus(SmsStatusEnums.WFS.getId()); | |
1759 | 1602 | |
1760 | 1603 | mr.setExt1(String.valueOf(model.getHospitalId())); |
1761 | 1604 | messages.add(mr); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BookbuildingFacade.java
View file @
71a6ee5
... | ... | @@ -74,10 +74,11 @@ |
74 | 74 | private BasicConfigService basicConfigService; |
75 | 75 | |
76 | 76 | @Autowired |
77 | - private BabyBookbuildingFacade babyBookbuildingFacade; | |
78 | - @Autowired | |
79 | 77 | private AntenatalExaminationFacade antenatalExaminationFacade; |
80 | 78 | |
79 | + @Autowired | |
80 | + private SmsConfigFacade smsConfigFacade; | |
81 | + | |
81 | 82 | /** |
82 | 83 | * 添加孕妇建档 |
83 | 84 | * @param yunRequest |
... | ... | @@ -425,7 +426,7 @@ |
425 | 426 | { |
426 | 427 | |
427 | 428 | //短信前缀 |
428 | - String messagePrefix = babyBookbuildingFacade.getSmsPrefix(configs.get(0), patient.getBookbuildingDoctor()); | |
429 | + String messagePrefix = smsConfigFacade.getSmsPrefix(configs.get(0), patient.getBookbuildingDoctor()); | |
429 | 430 | for (SmsTemplateModel templateModel : sendList) |
430 | 431 | { |
431 | 432 | if (templateModel != null && templateModel.getStatus() == 1) |
... | ... | @@ -436,6 +437,7 @@ |
436 | 437 | mr.setContent("【"+messagePrefix+"】"+templateModel.getContent()); |
437 | 438 | mr.setObjType(ServiceObjEnums.YUNOBJ.getId()); |
438 | 439 | mr.setPhone(patient.getPhone()); |
440 | + mr.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); | |
439 | 441 | //短信商 |
440 | 442 | mr.setServiceType(SmsProviderEnums.ALDY.getId()); |
441 | 443 | mr.setTypeId(ProjectTypeEnums.YNXT.getId()); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
View file @
71a6ee5
... | ... | @@ -2,8 +2,7 @@ |
2 | 2 | |
3 | 3 | import com.lyms.platform.biz.service.*; |
4 | 4 | import com.lyms.platform.common.constants.ErrorCodeConstants; |
5 | -import com.lyms.platform.common.enums.SmsServiceEnums; | |
6 | -import com.lyms.platform.common.enums.YnEnums; | |
5 | +import com.lyms.platform.common.enums.*; | |
7 | 6 | import com.lyms.platform.common.result.BaseListResponse; |
8 | 7 | import com.lyms.platform.common.result.BaseObjectResponse; |
9 | 8 | import com.lyms.platform.common.result.BaseResponse; |
... | ... | @@ -13,6 +12,7 @@ |
13 | 12 | import com.lyms.platform.operate.web.request.*; |
14 | 13 | import com.lyms.platform.operate.web.result.*; |
15 | 14 | import com.lyms.platform.operate.web.utils.CommonsHelper; |
15 | +import com.lyms.platform.operate.web.utils.MessageCenterService; | |
16 | 16 | import com.lyms.platform.permission.model.Users; |
17 | 17 | import com.lyms.platform.permission.service.UsersService; |
18 | 18 | import com.lyms.platform.pojo.*; |
19 | 19 | |
... | ... | @@ -55,7 +55,10 @@ |
55 | 55 | @Autowired |
56 | 56 | private PostReviewService postReviewService; |
57 | 57 | |
58 | + @Autowired | |
59 | + private SmsConfigFacade smsConfigFacade; | |
58 | 60 | |
61 | + | |
59 | 62 | /** |
60 | 63 | * 修改产妇的社区 |
61 | 64 | * |
... | ... | @@ -511,7 +514,18 @@ |
511 | 514 | return data; |
512 | 515 | } |
513 | 516 | |
514 | - public BaseResponse patientGuildSms(PatientGuideSmsRequest patientGuideSmsRequest) { | |
517 | + public BaseResponse patientGuildSms(PatientGuideSmsRequest patientGuideSmsRequest,Integer userId) { | |
518 | + | |
519 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
520 | + | |
521 | + //判断医院是否启动和对应的服务项是否启用 | |
522 | + SmsConfigModel configModel = null; | |
523 | + BaseResponse response = smsConfigFacade.hospitalIsStart(hospital,configModel); | |
524 | + if (response != null) | |
525 | + { | |
526 | + return response; | |
527 | + } | |
528 | + | |
515 | 529 | MessageListRequest smsList = new MessageListRequest(); |
516 | 530 | List<MessageRequest> messages = new ArrayList<>(); |
517 | 531 | List<Patients> sendModels = new ArrayList<>(); |
518 | 532 | |
519 | 533 | |
520 | 534 | |
... | ... | @@ -526,15 +540,21 @@ |
526 | 540 | for (Patients model : sendModels) { |
527 | 541 | if (model != null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(model.getPhone())) { |
528 | 542 | MessageRequest mr = new MessageRequest(); |
543 | + | |
544 | + //短信前缀 | |
545 | + String messagePrefix =smsConfigFacade.getSmsPrefix(configModel, model.getBookbuildingDoctor()); | |
529 | 546 | mr.setContent(patientGuideSmsRequest.getSmsContent()); |
530 | 547 | mr.setObjType(Integer.valueOf(patientGuideSmsRequest.getType())); |
531 | 548 | mr.setPhone(model.getPhone()); |
532 | 549 | //短信商 |
533 | - mr.setServiceType(1);//待定 | |
534 | - mr.setTypeId(1); //待定 | |
550 | + mr.setServiceType(SmsProviderEnums.ALDY.getId()); | |
551 | + mr.setTypeId(ProjectTypeEnums.YNXT.getId()); | |
535 | 552 | mr.setPlanTime(DateUtil.getyyyy_MM_dd_hms(new Date())); |
536 | 553 | mr.setSubTypeId(SmsServiceEnums.YSGXHZD.getId()); |
554 | + mr.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); | |
537 | 555 | |
556 | + mr.setStatus(SmsStatusEnums.WFS.getId()); | |
557 | + | |
538 | 558 | mr.setExt1(String.valueOf(model.getHospitalId())); |
539 | 559 | messages.add(mr); |
540 | 560 | } |
541 | 561 | |
... | ... | @@ -542,9 +562,10 @@ |
542 | 562 | } |
543 | 563 | |
544 | 564 | if (CollectionUtils.isNotEmpty(messages)) { |
545 | - smsList.setTypeId(1); | |
565 | + smsList.setTypeId(ProjectTypeEnums.YNXT.getId()); | |
546 | 566 | smsList.setMessages(messages); |
547 | - //调用发送接口 TODO | |
567 | + //调用发送接口 | |
568 | + MessageCenterService.saveSmsCenter(smsList); | |
548 | 569 | } |
549 | 570 | } |
550 | 571 | return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/SmsConfigFacade.java
View file @
71a6ee5
... | ... | @@ -14,12 +14,10 @@ |
14 | 14 | import com.lyms.platform.operate.web.result.*; |
15 | 15 | import com.lyms.platform.operate.web.utils.ConfigTask; |
16 | 16 | import com.lyms.platform.operate.web.utils.MessageCenterService; |
17 | -import com.lyms.platform.permission.model.Departments; | |
18 | -import com.lyms.platform.permission.model.DepartmentsQuery; | |
19 | -import com.lyms.platform.permission.model.Organization; | |
20 | -import com.lyms.platform.permission.model.OrganizationQuery; | |
17 | +import com.lyms.platform.permission.model.*; | |
21 | 18 | import com.lyms.platform.permission.service.DepartmentsService; |
22 | 19 | import com.lyms.platform.permission.service.OrganizationService; |
20 | +import com.lyms.platform.permission.service.UsersService; | |
23 | 21 | import com.lyms.platform.pojo.*; |
24 | 22 | import com.lyms.platform.query.*; |
25 | 23 | import com.qiniu.util.Json; |
... | ... | @@ -47,6 +45,9 @@ |
47 | 45 | @Autowired |
48 | 46 | private BasicConfigService basicConfigService; |
49 | 47 | |
48 | + @Autowired | |
49 | + private UsersService usersService; | |
50 | + | |
50 | 51 | /** |
51 | 52 | * 更新短信服务配置 |
52 | 53 | * @param request |
... | ... | @@ -350,41 +351,6 @@ |
350 | 351 | hospital.put("cityId",cityId); |
351 | 352 | String areaId = org.getAreaId(); |
352 | 353 | hospital.put("areaId",areaId); |
353 | - | |
354 | -// BasicConfigQuery query = new BasicConfigQuery(); | |
355 | -// query.setYn(YnEnums.YES.getId()); | |
356 | -// if (StringUtils.isNotEmpty(provinceId)) | |
357 | -// { | |
358 | -// query.setId(provinceId); | |
359 | -// List<BasicConfig> configList = basicConfigService.queryBasicConfig(query); | |
360 | -// if (CollectionUtils.isNotEmpty(configList)) | |
361 | -// { | |
362 | -// allAddress+=configList.get(0).getName(); | |
363 | -// } | |
364 | -// } | |
365 | -// | |
366 | -// String cityId = org.getCityId(); | |
367 | -// if (StringUtils.isNotEmpty(provinceId)) | |
368 | -// { | |
369 | -// query.setId(cityId); | |
370 | -// List<BasicConfig> configList = basicConfigService.queryBasicConfig(query); | |
371 | -// if (CollectionUtils.isNotEmpty(configList)) | |
372 | -// { | |
373 | -// allAddress+=configList.get(0).getName(); | |
374 | -// } | |
375 | -// } | |
376 | -// | |
377 | -// String areaId = org.getAreaId(); | |
378 | -// if (StringUtils.isNotEmpty(provinceId)) | |
379 | -// { | |
380 | -// query.setId(areaId); | |
381 | -// List<BasicConfig> configList = basicConfigService.queryBasicConfig(query); | |
382 | -// if (CollectionUtils.isNotEmpty(configList)) | |
383 | -// { | |
384 | -// allAddress+=configList.get(0).getName(); | |
385 | -// } | |
386 | -// } | |
387 | - | |
388 | 354 | String address = org.getAddress(); |
389 | 355 | hospital.put("address", address); |
390 | 356 | hospital.put("status",org.getStatus() == null ? "" : String.valueOf(org.getStatus())); |
... | ... | @@ -684,7 +650,7 @@ |
684 | 650 | content = content.replace(" ","+"); |
685 | 651 | } |
686 | 652 | |
687 | - SmsResult sms = MessageCenterService.querySmsList(hospitalIds, phone, smsType, smsStatus, content, planTimeStart, planTimeEnd, actualTimeStart, actualTimeEnd,objType, page, limit); | |
653 | + SmsResult sms = MessageCenterService.querySmsList(hospitalIds, phone, smsType, smsStatus, content, planTimeStart, planTimeEnd, actualTimeStart, actualTimeEnd, objType, page, limit); | |
688 | 654 | |
689 | 655 | if (sms != null && sms.getList() != null ) |
690 | 656 | { |
... | ... | @@ -746,6 +712,151 @@ |
746 | 712 | objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); |
747 | 713 | objectResponse.setErrormsg("成功"); |
748 | 714 | return objectResponse; |
715 | + } | |
716 | + | |
717 | + | |
718 | + public BaseResponse hospitalIsStart(String hospitalId,SmsConfigModel configModel) | |
719 | + { | |
720 | + OrganizationQuery orgQuery = new OrganizationQuery(); | |
721 | + orgQuery.setYn(YnEnums.YES.getId()); | |
722 | + orgQuery.setId(Integer.parseInt(hospitalId)); | |
723 | + List<Organization> list = organizationService.queryOrganization(orgQuery); | |
724 | + boolean isRunning = false; | |
725 | + if (CollectionUtils.isNotEmpty(list)) | |
726 | + { | |
727 | + Organization org = list.get(0); | |
728 | + if (org != null) | |
729 | + { | |
730 | + Integer status = org.getStatus(); | |
731 | + if (status != null && (status == HospitalStatusEnums.SYX.getId() || status == HospitalStatusEnums.ZSYX.getId())) | |
732 | + { | |
733 | + isRunning = true; | |
734 | + } | |
735 | + } | |
736 | + } | |
737 | + if (!isRunning) | |
738 | + { | |
739 | + BaseResponse objectResponse = new BaseResponse(); | |
740 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
741 | + objectResponse.setErrormsg("暂无发送权限"); | |
742 | + return objectResponse; | |
743 | + } | |
744 | + | |
745 | + SmsConfigQuery configQuery = new SmsConfigQuery(); | |
746 | + configQuery.setYn(YnEnums.YES.getId()); | |
747 | + configQuery.setHospitalId(hospitalId); | |
748 | + //查询出对应医院配置 | |
749 | + List<SmsConfigModel> configs = smsConfigService.querySmsConfig(configQuery); | |
750 | + boolean isStart = false; | |
751 | + if (CollectionUtils.isNotEmpty(configs)) | |
752 | + { | |
753 | + configModel = configs.get(0); | |
754 | + String serviceStr = configModel.getSmsService(); | |
755 | + if (StringUtils.isNotEmpty(serviceStr)) | |
756 | + { | |
757 | + isStart = isStartService(SmsServiceEnums.FWKT.getId(), serviceStr); | |
758 | + } | |
759 | + } | |
760 | + if (!isStart) | |
761 | + { | |
762 | + BaseResponse objectResponse = new BaseResponse(); | |
763 | + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS); | |
764 | + objectResponse.setErrormsg("暂无发送权限"); | |
765 | + return objectResponse; | |
766 | + } | |
767 | + | |
768 | + return null; | |
769 | + } | |
770 | + | |
771 | + /** | |
772 | + * 判断对应服务是否启动 | |
773 | + */ | |
774 | + private boolean isStartService(Integer smsType,String serviceStr) | |
775 | + { | |
776 | + if (StringUtils.isEmpty(serviceStr)) | |
777 | + { | |
778 | + return false; | |
779 | + } | |
780 | + //消息服务启动 | |
781 | + List<Map> smsServices = JsonUtil.toList(serviceStr, Map.class); | |
782 | + | |
783 | + if (CollectionUtils.isNotEmpty(smsServices)) | |
784 | + { | |
785 | + for (Map map : smsServices) | |
786 | + { | |
787 | + String status = String.valueOf(map.get(String.valueOf(smsType))); | |
788 | + if ("true".equals(status)) | |
789 | + { | |
790 | + return true; | |
791 | + } | |
792 | + } | |
793 | + } | |
794 | + return false; | |
795 | + } | |
796 | + | |
797 | + | |
798 | + /** | |
799 | + * 获取发送短信的前缀 如果配置为发送科室前缀 就通过医生查询到医生所在科室 | |
800 | + * 然后取对应科室前缀 如果为空就取医院前缀 | |
801 | + * @return | |
802 | + */ | |
803 | + public String getSmsPrefix(SmsConfigModel config,String doctorId) | |
804 | + { | |
805 | + String messagePrefix = config.getHospitalPrefix(); | |
806 | + //前缀类型 0医院前缀 1科室前缀 | |
807 | + if (config.getPrefixType() != null && config.getPrefixType() == 1) | |
808 | + { | |
809 | + String res = getDeptPrefix(doctorId, config.getDeptPrefix()); | |
810 | + messagePrefix = res == "" ? messagePrefix : res; | |
811 | + } | |
812 | + return messagePrefix; | |
813 | + } | |
814 | + | |
815 | + /** | |
816 | + * /通过医生查询科室前缀 | |
817 | + * @param doctorId | |
818 | + * @param detpPrefixStr | |
819 | + * @return | |
820 | + */ | |
821 | + private String getDeptPrefix(String doctorId,String detpPrefixStr) | |
822 | + { | |
823 | + | |
824 | + if (StringUtils.isEmpty(doctorId) || StringUtils.isEmpty(detpPrefixStr)) | |
825 | + { | |
826 | + return ""; | |
827 | + } | |
828 | + Integer userId = null; | |
829 | + try { | |
830 | + userId = Integer.valueOf(doctorId); | |
831 | + }catch (Exception e) | |
832 | + { | |
833 | + System.out.println(doctorId); | |
834 | + return ""; | |
835 | + } | |
836 | + | |
837 | + //通过建档医生查询用户信息 | |
838 | + Users user = usersService.getUsers(userId); | |
839 | + if (user != null) | |
840 | + { | |
841 | + //得到医生对应的部门id | |
842 | + Integer deptId = user.getDeptId(); | |
843 | + if (StringUtils.isNotEmpty(detpPrefixStr)) | |
844 | + { | |
845 | + List<Map> detpPrefixs = JsonUtil.toList(detpPrefixStr, Map.class); | |
846 | + if (CollectionUtils.isNotEmpty(detpPrefixs)) | |
847 | + { | |
848 | + for (Map map : detpPrefixs) | |
849 | + { | |
850 | + Integer preDeptId = Integer.valueOf(String.valueOf(map.get("deptId"))); | |
851 | + if (preDeptId == deptId) | |
852 | + { | |
853 | + return String.valueOf(map.get("deptPrefix")); | |
854 | + } | |
855 | + } | |
856 | + } | |
857 | + } | |
858 | + } | |
859 | + return ""; | |
749 | 860 | } |
750 | 861 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/MessageRequest.java
View file @
71a6ee5
... | ... | @@ -29,6 +29,17 @@ |
29 | 29 | |
30 | 30 | private String ext3; |
31 | 31 | |
32 | + //1 及时短信 2非及时短信 | |
33 | + private Integer timeType; | |
34 | + | |
35 | + public Integer getTimeType() { | |
36 | + return timeType; | |
37 | + } | |
38 | + | |
39 | + public void setTimeType(Integer timeType) { | |
40 | + this.timeType = timeType; | |
41 | + } | |
42 | + | |
32 | 43 | public Integer getStatus() { |
33 | 44 | return status; |
34 | 45 | } |