|
|
|
@ -82,57 +82,57 @@ public class WithoutController extends BaseController {
|
|
|
|
|
return AjaxResult.success(unitService.selectAllUnit(req));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据查询条件查询所有单位列表
|
|
|
|
|
*
|
|
|
|
|
* @return 单位
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation(value = "获取所有单位列表213", response = Unit.class)
|
|
|
|
|
@GetMapping("/test")
|
|
|
|
|
public void test() {
|
|
|
|
|
sendSms("123", "17638176947", "120ErrorMes");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 发送短信
|
|
|
|
|
*
|
|
|
|
|
* @param content 短信内容
|
|
|
|
|
* @param tel 手机号多个使用,拼接
|
|
|
|
|
* @param errorMes 异常通知的类别 即redis的key
|
|
|
|
|
*/
|
|
|
|
|
public void sendSms(String content, String tel, String errorMes) {
|
|
|
|
|
if (errorMes != null) {
|
|
|
|
|
Integer minutes = redisCache.getCacheObject(errorMes);
|
|
|
|
|
if (minutes == null) {
|
|
|
|
|
redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (minutes < 10) {
|
|
|
|
|
long expireTime = redisCache.getExpire(errorMes);
|
|
|
|
|
if (expireTime == -1 || expireTime == -2) {
|
|
|
|
|
redisCache.setCacheObject(errorMes, 1, 10, 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);
|
|
|
|
|
LocalDate sendDate = LocalDate.parse(sendDateStr);
|
|
|
|
|
if (LocalDate.now().equals(sendDate)) {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
dataKey.put(content, LocalDate.now());
|
|
|
|
|
redisCache.setCacheMap("dataKey", dataKey);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put(content, LocalDate.now());
|
|
|
|
|
redisCache.setCacheMap("dataKey", map);
|
|
|
|
|
}
|
|
|
|
|
System.err.println("已经发送短信");
|
|
|
|
|
}
|
|
|
|
|
// /**
|
|
|
|
|
// * 根据查询条件查询所有单位列表
|
|
|
|
|
// *
|
|
|
|
|
// * @return 单位
|
|
|
|
|
// */
|
|
|
|
|
// @ApiOperation(value = "获取所有单位列表213", response = Unit.class)
|
|
|
|
|
// @GetMapping("/test")
|
|
|
|
|
// public void test() {
|
|
|
|
|
// sendSms("123", "17638176947", "120ErrorMes");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /**
|
|
|
|
|
// * 发送短信
|
|
|
|
|
// *
|
|
|
|
|
// * @param content 短信内容
|
|
|
|
|
// * @param tel 手机号多个使用,拼接
|
|
|
|
|
// * @param errorMes 异常通知的类别 即redis的key
|
|
|
|
|
// */
|
|
|
|
|
// public void sendSms(String content, String tel, String errorMes) {
|
|
|
|
|
// if (errorMes != null) {
|
|
|
|
|
// Integer minutes = redisCache.getCacheObject(errorMes);
|
|
|
|
|
// if (minutes == null) {
|
|
|
|
|
// redisCache.setCacheObject(errorMes, 1, 10, TimeUnit.MINUTES);
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// if (minutes < 10) {
|
|
|
|
|
// long expireTime = redisCache.getExpire(errorMes);
|
|
|
|
|
// if (expireTime == -1 || expireTime == -2) {
|
|
|
|
|
// redisCache.setCacheObject(errorMes, 1, 10, 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);
|
|
|
|
|
// LocalDate sendDate = LocalDate.parse(sendDateStr);
|
|
|
|
|
// if (LocalDate.now().equals(sendDate)) {
|
|
|
|
|
// return;
|
|
|
|
|
// } else {
|
|
|
|
|
// dataKey.put(content, LocalDate.now());
|
|
|
|
|
// redisCache.setCacheMap("dataKey", dataKey);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// Map<String, Object> map = new HashMap<>();
|
|
|
|
|
// map.put(content, LocalDate.now());
|
|
|
|
|
// redisCache.setCacheMap("dataKey", map);
|
|
|
|
|
// }
|
|
|
|
|
// System.err.println("已经发送短信");
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|