|
|
@@ -13,6 +13,7 @@ import com.kym.common.utils.AESUtil;
|
|
|
import com.kym.common.utils.CommUtil;
|
|
|
import com.kym.entity.admin.*;
|
|
|
import com.kym.entity.admin.queryParams.StationQueryParam;
|
|
|
+import com.kym.entity.admin.vo.LocalStationVo;
|
|
|
import com.kym.entity.admin.vo.StationVo;
|
|
|
import com.kym.entity.enplus.EnEquipmentInfo;
|
|
|
import com.kym.entity.enplus.EnStationStatsInfo;
|
|
|
@@ -23,6 +24,7 @@ import com.kym.service.admin.*;
|
|
|
import com.kym.service.cache.KymCache;
|
|
|
import com.kym.service.enplus.EnPlusService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.aop.framework.AopContext;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -74,7 +76,7 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
|
|
|
stationIdSets.addAll(adminStationIds);
|
|
|
queryWrapper.in("station_id", stationIdSets);
|
|
|
}
|
|
|
- if(CommUtil.isNotEmptyAndNull(adminStationIds)){
|
|
|
+ if (CommUtil.isNotEmptyAndNull(adminStationIds)) {
|
|
|
queryWrapper.in("station_id", adminStationIds);
|
|
|
}
|
|
|
queryWrapper.orderByAsc("station_id");
|
|
|
@@ -126,6 +128,68 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @DynamicCache(timeout = 15 * 60 * 1000L)
|
|
|
+ @Override
|
|
|
+ public Map<String, List<EquipmentInfo>> getCachedEquipmentMap() {
|
|
|
+ return equipmentInfoService.list().stream().collect(Collectors.groupingBy(EquipmentInfo::getStationId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @DynamicCache(timeout = 15 * 60 * 1000L)
|
|
|
+ @Override
|
|
|
+ public Map<String, List<ConnectorInfo>> getCachedConnectorMap() {
|
|
|
+ return connectorInfoService.list().stream().collect(Collectors.groupingBy(ConnectorInfo::getEquipmentId));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @DynamicCache
|
|
|
+ public List<LocalStationVo> queryLocalStationInfo(int pageNum, int pageSize) {
|
|
|
+ StationService proxy = (StationService) AopContext.currentProxy();
|
|
|
+ var stationList = list();
|
|
|
+ var equipmentInfoMap = proxy.getCachedEquipmentMap();
|
|
|
+ var connectorInfoMap = proxy.getCachedConnectorMap();
|
|
|
+
|
|
|
+ var stationVoList = new ArrayList<LocalStationVo>();
|
|
|
+ for (var station : stationList) {
|
|
|
+ var stationVo = new LocalStationVo();
|
|
|
+ BeanUtils.copyProperties(station, stationVo);
|
|
|
+ var equipmentInfos = equipmentInfoMap.get(station.getStationId());
|
|
|
+ if (CommUtil.isNotEmptyAndNull(equipmentInfos)) {
|
|
|
+ equipmentInfos.parallelStream().forEach(equipmentInfo -> {
|
|
|
+ // 填充短编号和车位号
|
|
|
+ equipmentInfo.setShortId(KymCache.INSTANCE.getShortIdByEquipmentIdOrConnectorId(equipmentInfo.getEquipmentId()))
|
|
|
+ .setParkingNo(KymCache.INSTANCE.getParkNoByEquipmentIdOrConnectorId(equipmentInfo.getEquipmentId()))
|
|
|
+ .setConnectorInfos(connectorInfoMap.get(equipmentInfo.getEquipmentId()));
|
|
|
+
|
|
|
+ });
|
|
|
+ stationVo.setEquipmentInfos(equipmentInfos);
|
|
|
+ var res = stationList.stream().filter(item -> item.getStationId().equals(station.getStationId())).toList();
|
|
|
+ // 填充站点图片
|
|
|
+ if (!res.isEmpty()) {
|
|
|
+ station.setPictures(res.get(0).getPictures());
|
|
|
+ } else {
|
|
|
+ station.setPictures(null);
|
|
|
+ }
|
|
|
+ stationVoList.add(stationVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询正在进行中的活动和各站点正在进行中的活动
|
|
|
+ var activityList = activityService.lambdaQuery().eq(Activity::getStatus, Activity.STATUS_进行中).list();
|
|
|
+
|
|
|
+ var activityStationListMap = activityStationService.lambdaQuery().eq(ActivityStation::getStatus, Activity.STATUS_进行中).list()
|
|
|
+ .stream().collect(Collectors.groupingBy(ActivityStation::getStationId));
|
|
|
+
|
|
|
+ var station2ActivityList = new HashMap<String, List<Activity>>();
|
|
|
+
|
|
|
+ activityStationListMap.forEach((k, v) -> {
|
|
|
+ station2ActivityList.put(k,
|
|
|
+ v.stream().map(item -> activityList.stream().filter(activity -> activity.getId().equals(item.getActivityId())).findFirst().orElse(null)).toList());
|
|
|
+ });
|
|
|
+ stationVoList.forEach(vo -> vo.setActivityList(station2ActivityList.get(vo.getStationId())).setEquipmentInfos(vo.getEquipmentInfos().stream().sorted(Comparator.comparing(EquipmentInfo::getShortId)).toList()));
|
|
|
+ return stationVoList;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<EnStationStatusInfo> stationStatus(String[] ids) {
|