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, "发送异常!");
|
}
|
}
|
}
|