mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-08 03:50:13 +08:00
优化查询站点信息接口
This commit is contained in:
@@ -185,6 +185,12 @@ public class SpringBootTestController {
|
||||
@Autowired
|
||||
private IMemberBasicInfoService memberBasicInfoService;
|
||||
|
||||
@Test
|
||||
public void testGetPileTypeNum() {
|
||||
Long stationId = 1L;
|
||||
pileConnectorInfoService.getPileTypeNum(stationId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateStatus() {
|
||||
String pileConnectorCode = "8800000000012601";
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,9 +354,6 @@ public class AMapServiceImpl implements AMapService {
|
||||
*/
|
||||
@Override
|
||||
public String pushChargingDeviceDynamics(String stationId) throws Exception {
|
||||
|
||||
Map<String, Integer> pileNumMap = pileConnectorInfoService.getPileTypeNum(Long.parseLong(stationId));
|
||||
|
||||
// 根据站点id查询枪口信息
|
||||
List<AMapConnectorStatusInfo> connectorStatusInfoList = Lists.newArrayList();
|
||||
AMapConnectorStatusInfo info;
|
||||
@@ -369,6 +366,7 @@ public class AMapServiceImpl implements AMapService {
|
||||
connectorStatusInfoList.add(info);
|
||||
}
|
||||
|
||||
Map<String, Integer> pileNumMap = pileConnectorInfoService.getPileTypeNum(connectorList);
|
||||
// 拼装业务参数
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("stationID", stationId);
|
||||
|
||||
Reference in New Issue
Block a user