liusheng
2026-10-12 b25c3b5188e402695f3792ad7da53e452682cd80
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package com.ruoyi.message.config;
 
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
 
/**
 * 消息发送模块配置(统一入口)。
 * <p>
 * 由两块拼成,<b>不要合并</b>:
 * <ul>
 *   <li>存量配置({@code xhsmsPath} / {@code sms_accountName} / {@code accessKeyId} / {@code signName} ...)
 *       → {@link RootMessageProperties},字段名与 yml key 完全同名;</li>
 *   <li>新增项(原先硬编码在代码里、本次提为可配置的地址/密钥/文案)→ 本类的
 *       {@code message.sms.*} / {@code message.wechat.*} 前缀项。</li>
 * </ul>
 * 对业务代码只暴露分组的 {@code getSms()} / {@code getWechat()},屏蔽两种绑定的差异。
 * <p>
 * ⚠️ {@code getSms()} 是手写 getter,每次调用会把存量扁平字段合并进分组对象;这是幂等的,
 * 因此即使被调用多次也没有副作用。
 */
@Component
@ConfigurationProperties(prefix = "message")
public class MessageProperties {
 
    private final RootMessageProperties root;
 
    /** 绑定 {@code message.sms.*} */
    private Sms sms = new Sms();
 
    /** 绑定 {@code message.wechat.*} */
    private Wechat wechat = new Wechat();
 
    @Autowired
    public MessageProperties(RootMessageProperties root) {
        this.root = root;
    }
 
    public RootMessageProperties getRoot() {
        return root;
    }
 
    /**
     * 短信配置统一入口:存量扁平项 + 新增项
     */
    public Sms getSms() {
        this.sms.setXhsms(buildXhsms());
        this.sms.setMt(buildMt());
        this.sms.setAliyun(buildAliyun());
        return this.sms;
    }
 
    public void setSms(Sms sms) {
        this.sms = sms;
    }
 
    /**
     * 微信公众号配置统一入口
     */
    public Wechat getWechat() {
        return this.wechat;
    }
 
    public void setWechat(Wechat wechat) {
        this.wechat = wechat;
    }
 
    private XhsmsConfig buildXhsms() {
        XhsmsConfig xhsms = new XhsmsConfig();
        xhsms.setPath(root.getXhsmsPath());
        xhsms.setAccount(root.getXhsmsAccount());
        xhsms.setPwd(root.getXhsmsPwd());
        xhsms.setExtno(root.getXhsmsjrm());
        return xhsms;
    }
 
    private MtSmsConfig buildMt() {
        MtSmsConfig mt = new MtSmsConfig();
        mt.setAccountName(root.getSmsAccountName());
        mt.setPassword(root.getSmsPassword());
        mt.setUrl(root.getSmsUrl());
        mt.setSourceAddr(root.getSmsSourceAddr());
        mt.setServiceCode(root.getSmsServiceCode());
        mt.setAppkey(root.getSmsAppkey());
        mt.setFlag(root.getSmsFlag());
        return mt;
    }
 
    private AliyunSmsConfig buildAliyun() {
        AliyunSmsConfig aliyun = new AliyunSmsConfig();
        aliyun.setAccessKeyId(root.getAccessKeyId());
        aliyun.setAccessKeySecret(root.getAccessKeySecret());
        aliyun.setSignName(root.getSignName());
        return aliyun;
    }
 
    /**
     * 短信配置分组
     */
    @Data
    public static class Sms {
 
        private XhsmsConfig xhsms = new XhsmsConfig();
 
        private MtSmsConfig mt = new MtSmsConfig();
 
        private AliyunSmsConfig aliyun = new AliyunSmsConfig();
 
        private ShiyiSms shiyi = new ShiyiSms();
 
        private MessagingInsert messagingInsert = new MessagingInsert();
    }
 
    /**
     * 杭州市一 HIS 服务平台短信(shiyi-his 通道)
     */
    @Data
    public static class ShiyiSms {
 
        /**
         * HIS RunService 地址。
         * <p>
         * TODO 待确认:原实现把 {@code http://192.178.0.104:7790/MediInfoHis.svc} 硬编码在
         * {@code ShiyiSmsUtil.invokeRunService} 里,这里提为可配置,默认值与原硬编码保持一致。
         */
        private String wsUrl = "http://192.178.0.104:7790/MediInfoHis.svc";
 
        /**
         * 默认操作员代码
         */
        private String defaultCaozuoydm;
 
        /**
         * 默认操作员姓名
         */
        private String defaultCaozuoyxm;
 
        /**
         * 短信签名前缀(当前未使用,留给后续需要时)
         */
        private String sign = "";
    }
 
    /**
     * 预约挂号短信平台(MessagingInsert,Axis SOAP12)
     */
    @Data
    public static class MessagingInsert {
 
        /**
         * SOAP 服务地址。
         * <p>
         * TODO 待确认:原实现把 {@code http://218.108.11.29:8081/MessagingInsert.asmx} 硬编码在
         * {@code MessagingInsertLocator} 生成的代码里,这里提为可配置,默认值与原硬编码一致。
         */
        private String wsUrl = "http://218.108.11.29:8081/MessagingInsert.asmx";
    }
 
    /**
     * 微信公众号相关配置
     */
    @Data
    public static class Wechat {
 
        private ShiyiWechat shiyi = new ShiyiWechat();
 
        private Xinhua xinhua = new Xinhua();
    }
 
    /**
     * 市一微信公众号(hzszlyy 通道)
     */
    @Data
    public static class ShiyiWechat {
 
        /**
         * 接口地址。
         * <p>
         * TODO 待确认:原 {@code smsUtils.sendChat} 把 {@code http://192.200.54.14:5003/sfjk/SendMessage}
         * 硬编码在方法里,这里提为可配置,默认值与原硬编码保持一致。
         */
        private String url = "http://192.200.54.14:5003/sfjk/SendMessage";
 
        /**
         * 接口密钥。
         * <p>
         * TODO 待确认:原 {@code smsUtils.sendChat} 把 key
         * {@code ff76f8904f5f32b5ee1739e8ea46e60g} 硬编码在方法里,此值疑似为占位/测试密钥,请业务确认后替换。
         */
        private String key = "ff76f8904f5f32b5ee1739e8ea46e60g";
 
        /**
         * 消息标题。
         * <p>
         * TODO 待确认:原实现把「您好,邀请您填写出院调查表,请点击填写。」写死在 URL 里,
         * 所有外部链接(随访/问卷/宣教)都用同一句文案,这里提为可配置,默认值与原文案一致。
         */
        private String title = "您好,邀请您填写出院调查表,请点击填写。";
 
        /**
         * 消息内容占位。
         * <p>
         * TODO 待确认:原实现写死为「待随访」,此处默认值与原值一致。
         */
        private String content = "待随访";
    }
 
    /**
     * 新华微信公众号(xh 通道)
     */
    @Data
    public static class Xinhua {
 
        /**
         * 接口服务名,固定值。
         * <p>
         * 原 {@code XinHuaWXReq.service} 默认 {@code smarthos.pat.notice}
         */
        private String service = "smarthos.pat.notice";
    }
}