Przeglądaj źródła

1. 增加腾讯云短信

lilt085163@126.com 3 lat temu
rodzic
commit
fd21e967e5

+ 7 - 1
pom.xml

@@ -234,7 +234,13 @@
             <version>3.3.0</version>
         </dependency>
          <!-- 引入redis及相关组件 结束 -->
-
+        <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.283</version>
+        </dependency>
     </dependencies>
 
     <build>

+ 11 - 1
src/main/java/com/care/bms/service/BmsEventOrderService.java

@@ -62,7 +62,8 @@ public class BmsEventOrderService {
     private CareEventOrderOlderService careEventOrderOlderService;
     @Resource
     private CareEventOrderChambService careEventOrderChambService;
-
+    @Resource
+    private SmsSendService smsSendService;
 
     @Resource
     private BigScreenService bigScreenService;
@@ -464,6 +465,15 @@ public class BmsEventOrderService {
             });
             this.careEventOrderContactStatusService.saveBatch(orderContactList);
         }
+    }
 
+    /**
+     * 发送短信接口
+     * @param orderContactId
+     * @return
+     */
+    public boolean sendSmsToLianxiren(Long orderContactId){
+        CareEventOrderContactStatus contactStatus = this.careEventOrderContactStatusService.getById(orderContactId);
+        return smsSendService.sendSmsToLianxiren(contactStatus.getContactPhone(),null);
     }
 }

+ 10 - 5
src/main/java/com/care/common/entity/CareHouseDeviceRel.java

@@ -16,7 +16,7 @@ import java.io.Serializable;
  * 设备-房屋关系表(CareHouseDeviceRel)实体类
  *
  * @author makejava
- * @since 2021-06-02 21:43:18
+ * @since 2021-06-05 22:50:50
  */
 
 @Data
@@ -25,7 +25,7 @@ import java.io.Serializable;
 @TableName("care_house_device_rel")
 @ApiModel(value = "设备-房屋关系表", description = "")
 public class CareHouseDeviceRel implements Serializable {
-    private static final long serialVersionUID = -41169507202345645L;
+    private static final long serialVersionUID = 542599983021196368L;
 
     @TableId(value = "ID", type = IdType.AUTO)
     private Long id;
@@ -36,9 +36,14 @@ public class CareHouseDeviceRel implements Serializable {
     private Long devId;
 
 
-    @ApiModelProperty("被监护人ID")
-    @TableField("OLDER_ID")
-    private Long olderId;
+    @ApiModelProperty("房屋ID")
+    @TableField("HOUSE_ID")
+    private Long houseId;
+
+
+    @ApiModelProperty("设备别名:例如卧室")
+    @TableField("DEV_ALIAS_NAME")
+    private String devAliasName;
 
 
 }

+ 18 - 0
src/main/java/com/care/common/service/SmsSendService.java

@@ -0,0 +1,18 @@
+package com.care.common.service;
+
+/**
+ * 编码类型表(SysDimType)表服务接口
+ *
+ * @author makejava
+ * @since 2021-05-21 00:08:30
+ */
+public interface SmsSendService  {
+
+    /**
+     * 给紧急联系人发送短信
+     * @param phone
+     * @param params
+     * @return
+     */
+    boolean sendSmsToLianxiren(String phone,String[] params);
+}

+ 17 - 0
src/main/java/com/care/common/service/impl/SmsSendServiceImpl.java

@@ -0,0 +1,17 @@
+package com.care.common.service.impl;
+
+import com.care.common.service.SmsSendService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Author: lilt
+ * @Date: 2021/6/5
+ * @Desc:
+ */
+@Service
+public class SmsSendServiceImpl implements SmsSendService {
+    @Override
+    public boolean sendSmsToLianxiren(String phone, String[] params) {
+        return true;
+    }
+}

+ 58 - 0
src/main/java/com/care/common/util/SmsUtil.java

@@ -0,0 +1,58 @@
+package com.care.common.util;
+
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+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 com.tencentcloudapi.sms.v20210111.models.SendStatus;
+
+/**
+ * @Author: lilt
+ * @Date: 2021/6/5
+ * @Desc:
+ */
+public class SmsUtil {
+
+    public static SendStatus sendSms(String SecretId,
+                                       String SecretKey,
+                                       String phoneNumber,
+                                       String SmsSdkAppId,
+                                       String signName,
+                                       String templateId,
+                                       String[] templateParam){
+        SendStatus sendStatus = null;
+        try{
+
+            Credential cred = new Credential(SecretId, SecretKey);
+
+            HttpProfile httpProfile = new HttpProfile();
+            httpProfile.setEndpoint("sms.tencentcloudapi.com");
+
+            ClientProfile clientProfile = new ClientProfile();
+            clientProfile.setHttpProfile(httpProfile);
+
+            SmsClient client = new SmsClient(cred, "", clientProfile);
+
+            String[] phoneNumberSet = {phoneNumber};
+
+            SendSmsRequest req = new SendSmsRequest();
+            req.setPhoneNumberSet(phoneNumberSet);
+
+            req.setSmsSdkAppId(SmsSdkAppId);
+            req.setSignName(signName);
+            req.setTemplateId(templateId);
+
+            req.setTemplateParamSet(templateParam);
+
+            SendSmsResponse resp = client.SendSms(req);
+            sendStatus = resp.getSendStatusSet()[0];
+        } catch (TencentCloudSDKException e) {
+            System.out.println(e.toString());
+        }
+        return sendStatus;
+    }
+
+}

+ 7 - 1
src/main/resources/application-dev.properties

@@ -16,4 +16,10 @@ mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
 # 设置日志输出级别
 logging.level.root=info
 
-
+#################################### 以下是redis的集群标准配置 ##################################
+spring.redis.host=114.116.250.135
+spring.redis.port=7001
+spring.redis.database=0
+spring.redis.timeout=500
+spring.redis.password=106@!en4
+#################################### 以下是redis的集群标准配置 结束 ##############################

+ 7 - 7
src/main/resources/application.properties

@@ -51,11 +51,11 @@ spring.servlet.multipart.maxRequestSize=20MB
 spring.freemarker.template-loader-path=classpath:/template,classpath:/font
 #spring.freemarker.check-template-location=false
 
-#################################### 以下是redis的集群标准配置 ##################################
-spring.redis.host=114.116.250.135
-spring.redis.port=7001
-spring.redis.database=0
-spring.redis.timeout=500
-spring.redis.password=106@!en4
-#################################### 以下是redis的集群标准配置 结束 ##############################
 
+
+wx.codeUrl=https://api.weixin.qq.com/sns/jscode2session?appid={0}&secret={1}&js_code={2}&grant_type=authorization_code
+wx.tokenUrl=https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}
+wx.pinanbao.appid=wxda02870032b8f928
+wx.pinanbao.secret=7cf405b453e3b99a491980e3abf901d9
+
+file.savePath=/data/rfcare-file