liusheng
6 天以前 cc479e6a056785103996cc7ea67dbd5faa3e800e
smartor/src/main/java/com/smartor/service/impl/XHGatherPatArchiveServiceImpl.java
@@ -12,9 +12,13 @@
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.*;
import com.ruoyi.inhospvisit.domain.PatMedInhosp;
import com.smartor.mapper.*;
import com.smartor.service.*;
import lombok.extern.slf4j.Slf4j;
@@ -36,6 +40,7 @@
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
import com.ruoyi.common.core.domain.entity.PatArchive;
/**
 * 新华数据采集处理
@@ -57,17 +62,12 @@
    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;
    /**
@@ -135,28 +135,11 @@
                // 第二步:处理停诊记录信息
                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);