mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-28 02:57:55 +08:00
将 根据站点id查询快、慢充设备数量 方法进行封装、优化
This commit is contained in:
@@ -134,4 +134,11 @@ public interface IPileConnectorInfoService {
|
|||||||
List<ConnectorInfoVO> selectConnectorInfoList(String pileSn);
|
List<ConnectorInfoVO> selectConnectorInfoList(String pileSn);
|
||||||
|
|
||||||
PageResponse selectStationConnectorList(QueryConnectorListDTO dto);
|
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.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.jsowell.common.constant.CacheConstants;
|
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.domain.ykc.RealTimeMonitorData;
|
||||||
import com.jsowell.common.core.page.PageResponse;
|
import com.jsowell.common.core.page.PageResponse;
|
||||||
import com.jsowell.common.core.redis.RedisCache;
|
import com.jsowell.common.core.redis.RedisCache;
|
||||||
@@ -34,10 +35,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StopWatch;
|
import org.springframework.util.StopWatch;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -608,4 +606,39 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService {
|
|||||||
long l = DateUtils.intervalTime(lastConnectionTime, DateUtils.getTime());
|
long l = DateUtils.intervalTime(lastConnectionTime, DateUtils.getTime());
|
||||||
return l >= 1L;
|
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 org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -357,31 +358,16 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
|
|||||||
if (StringUtils.isNotBlank(pileStationVO.getPictures())) {
|
if (StringUtils.isNotBlank(pileStationVO.getPictures())) {
|
||||||
stationVO.setStationImgList(Lists.newArrayList(pileStationVO.getPictures().split(",")));
|
stationVO.setStationImgList(Lists.newArrayList(pileStationVO.getPictures().split(",")));
|
||||||
}
|
}
|
||||||
// 枪口数量
|
|
||||||
int fastTotal = 0;
|
Map<String, Integer> map = pileConnectorInfoService.getPileTypeNum(Long.parseLong(pileStationVO.getId()));
|
||||||
int fastFree = 0;
|
|
||||||
int slowTotal = 0;
|
Integer fastFree = map.get("fastFree");
|
||||||
int slowFree = 0;
|
Integer slowFree = map.get("slowFree");
|
||||||
List<ConnectorInfoVO> connectorList = pileConnectorInfoService.getUniAppConnectorList(Long.parseLong(pileStationVO.getId()));
|
|
||||||
for (ConnectorInfoVO connectorVO : connectorList) {
|
stationVO.setFastTotal(map.get("fastTotal"));
|
||||||
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);
|
|
||||||
stationVO.setFastFree(fastFree);
|
stationVO.setFastFree(fastFree);
|
||||||
stationVO.setSlowTotal(slowTotal);
|
stationVO.setSlowTotal(map.get("slowTotal"));
|
||||||
stationVO.setSlowFree(slowFree);
|
stationVO.setSlowFree(map.get("slowFree"));
|
||||||
stationVO.setTotalFree(fastFree + slowFree);
|
stationVO.setTotalFree(fastFree + slowFree);
|
||||||
|
|
||||||
// 查询当前时段电费
|
// 查询当前时段电费
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.jsowell.pile.domain.PileStationInfo;
|
|||||||
import com.jsowell.pile.dto.amap.ChargeDeviceDynamicsDTO;
|
import com.jsowell.pile.dto.amap.ChargeDeviceDynamicsDTO;
|
||||||
import com.jsowell.pile.dto.amap.GetStationInfoDTO;
|
import com.jsowell.pile.dto.amap.GetStationInfoDTO;
|
||||||
import com.jsowell.pile.service.*;
|
import com.jsowell.pile.service.*;
|
||||||
|
import com.jsowell.pile.service.impl.PileStationInfoServiceImpl;
|
||||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||||
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
||||||
import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO;
|
import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO;
|
||||||
@@ -103,7 +104,7 @@ public class AMapServiceImpl implements AMapService {
|
|||||||
List<AMapPriceChargingInfo> priceList = getPriceInfoByStationId(String.valueOf(stationInfo.getId()));
|
List<AMapPriceChargingInfo> priceList = getPriceInfoByStationId(String.valueOf(stationInfo.getId()));
|
||||||
aMapInfo.setAMapPriceChargingInfo(priceList);
|
aMapInfo.setAMapPriceChargingInfo(priceList);
|
||||||
|
|
||||||
Map<String, Integer> pileNumMap = getPileNum(stationInfo.getId());
|
Map<String, Integer> pileNumMap = pileConnectorInfoService.getPileTypeNum(stationInfo.getId());
|
||||||
aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal"));
|
aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal"));
|
||||||
aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal"));
|
aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal"));
|
||||||
|
|
||||||
@@ -130,7 +131,7 @@ public class AMapServiceImpl implements AMapService {
|
|||||||
throw new BusinessException("", "");
|
throw new BusinessException("", "");
|
||||||
}
|
}
|
||||||
String stationId = pileConnectorDetailVO.getStationId();
|
String stationId = pileConnectorDetailVO.getStationId();
|
||||||
Map<String, Integer> pileNumMap = getPileNum(Long.parseLong(stationId));
|
Map<String, Integer> pileNumMap = pileConnectorInfoService.getPileTypeNum(Long.parseLong(stationId));
|
||||||
|
|
||||||
AMapConnectorStatusInfo info = new AMapConnectorStatusInfo();
|
AMapConnectorStatusInfo info = new AMapConnectorStatusInfo();
|
||||||
info.setConnectorID(pileConnectorCode);
|
info.setConnectorID(pileConnectorCode);
|
||||||
@@ -155,43 +156,6 @@ public class AMapServiceImpl implements AMapService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据站点id查询快、慢充设备数量
|
|
||||||
* @param stationId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private Map<String, Integer> getPileNum(Long stationId) {
|
|
||||||
int fastTotal = 0;
|
|
||||||
int fastFree = 0;
|
|
||||||
int slowTotal = 0;
|
|
||||||
int slowFree = 0;
|
|
||||||
List<ConnectorInfoVO> connectorList = pileConnectorInfoService.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据站点id查询计费模板
|
* 根据站点id查询计费模板
|
||||||
* @param StationId
|
* @param StationId
|
||||||
|
|||||||
Reference in New Issue
Block a user