Merge branch 'development' into master
# Conflicts: # xhpc-modules/xhpc-charging-station/src/main/resources/bootstrap.yml # xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/service/XhpcSmsServiceImpl.java
This commit is contained in:
commit
37653fefd2
@ -10,13 +10,13 @@ import com.xhpc.common.redis.service.RedisService;
|
|||||||
import com.xhpc.general.domain.XhpcSms;
|
import com.xhpc.general.domain.XhpcSms;
|
||||||
import com.xhpc.general.mapper.XhpcSmsMapper;
|
import com.xhpc.general.mapper.XhpcSmsMapper;
|
||||||
import com.xhpc.general.util.sms.SmsUtil;
|
import com.xhpc.general.util.sms.SmsUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -26,6 +26,7 @@ import java.util.regex.Pattern;
|
|||||||
* @author yuyang
|
* @author yuyang
|
||||||
* @date 2021/7/30 18:50
|
* @date 2021/7/30 18:50
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
||||||
|
|
||||||
@ -82,12 +83,20 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
|||||||
String token = "token:" + phone;
|
String token = "token:" + phone;
|
||||||
logger.info("------------------------------");
|
logger.info("------------------------------");
|
||||||
String cacheObject = REDIS.getCacheObject(token);
|
String cacheObject = REDIS.getCacheObject(token);
|
||||||
|
System.out.println("过了redis");
|
||||||
if (cacheObject != null) {
|
if (cacheObject != null) {
|
||||||
return AjaxResult.error("1012", "操作过于频繁,请于1分钟后重试");
|
return AjaxResult.error("1012", "操作过于频繁,请于1分钟后重试");
|
||||||
}
|
}
|
||||||
logger.info("------------------------------");
|
logger.info("------------------------------");
|
||||||
//使用阿里云发送通知短信
|
//使用阿里云发送通知短信
|
||||||
Map<String, String> neededParam = aliyunSmsNotice(phone, signatureName, templateId, paramMap);
|
Map<String, String> neededParam = null;
|
||||||
|
try {
|
||||||
|
neededParam = aliyunSmsNotice(phone, signatureName, templateId, paramMap);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
throw new RuntimeException("阿里短信服务异常,neededParam为null");
|
||||||
|
}
|
||||||
|
System.out.println("过了阿里云");
|
||||||
|
|
||||||
if (!"".equals(random) && random != null) {
|
if (!"".equals(random) && random != null) {
|
||||||
xhpcSms.setCode(random);
|
xhpcSms.setCode(random);
|
||||||
@ -162,6 +171,19 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
|||||||
xhpcSmsMapper.addXhpcSms(xhpcSms);
|
xhpcSmsMapper.addXhpcSms(xhpcSms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getAliyunShortMessageInfo() {
|
||||||
|
|
||||||
|
Long successMessage = xhpcSmsMapper.querySumOfSuccessMessage();
|
||||||
|
Long failMessage = xhpcSmsMapper.querySumOfFailMessage();
|
||||||
|
Long sumOfMessage = successMessage + failMessage;
|
||||||
|
Map<String, Long> messageInfoMap = new HashMap<>();
|
||||||
|
messageInfoMap.put("successMessage", successMessage);
|
||||||
|
messageInfoMap.put("failMessage", failMessage);
|
||||||
|
messageInfoMap.put("sumOfMessage", sumOfMessage);
|
||||||
|
return messageInfoMap;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
for (int i = 0; i < 50; i++) {
|
for (int i = 0; i < 50; i++) {
|
||||||
@ -198,39 +220,20 @@ public class XhpcSmsServiceImpl implements IXhpcSmsService {
|
|||||||
String templateParam = JSONUtil.toJsonStr(paramMap);
|
String templateParam = JSONUtil.toJsonStr(paramMap);
|
||||||
sendSmsRequest.setTemplateParam(templateParam);
|
sendSmsRequest.setTemplateParam(templateParam);
|
||||||
SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest);
|
SendSmsResponse sendSmsResponse = client.sendSms(sendSmsRequest);
|
||||||
|
|
||||||
//获取发送结果状态码
|
//获取发送结果状态码
|
||||||
String statusCode = sendSmsResponse.getBody().getCode();
|
String statusCode = sendSmsResponse.getBody().getCode();
|
||||||
//获取短信的Biz号
|
|
||||||
//String bizId = sendSmsResponse.getBody().getBizId();
|
|
||||||
//获取短信的发送日期,并将其转换为yyyyMMdd的格式
|
|
||||||
//String date = sendSmsResponse.getHeaders().get("date");
|
|
||||||
//Date realDate = new Date(date);
|
|
||||||
//SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
||||||
//String formatData = sdf.format(realDate);
|
|
||||||
|
|
||||||
//获取实际的模板内容
|
//获取实际的模板内容
|
||||||
String templateContent = getTemplateContent(templateId, paramMap);
|
String templateContent = getTemplateContent(templateId, paramMap);
|
||||||
|
|
||||||
// //获取所发送的模板信息
|
|
||||||
// QuerySendDetailsRequest querySendDetailsRequest = new QuerySendDetailsRequest();
|
|
||||||
// querySendDetailsRequest.setPhoneNumber(phone);
|
|
||||||
// querySendDetailsRequest.setBizId(bizId);
|
|
||||||
// querySendDetailsRequest.setSendDate(formatData);
|
|
||||||
// querySendDetailsRequest.setCurrentPage(1L);
|
|
||||||
// querySendDetailsRequest.setPageSize(10L);
|
|
||||||
// Thread.sleep(400);
|
|
||||||
// String templateContent = client.querySendDetails(querySendDetailsRequest).getBody().getSmsSendDetailDTOs().getSmsSendDetailDTO().get(0).getContent();
|
|
||||||
|
|
||||||
//获取阿里云的返回值json字符串
|
//获取阿里云的返回值json字符串
|
||||||
SendSmsResponseBody body = sendSmsResponse.getBody();
|
SendSmsResponseBody body = sendSmsResponse.getBody();
|
||||||
String jsonResult = JSONUtil.toJsonStr(body);
|
String jsonResult = JSONUtil.toJsonStr(body);
|
||||||
|
System.out.println("阿里云返回值的json字符串=============》" + jsonResult);
|
||||||
//存放后面需要使用的返回值
|
//存放后面需要使用的返回值
|
||||||
HashMap<String, String> valueParam = new HashMap<>();
|
HashMap<String, String> valueParam = new HashMap<>();
|
||||||
valueParam.put("statusCode", statusCode);
|
valueParam.put("statusCode", statusCode);
|
||||||
valueParam.put("templateContent", templateContent);
|
valueParam.put("templateContent", templateContent);
|
||||||
valueParam.put("jsonResult", jsonResult);
|
valueParam.put("jsonResult", jsonResult);
|
||||||
|
System.out.println(("valueParam的值===========》" + valueParam));
|
||||||
return valueParam;
|
return valueParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user