From 25b19e60e004290531f61fdf608d1adb5e531903 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期六, 12 七月 2025 14:40:12 +0800 Subject: [PATCH] 保洁巡检本周代码 --- ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java | 150 +++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 129 insertions(+), 21 deletions(-) diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java index 119a5ea..cf681aa 100644 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java @@ -6,25 +6,13 @@ import com.aliyun.teaopenapi.models.Config; import com.aliyun.teautil.models.RuntimeOptions; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component @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 @@ -44,27 +32,147 @@ 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 sendMsg4(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 sendMsg5(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 sendMsg6(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); } } } -- Gitblit v1.7.1