优化查询站点信息接口

This commit is contained in:
2023-07-22 14:54:29 +08:00
parent 113184de20
commit 303f294c9d
4 changed files with 60 additions and 30 deletions

View File

@@ -111,6 +111,13 @@ public interface IPileConnectorInfoService {
PageResponse selectStationConnectorList(QueryConnectorListDTO dto);
/**
* 查询快、慢充设备数量
* @param connectorList 枪口列表
* @return
*/
Map<String, Integer> getPileTypeNum(List<ConnectorInfoVO> connectorList);
/**
* 根据站点id查询快、慢充设备数量
* @param stationId

View File

@@ -626,37 +626,56 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
}
/**
* 根据站点id查询快、慢充设备数量
*
* @param stationId
* @return
* 查询快、慢充设备数量
* @param connectorList 枪口列表
*/
public Map<String, Integer> getPileTypeNum(Long stationId) {
int fastTotal = 0;
int fastFree = 0;
int slowTotal = 0;
int slowFree = 0;
List<ConnectorInfoVO> connectorList = getUniAppConnectorList(stationId);
for (ConnectorInfoVO connectorVO : connectorList) {
if (StringUtils.equals(connectorVO.getChargingType(), Constants.ONE)) {
// 快充
fastTotal += 1;
if (StringUtils.equals(connectorVO.getConnectorStatus(), Constants.ONE)) {
fastFree += 1;
@Override
public Map<String, Integer> getPileTypeNum(List<ConnectorInfoVO> connectorList) {
Map<String, Integer> resultMap = new LinkedHashMap<>();
int fastTotal = 0; // 快充总数
int fastFree = 0; // 快充空闲数
int slowTotal = 0; // 慢充总数
int slowFree = 0; // 慢充空闲数
if (CollectionUtils.isNotEmpty(connectorList)) {
for (ConnectorInfoVO connectorVO : connectorList) {
String redisKey = CacheConstants.PILE_CONNECTOR_STATUS_KEY + connectorVO.getPileConnectorCode();
String status = redisCache.getCacheObject(redisKey);
if (StringUtils.isBlank(status)) {
status = connectorVO.getConnectorStatus();
}
} else {
//
slowTotal += 1;
if (StringUtils.equals(connectorVO.getConnectorStatus(), Constants.ONE)) {
slowFree += 1;
if (StringUtils.equals(connectorVO.getChargingType(), Constants.ONE)) {
//
fastTotal += 1;
if (StringUtils.equals(status, Constants.ONE)) {
fastFree += 1;
}
} else {
// 慢充
slowTotal += 1;
if (StringUtils.equals(status, Constants.ONE)) {
slowFree += 1;
}
}
}
}
Map<String, Integer> map = new LinkedHashMap<>();
map.put("fastTotal", fastTotal);
map.put("fastFree", fastFree);
map.put("slowTotal", slowTotal);
map.put("slowFree", slowFree);
return map;
// 组装结果集
resultMap.put("fastTotal", fastTotal);
resultMap.put("fastFree", fastFree);
resultMap.put("slowTotal", slowTotal);
resultMap.put("slowFree", slowFree);
return resultMap;
}
/**
* 根据站点id查询快、慢充设备数量
* @param stationId 站点id
*/
@Override
public Map<String, Integer> getPileTypeNum(Long stationId) {
// 获取充电站枪口列表
List<ConnectorInfoVO> connectorList = getUniAppConnectorList(stationId);
return getPileTypeNum(connectorList);
}
}