mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-07-03 21:48:13 +08:00
优化查询站点信息接口
This commit is contained in:
@@ -185,6 +185,12 @@ public class SpringBootTestController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IMemberBasicInfoService memberBasicInfoService;
|
private IMemberBasicInfoService memberBasicInfoService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetPileTypeNum() {
|
||||||
|
Long stationId = 1L;
|
||||||
|
pileConnectorInfoService.getPileTypeNum(stationId);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateStatus() {
|
public void testUpdateStatus() {
|
||||||
String pileConnectorCode = "8800000000012601";
|
String pileConnectorCode = "8800000000012601";
|
||||||
|
|||||||
@@ -111,6 +111,13 @@ public interface IPileConnectorInfoService {
|
|||||||
|
|
||||||
PageResponse selectStationConnectorList(QueryConnectorListDTO dto);
|
PageResponse selectStationConnectorList(QueryConnectorListDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询快、慢充设备数量
|
||||||
|
* @param connectorList 枪口列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map<String, Integer> getPileTypeNum(List<ConnectorInfoVO> connectorList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据站点id查询快、慢充设备数量
|
* 根据站点id查询快、慢充设备数量
|
||||||
* @param stationId
|
* @param stationId
|
||||||
|
|||||||
@@ -626,37 +626,56 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据站点id查询快、慢充设备数量
|
* 查询快、慢充设备数量
|
||||||
*
|
* @param connectorList 枪口列表
|
||||||
* @param stationId
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public Map<String, Integer> getPileTypeNum(Long stationId) {
|
@Override
|
||||||
int fastTotal = 0;
|
public Map<String, Integer> getPileTypeNum(List<ConnectorInfoVO> connectorList) {
|
||||||
int fastFree = 0;
|
Map<String, Integer> resultMap = new LinkedHashMap<>();
|
||||||
int slowTotal = 0;
|
int fastTotal = 0; // 快充总数
|
||||||
int slowFree = 0;
|
int fastFree = 0; // 快充空闲数
|
||||||
List<ConnectorInfoVO> connectorList = getUniAppConnectorList(stationId);
|
int slowTotal = 0; // 慢充总数
|
||||||
|
int slowFree = 0; // 慢充空闲数
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(connectorList)) {
|
||||||
for (ConnectorInfoVO connectorVO : 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();
|
||||||
|
}
|
||||||
if (StringUtils.equals(connectorVO.getChargingType(), Constants.ONE)) {
|
if (StringUtils.equals(connectorVO.getChargingType(), Constants.ONE)) {
|
||||||
// 快充
|
// 快充
|
||||||
fastTotal += 1;
|
fastTotal += 1;
|
||||||
if (StringUtils.equals(connectorVO.getConnectorStatus(), Constants.ONE)) {
|
if (StringUtils.equals(status, Constants.ONE)) {
|
||||||
fastFree += 1;
|
fastFree += 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 慢充
|
// 慢充
|
||||||
slowTotal += 1;
|
slowTotal += 1;
|
||||||
if (StringUtils.equals(connectorVO.getConnectorStatus(), Constants.ONE)) {
|
if (StringUtils.equals(status, Constants.ONE)) {
|
||||||
slowFree += 1;
|
slowFree += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<String, Integer> map = new LinkedHashMap<>();
|
}
|
||||||
map.put("fastTotal", fastTotal);
|
|
||||||
map.put("fastFree", fastFree);
|
// 组装结果集
|
||||||
map.put("slowTotal", slowTotal);
|
resultMap.put("fastTotal", fastTotal);
|
||||||
map.put("slowFree", slowFree);
|
resultMap.put("fastFree", fastFree);
|
||||||
return map;
|
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
|
@Override
|
||||||
public String pushChargingDeviceDynamics(String stationId) throws Exception {
|
public String pushChargingDeviceDynamics(String stationId) throws Exception {
|
||||||
|
|
||||||
Map<String, Integer> pileNumMap = pileConnectorInfoService.getPileTypeNum(Long.parseLong(stationId));
|
|
||||||
|
|
||||||
// 根据站点id查询枪口信息
|
// 根据站点id查询枪口信息
|
||||||
List<AMapConnectorStatusInfo> connectorStatusInfoList = Lists.newArrayList();
|
List<AMapConnectorStatusInfo> connectorStatusInfoList = Lists.newArrayList();
|
||||||
AMapConnectorStatusInfo info;
|
AMapConnectorStatusInfo info;
|
||||||
@@ -369,6 +366,7 @@ public class AMapServiceImpl implements AMapService {
|
|||||||
connectorStatusInfoList.add(info);
|
connectorStatusInfoList.add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, Integer> pileNumMap = pileConnectorInfoService.getPileTypeNum(connectorList);
|
||||||
// 拼装业务参数
|
// 拼装业务参数
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("stationID", stationId);
|
json.put("stationID", stationId);
|
||||||
|
|||||||
Reference in New Issue
Block a user