|
@@ -6,12 +6,17 @@ import cn.com.scca.api.data.request.message.SendSmsByTemplateRequest;
|
|
import cn.com.scca.api.data.response.message.SendSmsByTemplateResponse;
|
|
import cn.com.scca.api.data.response.message.SendSmsByTemplateResponse;
|
|
import cn.com.scca.api.error.ApiException;
|
|
import cn.com.scca.api.error.ApiException;
|
|
import cn.com.scca.api.result.ResponseResult;
|
|
import cn.com.scca.api.result.ResponseResult;
|
|
|
|
+import com.bootdo.common.utils.BDException;
|
|
import com.bootdo.datas.controller.GyDataImportController;
|
|
import com.bootdo.datas.controller.GyDataImportController;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @author zhouhj
|
|
* @author zhouhj
|
|
*/
|
|
*/
|
|
@@ -36,13 +41,14 @@ public class MessageService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 重要和核心数据目录审核驳回通知
|
|
* 重要和核心数据目录审核驳回通知
|
|
|
|
+ *
|
|
* @param phoneNumberList 手机集合
|
|
* @param phoneNumberList 手机集合
|
|
* @param templateParams 风险名称
|
|
* @param templateParams 风险名称
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public Integer importance(String phoneNumberList, String templateParams) {
|
|
|
|
- log.error("========短信的参数phoneNumberList:"+phoneNumberList);
|
|
|
|
- log.error("========短信的参数templateParams:"+templateParams);
|
|
|
|
|
|
+ public Integer importance(String phoneNumberList, String templateParams) throws BDException {
|
|
|
|
+ log.error("========短信的参数phoneNumberList:" + phoneNumberList);
|
|
|
|
+ log.error("========短信的参数templateParams:" + templateParams);
|
|
SccaClient sccaClient = new DefaultSccaClient(
|
|
SccaClient sccaClient = new DefaultSccaClient(
|
|
this.gateWayPrefix,
|
|
this.gateWayPrefix,
|
|
this.gatewayAppId,
|
|
this.gatewayAppId,
|
|
@@ -50,7 +56,8 @@ public class MessageService {
|
|
SendSmsByTemplateRequest request = new SendSmsByTemplateRequest();
|
|
SendSmsByTemplateRequest request = new SendSmsByTemplateRequest();
|
|
request.setTempleteId(this.catalogTemplateId);
|
|
request.setTempleteId(this.catalogTemplateId);
|
|
request.setTempleteParams(templateParams);
|
|
request.setTempleteParams(templateParams);
|
|
- request.setPhoneNumberList(phoneNumberList);
|
|
|
|
|
|
+ String result = this.removeEmptyValues(phoneNumberList);
|
|
|
|
+ request.setPhoneNumberList(result);
|
|
ResponseResult<SendSmsByTemplateResponse> execute = null;
|
|
ResponseResult<SendSmsByTemplateResponse> execute = null;
|
|
try {
|
|
try {
|
|
execute = sccaClient.execute(request);
|
|
execute = sccaClient.execute(request);
|
|
@@ -64,11 +71,12 @@ public class MessageService {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 安全风险评估审核驳回通知
|
|
* 安全风险评估审核驳回通知
|
|
|
|
+ *
|
|
* @param phoneNumberList 手机集合
|
|
* @param phoneNumberList 手机集合
|
|
- * @param templateParams 风险名称
|
|
|
|
|
|
+ * @param templateParams 风险名称
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public Integer securityRisk(String phoneNumberList, String templateParams) {
|
|
|
|
|
|
+ public Integer securityRisk(String phoneNumberList, String templateParams) throws BDException {
|
|
SccaClient sccaClient = new DefaultSccaClient(
|
|
SccaClient sccaClient = new DefaultSccaClient(
|
|
gateWayPrefix,
|
|
gateWayPrefix,
|
|
this.gatewayAppId,
|
|
this.gatewayAppId,
|
|
@@ -76,7 +84,8 @@ public class MessageService {
|
|
SendSmsByTemplateRequest request = new SendSmsByTemplateRequest();
|
|
SendSmsByTemplateRequest request = new SendSmsByTemplateRequest();
|
|
request.setTempleteId(this.riskTemplateId);
|
|
request.setTempleteId(this.riskTemplateId);
|
|
request.setTempleteParams(templateParams);
|
|
request.setTempleteParams(templateParams);
|
|
- request.setPhoneNumberList(phoneNumberList);
|
|
|
|
|
|
+ String result = this.removeEmptyValues(phoneNumberList);
|
|
|
|
+ request.setPhoneNumberList(result);
|
|
ResponseResult<SendSmsByTemplateResponse> execute = null;
|
|
ResponseResult<SendSmsByTemplateResponse> execute = null;
|
|
try {
|
|
try {
|
|
execute = sccaClient.execute(request);
|
|
execute = sccaClient.execute(request);
|
|
@@ -86,4 +95,19 @@ public class MessageService {
|
|
System.out.println("====短信发送反馈状态码:" + execute.getResult_code() + "====反馈信息:" + execute.getResult_msg());
|
|
System.out.println("====短信发送反馈状态码:" + execute.getResult_code() + "====反馈信息:" + execute.getResult_msg());
|
|
return execute.getResult_code();
|
|
return execute.getResult_code();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private String removeEmptyValues(String phoneNumberList) throws BDException {
|
|
|
|
+ if (Objects.isNull(phoneNumberList)) {
|
|
|
|
+ throw new BDException("电话号码列表不得为空!");
|
|
|
|
+ } else {
|
|
|
|
+ String result = Arrays.stream(phoneNumberList.split(","))
|
|
|
|
+ .filter(s -> s != null && !s.trim().isEmpty() && !s.equals("null"))
|
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
|
+ System.out.println("=========去除空值后的电话号码列表:" + result);
|
|
|
|
+ if (Objects.isNull(result)) {
|
|
|
|
+ throw new BDException("电话号码列表不得为空!");
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|