md
This commit is contained in:
parent
00e29ee40b
commit
5ddddd34c5
@ -1424,7 +1424,7 @@ public class EmisBaseService {
|
|||||||
jObjParam.put("Nationalcity",nationalcity);
|
jObjParam.put("Nationalcity",nationalcity);
|
||||||
jObjParam.put("name",dt.getBillCode());
|
jObjParam.put("name",dt.getBillCode());
|
||||||
|
|
||||||
aliyunSMSService.sendMessage("探路速运", dt.getPhone(),"SMS_465316363", jObjParam.toJSONString());
|
// aliyunSMSService.sendMessage("探路速运", dt.getPhone(),"SMS_465316363", jObjParam.toJSONString());
|
||||||
|
|
||||||
// cmccSMSService.sendMessage(DBUtil.getSeqNoByLen(10),dt.getPhone(),dt.getContent());
|
// cmccSMSService.sendMessage(DBUtil.getSeqNoByLen(10),dt.getPhone(),dt.getContent());
|
||||||
}
|
}
|
||||||
@ -1460,7 +1460,7 @@ public class EmisBaseService {
|
|||||||
jObjParam.put("Problemtype",emisProblemType.getTypeName());
|
jObjParam.put("Problemtype",emisProblemType.getTypeName());
|
||||||
jObjParam.put("time",DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,waybill.getEstimateDate()));
|
jObjParam.put("time",DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,waybill.getEstimateDate()));
|
||||||
|
|
||||||
aliyunSMSService.sendMessage("探路速运", dt.getPhone(),"SMS_465386407", jObjParam.toJSONString());
|
// aliyunSMSService.sendMessage("探路速运", dt.getPhone(),"SMS_465386407", jObjParam.toJSONString());
|
||||||
// cmccSMSService.sendMessage(DBUtil.getSeqNoByLen(10),dt.getPhone(),dt.getContent());
|
// cmccSMSService.sendMessage(DBUtil.getSeqNoByLen(10),dt.getPhone(),dt.getContent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
package com.xdadan.erp.emis.service.sms;
|
package com.xdadan.erp.emis.service.sms;
|
||||||
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.aliyun.dysmsapi20170525.Client;
|
import com.aliyun.dysmsapi20170525.Client;
|
||||||
import com.aliyun.tea.TeaModel;
|
|
||||||
import com.aliyun.teautil.Common;
|
|
||||||
import com.aliyun.teautil.models.RuntimeOptions;
|
|
||||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
|
||||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||||
import com.xdadan.erp.system.service.ISysConfigService;
|
import com.xdadan.erp.system.service.ISysConfigService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -30,12 +25,14 @@ public class AliyunSMSService {
|
|||||||
*/
|
*/
|
||||||
public int sendMessage(String signName,String phone, String templateCode,String tplParam) throws EmisBizError {
|
public int sendMessage(String signName,String phone, String templateCode,String tplParam) throws EmisBizError {
|
||||||
|
|
||||||
String jsonParamStr=configService.selectConfigByKey("sys.aliyun.sms");
|
// String jsonParamStr=configService.selectConfigByKey("sys.aliyun.sms");
|
||||||
JSONObject jObjAliyunParam=JSONObject.parseObject(jsonParamStr);
|
// JSONObject jObjAliyunParam=JSONObject.parseObject(jsonParamStr);
|
||||||
String accessKeyId=jObjAliyunParam.getString("accessKeyId");
|
// String accessKeyId=jObjAliyunParam.getString("accessKeyId");
|
||||||
String accessKeySecret=jObjAliyunParam.getString("accessKeySecret");
|
// String accessKeySecret=jObjAliyunParam.getString("accessKeySecret");
|
||||||
|
//
|
||||||
|
// return innerSendMessage(accessKeyId,accessKeySecret,signName,templateCode,phone,tplParam);
|
||||||
|
|
||||||
return innerSendMessage(accessKeyId,accessKeySecret,signName,templateCode,phone,tplParam);
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,93 +44,45 @@ public class AliyunSMSService {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
||||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
// com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||||
.setAccessKeyId(accessKeyId)
|
// .setAccessKeyId(accessKeyId)
|
||||||
.setAccessKeySecret(accessKeySecret);
|
// .setAccessKeySecret(accessKeySecret);
|
||||||
// 访问的域名
|
// // 访问的域名
|
||||||
config.endpoint = "dysmsapi.aliyuncs.com";
|
// config.endpoint = "dysmsapi.aliyuncs.com";
|
||||||
return new Client(config);
|
// return new Client(config);
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int innerSendMessage(String accessKeyId,String accessKeySecret,String signName,String templateCode, String phone, String tplParam) throws EmisBizError {
|
public static int innerSendMessage(String accessKeyId,String accessKeySecret,String signName,String templateCode, String phone, String tplParam) throws EmisBizError {
|
||||||
try {
|
|
||||||
Client client = createClient(accessKeyId, accessKeySecret);
|
|
||||||
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest();
|
|
||||||
sendSmsRequest.setPhoneNumbers(phone);
|
|
||||||
sendSmsRequest.setSignName(signName);
|
|
||||||
sendSmsRequest.setTemplateCode(templateCode);
|
|
||||||
// sendSmsRequest.setTemplateParam("{\"code\":\""+param+"\"}");
|
|
||||||
sendSmsRequest.setTemplateParam(tplParam);
|
|
||||||
RuntimeOptions runtime = new RuntimeOptions();
|
|
||||||
com.aliyun.dysmsapi20170525.models.SendSmsResponse response = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
|
||||||
String jsonStr= Common.toJSONString(TeaModel.buildMap(response));
|
|
||||||
|
|
||||||
if(response.getStatusCode()==200) {
|
|
||||||
if ("OK".equals(response.getBody().getCode())) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
throw new EmisBizError(EmisBizErrorType.FAIL,response.getBody().getMessage());
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道发送错误");
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道异常");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static AsyncClient createClient(String accessKeyId, String accessKeySecret) throws Exception {
|
|
||||||
// StaticCredentialProvider provider = StaticCredentialProvider.create(Credential.builder()
|
|
||||||
// .accessKeyId(accessKeyId)
|
|
||||||
// .accessKeySecret(accessKeySecret)
|
|
||||||
// .build());
|
|
||||||
//
|
|
||||||
// return AsyncClient.builder()
|
|
||||||
// .credentialsProvider(provider)
|
|
||||||
// .overrideConfiguration(
|
|
||||||
// ClientOverrideConfiguration.create().setEndpointOverride("dysmsapi.aliyuncs.com")
|
|
||||||
// )
|
|
||||||
// .build();
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public static int innerSendMessage(String accessKeyId,String accessKeySecret,String signName,String templateCode, String phone, String tplParam) throws EmisBizError {
|
|
||||||
// try {
|
// try {
|
||||||
// AsyncClient client = createClient(accessKeyId, accessKeySecret);
|
// Client client = createClient(accessKeyId, accessKeySecret);
|
||||||
|
// com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest();
|
||||||
|
// sendSmsRequest.setPhoneNumbers(phone);
|
||||||
|
// sendSmsRequest.setSignName(signName);
|
||||||
|
// sendSmsRequest.setTemplateCode(templateCode);
|
||||||
|
//// sendSmsRequest.setTemplateParam("{\"code\":\""+param+"\"}");
|
||||||
|
// sendSmsRequest.setTemplateParam(tplParam);
|
||||||
|
// RuntimeOptions runtime = new RuntimeOptions();
|
||||||
|
// com.aliyun.dysmsapi20170525.models.SendSmsResponse response = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||||
|
// String jsonStr= Common.toJSONString(TeaModel.buildMap(response));
|
||||||
//
|
//
|
||||||
//
|
// if(response.getStatusCode()==200) {
|
||||||
// SendSmsRequest sendSmsRequest = SendSmsRequest.builder()
|
// if ("OK".equals(response.getBody().getCode())) {
|
||||||
// .phoneNumbers(phone)
|
|
||||||
// .signName(signName)
|
|
||||||
// .templateCode(templateCode)
|
|
||||||
// .templateParam(tplParam)
|
|
||||||
// .build();
|
|
||||||
//
|
|
||||||
// CompletableFuture<SendSmsResponse> response = client.sendSms(sendSmsRequest);
|
|
||||||
// SendSmsResponse resp = response.get();
|
|
||||||
//// String jsonStr=resp.getBody();
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// if(resp.getStatusCode()==200) {
|
|
||||||
// if ("OK".equals(resp.getBody().getCode())) {
|
|
||||||
// client.close();
|
|
||||||
// return 1;
|
// return 1;
|
||||||
// } else {
|
// } else {
|
||||||
// client.close();
|
// throw new EmisBizError(EmisBizErrorType.FAIL,response.getBody().getMessage());
|
||||||
// throw new EmisBizError(EmisBizErrorType.FAIL,resp.getBody().getMessage());
|
|
||||||
// }
|
// }
|
||||||
// }else{
|
// }else{
|
||||||
// client.close();
|
|
||||||
// throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道发送错误");
|
// throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道发送错误");
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// }catch (Exception e) {
|
// }catch (Exception e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
// throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道异常");
|
// throw new EmisBizError(EmisBizErrorType.FAIL,"短信渠道异常");
|
||||||
// }
|
// }
|
||||||
// }
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user