|
|
@@ -1,9 +1,11 @@
|
|
|
package com.kym.service.cache;
|
|
|
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.kym.entity.admin.ConnectorInfo;
|
|
|
import com.kym.entity.admin.EquipmentRelation;
|
|
|
import com.kym.entity.admin.Station;
|
|
|
import com.kym.entity.common.RedisKeys;
|
|
|
+import com.kym.service.admin.ConnectorInfoService;
|
|
|
import com.kym.service.admin.EquipmentRelationService;
|
|
|
import com.kym.service.admin.StationService;
|
|
|
import org.springframework.boot.context.event.ApplicationStartedEvent;
|
|
|
@@ -100,6 +102,17 @@ public enum KymCache {
|
|
|
return KymCacheInjector.redisTemplate.opsForValue().get(RedisKeys.STATION_ID_TO_NAME + stationId);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过充电接口id获取站点名称
|
|
|
+ *
|
|
|
+ * @param connectorId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getStationNameByConnectorId(String connectorId) {
|
|
|
+ var stationId = getStationIdByEquipmentIdOrConnectorId(connectorId);
|
|
|
+ return KymCacheInjector.redisTemplate.opsForValue().get(RedisKeys.STATION_ID_TO_NAME + stationId);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 操作员对应有权限的站点
|
|
|
*
|
|
|
@@ -161,10 +174,13 @@ public enum KymCache {
|
|
|
private final EquipmentRelationService equipmentRelationService;
|
|
|
private final StationService stationService;
|
|
|
|
|
|
+ private final ConnectorInfoService connectorInfoService;
|
|
|
|
|
|
- private KymCacheInjector(EquipmentRelationService equipmentRelationService, StationService stationService) {
|
|
|
+
|
|
|
+ private KymCacheInjector(EquipmentRelationService equipmentRelationService, StationService stationService, ConnectorInfoService connectorInfoService) {
|
|
|
this.equipmentRelationService = equipmentRelationService;
|
|
|
this.stationService = stationService;
|
|
|
+ this.connectorInfoService = connectorInfoService;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -183,6 +199,9 @@ public enum KymCache {
|
|
|
|
|
|
var connectorId2ParkingNo = equipmentRelations.stream().collect(Collectors.toMap(EquipmentRelation::getConnectorId, EquipmentRelation::getParkingNo));
|
|
|
KymCache.INSTANCE.putConnectorId2ParkingNo(connectorId2ParkingNo);
|
|
|
+
|
|
|
+ var ConnectorId2Status = connectorInfoService.list().stream().collect(Collectors.toMap(ConnectorInfo::getConnectorId, ConnectorInfo::getStatus));
|
|
|
+ KymCache.INSTANCE.putConnectorId2Status(ConnectorId2Status);
|
|
|
}
|
|
|
}
|
|
|
}
|