mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
优化查询站点信息接口
This commit is contained in:
@@ -111,6 +111,13 @@ public interface IPileConnectorInfoService {
|
||||
|
||||
PageResponse selectStationConnectorList(QueryConnectorListDTO dto);
|
||||
|
||||
/**
|
||||
* 查询快、慢充设备数量
|
||||
* @param connectorList 枪口列表
|
||||
* @return
|
||||
*/
|
||||
Map<String, Integer> getPileTypeNum(List<ConnectorInfoVO> connectorList);
|
||||
|
||||
/**
|
||||
* 根据站点id查询快、慢充设备数量
|
||||
* @param stationId
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user