xuekang
2024-05-11 bac0878349a1db23e7b420ea164e22fb9db73a99
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
package com.nuvole.util.sc.sms;
 
 
import cn.hutool.core.util.StrUtil;
import com.nuvole.common.domain.emnu.SMSResultEmnu;
import com.nuvole.common.domain.result.SMSResult;
import com.wisentsoft.service.sms.gsmp.GsmpCPSrv;
 
/**
 * 短信(四川省)
 *
 * @Author: lc
 * @Date: 2019/6/1 11:09
 */
public class ScSMSUtil {
    private static String ip = "10.1.210.7";
    private static int port = 13013;
    private static String cpUser = "950013";
    private static String cpPass = "950013";
    private static int timeout = 30;
    private static String cpSrvId = "SCYYPDX950013";
    private static GsmpCPSrv gsmpCPSrv;
 
    static {
        try {
            if (gsmpCPSrv == null) {
                gsmpCPSrv = new GsmpCPSrv(ScSMSUtil.ip, ScSMSUtil.port, ScSMSUtil.cpUser, ScSMSUtil.cpPass, ScSMSUtil.timeout, "/yypdx.log", false);
                gsmpCPSrv.start();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
    /**
     * 发送短信
     *
     * @param mobile  手机号码
     * @param message 发送消息文本
     * @return
     * @throws Exception
     */
    public static SMSResult sendSMS(String mobile, String message) {
 
        try {
            String result = gsmpCPSrv.submitMTSMS(mobile, message, cpSrvId);
            if (StrUtil.isEmpty(result)) {
                return new SMSResult(SMSResultEmnu.ERROR, "发送失败!");
            }
 
            return new SMSResult(SMSResultEmnu.OK);
        } catch (Exception e) {
            e.printStackTrace();
            return new SMSResult(SMSResultEmnu.ERROR, "发送异常!");
        }
    }
}