|
@@ -260,29 +260,39 @@ public class DeviceMqttConsumerImpl implements DeviceMqttConsumer {
|
|
boolean isSubscribed = BooleanUtil.isTrue(b);
|
|
boolean isSubscribed = BooleanUtil.isTrue(b);
|
|
//商户是否订阅短信通知
|
|
//商户是否订阅短信通知
|
|
if(isSubscribed&&StrUtil.isNotEmpty(exceptionType)){
|
|
if(isSubscribed&&StrUtil.isNotEmpty(exceptionType)){
|
|
- UserInfoDto.Vo userInfo = R.feignCheckData(userInfoService.obj(new UserInfoDto.Vo().setUserId(merc.getUserInfoId())));
|
|
|
|
- if(userInfo!= null && StrUtil.isNotEmpty(userInfo.getTel())){
|
|
|
|
- String tel = userInfo.getTel();
|
|
|
|
- //短信推送 设备告警:设备${device_id}于${time}发生${exception_type}异常。请登录后台查看详情并及时处理。
|
|
|
|
- Long configId = MsgConfigId.SMS_NOTIFY_DEVICE.getId();
|
|
|
|
- String formatDate = LocalDateTimeUtil.format(createTime, DatePattern.NORM_DATETIME_PATTERN);
|
|
|
|
- Map<String, Object> templateParams = MapUtil.newHashMap();
|
|
|
|
- templateParams.put("device_id", deviceName);
|
|
|
|
- templateParams.put("time", formatDate);
|
|
|
|
- templateParams.put("exception_type", exceptionType);
|
|
|
|
- log.info("商户设备告警短信通知:{}", JSONUtil.toJsonPrettyStr(templateParams));
|
|
|
|
- // 扣除商户短信资源包
|
|
|
|
- R deduct = mercSmsService.deduct(new MercSmsPackageDto.Deduct()
|
|
|
|
- .setMercId(merc.getId())
|
|
|
|
- .setMsg("设备告警短信通知,设备号:" + deviceId)
|
|
|
|
- );
|
|
|
|
- if (deduct.getCode() == R.Enum.SUCCESS.getCode()) {
|
|
|
|
- R.feignCheck(aliSmsService.sendMsgCommon(new SmsSendCommonDTO().setSignName("").setMsgConfigId(configId).setMobile(tel).setTemplateParams(templateParams).setScene(SmsSceneEnum.B_DEVICE_ALARM_NOTIFY.getScene())));
|
|
|
|
- }else{
|
|
|
|
- log.info("设备告警短信通知#商户{}短信资源包不足,无法发送短信通知:{}",merc.getId());
|
|
|
|
- }
|
|
|
|
|
|
+ MercSmsSubscriptionDto.SelectList selectList = new MercSmsSubscriptionDto.SelectList();
|
|
|
|
+ selectList.setEventCode(eventCode).setMercId(merc.getId());
|
|
|
|
+ List<MercSmsSubscriptionDto.Vo> mercSmsSubList = R.feignCheckData(mercSmsSubscriptionService.list(selectList));
|
|
|
|
+ if(CollUtil.isNotEmpty(mercSmsSubList)){
|
|
|
|
+ MercSmsSubscriptionDto.Vo mss = mercSmsSubList.get(0);
|
|
|
|
+ String phones = mss.getPhones();
|
|
|
|
+ if(StrUtil.isNotEmpty(phones)){
|
|
|
|
+ List<String> telList = StrUtil.split(phones, ",");
|
|
|
|
+ //短信推送 设备告警:设备${device_id}于${time}发生${exception_type}异常。请登录后台查看详情并及时处理。
|
|
|
|
+ Long configId = MsgConfigId.SMS_NOTIFY_DEVICE.getId();
|
|
|
|
+ String formatDate = LocalDateTimeUtil.format(createTime, DatePattern.NORM_DATETIME_PATTERN);
|
|
|
|
+ Map<String, Object> templateParams = MapUtil.newHashMap();
|
|
|
|
+ templateParams.put("device_id", deviceName);
|
|
|
|
+ templateParams.put("time", formatDate);
|
|
|
|
+ templateParams.put("exception_type", exceptionType);
|
|
|
|
+ log.info("商户设备告警短信通知:{}", JSONUtil.toJsonPrettyStr(templateParams));
|
|
|
|
+ for (String tel : telList) {
|
|
|
|
+ // 扣除商户短信资源包
|
|
|
|
+ R deduct = mercSmsService.deduct(new MercSmsPackageDto.Deduct()
|
|
|
|
+ .setMercId(merc.getId())
|
|
|
|
+ .setMsg("设备告警短信通知,设备号:" + deviceId)
|
|
|
|
+ );
|
|
|
|
+ if (deduct.getCode() == R.Enum.SUCCESS.getCode()) {
|
|
|
|
+ log.info("设备告警短信通知#商户{}:,短信资源包扣除成功,手机号:{}",merc.getId(),tel);
|
|
|
|
+ R.feignCheck(aliSmsService.sendMsgCommon(new SmsSendCommonDTO().setSignName("").setMsgConfigId(configId).setMobile(tel).setTemplateParams(templateParams).setScene(SmsSceneEnum.B_DEVICE_ALARM_NOTIFY.getScene())));
|
|
|
|
+ }else{
|
|
|
|
+ log.info("设备告警短信通知#商户{}短信资源包不足,无法发送短信通知:{},手机号:{}",merc.getId(),tel);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|