mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
将 根据站点id查询快、慢充设备数量 方法进行封装、优化
This commit is contained in:
@@ -134,4 +134,11 @@ public interface IPileConnectorInfoService {
|
||||
List<ConnectorInfoVO> selectConnectorInfoList(String pileSn);
|
||||
|
||||
PageResponse selectStationConnectorList(QueryConnectorListDTO dto);
|
||||
|
||||
/**
|
||||
* 根据站点id查询快、慢充设备数量
|
||||
* @param stationId
|
||||
* @return
|
||||
*/
|
||||
Map<String, Integer> getPileTypeNum(Long stationId);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
@@ -34,10 +35,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -608,4 +606,39 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
|
||||
long l = DateUtils.intervalTime(lastConnectionTime, DateUtils.getTime());
|
||||
return l >= 1L;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据站点id查询快、慢充设备数量
|
||||
* @param stationId
|
||||
* @return
|
||||
*/
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
// 慢充
|
||||
slowTotal += 1;
|
||||
if (StringUtils.equals(connectorVO.getConnectorStatus(), 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -357,31 +358,16 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
|
||||
if (StringUtils.isNotBlank(pileStationVO.getPictures())) {
|
||||
stationVO.setStationImgList(Lists.newArrayList(pileStationVO.getPictures().split(",")));
|
||||
}
|
||||
// 枪口数量
|
||||
int fastTotal = 0;
|
||||
int fastFree = 0;
|
||||
int slowTotal = 0;
|
||||
int slowFree = 0;
|
||||
List<ConnectorInfoVO> connectorList = pileConnectorInfoService.getUniAppConnectorList(Long.parseLong(pileStationVO.getId()));
|
||||
for (ConnectorInfoVO connectorVO : connectorList) {
|
||||
if (StringUtils.equals(connectorVO.getChargingType(), Constants.ONE)) {
|
||||
// 快充
|
||||
fastTotal += 1;
|
||||
if (StringUtils.equals(connectorVO.getConnectorStatus(), Constants.ONE)) {
|
||||
fastFree += 1;
|
||||
}
|
||||
} else {
|
||||
// 慢充
|
||||
slowTotal += 1;
|
||||
if (StringUtils.equals(connectorVO.getConnectorStatus(), Constants.ONE)) {
|
||||
slowFree += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
stationVO.setFastTotal(fastTotal);
|
||||
|
||||
Map<String, Integer> map = pileConnectorInfoService.getPileTypeNum(Long.parseLong(pileStationVO.getId()));
|
||||
|
||||
Integer fastFree = map.get("fastFree");
|
||||
Integer slowFree = map.get("slowFree");
|
||||
|
||||
stationVO.setFastTotal(map.get("fastTotal"));
|
||||
stationVO.setFastFree(fastFree);
|
||||
stationVO.setSlowTotal(slowTotal);
|
||||
stationVO.setSlowFree(slowFree);
|
||||
stationVO.setSlowTotal(map.get("slowTotal"));
|
||||
stationVO.setSlowFree(map.get("slowFree"));
|
||||
stationVO.setTotalFree(fastFree + slowFree);
|
||||
|
||||
// 查询当前时段电费
|
||||
|
||||
Reference in New Issue
Block a user