| | |
| | | import com.ruoyi.common.utils.HttpUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.message.SendResult; |
| | | import com.ruoyi.message.sms.SmsSendRequest; |
| | | import com.ruoyi.message.sms.SmsSenderFactory; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.smartor.domain.*; |
| | |
| | | IServiceAppointRecordService iServiceAppointRecordService; |
| | | @Autowired |
| | | private SysConfigMapper sysConfigMapper; |
| | | @Value("${xhsmsPath}") |
| | | private String xhsmsPath; |
| | | // 帐号 |
| | | @Value("${xhsmsAccount}") |
| | | private String xhsmsAccount; |
| | | // 接口密码 |
| | | @Value("${xhsmsPwd}") |
| | | private String xhsmsPwd; |
| | | // 虚拟接入码 |
| | | @Value("${xhsmsjrm}") |
| | | private String xhsmsjrm; |
| | | |
| | | /** |
| | | * 消息发送方工厂(短信/微信公众号),替代原来直接注入 xhsms* 配置 + HttpUtils 的写法 |
| | | */ |
| | | @Autowired |
| | | private SmsSenderFactory smsSenderFactory; |
| | | |
| | | |
| | | /** |
| | |
| | | // 第二步:处理停诊记录信息 |
| | | for (ServiceAppointRecord serviceAppointRecord : appointRecordFromHIS) { |
| | | String replace = smsContemt.replace("${patFileName}", StringUtils.defaultString(serviceAppointRecord.getPatFileName())).replace("${registTimeRange}", StringUtils.defaultString(serviceAppointRecord.getRegistTimeRange())).replace("${registDeptName}", StringUtils.defaultString(serviceAppointRecord.getRegistDeptName())).replace("${treatDoctName}", StringUtils.defaultString(serviceAppointRecord.getTreatDoctName())); |
| | | Map<String, String> map2 = new HashMap<String, String>(); |
| | | map2.put("action", "send"); |
| | | map2.put("account", xhsmsAccount); |
| | | map2.put("password", xhsmsPwd); |
| | | map2.put("mobile", serviceAppointRecord.getPatTel()); |
| | | map2.put("content", replace); |
| | | map2.put("extno", xhsmsjrm); |
| | | map2.put("rt", "json"); |
| | | StringBuilder encodedParams = new StringBuilder(); |
| | | |
| | | for (Map.Entry<String, String> entry : map2.entrySet()) { |
| | | if (encodedParams.length() > 0) { |
| | | encodedParams.append("&"); |
| | | } |
| | | // 对键和值进行URL编码 |
| | | String encodedKey = URLEncoder.encode(entry.getKey(), "UTF-8"); |
| | | String encodedValue = URLEncoder.encode(entry.getValue(), "UTF-8"); |
| | | encodedParams.append(encodedKey).append("=").append(encodedValue); |
| | | } |
| | | Boolean isSuccess = HttpUtils.sendPost(xhsmsPath, encodedParams.toString()); |
| | | if (isSuccess) { |
| | | log.info("---处理停诊记录信息发送成功,入参为:{}", encodedParams.toString()); |
| | | //短信发送已收口到 ruoyi-message 模块(新华通道走表单模式,与原实现一致) |
| | | SendResult sendResult = smsSenderFactory.send("xh", |
| | | SmsSendRequest.of(serviceAppointRecord.getPatTel(), replace)); |
| | | if (sendResult.isOk()) { |
| | | log.info("---处理停诊记录信息发送成功,入参为:{}", sendResult.getRawResponse()); |
| | | serviceAppointRecord.setSendTime(new Date()); |
| | | serviceAppointRecord.setSenderName("系统管理员"); |
| | | iServiceAppointRecordService.insertServiceAppointRecord(serviceAppointRecord); |