|
|
@@ -19,6 +19,7 @@ import com.kym.entity.admin.*;
|
|
|
import com.kym.entity.admin.queryParams.StationQueryParam;
|
|
|
import com.kym.entity.admin.vo.*;
|
|
|
import com.kym.entity.common.PageBean;
|
|
|
+import com.kym.entity.miniapp.vo.PlatformPolicyInfoVo;
|
|
|
import com.kym.entity.platform.PlatformStationStatsInfo;
|
|
|
import com.kym.entity.platform.PlatformStationStatusInfo;
|
|
|
import com.kym.entity.platform.response.PlatformResponse;
|
|
|
@@ -35,6 +36,7 @@ import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
@@ -165,7 +167,7 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
|
|
|
*/
|
|
|
@DynamicCache(timeout = 15 * 60 * 1000L)
|
|
|
@Override
|
|
|
- public Map<String, List<ConnectorInfo>> getCachedStationConnectorMap(String... stationId) {
|
|
|
+ public Map<String, List<ConnectorInfo>> getCachedEquipmentConnectorMap(String... stationId) {
|
|
|
var list = connectorInfoService.lambdaQuery()
|
|
|
.eq(CommUtil.isNotEmptyAndNull(stationId), ConnectorInfo::getStationId, stationId[0])
|
|
|
.list();
|
|
|
@@ -179,7 +181,7 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
|
|
|
*/
|
|
|
@DynamicCache(timeout = 15 * 60 * 1000L)
|
|
|
@Override
|
|
|
- public Map<String, List<ConnectorInfo>> getCachedStationConnectorMap() {
|
|
|
+ public Map<String, List<ConnectorInfo>> getCachedEquipmentConnectorMap() {
|
|
|
return connectorInfoService.list().stream().collect(Collectors.groupingBy(ConnectorInfo::getEquipmentId));
|
|
|
}
|
|
|
|
|
|
@@ -198,7 +200,7 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
|
|
|
LambdaQueryWrapper<Station> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.select(Station::getStationId, Station::getStationName, Station::getAddress, Station::getLocation,
|
|
|
Station::getStationStatus, Station::getParkingNum, Station::getElectricityFee, Station::getServiceFee, Station::getParkFee);
|
|
|
- queryWrapper.in(CommUtil.isNotEmptyAndNull(params.getStationIdList()),Station::getStationId,params.getStationIdList());
|
|
|
+ queryWrapper.in(CommUtil.isNotEmptyAndNull(params.getStationIdList()), Station::getStationId, params.getStationIdList());
|
|
|
var stationVoList = new ArrayList<SimpleStationVo>();
|
|
|
var stationList = list(queryWrapper);
|
|
|
for (var station : stationList) {
|
|
|
@@ -211,6 +213,20 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
|
|
|
params.getLongitude(),
|
|
|
params.getLatitude(),
|
|
|
2));
|
|
|
+ // 站点费率
|
|
|
+ var policyInfoList = KymCache.INSTANCE.getStationPolicyInfo(station.getStationId());
|
|
|
+ CommUtil.asserts(policyInfoList != null, "站点费率信息为空");
|
|
|
+
|
|
|
+ // 根据当前时间获取当前策略
|
|
|
+ var now = LocalTime.now();
|
|
|
+ if (policyInfoList.size() == 1) {
|
|
|
+ simpleStationVo.setCurrentPolicyInfo(policyInfoList.get(0));
|
|
|
+ } else {
|
|
|
+ policyInfoList.stream()
|
|
|
+ .filter(policyInfo -> policyInfo.getStartTime().isBefore(now))
|
|
|
+ .max(Comparator.comparing(PlatformPolicyInfoVo::getStartTime))
|
|
|
+ .ifPresent(simpleStationVo::setCurrentPolicyInfo);
|
|
|
+ }
|
|
|
stationVoList.add(simpleStationVo);
|
|
|
}
|
|
|
// 按照距离由近到远排序
|
|
|
@@ -247,21 +263,21 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
|
|
|
@Override
|
|
|
public DetailStationVo stationInfoByShortId(String shortId) {
|
|
|
EquipmentRelation equipmentRel = equipmentRelationService.getByShortId(shortId);
|
|
|
- CommUtil.assertsNonNull(equipmentRel,"该设备信息有误");
|
|
|
+ CommUtil.assertsNonNull(equipmentRel, "该设备信息有误");
|
|
|
return stationInfo(equipmentRel.getStationId());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public DetailStationVo stationInfoByConnectorId(String connectorId) {
|
|
|
EquipmentRelation equipmentRel = equipmentRelationService.getByConnectorId(connectorId);
|
|
|
- CommUtil.assertsNonNull(equipmentRel,"该设备信息有误");
|
|
|
+ CommUtil.assertsNonNull(equipmentRel, "该设备信息有误");
|
|
|
return stationInfo(equipmentRel.getStationId());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public DetailStationVo stationInfoByEquipmentId(String equipmentId) {
|
|
|
EquipmentRelation equipmentRel = equipmentRelationService.getByEquipmentId(equipmentId);
|
|
|
- CommUtil.assertsNonNull(equipmentRel,"该设备信息有误");
|
|
|
+ CommUtil.assertsNonNull(equipmentRel, "该设备信息有误");
|
|
|
return stationInfo(equipmentRel.getStationId());
|
|
|
}
|
|
|
|
|
|
@@ -277,10 +293,10 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
|
|
|
var vo = new DetailStationVo();
|
|
|
BeanUtils.copyProperties(s, vo);
|
|
|
// 填充桩信息
|
|
|
- var list = getCachedStationConnectorMap(s.getStationId()).get(s.getStationId()).stream()
|
|
|
+ var list = getCachedEquipmentConnectorMap(s.getStationId()).get(s.getStationId()).stream()
|
|
|
.map(connectorInfo -> {
|
|
|
ConnectorInfoVo v = new ConnectorInfoVo();
|
|
|
- BeanUtils.copyProperties(connectorInfo,v);
|
|
|
+ BeanUtils.copyProperties(connectorInfo, v);
|
|
|
v.setShortId(KymCache.INSTANCE.getShortIdByEquipmentIdOrConnectorId(connectorInfo.getConnectorId()));
|
|
|
return v;
|
|
|
})
|
|
|
@@ -299,7 +315,7 @@ public class StationServiceImpl extends MyBaseServiceImpl<StationMapper, Station
|
|
|
var stationList = list();
|
|
|
// 获取桩号等映射信息缓存
|
|
|
var equipmentInfoMap = proxy.getCachedEquipmentMap();
|
|
|
- var connectorInfoMap = proxy.getCachedStationConnectorMap();
|
|
|
+ var connectorInfoMap = proxy.getCachedEquipmentConnectorMap();
|
|
|
|
|
|
var stationVoList = new ArrayList<LocalStationVo>();
|
|
|
for (var station : stationList) {
|