liusheng
2026-10-10 0afac42fb2e9d6e5291304dd0044ce3042b45d2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.ruoyi.message.sms.provider.shiyi;
 
import com.ruoyi.message.MessageChannel;
import com.ruoyi.message.SendResult;
import com.ruoyi.message.sms.AbstractSmsSender;
import com.ruoyi.message.sms.SmsSendRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
 
/**
 * 杭州市一 HIS 平台短信发送方({@code shiyi-his} 通道)。
 * <p>
 * 对接特征:WCF SOAP {@code RunService(TradeType=FASONGDX)},报文体为 XML,
 * 成功判定为响应 {@code ERRNO == "0"}。
 * <p>
 * 说明:该通道目前<b>还没有业务调用点</b>(只有 {@code /sms/sendShiyiTest} 测试接口),
 * 收口到本模块后可由工厂统一调度。
 * 代码来源:原 {@code com.smartor.common.ShiyiSmsUtil}(行为保持不变)。
 */
@Slf4j
@Component
public class ShiyiHisSmsSender extends AbstractSmsSender {
 
    /**
     * 渠道 key(不是 profile 名,因为当前站点都会走自己的通道)
     */
    public static final String KEY = "shiyi-his";
 
    private final ShiyiSmsUtil shiyiSmsUtil;
 
    public ShiyiHisSmsSender(ShiyiSmsUtil shiyiSmsUtil) {
        this.shiyiSmsUtil = shiyiSmsUtil;
    }
 
    @Override
    public String key() {
        return KEY;
    }
 
    @Override
    public String description() {
        return "杭州市一 HIS 平台短信(WCF SOAP FASONGDX)";
    }
 
    @Override
    protected SendResult doSend(SmsSendRequest request) {
        ShiyiSmsRequest smsRequest = new ShiyiSmsRequest();
        smsRequest.setShoujihao(request.getPhone());
        smsRequest.setDuanxinnr(request.getContent());
        smsRequest.setJigoudm(request.getOrgid());
        if (request.getTemplateCode() != null) {
            smsRequest.setDuanxinlx(request.getTemplateCode());
        }
 
        ShiyiSmsResponse response = shiyiSmsUtil.sendSms(smsRequest);
        if (response.isSuccess()) {
            return SendResult.success(KEY, MessageChannel.SMS, response.getRawXml())
                    .withCode(response.getErrno())
                    .withMessage(response.getErrmsg());
        }
        return SendResult.fail(KEY, MessageChannel.SMS,
                "短信发送失败:" + response.getErrmsg(), response.getRawXml())
                .withCode(response.getErrno());
    }
}