This commit is contained in:
2023-06-15 14:06:39 +08:00
3 changed files with 153 additions and 18 deletions

View File

@@ -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);
}

View File

@@ -46,4 +46,14 @@ public class ConnectorInfoVO {
*/
private String ratedPower;
/**
* 额定电流
*/
private String ratedCurrent;
/**
* 额定电压
*/
private String ratedVoltage;
}

View File

@@ -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<AMapStationInfo> getStationInfos(GetStationInfoDTO dto) {
List<AMapStationInfo> 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<ConnectorInfoVO> 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<AMapPriceChargingInfo> priceList = getPriceInfoByStationId(String.valueOf(stationInfo.getId()));
aMapInfo.setAMapPriceChargingInfo(priceList);
Map<String, Integer> pileNumMap = getPileNum(stationInfo.getId());
aMapInfo.setFastEquipmentNum(pileNumMap.get("fastTotal"));
aMapInfo.setSlowEquipmentNum(pileNumMap.get("slowTotal"));
List<AMapEquipmentInfo> aMapEquipmentInfos = getPileListByStationId(String.valueOf(stationInfo.getId()));
aMapInfo.setAMapEquipmentInfos(aMapEquipmentInfos);
resultList.add(aMapInfo);
}
return resultList;
}
/**
* 根据站点id查询快、慢充设备数量
* @param stationId
* @return
*/
private Map<String, Integer> getPileNum(Long stationId) {
int fastTotal = 0;
int slowTotal = 0;
List<ConnectorInfoVO> connectorList = pileConnectorInfoService.getUniAppConnectorList(stationId);
for (ConnectorInfoVO connectorVO : connectorList) {
if (StringUtils.equals(connectorVO.getChargingType(), Constants.ONE)) {
// 快充
fastTotal += 1;
} else {
// 慢充
slowTotal += 1;
}
}
Map<String, Integer> map = new LinkedHashMap<>();
map.put("fastTotal", fastTotal);
map.put("slowTotal", slowTotal);
return map;
}
/**
* 根据站点id查询计费模板
* @param StationId
* @return
*/
private List<AMapPriceChargingInfo> getPriceInfoByStationId(String StationId) {
List<AMapPriceChargingInfo> priceList = new ArrayList<>();
// 查询计费模板
List<BillingPriceVO> 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<AMapEquipmentInfo> getPileListByStationId(String stationId) {
List<AMapEquipmentInfo> pileList = new ArrayList<>();
// 根据站点查询站点下所有桩
List<PileBasicInfo> 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<AMapConnectorInfo> aMapConnectorInfos = getConnectorListBySN(pileBasicInfo.getSn());
info.setAMapConnectorInfos(aMapConnectorInfos);
pileList.add(info);
}
return pileList;
}
/**
* 根据桩号查询枪口列表
* @param pileSn
* @return
*/
private List<AMapConnectorInfo> getConnectorListBySN(String pileSn) {
List<AMapConnectorInfo> list = new ArrayList<>();
// 根据桩号查询枪口列表
List<ConnectorInfoVO> 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;
}
}