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 637a5fbaa..2ebdd33da 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 @@ -426,6 +426,8 @@ public class PileConnectorInfoServiceImpl implements IPileConnectorInfoService { if (pileModelInfoVO != null) { infoVO.setChargingType(pileModelInfoVO.getSpeedType()); infoVO.setRatedPower(pileModelInfoVO.getRatedPower()); + infoVO.setRatedCurrent(pileModelInfoVO.getRatedCurrent()); + infoVO.setRatedVoltage(pileModelInfoVO.getRatedVoltage()); } connectorInfoList.add(infoVO); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java index 60ed57599..bb7688249 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/base/ConnectorInfoVO.java @@ -46,4 +46,14 @@ public class ConnectorInfoVO { */ private String ratedPower; + /** + * 额定电流 + */ + private String ratedCurrent; + + /** + * 额定电压 + */ + private String ratedVoltage; + } 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 795056fcf..c4e3c2a3f 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 @@ -3,11 +3,16 @@ package com.jsowell.thirdparty.amap.service.impl; import com.jsowell.common.constant.Constants; import com.jsowell.common.util.PageUtils; import com.jsowell.common.util.StringUtils; +import com.jsowell.pile.domain.PileBasicInfo; import com.jsowell.pile.domain.PileStationInfo; import com.jsowell.pile.dto.amap.GetStationInfoDTO; -import com.jsowell.pile.service.IPileConnectorInfoService; -import com.jsowell.pile.service.IPileStationInfoService; +import com.jsowell.pile.service.*; import com.jsowell.pile.vo.base.ConnectorInfoVO; +import com.jsowell.pile.vo.uniapp.BillingPriceVO; +import com.jsowell.pile.vo.web.PileModelInfoVO; +import com.jsowell.thirdparty.amap.domain.AMapConnectorInfo; +import com.jsowell.thirdparty.amap.domain.AMapEquipmentInfo; +import com.jsowell.thirdparty.amap.domain.AMapPriceChargingInfo; import com.jsowell.thirdparty.amap.domain.AMapStationInfo; import com.jsowell.thirdparty.amap.service.AMapService; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +21,9 @@ import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; /** * 高德地图Service @@ -33,6 +40,15 @@ public class AMapServiceImpl implements AMapService { @Autowired private IPileConnectorInfoService pileConnectorInfoService; + @Autowired + private IPileBillingTemplateService pileBillingTemplateService; + + @Autowired + private IPileBasicInfoService pileBasicInfoService; + + @Autowired + private IPileModelInfoService pileModelInfoService; + /** * 高德拉取充电站静态数据 * @param dto @@ -41,6 +57,7 @@ public class AMapServiceImpl implements AMapService { @Override public List getStationInfos(GetStationInfoDTO dto) { List resultList = new ArrayList<>(); + if (StringUtils.equals("page", dto.getType())) { int pageNo = dto.getCurrentPage() == null ? 1 : dto.getCurrentPage(); int pageSize = dto.getPageSize() == null ? 10 : dto.getPageSize(); @@ -80,28 +97,134 @@ public class AMapServiceImpl implements AMapService { } aMapInfo.setConstruction(Integer.parseInt(construction)); aMapInfo.setBusineHours(stationInfo.getBusinessHours()); - // aMapInfo.setAMapPriceChargingInfo(); - int fastTotal = 0; - int slowTotal = 0; - List connectorList = pileConnectorInfoService.getUniAppConnectorList(stationInfo.getId()); - for (ConnectorInfoVO connectorVO : connectorList) { - if (StringUtils.equals(connectorVO.getChargingType(), Constants.ONE)) { - // 快充 - fastTotal += 1; - } else { - // 慢充 - slowTotal += 1; - } - } - aMapInfo.setFastEquipmentNum(fastTotal); - aMapInfo.setSlowEquipmentNum(slowTotal); - // aMapInfo.setAMapEquipmentInfos(); + List priceList = getPriceInfoByStationId(String.valueOf(stationInfo.getId())); + aMapInfo.setAMapPriceChargingInfo(priceList); + Map pileNumMap = getPileNum(stationInfo.getId()); + + aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal")); + aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal")); + + List aMapEquipmentInfos = getPileListByStationId(String.valueOf(stationInfo.getId())); + + aMapInfo.setAMapEquipmentInfos(aMapEquipmentInfos); resultList.add(aMapInfo); } return resultList; } + + /** + * 根据站点id查询快、慢充设备数量 + * @param stationId + * @return + */ + private Map getPileNum(Long stationId) { + int fastTotal = 0; + int slowTotal = 0; + List connectorList = pileConnectorInfoService.getUniAppConnectorList(stationId); + for (ConnectorInfoVO connectorVO : connectorList) { + if (StringUtils.equals(connectorVO.getChargingType(), Constants.ONE)) { + // 快充 + fastTotal += 1; + } else { + // 慢充 + slowTotal += 1; + } + } + Map map = new LinkedHashMap<>(); + map.put("fastTotal", fastTotal); + map.put("slowTotal", slowTotal); + + return map; + } + + /** + * 根据站点id查询计费模板 + * @param StationId + * @return + */ + private List getPriceInfoByStationId(String StationId) { + List priceList = new ArrayList<>(); + // 查询计费模板 + List billingPriceList = pileBillingTemplateService.queryBillingPrice(StationId); + for (BillingPriceVO billingPriceVO : billingPriceList) { + AMapPriceChargingInfo info = new AMapPriceChargingInfo(); + info.setFeeTime(billingPriceVO.getStartTime() + "-" + billingPriceVO.getEndTime()); // 时间段 + info.setElectricityFee(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); // 电费 + info.setServiceFee(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP)); // 服务费 + + priceList.add(info); + } + return priceList; + } + + + /** + * 根据站点查询站点下所有桩 + * @param stationId + * @return + */ + private List getPileListByStationId(String stationId) { + List pileList = new ArrayList<>(); + // 根据站点查询站点下所有桩 + List pileBasicInfoList = pileBasicInfoService.getPileListByStationId(String.valueOf(stationId)); + if (CollectionUtils.isEmpty(pileBasicInfoList)) { + return new ArrayList<>(); + } + for (PileBasicInfo pileBasicInfo : pileBasicInfoList) { + AMapEquipmentInfo info = new AMapEquipmentInfo(); + + info.setEquipmentID(pileBasicInfo.getSn()); + info.setManufacturerName("举视"); + // 查询型号 + PileModelInfoVO modelInfo = pileModelInfoService.getPileModelInfoByPileSn(pileBasicInfo.getSn()); + + info.setEquipmentType(Integer.parseInt(modelInfo.getSpeedType())); + info.setPower(new BigDecimal(modelInfo.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)); + + List aMapConnectorInfos = getConnectorListBySN(pileBasicInfo.getSn()); + + info.setAMapConnectorInfos(aMapConnectorInfos); + + pileList.add(info); + } + return pileList; + } + + + /** + * 根据桩号查询枪口列表 + * @param pileSn + * @return + */ + private List getConnectorListBySN(String pileSn) { + List list = new ArrayList<>(); + + // 根据桩号查询枪口列表 + List connectorInfoList = pileConnectorInfoService.selectConnectorInfoList(pileSn); + if (CollectionUtils.isEmpty(connectorInfoList)) { + return new ArrayList<>(); + } + + for (ConnectorInfoVO connectorInfoVO : connectorInfoList) { + AMapConnectorInfo aMapConnectorInfo = new AMapConnectorInfo(); + + aMapConnectorInfo.setConnectorID(connectorInfoVO.getPileConnectorCode()); + + Integer connectorType = Integer.parseInt(connectorInfoVO.getChargingType()) == 1 ? 4 : 3; + aMapConnectorInfo.setConnectorType(connectorType); + aMapConnectorInfo.setVoltageLowerLimits(0); + aMapConnectorInfo.setVoltageUpperLimits(Integer.parseInt(connectorInfoVO.getRatedVoltage())); + aMapConnectorInfo.setCurrent(Integer.parseInt(connectorInfoVO.getRatedCurrent())); + aMapConnectorInfo.setPower(new BigDecimal(connectorInfoVO.getRatedPower()).setScale(1, BigDecimal.ROUND_HALF_UP)); + aMapConnectorInfo.setNationalStandard(2); + aMapConnectorInfo.setBrandDesc("举视"); + + list.add(aMapConnectorInfo); + } + return list; + } }