| | |
| | | @Slf4j |
| | | public class MsgUtils { |
| | | |
| | | @Value("${code.config.accessKeyId}") |
| | | private String accessKeyId; |
| | | @Value("${code.config.accessKeySecret}") |
| | | private String accessKeySecret; |
| | | @Value("${code.config.signName}") |
| | | private String signName; |
| | | @Value("${code.config.templateCode}") |
| | | private String templateCode; |
| | | @Value("${code.config.signNameTest}") |
| | | private String signNameTest; |
| | | @Value("${code.config.templateCodeTest}") |
| | | private String templateCodeTest; |
| | | |
| | | |
| | | /** |
| | | * 使用AK&SK初始化账号Client |
| | |
| | | return new com.aliyun.dysmsapi20170525.Client(config); |
| | | } |
| | | |
| | | public void sendMsg(String phone,String code) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient(accessKeyId,accessKeySecret); |
| | | // 任务审核结果通知 |
| | | public void sendMsg1(String phone,String point,String result) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName(signName) |
| | | .setTemplateCode(templateCode) |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490460059") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"code\":\""+code+"\"}"); |
| | | .setTemplateParam("{\"point\":\""+point+"\",\"result\":\""+result+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | log.info("任务审核结果通知短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("短信发送失败:{}",error.message); |
| | | log.info("任务审核结果通知短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("短信发送失败:{}",error.message); |
| | | log.info("任务审核结果通知短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 今日任务未完成 |
| | | public void sendMsg2(String phone,String count) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490450039") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"count\":\""+count+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("今日任务未完成短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("今日任务未完成短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("今日任务未完成短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 申诉结果通知通知 |
| | | public void sendMsg3(String phone,String point,String result) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490535047") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"point\":\""+point+"\",\"result\":\""+result+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("申诉结果通知短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("申诉结果通知短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("申诉结果通知短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 请假待审核提醒 |
| | | public void sendMsg3(String phone) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490305062") |
| | | .setPhoneNumbers(phone); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("请假待审核提醒短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假待审核提醒短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假待审核提醒短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 请假结果抄送 |
| | | public void sendMsg4(String phone,String name,String date) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490325051") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"name\":\""+name+"\",\"date\":\""+date+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("请假结果抄送短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假结果抄送短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("请假结果抄送短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | // 督察任务整改通知 |
| | | public void sendMsg5(String phone,String point) throws Exception { |
| | | com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient("LTAI5t6SvJEZ9Wv28ranrfLV","hL9wbTdM3rPOLMj0DAhCn90URVzvvw"); |
| | | SendSmsRequest sendSmsRequest = new SendSmsRequest() |
| | | .setSignName("沿海市政") |
| | | .setTemplateCode("SMS_490375046") |
| | | .setPhoneNumbers(phone) |
| | | .setTemplateParam("{\"point\":\""+point+"\"}"); |
| | | RuntimeOptions runtime = new RuntimeOptions(); |
| | | try { |
| | | // 复制代码运行请自行打印 API 的返回值 |
| | | SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); |
| | | log.info("督察任务整改通知短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); |
| | | } catch (TeaException error) { |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("督察任务整改通知短信发送失败:{}",error.message); |
| | | } catch (Exception _error) { |
| | | TeaException error = new TeaException(_error.getMessage(), _error); |
| | | // 如有需要,请打印 error |
| | | com.aliyun.teautil.Common.assertAsString(error.message); |
| | | log.info("督察任务整改通知短信发送失败:{}",error.message); |
| | | } |
| | | } |
| | | } |