فهرست منبع

短信记录和配置修改

wukai 1 سال پیش
والد
کامیت
d1a30a173f
21فایلهای تغییر یافته به همراه1306 افزوده شده و 302 حذف شده
  1. 7 2
      doc-biz/src/main/java/com/doc/biz/controller/DocActorController.java
  2. 6 2
      doc-biz/src/main/java/com/doc/biz/controller/DocShareController.java
  3. 7 3
      doc-biz/src/main/java/com/doc/biz/controller/DocSpaceExpansionController.java
  4. 8 1
      doc-common/pom.xml
  5. 36 0
      doc-common/src/main/java/com/doc/common/enums/SmsType.java
  6. 114 0
      doc-common/src/main/java/com/doc/common/utils/TencentSmsUtils.java
  7. 1 1
      doc-common/src/main/java/com/doc/common/utils/encrypt/Sm3Util.java
  8. 1 9
      doc-system/pom.xml
  9. 51 0
      doc-system/src/main/java/com/doc/sms/controller/SmsConfigController.java
  10. 114 0
      doc-system/src/main/java/com/doc/sms/controller/SmsRecordController.java
  11. 119 0
      doc-system/src/main/java/com/doc/sms/domain/SmsRecord.java
  12. 63 0
      doc-system/src/main/java/com/doc/sms/mapper/SmsRecordMapper.java
  13. 61 0
      doc-system/src/main/java/com/doc/sms/service/ISmsRecordService.java
  14. 19 0
      doc-system/src/main/java/com/doc/sms/service/ISmsService.java
  15. 87 0
      doc-system/src/main/java/com/doc/sms/service/impl/SmsRecordServiceImpl.java
  16. 161 0
      doc-system/src/main/java/com/doc/sms/service/impl/SmsServiceImpl.java
  17. 67 0
      doc-system/src/main/java/com/doc/sms/vo/SmsConfigVO.java
  18. 193 193
      doc-system/src/main/java/com/doc/system/service/TencentSmsService.java
  19. 28 19
      doc-system/src/main/java/com/doc/system/service/impl/SysAlarmServiceImpl.java
  20. 79 0
      doc-system/src/main/resources/mapper/sms/SmsRecordMapper.xml
  21. 84 72
      doc-system/src/main/resources/mapper/system/SysConfigMapper.xml

+ 7 - 2
doc-biz/src/main/java/com/doc/biz/controller/DocActorController.java

@@ -13,10 +13,11 @@ import com.doc.common.core.controller.BaseController;
 import com.doc.common.core.domain.AjaxResult;
 import com.doc.common.core.page.TableDataInfo;
 import com.doc.common.enums.BusinessType;
+import com.doc.common.enums.SmsType;
 import com.doc.common.utils.SecurityUtils;
+import com.doc.sms.service.ISmsService;
 import com.doc.system.service.ISysConfigService;
 import com.doc.system.service.ISysUserService;
-import com.doc.system.service.TencentSmsService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -52,6 +53,9 @@ public class DocActorController extends BaseController {
     @Resource
     private ISysUserService userService;
 
+    @Resource
+    private ISmsService smsService;
+
     @ApiOperation("归档")
     @PutMapping("/{docId}")
     @Log(title = "文档协作", businessType = BusinessType.UPDATE)
@@ -119,13 +123,14 @@ public class DocActorController extends BaseController {
                     fileName = fileName.substring(0, fileName.indexOf("."));
                 }
                 //如果不在线发送短信
-                TencentSmsService.send(TencentSmsService.FILE_ACTOR, pair.getValue(), fromUser, fileName);
+                smsService.send(SmsType.FILE_ACTOR, pair.getValue(), fromUser, fileName);
             }
         });
 
         return success();
     }
 
