|
@@ -22,7 +22,6 @@ import com.kym.service.utils.KymCache;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
@@ -54,8 +53,6 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
|
|
|
|
|
private final KymCache kymCache;
|
|
private final KymCache kymCache;
|
|
|
|
|
|
|
|
- private final StringRedisTemplate redisTemplate;
|
|
|
|
|
-
|
|
|
|
|
private final RedisDBChangeUtil redisDBChangeUtil;
|
|
private final RedisDBChangeUtil redisDBChangeUtil;
|
|
|
|
|
|
|
|
@Value("${kym.notify-email}")
|
|
@Value("${kym.notify-email}")
|
|
@@ -64,7 +61,7 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
public EnNotifyServiceImpl(EnPlusService enPlusService, ChargeOrderService chargeOrderService,
|
|
public EnNotifyServiceImpl(EnPlusService enPlusService, ChargeOrderService chargeOrderService,
|
|
|
AccountService accountService, WalletDetailService walletDetailService,
|
|
AccountService accountService, WalletDetailService walletDetailService,
|
|
|
MonitorLogService monitorLogService, EquipmentInfoService equipmentInfoService,
|
|
MonitorLogService monitorLogService, EquipmentInfoService equipmentInfoService,
|
|
|
- KymCache kymCache, StringRedisTemplate redisTemplate, RedisDBChangeUtil redisDBChangeUtil) {
|
|
|
|
|
|
|
+ KymCache kymCache, RedisDBChangeUtil redisDBChangeUtil) {
|
|
|
this.enPlusService = enPlusService;
|
|
this.enPlusService = enPlusService;
|
|
|
this.chargeOrderService = chargeOrderService;
|
|
this.chargeOrderService = chargeOrderService;
|
|
|
this.accountService = accountService;
|
|
this.accountService = accountService;
|
|
@@ -72,7 +69,6 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
this.monitorLogService = monitorLogService;
|
|
this.monitorLogService = monitorLogService;
|
|
|
this.equipmentInfoService = equipmentInfoService;
|
|
this.equipmentInfoService = equipmentInfoService;
|
|
|
this.kymCache = kymCache;
|
|
this.kymCache = kymCache;
|
|
|
- this.redisTemplate = redisTemplate;
|
|
|
|
|
this.redisDBChangeUtil = redisDBChangeUtil;
|
|
this.redisDBChangeUtil = redisDBChangeUtil;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -110,14 +106,14 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
monitorLogService.save(monitorLog);
|
|
monitorLogService.save(monitorLog);
|
|
|
|
|
|
|
|
// 离线设备放入队列,5分钟之后如果还未恢复则放入长时间离线设备集合中并发送提醒,上线后发送提醒
|
|
// 离线设备放入队列,5分钟之后如果还未恢复则放入长时间离线设备集合中并发送提醒,上线后发送提醒
|
|
|
- redisTemplate.opsForZSet().add(RedisKeys.OFFLINE, connectorStatusInfo.getConnectorId(), System.currentTimeMillis() + 5 * 60 * 1000);
|
|
|
|
|
|
|
+ redisDBChangeUtil.redisTemplate.opsForZSet().add(RedisKeys.OFFLINE, connectorStatusInfo.getConnectorId(), System.currentTimeMillis() + 5 * 60 * 1000);
|
|
|
|
|
|
|
|
// MailUtil.send(notifyEmail, "【设备离线通知】", "站点:%s,设备%s离线"
|
|
// MailUtil.send(notifyEmail, "【设备离线通知】", "站点:%s,设备%s离线"
|
|
|
// .formatted(kymCache.getStationName(monitorLog.getStationId()), kymCache.getShortId(monitorLog.getSn())), false);
|
|
// .formatted(kymCache.getStationName(monitorLog.getStationId()), kymCache.getShortId(monitorLog.getSn())), false);
|
|
|
} else {
|
|
} else {
|
|
|
// 先删除离线设备队列的记录,再删除离线超时队列中的记录
|
|
// 先删除离线设备队列的记录,再删除离线超时队列中的记录
|
|
|
- var isDelete = redisTemplate.opsForZSet().remove(RedisKeys.OFFLINE, connectorStatusInfo.getConnectorId());
|
|
|
|
|
- var exist = redisTemplate.opsForSet().remove(RedisKeys.OFFLINE_EXPIRED, connectorStatusInfo.getConnectorId());
|
|
|
|
|
|
|
+ var isDelete = redisDBChangeUtil.redisTemplate.opsForZSet().remove(RedisKeys.OFFLINE, connectorStatusInfo.getConnectorId());
|
|
|
|
|
+ var exist = redisDBChangeUtil.redisTemplate.opsForSet().remove(RedisKeys.OFFLINE_EXPIRED, connectorStatusInfo.getConnectorId());
|
|
|
if ((isDelete != null && isDelete > 0) || (exist != null && exist > 0)) {
|
|
if ((isDelete != null && isDelete > 0) || (exist != null && exist > 0)) {
|
|
|
// 更新设备监控表
|
|
// 更新设备监控表
|
|
|
monitorLogService.lambdaUpdate()
|
|
monitorLogService.lambdaUpdate()
|