|
@@ -6,6 +6,7 @@ import com.zanxiang.game.data.serve.utils.RedisUtil;
|
|
|
import com.zanxiang.module.sms.pojo.SendResult;
|
|
|
import com.zanxiang.module.sms.service.impl.AliSmsService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.nutz.dao.Cnd;
|
|
|
import org.nutz.dao.Dao;
|
|
@@ -59,7 +60,7 @@ public class OrderCostMonitorAlarmBySmsServiceImpl implements IOrderCostMonitorA
|
|
|
if (count == 0) {
|
|
|
String msg = "前一小时订单表数据为空,请检查";
|
|
|
log.info(msg);
|
|
|
- if(!sendSms(msg)){
|
|
|
+ if (!sendSms(msg)) {
|
|
|
throw new RuntimeException("短信发送失败");
|
|
|
}
|
|
|
}
|
|
@@ -74,13 +75,13 @@ public class OrderCostMonitorAlarmBySmsServiceImpl implements IOrderCostMonitorA
|
|
|
int newHeadCostCount = headCostSql.getInt(0);
|
|
|
//从redis中取旧的消耗值
|
|
|
String oldHeadCostCount = redisUtil.getCache(HEADLINE_COST_COUNT);
|
|
|
- if(StringUtils.isNotBlank(oldHeadCostCount)){
|
|
|
+ if (StringUtils.isNotBlank(oldHeadCostCount)) {
|
|
|
//如果不为空,则比较
|
|
|
if (newHeadCostCount - Integer.parseInt(oldHeadCostCount) == 0) {
|
|
|
//如果没期间没消耗就告警
|
|
|
String msg = "前半小时头条广告数据为空,请检查";
|
|
|
log.info(msg);
|
|
|
- if(!sendSms(msg)){
|
|
|
+ if (!sendSms(msg)) {
|
|
|
throw new RuntimeException("短信发送失败");
|
|
|
}
|
|
|
}
|
|
@@ -99,11 +100,11 @@ public class OrderCostMonitorAlarmBySmsServiceImpl implements IOrderCostMonitorA
|
|
|
int newTencentCostCount = tencentCostSql.getInt(0);
|
|
|
//从redis中取旧的消耗值
|
|
|
String oldTencentCostCount = redisUtil.getCache(TENCENT_COST_COUNT);
|
|
|
- if(StringUtils.isNotBlank(oldTencentCostCount)){
|
|
|
+ if (StringUtils.isNotBlank(oldTencentCostCount)) {
|
|
|
if (newTencentCostCount - Integer.parseInt(oldTencentCostCount) == 0) {
|
|
|
String msg = "前半小时腾讯广告数据为空,请检查";
|
|
|
log.info(msg);
|
|
|
- if(!sendSms(msg)){
|
|
|
+ if (!sendSms(msg)) {
|
|
|
throw new RuntimeException("短信发送失败");
|
|
|
}
|
|
|
}
|
|
@@ -113,9 +114,9 @@ public class OrderCostMonitorAlarmBySmsServiceImpl implements IOrderCostMonitorA
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 发送短信
|
|
|
+ *
|
|
|
* @param content 内容
|
|
|
* @return 是否发送成功
|
|
|
*/
|
|
@@ -124,15 +125,16 @@ public class OrderCostMonitorAlarmBySmsServiceImpl implements IOrderCostMonitorA
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put(smsProperties.getMsgParamName(), content);
|
|
|
- params.put(smsProperties.getTimeParamName(),formatter.format(date));
|
|
|
+ params.put(smsProperties.getTimeParamName(), formatter.format(date));
|
|
|
//存储在配置文件
|
|
|
- Set<String> numberList = new HashSet<>(Arrays.asList(phoneNumber.split(",")));
|
|
|
-
|
|
|
- Map<String, SendResult> resultMap = aliSmsService.send(smsProperties.getDefaultSignName(), smsProperties.getDefaultStstemErrorTemplate(), params, numberList);
|
|
|
- for (SendResult next : resultMap.values()) {
|
|
|
- if (!next.isSuccess()) {
|
|
|
- log.error("短信发送失败,失败原因:{}", next.getMsg());
|
|
|
- return false;
|
|
|
+ if (StringUtils.isNotEmpty(phoneNumber)) {
|
|
|
+ Set<String> numberList = new HashSet<>(Arrays.asList(phoneNumber.split(",")));
|
|
|
+ Map<String, SendResult> resultMap = aliSmsService.send(smsProperties.getDefaultSignName(), smsProperties.getDefaultStstemErrorTemplate(), params, numberList);
|
|
|
+ for (SendResult next : resultMap.values()) {
|
|
|
+ if (!next.isSuccess()) {
|
|
|
+ log.error("短信发送失败,失败原因:{}", next.getMsg());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
@@ -146,7 +148,6 @@ public class OrderCostMonitorAlarmBySmsServiceImpl implements IOrderCostMonitorA
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
private Sql getSql(String sqlStr) {
|
|
|
Sql sql = Sqls.create(sqlStr);
|
|
|
sql.setCallback(Sqls.callback.integer());
|
|
@@ -182,6 +183,4 @@ public class OrderCostMonitorAlarmBySmsServiceImpl implements IOrderCostMonitorA
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|