将 根据站点id查询快、慢充设备数量 方法进行封装、优化

This commit is contained in:
Lemon
2023-06-15 17:10:16 +08:00
parent cd220611c5
commit 5eb1e8bee9
4 changed files with 57 additions and 67 deletions

View File

@@ -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<AMapPriceChargingInfo> priceList = getPriceInfoByStationId(String.valueOf(stationInfo.getId()));
aMapInfo.setAMapPriceChargingInfo(priceList);
Map<String, Integer> pileNumMap = getPileNum(stationInfo.getId());
Map<String, Integer> 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<String, Integer> pileNumMap = getPileNum(Long.parseLong(stationId));
Map<String, Integer> 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<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查询计费模板
* @param StationId