diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java index f1615ba9a..0b0d45eaf 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileConnectorInfoService.java @@ -134,4 +134,11 @@ public interface IPileConnectorInfoService { List selectConnectorInfoList(String pileSn); PageResponse selectStationConnectorList(QueryConnectorListDTO dto); + + /** + * 根据站点id查询快、慢充设备数量 + * @param stationId + * @return + */ + Map getPileTypeNum(Long stationId); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java index 2ebdd33da..70d22de87 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileConnectorInfoServiceImpl.java @@ -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 getPileTypeNum(Long stationId) { + int fastTotal = 0; + int fastFree = 0; + int slowTotal = 0; + int slowFree = 0; + List 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 map = new LinkedHashMap<>(); + map.put("fastTotal", fastTotal); + map.put("fastFree", fastFree); + map.put("slowTotal", slowTotal); + map.put("slowFree", slowFree); + + return map; + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java index d39c64b67..e04b3442d 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileStationInfoServiceImpl.java @@ -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 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 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); // 查询当前时段电费 diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java index 65fbb5567..ea4470c8d 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/amap/service/impl/AMapServiceImpl.java @@ -10,6 +10,7 @@ import com.jsowell.pile.domain.PileStationInfo; import com.jsowell.pile.dto.amap.ChargeDeviceDynamicsDTO; import com.jsowell.pile.dto.amap.GetStationInfoDTO; import com.jsowell.pile.service.*; +import com.jsowell.pile.service.impl.PileStationInfoServiceImpl; import com.jsowell.pile.vo.base.ConnectorInfoVO; import com.jsowell.pile.vo.uniapp.BillingPriceVO; import com.jsowell.pile.vo.uniapp.PileConnectorDetailVO; @@ -103,7 +104,7 @@ public class AMapServiceImpl implements AMapService { List priceList = getPriceInfoByStationId(String.valueOf(stationInfo.getId())); aMapInfo.setAMapPriceChargingInfo(priceList); - Map pileNumMap = getPileNum(stationInfo.getId()); + Map pileNumMap = pileConnectorInfoService.getPileTypeNum(stationInfo.getId()); aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal")); aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal")); @@ -130,7 +131,7 @@ public class AMapServiceImpl implements AMapService { throw new BusinessException("", ""); } String stationId = pileConnectorDetailVO.getStationId(); - Map pileNumMap = getPileNum(Long.parseLong(stationId)); + Map pileNumMap = pileConnectorInfoService.getPileTypeNum(Long.parseLong(stationId)); AMapConnectorStatusInfo info = new AMapConnectorStatusInfo(); info.setConnectorID(pileConnectorCode); @@ -155,43 +156,6 @@ public class AMapServiceImpl implements AMapService { } - - - /** - * 根据站点id查询快、慢充设备数量 - * @param stationId - * @return - */ - private Map getPileNum(Long stationId) { - int fastTotal = 0; - int fastFree = 0; - int slowTotal = 0; - int slowFree = 0; - List 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 map = new LinkedHashMap<>(); - map.put("fastTotal", fastTotal); - map.put("fastFree", fastFree); - map.put("slowTotal", slowTotal); - map.put("slowFree", slowFree); - - return map; - } - /** * 根据站点id查询计费模板 * @param StationId