|
|
@@ -4,11 +4,13 @@ import cn.hutool.extra.mail.MailUtil;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.kym.entity.admin.EquipmentInfo;
|
|
|
import com.kym.entity.admin.MonitorLog;
|
|
|
import com.kym.entity.common.RedisKeys;
|
|
|
import com.kym.entity.enplus.EnConnectorStatusInfo;
|
|
|
import com.kym.entity.miniapp.ChargeOrder;
|
|
|
import com.kym.entity.miniapp.WalletDetail;
|
|
|
+import com.kym.service.admin.EquipmentInfoService;
|
|
|
import com.kym.service.admin.MonitorLogService;
|
|
|
import com.kym.service.enplus.EnNotifyService;
|
|
|
import com.kym.service.enplus.EnPlusService;
|
|
|
@@ -47,6 +49,8 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
|
|
|
private final MonitorLogService monitorLogService;
|
|
|
|
|
|
+ private final EquipmentInfoService equipmentInfoService;
|
|
|
+
|
|
|
private final KymCache kymCache;
|
|
|
|
|
|
private final RedisTemplate<String, String> redisTemplate;
|
|
|
@@ -54,12 +58,15 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
@Value("${kym.notify-email}")
|
|
|
private String notifyEmail;
|
|
|
|
|
|
- public EnNotifyServiceImpl(EnPlusService enPlusService, ChargeOrderService chargeOrderService, AccountService accountService, WalletDetailService walletDetailService, MonitorLogService monitorLogService, KymCache kymCache, RedisTemplate<String, String> redisTemplate) {
|
|
|
+ public EnNotifyServiceImpl(EnPlusService enPlusService, ChargeOrderService chargeOrderService,
|
|
|
+ AccountService accountService, WalletDetailService walletDetailService,
|
|
|
+ MonitorLogService monitorLogService, EquipmentInfoService equipmentInfoService, KymCache kymCache, RedisTemplate<String, String> redisTemplate) {
|
|
|
this.enPlusService = enPlusService;
|
|
|
this.chargeOrderService = chargeOrderService;
|
|
|
this.accountService = accountService;
|
|
|
this.walletDetailService = walletDetailService;
|
|
|
this.monitorLogService = monitorLogService;
|
|
|
+ this.equipmentInfoService = equipmentInfoService;
|
|
|
this.kymCache = kymCache;
|
|
|
this.redisTemplate = redisTemplate;
|
|
|
}
|
|
|
@@ -78,9 +85,13 @@ public class EnNotifyServiceImpl implements EnNotifyService {
|
|
|
LOGGER.info("【EN+推送】收到充电桩设备状态变化推送:\n{} \n 解密数据:{}", json, data);
|
|
|
// 更新数据库,存入redis,发送邮件通知
|
|
|
var connectorStatusInfo = JSONObject.parseObject(data).getJSONObject("ConnectorStatusInfo").toJavaObject(EnConnectorStatusInfo.class);
|
|
|
+ equipmentInfoService.lambdaUpdate()
|
|
|
+ .eq(EquipmentInfo::getEquipmentId, connectorStatusInfo.getConnectorId().substring(0, 16))
|
|
|
+ .set(EquipmentInfo::getServiceStatus, connectorStatusInfo.getStatus())
|
|
|
+ .update();
|
|
|
if (connectorStatusInfo.getStatus() == 0) {
|
|
|
LOGGER.info("充电桩设备离线:{}", connectorStatusInfo.getConnectorId());
|
|
|
- // 如果设备离线,则存入redis,有效期24h
|
|
|
+ // 如果设备离线,则存入redis
|
|
|
var monitorLog = new MonitorLog()
|
|
|
.setStationId(kymCache.getStationId(connectorStatusInfo.getConnectorId()))
|
|
|
.setSn(connectorStatusInfo.getConnectorId())
|