+
     @ApiOperation("我发起的")
     @GetMapping("/initiation")
     public TableDataInfo initiation() {

+ 6 - 2
doc-biz/src/main/java/com/doc/biz/controller/DocShareController.java

@@ -8,9 +8,10 @@ import com.doc.chat.domain.ChatMsg;
 import com.doc.chat.service.IChatMsgService;
 import com.doc.common.core.controller.BaseController;
 import com.doc.common.core.domain.AjaxResult;
+import com.doc.common.enums.SmsType;
 import com.doc.common.utils.SecurityUtils;
+import com.doc.sms.service.ISmsService;
 import com.doc.system.service.ISysUserService;
-import com.doc.system.service.TencentSmsService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -40,6 +41,9 @@ public class DocShareController extends BaseController {
     @Resource
     private IDocInfoService docInfoService;
 
+    @Resource
+    private ISmsService smsService;
+
     /**
      * 文件分享
      */
@@ -92,7 +96,7 @@ public class DocShareController extends BaseController {
                 }
 
                 //如果不在线发送短信
-                TencentSmsService.send(TencentSmsService.FILE_SHARE, pair.getValue(), fromUser, fileName);
+                smsService.send(SmsType.FILE_SHARE, pair.getValue(), fromUser, fileName);
             }
 
             //添加人员

+ 7 - 3
doc-biz/src/main/java/com/doc/biz/controller/DocSpaceExpansionController.java

@@ -13,8 +13,9 @@ import com.doc.common.core.domain.AjaxResult;
 import com.doc.common.core.page.TableDataInfo;
 import com.doc.common.enums.BusinessType;
 import com.doc.common.enums.EventLevel;
+import com.doc.common.enums.SmsType;
 import com.doc.common.utils.SecurityUtils;
-import com.doc.system.service.TencentSmsService;
+import com.doc.sms.service.ISmsService;
 import com.doc.system.service.ISysUserService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -44,6 +45,9 @@ public class DocSpaceExpansionController extends BaseController {
     @Resource
     private ISysUserService userService;
 
+    @Resource
+    private ISmsService smsService;
+
     /**
      * 查询空间扩容管理列表
      */
@@ -107,7 +111,7 @@ public class DocSpaceExpansionController extends BaseController {
         Pair<Boolean, String> pair = userService.isOnline(expansion.getCreated());
         if (!pair.getKey()) {
             //如果不在线发送短信
-            TencentSmsService.send(TencentSmsService.CAP_EXPAND_SUCCESS, pair.getValue(), space.getFreeCap().toString() + "GB");
+            smsService.send(SmsType.CAP_EXPAND_SUCCESS, pair.getValue(), space.getFreeCap().toString() + "GB");
         }
         return success(docSpaceExpansionService.updateDocSpaceExpansion(expansion));
     }
@@ -132,7 +136,7 @@ public class DocSpaceExpansionController extends BaseController {
         Pair<Boolean, String> pair = userService.isOnline(expansion.getCreated());
         if (!pair.getKey()) {
             //如果不在线发送短信
-            TencentSmsService.send(TencentSmsService.CAP_EXPAND_FAIL, pair.getValue());
+            smsService.send(SmsType.CAP_EXPAND_FAIL, pair.getValue());
         }
         return success(docSpaceExpansionService.updateDocSpaceExpansion(expansion));
     }

+ 8 - 1
doc-common/pom.xml

@@ -195,7 +195,14 @@
             <scope>system</scope>
             <systemPath>${project.basedir}/lib/org.springframework.data-5.3.jar</systemPath>
         </dependency>
-
+        <!--腾讯短信-->
+        <dependency>
+            <groupId>com.tencentcloudapi</groupId>
+            <artifactId>tencentcloud-sdk-java</artifactId>
+            <!-- go to https://search.maven.org/search?q=tencentcloud-sdk-java and get the latest version. -->
+            <!-- 请到https://search.maven.org/search?q=tencentcloud-sdk-java查询所有版本,最新版本如下 -->
+            <version>3.1.899</version>
+        </dependency>
     </dependencies>
 
 </project>

+ 36 - 0
doc-common/src/main/java/com/doc/common/enums/SmsType.java

@@ -0,0 +1,36 @@
+package com.doc.common.enums;
+
+/**
+ * 短信类型
+ *
+ * @author wukai
+ */
+
+public enum SmsType {
+    /**
+     * 发送系统监控信息
+     * 您的服务器{1} {2}使用率{3},请尽快处理!
+     */
+    PERFORMANCE_MONITORING,
+    /**
+     * 发送非法操作信息
+     * 于北京时间{1}拦截到{2}非法操作:{3}
+     */
+    ALARM_ILLEGAL,
+    /**
+     * 你的扩容申请成功,当前可使用容量为{1},快去看看吧!
+     */
+    CAP_EXPAND_SUCCESS,
+    /**
+     * 很抱歉!管理员拒绝了您的扩容申请!
+     */
+    CAP_EXPAND_FAIL,
+    /**
+     * {1}向您分享了名为"{2}"的文件,请注意查收!
+     */
+    FILE_SHARE,
+    /**
+     * {1}向你发起了名为"{2}”的协作文件,请尽快登录系统查看!
+     */
+    FILE_ACTOR
+}

+ 114 - 0
doc-common/src/main/java/com/doc/common/utils/TencentSmsUtils.java

@@ -0,0 +1,114 @@
+//package com.doc.common.utils;
+//
+//import com.tencentcloudapi.common.Credential;
+//import com.tencentcloudapi.common.profile.ClientProfile;
+//import com.tencentcloudapi.common.profile.HttpProfile;
+//import com.tencentcloudapi.sms.v20210111.SmsClient;
+//import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
+//import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//
+///**
+// * 腾讯云短信接口
+// *
+// * @author wukai
+// * @date 2022-12-19
+// */
+//public class TencentSmsUtils {
+//    private static final String SECRET_ID = "AKIDKTMzLQErDJ8gxwe5F8j36sMZWCbjaBUW";
+//    private static final String SECRET_KEY = "mHVR6UbRzGGzRbU6RUGlzwc2A1astgIi";
+//    private static final String APPID = "1400871556";
+//    private static final String SIGN_NAME = "四川聚聚通科技有限公司";
+//    private static final Logger log = LoggerFactory.getLogger(TencentSmsUtils.class);
+//
+//    /**
+//     * 发送验证码
+//     * 您的当前验证码为:{1},若非本人操作,请勿泄露。
+//     */
+//    public static final String VERIFICATION_CODE = "1647196";
+//    /**
+//     * 发送系统监控信息
+//     * 您的服务器{1} {2}使用率{3},请尽快处理!
+//     */
+//    public static final String PERFORMANCE_MONITORING = "1454381";
+//    /**
+//     * 发送非法操作信息
+//     * 于北京时间{1}拦截到{2}非法操作:{3}
+//     */
+//    public static final String ALARM_ILLEGAL = "1999844";
+//    /**
+//     * 你的扩容申请成功,当前可使用容量为{1},快去看看吧!
+//     */
+//    public static final String CAP_EXPAND_SUCCESS = "2013992";
+//    /**
+//     * 很抱歉!管理员拒绝了您的扩容申请!
+//     */
+//    public static final String CAP_EXPAND_FAIL = "2013988";
+//    /**
+//     * {1}向您分享了名为"{2}"的文件,请注意查收!
+//     */
+//    public static final String FILE_SHARE = "2013984";
+//    /**
+//     * {1}向你发起了名为"{2}”的协作文件,请尽快登录系统查看!
+//     */
+//    public static final String FILE_ACTOR = "2013987";
+//
+//    public static SendSmsResponse sendSms(String phone, String templateId, String[] templateParamSet) throws Exception {
+//        // 实例化一个认证对象cred,入参需要传入腾讯云账户密钥 secretId,secretKey, 前往 API 密钥管理 页面,即可进行获取密钥。此处还需注意密钥对的保密。
+//        Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+//        //  从3.1.16版本开始, 单独设置 HTTP 代理
+//        HttpProfile httpProfile = new HttpProfile();
+//        // get请求(默认为post请求)
+//        httpProfile.setReqMethod("POST");
+//        // 请求连接超时时间,单位为秒(默认60秒)
+//        httpProfile.setConnTimeout(60);
+//        // 指定接入地域域名(默认就近接入)
+//        httpProfile.setEndpoint("sms.tencentcloudapi.com");
+//        ClientProfile clientProfile = new ClientProfile();
+//        // 指定签名算法(默认为HmacSHA256)
+//        clientProfile.setSignMethod("HmacSHA256");
+//        // 自3.1.80版本开始,SDK 支持打印日志。
+//        clientProfile.setHttpProfile(httpProfile);
+//        clientProfile.setDebug(true);
+//        //实例化要请求产品的client对象。
+//        SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
+//        SendSmsRequest req = new SendSmsRequest();
+//
+//        req.setSmsSdkAppId(APPID);
+//        req.setSignName(SIGN_NAME);
+//        req.setTemplateId(templateId);
+//        req.setTemplateParamSet(templateParamSet);
+//
+//        String preStr = "+86";
+//        String[] phoneNumberSet = new String[]{preStr + phone};
+//        req.setPhoneNumberSet(phoneNumberSet);
+//        String sessionContext = "";
+//        req.setSessionContext(sessionContext);
+//        String extendCode = "";
+//        req.setExtendCode(extendCode);
+//        String senderId = "";
+//        req.setSenderId(senderId);
+//        return client.SendSms(req);
+//    }
+//
+//    public static void send(String templateId, String phone, String... data) {
+//        try {
+//            SendSmsResponse res = sendSms(phone, templateId, data);
+//            log.info(SendSmsResponse.toJsonString(res));
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            log.error("passSms:{}", e.getMessage());
+//        }
+//    }
+//
+//    public static void main(String[] args) throws Exception {
+////        {"SendStatusSet":[{"SerialNo":"4249:221093732417050495444017078","PhoneNumber":"+8617760370787","Fee":1,"SessionContext":"","Code":"Ok","Message":"send success","IsoCode":"CN"}],"RequestId":"2ed7bbc6-5934-4853-aaa4-a89d0a63ae30"}
+//        String phone = "17760370787";
+//        TencentSmsUtils.send(TencentSmsUtils.ALARM_ILLEGAL, phone, DateUtils.getTime(), "192.168.188.88", "非法访问!");
+////        TencentSmsService.send("1647196", phone, "1234");
+////        TencentSmsService.send("1454381", phone, "192.168.188.11", "CPU", "80%");
+//        //service.alarmIllegal(phone, DateUtils.dateTime(), "192.168.1.11", "非法访问!");
+//        //service.performanceMonitoring(phone, "192.168.1.11", "CPU", "80%");
+//    }
+//}

+ 1 - 1
doc-common/src/main/java/com/doc/common/utils/encrypt/Sm3Util.java

@@ -35,7 +35,7 @@ public class Sm3Util {
         Random random = new Random();
         int number = random.nextInt(9000) + 1000;
         System.out.println("随机数字: " + number);
-        String message = "123456";
+        String message = "1qaz@WSX";
         String en1 = encrypt(message);
         String en2 = SecurityUtils.encryptPassword(en1);
         System.out.println("SM3 Digest 1: " + en1);

+ 1 - 9
doc-system/pom.xml

@@ -16,14 +16,6 @@
     </description>
 
     <dependencies>
-        <!--腾讯短信-->
-        <dependency>
-            <groupId>com.tencentcloudapi</groupId>
-            <artifactId>tencentcloud-sdk-java</artifactId>
-            <!-- go to https://search.maven.org/search?q=tencentcloud-sdk-java and get the latest version. -->
-            <!-- 请到https://search.maven.org/search?q=tencentcloud-sdk-java查询所有版本,最新版本如下 -->
-            <version>3.1.899</version>
-        </dependency>
         <!-- 通用工具-->
         <dependency>
             <groupId>com.jjt</groupId>
@@ -32,4 +24,4 @@
 
     </dependencies>
 
-</project>
+</project>

+ 51 - 0
doc-system/src/main/java/com/doc/sms/controller/SmsConfigController.java

@@ -0,0 +1,51 @@
+package com.doc.sms.controller;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.doc.common.annotation.Log;
+import com.doc.common.core.controller.BaseController;
+import com.doc.common.core.domain.AjaxResult;
+import com.doc.common.enums.BusinessType;
+import com.doc.sms.vo.SmsConfigVO;
+import com.doc.system.domain.SysConfig;
+import com.doc.system.service.ISysConfigService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+/**
+ * 短信配置Controller
+ *
+ * @author wukai
+ * @date 2024-01-19
+ */
+@Api(tags = "短信配置")
+@RestController
+@RequestMapping("/sms/config")
+public class SmsConfigController extends BaseController {
+    @Resource
+    private ISysConfigService configService;
+
+    @ApiOperation("修改短信配置")
+    @Log(title = "系统告警", businessType = BusinessType.UPDATE)
+    @PostMapping()
+    public AjaxResult config(@RequestBody SmsConfigVO vo) {
+        SysConfig config = configService.selectConfig("sms.config");
+        config.setConfigValue(JSON.toJSONString(vo));
+        return toAjax(configService.updateConfig(config));
+    }
+
+    @ApiOperation("获取短信配置")
+    @GetMapping()
+    public AjaxResult getConfig() {
+        SysConfig config = configService.selectConfig("sms.config");
+        SmsConfigVO vo = new SmsConfigVO();
+        try {
+            vo = JSONObject.parseObject(config.getConfigValue(), SmsConfigVO.class);
+        } catch (Exception ignored) {
+        }
+        return AjaxResult.success(vo);
+    }
+}

+ 114 - 0
doc-system/src/main/java/com/doc/sms/controller/SmsRecordController.java

@@ -0,0 +1,114 @@
+package com.doc.sms.controller;
+
+import java.util.List;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.doc.common.annotation.Log;
+import com.doc.common.core.controller.BaseController;
+import com.doc.common.core.domain.AjaxResult;
+import com.doc.common.enums.BusinessType;
+import com.doc.sms.domain.SmsRecord;
+import com.doc.sms.service.ISmsRecordService;
+import com.doc.common.utils.poi.ExcelUtil;
+import com.doc.common.core.page.TableDataInfo;
+
+/**
+ * 短信记录Controller
+ *
+ * @author wukai
+ * @date 2024-01-19
+ */
+@Api(tags="短信记录")
+@RestController
+@RequestMapping("/sms/record")
+public class SmsRecordController extends BaseController
+{
+    @Resource
+    private ISmsRecordService smsRecordService;
+
+    /**
+     * 查询短信记录列表
+     */
+    @ApiOperation("查询短信记录列表")
+    @PreAuthorize("@ss.hasPermi('sms:record:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(SmsRecord smsRecord)
+    {
+        startPage();
+        List<SmsRecord> list = smsRecordService.selectSmsRecordList(smsRecord);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出短信记录列表
+     */
+    @ApiOperation("导出短信记录列表")
+    @PreAuthorize("@ss.hasPermi('sms:record:export')")
+    @Log(title = "短信记录", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, SmsRecord smsRecord)
+    {
+        List<SmsRecord> list = smsRecordService.selectSmsRecordList(smsRecord);
+        ExcelUtil<SmsRecord> util = new ExcelUtil<SmsRecord>(SmsRecord.class);
+        util.exportExcel(response, list, "短信记录数据");
+    }
+
+    /**
+     * 获取短信记录详细信息
+     */
+    @ApiOperation("获取短信记录详细信息")
+    @PreAuthorize("@ss.hasPermi('sms:record:query')")
+    @GetMapping(value = "/{recordId}")
+    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
+    {
+        return success(smsRecordService.selectSmsRecordByRecordId(recordId));
+    }
+
+    /**
+     * 新增短信记录
+     */
+    @ApiOperation("新增短信记录")
+    @PreAuthorize("@ss.hasPermi('sms:record:add')")
+    @Log(title = "短信记录", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody SmsRecord smsRecord)
+    {
+        return toAjax(smsRecordService.insertSmsRecord(smsRecord));
+    }
+
+    /**
+     * 修改短信记录
+     */
+    @ApiOperation("修改短信记录")
+    @PreAuthorize("@ss.hasPermi('sms:record:edit')")
+    @Log(title = "短信记录", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody SmsRecord smsRecord)
+    {
+        return toAjax(smsRecordService.updateSmsRecord(smsRecord));
+    }
+
+    /**
+     * 删除短信记录
+     */
+    @ApiOperation("删除短信记录")
+    @PreAuthorize("@ss.hasPermi('sms:record:remove')")
+    @Log(title = "短信记录", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{recordIds}")
+    public AjaxResult remove(@PathVariable Long[] recordIds)
+    {
+        return toAjax(smsRecordService.deleteSmsRecordByRecordIds(recordIds));
+    }
+}

+ 119 - 0
doc-system/src/main/java/com/doc/sms/domain/SmsRecord.java

@@ -0,0 +1,119 @@
+package com.doc.sms.domain;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.doc.common.annotation.Excel;
+import com.doc.common.core.domain.BaseEntity;
+
+/**
+ * 短信记录对象 sms_record
+ *
+ * @author wukai
+ * @date 2024-01-19
+ */
+@ApiModel(value = "SmsRecord", description = "短信记录")
+public class SmsRecord extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 记录ID */
+    @ApiModelProperty("记录ID")
+    @Excel(name = "记录ID")
+    @TableId
+    private Long recordId;
+
+    /** 接收手机号 */
+    @ApiModelProperty("接收手机号")
+    @Excel(name = "接收手机号")
+    private String sendPhone;
+
+    /** 数据 */
+    @ApiModelProperty("数据")
+    @Excel(name = "数据")
+    private String sendContent;
+
+    /** 模板ID */
+    @ApiModelProperty("模板ID")
+    @Excel(name = "模板ID")
+    private String templateId;
+
+    /** 成功状态 */
+    @ApiModelProperty("成功状态")
+    @Excel(name = "成功状态")
+    private String snedSuccess;
+
+    /** 返回值 */
+    @ApiModelProperty("返回值")
+    @Excel(name = "返回值")
+    private String sendResult;
+
+    public void setRecordId(Long recordId)
+    {
+        this.recordId = recordId;
+    }
+
+    public Long getRecordId()
+    {
+        return recordId;
+    }
+    public void setSendPhone(String sendPhone)
+    {
+        this.sendPhone = sendPhone;
+    }
+
+    public String getSendPhone()
+    {
+        return sendPhone;
+    }
+    public void setSendContent(String sendContent)
+    {
+        this.sendContent = sendContent;
+    }
+
+    public String getSendContent()
+    {
+        return sendContent;
+    }
+    public void setTemplateId(String templateId)
+    {
+        this.templateId = templateId;
+    }
+
+    public String getTemplateId()
+    {
+        return templateId;
+    }
+    public void setSnedSuccess(String snedSuccess)
+    {
+        this.snedSuccess = snedSuccess;
+    }
+
+    public String getSnedSuccess()
+    {
+        return snedSuccess;
+    }
+    public void setSendResult(String sendResult)
+    {
+        this.sendResult = sendResult;
+    }
+
+    public String getSendResult()
+    {
+        return sendResult;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("recordId", getRecordId())
+            .append("sendPhone", getSendPhone())
+            .append("sendContent", getSendContent())
+            .append("templateId", getTemplateId())
+            .append("snedSuccess", getSnedSuccess())
+            .append("sendResult", getSendResult())
+            .toString();
+    }
+}

+ 63 - 0
doc-system/src/main/java/com/doc/sms/mapper/SmsRecordMapper.java

@@ -0,0 +1,63 @@
+package com.doc.sms.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.doc.sms.domain.SmsRecord;
+
+import java.util.List;
+
+/**
+ * 短信记录Mapper接口
+ *
+ * @author wukai
+ * @date 2024-01-19
+ */
+public interface SmsRecordMapper extends BaseMapper<SmsRecord>
+{
+    /**
+     * 查询短信记录
+     *
+     * @param recordId 短信记录主键
+     * @return 短信记录
+     */
+    public SmsRecord selectSmsRecordByRecordId(Long recordId);
+
+    /**
+     * 查询短信记录列表
+     *
+     * @param smsRecord 短信记录
+     * @return 短信记录集合
+     */
+    public List<SmsRecord> selectSmsRecordList(SmsRecord smsRecord);
+
+    /**
+     * 新增短信记录
+     *
+     * @param smsRecord 短信记录
+     * @return 结果
+     */
+    public int insertSmsRecord(SmsRecord smsRecord);
+
+    /**
+     * 修改短信记录
+     *
+     * @param smsRecord 短信记录
+     * @return 结果
+     */
+    public int updateSmsRecord(SmsRecord smsRecord);
+
+    /**
+     * 删除短信记录
+     *
+     * @param recordId 短信记录主键
+     * @return 结果
+     */
+    public int deleteSmsRecordByRecordId(Long recordId);
+
+    /**
+     * 批量删除短信记录
+     *
+     * @param recordIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteSmsRecordByRecordIds(Long[] recordIds);
+}

+ 61 - 0
doc-system/src/main/java/com/doc/sms/service/ISmsRecordService.java

@@ -0,0 +1,61 @@
+package com.doc.sms.service;
+
+import java.util.List;
+import com.doc.sms.domain.SmsRecord;
+
+/**
+ * 短信记录Service接口
+ *
+ * @author wukai
+ * @date 2024-01-19
+ */
+public interface ISmsRecordService
+{
+    /**
+     * 查询短信记录
+     *
+     * @param recordId 短信记录主键
+     * @return 短信记录
+     */
+    public SmsRecord selectSmsRecordByRecordId(Long recordId);
+
+    /**
+     * 查询短信记录列表
+     *
+     * @param smsRecord 短信记录
+     * @return 短信记录集合
+     */
+    public List<SmsRecord> selectSmsRecordList(SmsRecord smsRecord);
+
+    /**
+     * 新增短信记录
+     *
+     * @param smsRecord 短信记录
+     * @return 结果
+     */
+    public int insertSmsRecord(SmsRecord smsRecord);
+
+    /**
+     * 修改短信记录
+     *
+     * @param smsRecord 短信记录
+     * @return 结果
+     */
+    public int updateSmsRecord(SmsRecord smsRecord);
+
+    /**
+     * 批量删除短信记录
+     *
+     * @param recordIds 需要删除的短信记录主键集合
+     * @return 结果
+     */
+    public int deleteSmsRecordByRecordIds(Long[] recordIds);
+
+    /**
+     * 删除短信记录信息
+     *
+     * @param recordId 短信记录主键
+     * @return 结果
+     */
+    public int deleteSmsRecordByRecordId(Long recordId);
+}

+ 19 - 0
doc-system/src/main/java/com/doc/sms/service/ISmsService.java

@@ -0,0 +1,19 @@
+package com.doc.sms.service;
+
+import com.doc.common.enums.SmsType;
+
+/**
+ * 用户 业务层
+ *
+ * @author ruoyi
+ */
+public interface ISmsService {
+    /**
+     * 发送短信
+     *
+     * @param smsType 短信类型
+     * @param phone      电话号码
+     * @param data       数据项
+     */
+    void send(SmsType smsType, String phone, String... data);
+}

+ 87 - 0
doc-system/src/main/java/com/doc/sms/service/impl/SmsRecordServiceImpl.java

@@ -0,0 +1,87 @@
+package com.doc.sms.service.impl;
+
+import com.doc.sms.domain.SmsRecord;
+import com.doc.sms.mapper.SmsRecordMapper;
+import com.doc.sms.service.ISmsRecordService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 短信记录Service业务层处理
+ *
+ * @author wukai
+ * @date 2024-01-19
+ */
+@Service
+public class SmsRecordServiceImpl implements ISmsRecordService {
+    @Resource
+    private SmsRecordMapper smsRecordMapper;
+
+    /**
+     * 查询短信记录
+     *
+     * @param recordId 短信记录主键
+     * @return 短信记录
+     */
+    @Override
+    public SmsRecord selectSmsRecordByRecordId(Long recordId) {
+        return smsRecordMapper.selectSmsRecordByRecordId(recordId);
+    }
+
+    /**
+     * 查询短信记录列表
+     *
+     * @param smsRecord 短信记录
+     * @return 短信记录
+     */
+    @Override
+    public List<SmsRecord> selectSmsRecordList(SmsRecord smsRecord) {
+        return smsRecordMapper.selectSmsRecordList(smsRecord);
+    }
+
+    /**
+     * 新增短信记录
+     *
+     * @param smsRecord 短信记录
+     * @return 结果
+     */
+    @Override
+    public int insertSmsRecord(SmsRecord smsRecord) {
+            return smsRecordMapper.insertSmsRecord(smsRecord);
+    }
+
+    /**
+     * 修改短信记录
+     *
+     * @param smsRecord 短信记录
+     * @return 结果
+     */
+    @Override
+    public int updateSmsRecord(SmsRecord smsRecord) {
+        return smsRecordMapper.updateSmsRecord(smsRecord);
+    }
+
+    /**
+     * 批量删除短信记录
+     *
+     * @param recordIds 需要删除的短信记录主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSmsRecordByRecordIds(Long[] recordIds) {
+        return smsRecordMapper.deleteSmsRecordByRecordIds(recordIds);
+    }
+
+    /**
+     * 删除短信记录信息
+     *
+     * @param recordId 短信记录主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSmsRecordByRecordId(Long recordId) {
+        return smsRecordMapper.deleteSmsRecordByRecordId(recordId);
+    }
+}

+ 161 - 0
doc-system/src/main/java/com/doc/sms/service/impl/SmsServiceImpl.java

@@ -0,0 +1,161 @@
+package com.doc.sms.service.impl;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.doc.common.enums.SmsType;
+import com.doc.sms.domain.SmsRecord;
+import com.doc.sms.service.ISmsRecordService;
+import com.doc.sms.service.ISmsService;
+import com.doc.sms.vo.SmsConfigVO;
+import com.doc.system.domain.SysConfig;
+import com.doc.system.service.ISysConfigService;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import com.tencentcloudapi.sms.v20210111.SmsClient;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * 用户 业务层处理
+ *
+ * @author ruoyi
+ */
+@Service
+@Slf4j
+public class SmsServiceImpl implements ISmsService {
+    @Resource
+    private ISmsRecordService recordService;
+    @Resource
+    private ISysConfigService configService;
+    private String secretId;
+    private String secretKey;
+    private String appId;
+    private String signName;
+
+    /**
+     * 发送短信
+     *
+     * @param smsType 模板ID
+     * @param phone   电话号码
+     * @param data    数据项
+     */
+    @Override
+    public void send(SmsType smsType, String phone, String... data) {
+        SysConfig config = configService.selectConfig("sms.config");
+        SmsConfigVO vo = new SmsConfigVO();
+        String yes = "1";
+        try {
+            vo = JSONObject.parseObject(config.getConfigValue(), SmsConfigVO.class);
+            this.secretId = vo.getSecretId();
+            this.secretKey = vo.getSecretKey();
+            this.appId = vo.getAppid();
+            this.signName = vo.getSignName();
+            if (!yes.equals(vo.getIsOpen())) {
+                //如果没有配置短信,则直接退出
+                return;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        String templateId = "";
+        boolean isOpen;
+        switch (smsType) {
+            case PERFORMANCE_MONITORING:
+                isOpen = yes.equals(vo.getMonitorOpen());
+                templateId = vo.getMonitorId();
+                break;
+            case ALARM_ILLEGAL:
+                isOpen = yes.equals(vo.getIllegalOpen());
+                templateId = vo.getIllegalId();
+                break;
+            case CAP_EXPAND_SUCCESS:
+                isOpen = yes.equals(vo.getCapOkOpen());
+                templateId = vo.getCapOkId();
+                break;
+            case CAP_EXPAND_FAIL:
+                isOpen = yes.equals(vo.getCapFailOpen());
+                templateId = vo.getCapFailId();
+                break;
+            case FILE_SHARE:
+                isOpen = yes.equals(vo.getShareOpen());
+                templateId = vo.getShareId();
+                break;
+            case FILE_ACTOR:
+                isOpen = yes.equals(vo.getActorOpen());
+                templateId = vo.getActorId();
+                break;
+            default:
+                return;
+        }
+
+        if (!isOpen) {
+            //是否打开短信功能
+            return;
+        }
+
+        SmsRecord record = new SmsRecord();
+        record.setSendContent(JSON.toJSONString(data));
+        record.setTemplateId(templateId);
+        record.setSendPhone(phone);
+        try {
+            SendSmsResponse res = sendTencentSms(phone, templateId, data);
+            record.setSnedSuccess(res.getSendStatusSet()[0].getCode());
+            record.setSendResult(SendSmsResponse.toJsonString(res));
+        } catch (Exception e) {
+            record.setSendResult(e.getMessage());
+            e.printStackTrace();
+        }
+        recordService.insertSmsRecord(record);
+    }
+
+    private SendSmsResponse sendTencentSms(String phone, String templateId, String[] templateParamSet) throws Exception {
+        // 实例化一个认证对象cred,入参需要传入腾讯云账户密钥 secretId,secretKey, 前往 API 密钥管理 页面,即可进行获取密钥。此处还需注意密钥对的保密。
+        Credential cred = new Credential(this.secretId, this.secretKey);
+        //  从3.1.16版本开始, 单独设置 HTTP 代理
+        HttpProfile httpProfile = new HttpProfile();
+        // get请求(默认为post请求)
+        httpProfile.setReqMethod("POST");
+        // 请求连接超时时间,单位为秒(默认60秒)
+        httpProfile.setConnTimeout(60);
+        // 指定接入地域域名(默认就近接入)
+        httpProfile.setEndpoint("sms.tencentcloudapi.com");
+        ClientProfile clientProfile = new ClientProfile();
+        // 指定签名算法(默认为HmacSHA256)
+        clientProfile.setSignMethod("HmacSHA256");
+        // 自3.1.80版本开始,SDK 支持打印日志。
+        clientProfile.setHttpProfile(httpProfile);
+        clientProfile.setDebug(true);
+        //实例化要请求产品的client对象。
+        SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
+        SendSmsRequest req = new SendSmsRequest();
+
+        req.setSmsSdkAppId(this.appId);
+        req.setSignName(this.signName);
+        req.setTemplateId(templateId);
+        req.setTemplateParamSet(templateParamSet);
+
+        String preStr = "+86";
+        String[] phoneNumberSet = new String[]{preStr + phone};
+        req.setPhoneNumberSet(phoneNumberSet);
+        String sessionContext = "";
+        req.setSessionContext(sessionContext);
+        String extendCode = "";
+        req.setExtendCode(extendCode);
+        String senderId = "";
+        req.setSenderId(senderId);
+        return client.SendSms(req);
+    }
+
+//    {
+//        "SendStatusSet":[{
+//        "SerialNo":"4249:221093732417050495444017078", "PhoneNumber":"+8617760370787", "Fee":1, "SessionContext":
+//        "", "Code":"Ok", "Message":"send success", "IsoCode":"CN"
+//    }],"RequestId":"2ed7bbc6-5934-4853-aaa4-a89d0a63ae30"
+//    }
+}

+ 67 - 0
doc-system/src/main/java/com/doc/sms/vo/SmsConfigVO.java

@@ -0,0 +1,67 @@
+package com.doc.sms.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 短信配置对象 sms_config
+ *
+ * @author wukai
+ * @date 2024-01-19
+ */
+@Data
+@ApiModel(value = "SmsConfig", description = "短信配置")
+public class SmsConfigVO {
+    @ApiModelProperty("是否开启短信")
+    private String isOpen;
+
+    @ApiModelProperty("SECRET_ID")
+    private String secretId;
+
+    @ApiModelProperty("SECRET_KEY")
+    private String secretKey;
+
+    @ApiModelProperty("APPID")
+    private String appid;
+
+    @ApiModelProperty("SIGN_NAME")
+    private String signName;
+
+    @ApiModelProperty("监控信息开关")
+    private String monitorOpen;
+
+    @ApiModelProperty("监控信息模板ID")
+    private String monitorId;
+
+    @ApiModelProperty("非法访问开关")
+    private String illegalOpen;
+
+    @ApiModelProperty("非法访问模板ID")
+    private String illegalId;
+
+    @ApiModelProperty("扩容成功开关")
+    private String capOkOpen;
+
+    @ApiModelProperty("扩容成功模板ID")
+    private String capOkId;
+
+    @ApiModelProperty("扩容失败开关")
+    private String capFailOpen;
+
+    @ApiModelProperty("扩容失败模板ID")
+    private String capFailId;
+
+    @ApiModelProperty("协作开关")
+    private String actorOpen;
+
+    @ApiModelProperty("协作模板ID")
+    private String actorId;
+
+    @ApiModelProperty("分享开关")
+    private String shareOpen;
+
+    @ApiModelProperty("分享模板ID")
+    private String shareId;
+
+}

+ 193 - 193
doc-system/src/main/java/com/doc/system/service/TencentSmsService.java

@@ -1,199 +1,199 @@
-package com.doc.system.service;
-
-import com.doc.common.utils.DateUtils;
-import com.tencentcloudapi.common.Credential;
-import com.tencentcloudapi.common.profile.ClientProfile;
-import com.tencentcloudapi.common.profile.HttpProfile;
-import com.tencentcloudapi.sms.v20210111.SmsClient;
-import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
-import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.scheduling.annotation.Async;
-
-/**
- * 腾讯云短信接口
- *
- * @author wukai
- * @date 2022-12-19
- */
-public class TencentSmsService {
-    private static final String SECRET_ID = "AKIDKTMzLQErDJ8gxwe5F8j36sMZWCbjaBUW";
-    private static final String SECRET_KEY = "mHVR6UbRzGGzRbU6RUGlzwc2A1astgIi";
-    private static final String APPID = "1400871556";
-    private static final String SIGN_NAME = "四川聚聚通科技有限公司";
-    private static final Logger log = LoggerFactory.getLogger(TencentSmsService.class);
-
-    private static SendSmsResponse sendSms(String phone, String templateId, String[] templateParamSet) throws Exception {
-        // 实例化一个认证对象cred,入参需要传入腾讯云账户密钥 secretId,secretKey, 前往 API 密钥管理 页面,即可进行获取密钥。此处还需注意密钥对的保密。
-        Credential cred = new Credential(SECRET_ID, SECRET_KEY);
-        //  从3.1.16版本开始, 单独设置 HTTP 代理
-        HttpProfile httpProfile = new HttpProfile();
-        // get请求(默认为post请求)
-        httpProfile.setReqMethod("POST");
-        // 请求连接超时时间,单位为秒(默认60秒)
-        httpProfile.setConnTimeout(60);
-        // 指定接入地域域名(默认就近接入)
-        httpProfile.setEndpoint("sms.tencentcloudapi.com");
-        ClientProfile clientProfile = new ClientProfile();
-        // 指定签名算法(默认为HmacSHA256)
-        clientProfile.setSignMethod("HmacSHA256");
-        // 自3.1.80版本开始,SDK 支持打印日志。
-        clientProfile.setHttpProfile(httpProfile);
-        clientProfile.setDebug(true);
-        //实例化要请求产品的client对象。
-        SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
-        SendSmsRequest req = new SendSmsRequest();
-
-        req.setSmsSdkAppId(APPID);
-        req.setSignName(SIGN_NAME);
-        req.setTemplateId(templateId);
-        req.setTemplateParamSet(templateParamSet);
-
-        String preStr = "+86";
-        String[] phoneNumberSet = new String[]{preStr + phone};
-        req.setPhoneNumberSet(phoneNumberSet);
-        String sessionContext = "";
-        req.setSessionContext(sessionContext);
-        String extendCode = "";
-        req.setExtendCode(extendCode);
-        String senderId = "";
-        req.setSenderId(senderId);
-        return client.SendSms(req);
-    }
-
-    /**
-     * 发送验证码
-     *
-     * @param phone 电话
-     * @param code  验证码
-     */
-    @Async("threadPoolTaskExecutor")
-    public void verificationCode(String phone, String code) {
-        try {
-            String templateId = "1647196";
-            String[] templateParamSet = new String[]{code};
-            SendSmsResponse res = sendSms(phone, templateId, templateParamSet);
-            log.info(SendSmsResponse.toJsonString(res));
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error("passSms:{}", e.getMessage());
-        }
-    }
-
-
-    /**
-     * 业务信息告警
-     *
-     * @param phone   电话
-     * @param time    时间
-     * @param account 账号
-     * @param msg     ip
-     */
-    @Async("threadPoolTaskExecutor")
-    public void alarmIllegal(String phone, String time, String account, String msg) {
-        try {
-            String templateId = "1999844";
-            String[] templateParamSet = new String[]{time, account, msg};
-            SendSmsResponse res = sendSms(phone, templateId, templateParamSet);
-            log.info(SendSmsResponse.toJsonString(res));
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error("passSms:{}", e.getMessage());
-        }
-    }
-
-    /**
-     * 性能监控
-     *
-     * @param phone 电话
-     * @param ip    服务器IP
-     * @param type  类型 CPU 内存 硬盘
-     * @param data  百分比
-     */
-    @Async("threadPoolTaskExecutor")
-    public void performanceMonitoring(String phone, String ip, String type, String data) {
-        try {
-            String templateId = "1454381";
-            String[] templateParamSet = new String[]{ip, type, data};
-            SendSmsResponse res = sendSms(phone, templateId, templateParamSet);
-            log.info(SendSmsResponse.toJsonString(res));
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error("passSms:{}", e.getMessage());
-        }
-    }
-
+//package com.doc.system.service;
+//
+//import com.doc.common.utils.DateUtils;
+//import com.tencentcloudapi.common.Credential;
+//import com.tencentcloudapi.common.profile.ClientProfile;
+//import com.tencentcloudapi.common.profile.HttpProfile;
+//import com.tencentcloudapi.sms.v20210111.SmsClient;
+//import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
+//import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.scheduling.annotation.Async;
+//
+///**
+// * 腾讯云短信接口
+// *
+// * @author wukai
+// * @date 2022-12-19
+// */
+//public class TencentSmsService {
+//    private static final String SECRET_ID = "AKIDKTMzLQErDJ8gxwe5F8j36sMZWCbjaBUW";
+//    private static final String SECRET_KEY = "mHVR6UbRzGGzRbU6RUGlzwc2A1astgIi";
+//    private static final String APPID = "1400871556";
+//    private static final String SIGN_NAME = "四川聚聚通科技有限公司";
+//    private static final Logger log = LoggerFactory.getLogger(TencentSmsService.class);
+//
+//    private static SendSmsResponse sendSms(String phone, String templateId, String[] templateParamSet) throws Exception {
+//        // 实例化一个认证对象cred,入参需要传入腾讯云账户密钥 secretId,secretKey, 前往 API 密钥管理 页面,即可进行获取密钥。此处还需注意密钥对的保密。
+//        Credential cred = new Credential(SECRET_ID, SECRET_KEY);
+//        //  从3.1.16版本开始, 单独设置 HTTP 代理
+//        HttpProfile httpProfile = new HttpProfile();
+//        // get请求(默认为post请求)
+//        httpProfile.setReqMethod("POST");
+//        // 请求连接超时时间,单位为秒(默认60秒)
+//        httpProfile.setConnTimeout(60);
+//        // 指定接入地域域名(默认就近接入)
+//        httpProfile.setEndpoint("sms.tencentcloudapi.com");
+//        ClientProfile clientProfile = new ClientProfile();
+//        // 指定签名算法(默认为HmacSHA256)
+//        clientProfile.setSignMethod("HmacSHA256");
+//        // 自3.1.80版本开始,SDK 支持打印日志。
+//        clientProfile.setHttpProfile(httpProfile);
+//        clientProfile.setDebug(true);
+//        //实例化要请求产品的client对象。
+//        SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
+//        SendSmsRequest req = new SendSmsRequest();
+//
+//        req.setSmsSdkAppId(APPID);
+//        req.setSignName(SIGN_NAME);
+//        req.setTemplateId(templateId);
+//        req.setTemplateParamSet(templateParamSet);
+//
+//        String preStr = "+86";
+//        String[] phoneNumberSet = new String[]{preStr + phone};
+//        req.setPhoneNumberSet(phoneNumberSet);
+//        String sessionContext = "";
+//        req.setSessionContext(sessionContext);
+//        String extendCode = "";
+//        req.setExtendCode(extendCode);
+//        String senderId = "";
+//        req.setSenderId(senderId);
+//        return client.SendSms(req);
+//    }
+//
+//    /**
+//     * 发送验证码
+//     *
+//     * @param phone 电话
+//     * @param code  验证码
+//     */
+//    @Async("threadPoolTaskExecutor")
+//    public void verificationCode(String phone, String code) {
+//        try {
+//            String templateId = "1647196";
+//            String[] templateParamSet = new String[]{code};
+//            SendSmsResponse res = sendSms(phone, templateId, templateParamSet);
+//            log.info(SendSmsResponse.toJsonString(res));
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            log.error("passSms:{}", e.getMessage());
+//        }
+//    }
+//
+//
 //    /**
-//     * 扩容申请成功
+//     * 业务信息告警
 //     *
 //     * @param phone   电话
-//     * @param useAble 可用容量
-//     * @param type    类型 CPU 内存 硬盘
-//     * @param data    百分比
+//     * @param time    时间
+//     * @param account 账号
+//     * @param msg     ip
 //     */
 //    @Async("threadPoolTaskExecutor")
-//    public void capExpandSuccess(String phone, String useAble) {
-//try {
-//    String templateId = "2013992";
-//    String[] templateParamSet = new String[]{useAble};
-//    SendSmsResponse res = sendSms(phone, templateId, templateParamSet);
-//    log.info(SendSmsResponse.toJsonString(res));
-//} catch (Exception e) {
-//    e.printStackTrace();
-//    log.error("passSms:{}", e.getMessage());
-//}
+//    public void alarmIllegal(String phone, String time, String account, String msg) {
+//        try {
+//            String templateId = "1999844";
+//            String[] templateParamSet = new String[]{time, account, msg};
+//            SendSmsResponse res = sendSms(phone, templateId, templateParamSet);
+//            log.info(SendSmsResponse.toJsonString(res));
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            log.error("passSms:{}", e.getMessage());
+//        }
 //    }
-
-    public static void send(String templateId, String phone, String... data) {
-        try {
-            SendSmsResponse res = sendSms(phone, templateId, data);
-            log.info(SendSmsResponse.toJsonString(res));
-        } catch (Exception e) {
-            e.printStackTrace();
-            log.error("passSms:{}", e.getMessage());
-        }
-    }
-
-    /**
-     * 发送验证码
-     * 您的当前验证码为:{1},若非本人操作,请勿泄露。
-     */
-    public static final String VERIFICATION_CODE = "1647196";
-    /**
-     * 发送系统监控信息
-     * 您的服务器{1} {2}使用率{3},请尽快处理!
-     */
-    public static final String PERFORMANCE_MONITORING = "1454381";
-    /**
-     * 发送非法操作信息
-     * 于北京时间{1}拦截到{2}非法操作:{3}
-     */
-    public static final String ALARM_ILLEGAL = "1999844";
-    /**
-     * 你的扩容申请成功,当前可使用容量为{1},快去看看吧!
-     */
-    public static final String CAP_EXPAND_SUCCESS = "2013992";
-    /**
-     * 很抱歉!管理员拒绝了您的扩容申请!
-     */
-    public static final String CAP_EXPAND_FAIL = "2013988";
-    /**
-     * {1}向您分享了名为"{2}"的文件,请注意查收!
-     */
-    public static final String FILE_SHARE = "2013984";
-    /**
-     * {1}向你发起了名为"{2}”的协作文件,请尽快登录系统查看!
-     */
-    public static final String FILE_ACTOR = "2013987";
-
-
-    public static void main(String[] args) throws Exception {
-        String phone = "17760370787";
-        TencentSmsService.send(TencentSmsService.ALARM_ILLEGAL, phone, DateUtils.getTime(), "192.168.188.88", "非法访问!");
-//        TencentSmsService.send("1647196", phone, "1234");
-//        TencentSmsService.send("1454381", phone, "192.168.188.11", "CPU", "80%");
-        //service.alarmIllegal(phone, DateUtils.dateTime(), "192.168.1.11", "非法访问!");
-        //service.performanceMonitoring(phone, "192.168.1.11", "CPU", "80%");
-    }
-}
+//
+//    /**
+//     * 性能监控
+//     *
+//     * @param phone 电话
+//     * @param ip    服务器IP
+//     * @param type  类型 CPU 内存 硬盘
+//     * @param data  百分比
+//     */
+//    @Async("threadPoolTaskExecutor")
+//    public void performanceMonitoring(String phone, String ip, String type, String data) {
+//        try {
+//            String templateId = "1454381";
+//            String[] templateParamSet = new String[]{ip, type, data};
+//            SendSmsResponse res = sendSms(phone, templateId, templateParamSet);
+//            log.info(SendSmsResponse.toJsonString(res));
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            log.error("passSms:{}", e.getMessage());
+//        }
+//    }
+//
+////    /**
+////     * 扩容申请成功
+////     *
+////     * @param phone   电话
+////     * @param useAble 可用容量
+////     * @param type    类型 CPU 内存 硬盘
+////     * @param data    百分比
+////     */
+////    @Async("threadPoolTaskExecutor")
+////    public void capExpandSuccess(String phone, String useAble) {
+////try {
+////    String templateId = "2013992";
+////    String[] templateParamSet = new String[]{useAble};
+////    SendSmsResponse res = sendSms(phone, templateId, templateParamSet);
+////    log.info(SendSmsResponse.toJsonString(res));
+////} catch (Exception e) {
+////    e.printStackTrace();
+////    log.error("passSms:{}", e.getMessage());
+////}
+////    }
+//
+//    public static void send1(String templateId, String phone, String... data) {
+//        try {
+//            SendSmsResponse res = sendSms(phone, templateId, data);
+//            log.info(SendSmsResponse.toJsonString(res));
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//            log.error("passSms:{}", e.getMessage());
+//        }
+//    }
+//
+//    /**
+//     * 发送验证码
+//     * 您的当前验证码为:{1},若非本人操作,请勿泄露。
+//     */
+//    public static final String VERIFICATION_CODE = "1647196";
+//    /**
+//     * 发送系统监控信息
+//     * 您的服务器{1} {2}使用率{3},请尽快处理!
+//     */
+//    public static final String PERFORMANCE_MONITORING = "1454381";
+//    /**
+//     * 发送非法操作信息
+//     * 于北京时间{1}拦截到{2}非法操作:{3}
+//     */
+//    public static final String ALARM_ILLEGAL = "1999844";
+//    /**
+//     * 你的扩容申请成功,当前可使用容量为{1},快去看看吧!
+//     */
+//    public static final String CAP_EXPAND_SUCCESS = "2013992";
+//    /**
+//     * 很抱歉!管理员拒绝了您的扩容申请!
+//     */
+//    public static final String CAP_EXPAND_FAIL = "2013988";
+//    /**
+//     * {1}向您分享了名为"{2}"的文件,请注意查收!
+//     */
+//    public static final String FILE_SHARE = "2013984";
+//    /**
+//     * {1}向你发起了名为"{2}”的协作文件,请尽快登录系统查看!
+//     */
+//    public static final String FILE_ACTOR = "2013987";
+//
+//
+//    public static void main(String[] args) throws Exception {
+//        String phone = "17760370787";
+//        TencentSmsService.send(TencentSmsService.ALARM_ILLEGAL, phone, DateUtils.getTime(), "192.168.188.88", "非法访问!");
+////        TencentSmsService.send("1647196", phone, "1234");
+////        TencentSmsService.send("1454381", phone, "192.168.188.11", "CPU", "80%");
+//        //service.alarmIllegal(phone, DateUtils.dateTime(), "192.168.1.11", "非法访问!");
+//        //service.performanceMonitoring(phone, "192.168.1.11", "CPU", "80%");
+//    }
+//}

+ 28 - 19
doc-system/src/main/java/com/doc/system/service/impl/SysAlarmServiceImpl.java

@@ -3,7 +3,9 @@ package com.doc.system.service.impl;
 import com.alibaba.fastjson2.JSONObject;
 import com.doc.common.enums.AlarmType;
 import com.doc.common.enums.EventLevel;
+import com.doc.common.enums.SmsType;
 import com.doc.common.utils.DateUtils;
+import com.doc.sms.service.ISmsService;
 import com.doc.system.domain.SysAlarm;
 import com.doc.system.domain.SysConfig;
 import com.doc.system.domain.vo.AlarmVO;
@@ -11,7 +13,6 @@ import com.doc.system.mapper.SysAlarmMapper;
 import com.doc.system.service.ISysAlarmService;
 import com.doc.system.service.ISysAlarmSmsService;
 import com.doc.system.service.ISysConfigService;
-import com.doc.system.service.TencentSmsService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -36,7 +37,8 @@ public class SysAlarmServiceImpl implements ISysAlarmService {
     private ISysConfigService sysConfigService;
     @Resource
     private ISysAlarmSmsService alarmSmsService;
-
+    @Resource
+    private ISmsService smsService;
 
     /**
      * 查询系统告警
@@ -70,9 +72,8 @@ public class SysAlarmServiceImpl implements ISysAlarmService {
     public int insertSysAlarm(SysAlarm sysAlarm) {
         int r = sysAlarmMapper.insertSysAlarm(sysAlarm);
         SysConfig config = sysConfigService.selectConfig("alarm.config");
-        AlarmVO vo = new AlarmVO();
         try {
-            vo = JSONObject.parseObject(config.getConfigValue(), AlarmVO.class);
+            AlarmVO vo = JSONObject.parseObject(config.getConfigValue(), AlarmVO.class);
             String open = "1";
             //短信开启状态为1
             if (!open.equals(vo.getStatus())) {
@@ -88,7 +89,7 @@ public class SysAlarmServiceImpl implements ISysAlarmService {
             if (type == AlarmType.MONITOR_HDD.ordinal()) {
                 if (Double.parseDouble(sysAlarm.getRemark()) > vo.getHdd_used()) {
                     //发送短信
-                    TencentSmsService.send(TencentSmsService.PERFORMANCE_MONITORING, vo.getPhone(), "硬盘", "空间", sysAlarm.getRemark() + "%");
+                    smsService.send(SmsType.PERFORMANCE_MONITORING, vo.getPhone(), "硬盘", "空间", sysAlarm.getRemark() + "%");
                 }
             }
             SysAlarm search = new SysAlarm();
@@ -100,25 +101,33 @@ public class SysAlarmServiceImpl implements ISysAlarmService {
                 list = sysAlarmMapper.selectSysAlarmList(search);
                 if (list.size() > vo.getIp_times()) {
                     //发送短信
-                    TencentSmsService.send(TencentSmsService.ALARM_ILLEGAL, vo.getPhone(), DateUtils.getTime(), sysAlarm.getRemark(), "非法IP访问");
+                    smsService.send(SmsType.ALARM_ILLEGAL, vo.getPhone(), DateUtils.getTime(), sysAlarm.getRemark(), "非法IP访问");
                 }
             } else {
                 list = sysAlarmMapper.selectSysAlarmList(search);
-                AlarmVO finalVo = vo;
-                AtomicInteger times = new AtomicInteger();
-                list.forEach(alarm -> {
-                    double d = Double.parseDouble(alarm.getRemark());
-                    if (d > finalVo.getCpu_used()) {
-                        times.getAndIncrement();
+                if (type == AlarmType.MONITOR_CPU.ordinal()) {
+                    AtomicInteger times = new AtomicInteger();
+                    list.forEach(alarm -> {
+                        double d = Double.parseDouble(alarm.getRemark());
+                        if (d > vo.getCpu_used()) {
+                            times.getAndIncrement();
+                        }
+                    });
+                    if (times.intValue() > vo.getCpu_times()) {
+                        smsService.send(SmsType.PERFORMANCE_MONITORING, vo.getPhone(), "CPU", "当前", sysAlarm.getRemark() + "%");
                     }
-                });
-                if (times.intValue() > finalVo.getCpu_times()) {
-                    //发送短信
-                    if (type == AlarmType.MONITOR_CPU.ordinal()) {
-                        TencentSmsService.send(TencentSmsService.PERFORMANCE_MONITORING, vo.getPhone(), "CPU", "当前", sysAlarm.getRemark() + "%");
-                    } else if (type == AlarmType.MONITOR_MEM.ordinal()) {
-                        TencentSmsService.send(TencentSmsService.PERFORMANCE_MONITORING, vo.getPhone(), "内存", "当前", sysAlarm.getRemark() + "%");
+                }
 
+                if (type == AlarmType.MONITOR_MEM.ordinal()) {
+                    AtomicInteger times = new AtomicInteger();
+                    list.forEach(alarm -> {
+                        double d = Double.parseDouble(alarm.getRemark());
+                        if (d > vo.getMem_used()) {
+                            times.getAndIncrement();
+                        }
+                    });
+                    if (times.intValue() > vo.getMem_times()) {
+                        smsService.send(SmsType.PERFORMANCE_MONITORING, vo.getPhone(), "内存", "当前", sysAlarm.getRemark() + "%");
                     }
                 }
 

+ 79 - 0
doc-system/src/main/resources/mapper/sms/SmsRecordMapper.xml

@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.doc.sms.mapper.SmsRecordMapper">
+
+    <resultMap type="SmsRecord" id="SmsRecordResult">
+        <result property="recordId"    column="RECORD_ID"    />
+        <result property="sendPhone"    column="SEND_PHONE"    />
+        <result property="sendContent"    column="SEND_CONTENT"    />
+        <result property="templateId"    column="TEMPLATE_ID"    />
+        <result property="snedSuccess"    column="SNED_SUCCESS"    />
+        <result property="sendResult"    column="SEND_RESULT"    />
+    </resultMap>
+
+    <sql id="selectSmsRecordVo">
+        select RECORD_ID, SEND_PHONE, SEND_CONTENT, TEMPLATE_ID, SNED_SUCCESS, SEND_RESULT from sms_record
+    </sql>
+
+    <select id="selectSmsRecordList" parameterType="SmsRecord" resultMap="SmsRecordResult">
+        <include refid="selectSmsRecordVo"/>
+        <where>
+            <if test="recordId != null "> and RECORD_ID = #{recordId}</if>
+            <if test="sendPhone != null  and sendPhone != ''"> and SEND_PHONE = #{sendPhone}</if>
+            <if test="sendContent != null  and sendContent != ''"> and SEND_CONTENT = #{sendContent}</if>
+            <if test="templateId != null  and templateId != ''"> and TEMPLATE_ID = #{templateId}</if>
+            <if test="snedSuccess != null  and snedSuccess != ''"> and SNED_SUCCESS = #{snedSuccess}</if>
+            <if test="sendResult != null  and sendResult != ''"> and SEND_RESULT = #{sendResult}</if>
+        </where>
+    </select>
+
+    <select id="selectSmsRecordByRecordId" parameterType="Long" resultMap="SmsRecordResult">
+        <include refid="selectSmsRecordVo"/>
+        where RECORD_ID = #{recordId}
+    </select>
+
+    <insert id="insertSmsRecord" parameterType="SmsRecord">
+        insert into sms_record
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="recordId != null">RECORD_ID,</if>
+            <if test="sendPhone != null">SEND_PHONE,</if>
+            <if test="sendContent != null">SEND_CONTENT,</if>
+            <if test="templateId != null">TEMPLATE_ID,</if>
+            <if test="snedSuccess != null">SNED_SUCCESS,</if>
+            <if test="sendResult != null">SEND_RESULT,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="recordId != null">#{recordId},</if>
+            <if test="sendPhone != null">#{sendPhone},</if>
+            <if test="sendContent != null">#{sendContent},</if>
+            <if test="templateId != null">#{templateId},</if>
+            <if test="snedSuccess != null">#{snedSuccess},</if>
+            <if test="sendResult != null">#{sendResult},</if>
+         </trim>
+    </insert>
+
+    <update id="updateSmsRecord" parameterType="SmsRecord">
+        update sms_record
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="sendPhone != null">SEND_PHONE = #{sendPhone},</if>
+            <if test="sendContent != null">SEND_CONTENT = #{sendContent},</if>
+            <if test="templateId != null">TEMPLATE_ID = #{templateId},</if>
+            <if test="snedSuccess != null">SNED_SUCCESS = #{snedSuccess},</if>
+            <if test="sendResult != null">SEND_RESULT = #{sendResult},</if>
+        </trim>
+        where RECORD_ID = #{recordId}
+    </update>
+
+    <delete id="deleteSmsRecordByRecordId" parameterType="Long">
+        delete from sms_record where RECORD_ID = #{recordId}
+    </delete>
+
+    <delete id="deleteSmsRecordByRecordIds" parameterType="String">
+        delete from sms_record where RECORD_ID in
+        <foreach item="recordId" collection="array" open="(" separator="," close=")">
+            #{recordId}
+        </foreach>
+    </delete>
+</mapper>

+ 84 - 72
doc-system/src/main/resources/mapper/system/SysConfigMapper.xml

@@ -1,96 +1,106 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.doc.system.mapper.SysConfigMapper">
-    
+
     <resultMap type="SysConfig" id="SysConfigResult">
-    	<id     property="configId"      column="config_id"      />
-        <result property="configName"    column="config_name"    />
-        <result property="configKey"     column="config_key"     />
-        <result property="configValue"   column="config_value"   />
-        <result property="configType"    column="config_type"    />
-        <result property="createBy"      column="create_by"      />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"      column="update_by"      />
-        <result property="updateTime"    column="update_time"    />
+        <id property="configId" column="config_id"/>
+        <result property="configName" column="config_name"/>
+        <result property="configKey" column="config_key"/>
+        <result property="configValue" column="config_value"/>
+        <result property="configType" column="config_type"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
     </resultMap>
-    
+
     <sql id="selectConfigVo">
-        select config_id, config_name, config_key, config_value, config_type, create_by, create_time, update_by, update_time, remark 
-		from sys_config
+        select config_id,
+               config_name,
+               config_key,
+               config_value,
+               config_type,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               remark
+        from sys_config
     </sql>
-    
+
     <!-- 查询条件 -->
-	<sql id="sqlwhereSearch">
-		<where>
-			<if test="configId !=null">
-				and config_id = #{configId}
-			</if>
-			<if test="configKey !=null and configKey != ''">
-				and config_key = #{configKey}
-			</if>
-		</where>
-	</sql>
-    
+    <sql id="sqlwhereSearch">
+        <where>
+            <if test="configId !=null">
+                and config_id = #{configId}
+            </if>
+            <if test="configKey !=null and configKey != ''">
+                and config_key = #{configKey}
+            </if>
+        </where>
+    </sql>
+
     <select id="selectConfig" parameterType="SysConfig" resultMap="SysConfigResult">
         <include refid="selectConfigVo"/>
         <include refid="sqlwhereSearch"/>
     </select>
-    
+
     <select id="selectConfigList" parameterType="SysConfig" resultMap="SysConfigResult">
         <include refid="selectConfigVo"/>
         <where>
-			<if test="configName != null and configName != ''">
-				AND config_name like concat('%', #{configName}, '%')
-			</if>
-			<if test="configType != null and configType != ''">
-				AND config_type = #{configType}
-			</if>
-			<if test="configKey != null and configKey != ''">
-				AND config_key like concat('%', #{configKey}, '%')
-			</if>
-			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
-				and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
-			</if>
-			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
-				and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
-			</if>
-		</where>
+            <if test="configName != null and configName != ''">
+                AND config_name like concat('%', #{configName}, '%')
+            </if>
+            <if test="configType != null and configType != ''">
+                AND config_type = #{configType}
+            </if>
+            <if test="configKey != null and configKey != ''">
+                AND config_key like concat('%', #{configKey}, '%')
+            </if>
+            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
+                and date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
+            </if>
+            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
+                and date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
+            </if>
+            and config_type!='X'
+        </where>
     </select>
-    
+
     <select id="selectConfigById" parameterType="Long" resultMap="SysConfigResult">
         <include refid="selectConfigVo"/>
         where config_id = #{configId}
     </select>
-	
+
     <select id="checkConfigKeyUnique" parameterType="String" resultMap="SysConfigResult">
         <include refid="selectConfigVo"/>
         where config_key = #{configKey} limit 1
     </select>
-    
+
     <insert id="insertConfig" parameterType="SysConfig">
         insert into sys_config (
-			<if test="configName != null and configName != '' ">config_name,</if>
-			<if test="configKey != null and configKey != '' ">config_key,</if>
-			<if test="configValue != null and configValue != '' ">config_value,</if>
-			<if test="configType != null and configType != '' ">config_type,</if>
-			<if test="createBy != null and createBy != ''">create_by,</if>
-			<if test="remark != null and remark != ''">remark,</if>
- 			create_time
+        <if test="configName != null and configName != '' ">config_name,</if>
+        <if test="configKey != null and configKey != '' ">config_key,</if>
+        <if test="configValue != null and configValue != '' ">config_value,</if>
+        <if test="configType != null and configType != '' ">config_type,</if>
+        <if test="createBy != null and createBy != ''">create_by,</if>
+        <if test="remark != null and remark != ''">remark,</if>
+        create_time
         )values(
-			<if test="configName != null and configName != ''">#{configName},</if>
-			<if test="configKey != null and configKey != ''">#{configKey},</if>
-			<if test="configValue != null and configValue != ''">#{configValue},</if>
-			<if test="configType != null and configType != ''">#{configType},</if>
-			<if test="createBy != null and createBy != ''">#{createBy},</if>
-			<if test="remark != null and remark != ''">#{remark},</if>
- 			sysdate()
-		)
+        <if test="configName != null and configName != ''">#{configName},</if>
+        <if test="configKey != null and configKey != ''">#{configKey},</if>
+        <if test="configValue != null and configValue != ''">#{configValue},</if>
+        <if test="configType != null and configType != ''">#{configType},</if>
+        <if test="createBy != null and createBy != ''">#{createBy},</if>
+        <if test="remark != null and remark != ''">#{remark},</if>
+        sysdate()
+        )
     </insert>
-	 
+
     <update id="updateConfig" parameterType="SysConfig">
-        update sys_config 
+        update sys_config
         <set>
             <if test="configName != null and configName != ''">config_name = #{configName},</if>
             <if test="configKey != null and configKey != ''">config_key = #{configKey},</if>
@@ -98,20 +108,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="configType != null and configType != ''">config_type = #{configType},</if>
             <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
             <if test="remark != null">remark = #{remark},</if>
- 			update_time = sysdate()
+            update_time = sysdate()
         </set>
         where config_id = #{configId}
     </update>
-	
+
     <delete id="deleteConfigById" parameterType="Long">
-        delete from sys_config where config_id = #{configId}
+        delete
+        from sys_config
+        where config_id = #{configId}
     </delete>
-    
+
     <delete id="deleteConfigByIds" parameterType="Long">
-        delete from sys_config where config_id in 
+        delete from sys_config where config_id in
         <foreach item="configId" collection="array" open="(" separator="," close=")">
-        	#{configId}
+            #{configId}
         </foreach>
     </delete>
-    
-</mapper>
+
+</mapper>