|
|
|
@ -39,10 +39,7 @@ public class SmsUtil {
|
|
|
|
|
bodyMap.put("uid", "yjglj_yjjyszzh");
|
|
|
|
|
bodyMap.put("pwd", "f604d2d6de51573b5cef5c95c11ffabe");
|
|
|
|
|
String bodyJson = JSONUtil.toJsonStr(bodyMap);
|
|
|
|
|
String responseStr = HttpRequest.post("http://2.46.42.43:80/admin-api/sms/token")
|
|
|
|
|
.body(bodyJson)
|
|
|
|
|
.execute()
|
|
|
|
|
.body();
|
|
|
|
|
String responseStr = HttpRequest.post("http://2.46.42.43:80/admin-api/sms/token").body(bodyJson).execute().body();
|
|
|
|
|
JSONObject responseJson = JSONUtil.parseObj(responseStr);
|
|
|
|
|
log.error("----------------------------短信token======================");
|
|
|
|
|
log.error("短信token: " + JSONUtil.toJsonStr(responseJson));
|
|
|
|
@ -60,35 +57,40 @@ public class SmsUtil {
|
|
|
|
|
if (errorMes != null) {
|
|
|
|
|
Integer minutes = redisCache.getCacheObject(errorMes);
|
|
|
|
|
if (minutes == null) {
|
|
|
|
|
redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES);
|
|
|
|
|
redisCache.setCacheObject(errorMes, 1, 11, TimeUnit.MINUTES);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (minutes < 10) {
|
|
|
|
|
long expireTime = redisCache.getExpire(errorMes);
|
|
|
|
|
if (expireTime == -1 || expireTime == -2) {
|
|
|
|
|
redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES);
|
|
|
|
|
redisCache.setCacheObject(errorMes, 1, 11, TimeUnit.MINUTES);
|
|
|
|
|
} else {
|
|
|
|
|
redisCache.setCacheObject(errorMes, minutes + 1, (int) expireTime, TimeUnit.SECONDS);
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 限制每种tel每天只能发一次短信
|
|
|
|
|
Map<String, Object> dataKey = redisCache.getCacheMap("dataKey");
|
|
|
|
|
if (CollectionUtil.isNotEmpty(dataKey)) {
|
|
|
|
|
String sendDateStr = (String) dataKey.get(content);
|
|
|
|
|
String sendDateStr = (String) dataKey.get(errorMes);
|
|
|
|
|
if (StrUtil.isEmpty(sendDateStr)) {
|
|
|
|
|
dataKey.put(errorMes, LocalDate.now());
|
|
|
|
|
redisCache.setCacheMap("dataKey", dataKey);
|
|
|
|
|
} else {
|
|
|
|
|
LocalDate sendDate = LocalDate.parse(sendDateStr);
|
|
|
|
|
if (LocalDate.now().equals(sendDate)) {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
dataKey.put(content, LocalDate.now());
|
|
|
|
|
dataKey.put(errorMes, LocalDate.now());
|
|
|
|
|
redisCache.setCacheMap("dataKey", dataKey);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put(content, LocalDate.now());
|
|
|
|
|
map.put(errorMes, LocalDate.now());
|
|
|
|
|
redisCache.setCacheMap("dataKey", map);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String token = getSmsToken();
|
|
|
|
|
Map<String, Object> bodyMap = new HashMap<>();
|
|
|
|
|
bodyMap.put("uid", "yjglj_yjjyszzh");
|
|
|
|
@ -102,11 +104,7 @@ public class SmsUtil {
|
|
|
|
|
bodyMap.put("content", "市应急局提醒:" + content);
|
|
|
|
|
String bodyJson = JSONUtil.toJsonStr(bodyMap);
|
|
|
|
|
log.error("bodyJson: " + bodyJson);
|
|
|
|
|
String responseStr = HttpRequest.post("http://2.46.42.43:80/admin-api/sms/send")
|
|
|
|
|
.header("Authorization", "Bearer " + token)
|
|
|
|
|
.body(bodyJson)
|
|
|
|
|
.execute()
|
|
|
|
|
.body();
|
|
|
|
|
String responseStr = HttpRequest.post("http://2.46.42.43:80/admin-api/sms/send").header("Authorization", "Bearer " + token).body(bodyJson).execute().body();
|
|
|
|
|
log.error("----------------------------短信响应======================");
|
|
|
|
|
log.error("短信: " + JSONUtil.toJsonStr(responseStr));
|
|
|
|
|
}
|
|
|
|
|