电站信息加入费率

This commit is contained in:
ZZ 2021-11-01 14:55:44 +08:00
parent fe541b0c3e
commit 9cb93c094c
2 changed files with 75 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package com.xhpc.evcs.api;
import com.xhpc.common.api.dto.ChargingStationDto;
import com.xhpc.common.data.redis.CacheRateModel;
import com.xhpc.evcs.domain.XhpcChargingPile;
import com.xhpc.evcs.domain.XhpcChargingStation;
import com.xhpc.evcs.domain.XhpcStationInternetBlacklist;
@ -116,6 +117,9 @@ public class QueryStationsInfoController {
station.setServiceTel(chargingStationDto.getServiceTel());
station.setAreaCode(chargingStationDto.getAreaCode());
station.setConstruction(chargingStationDto.getConstruction());
String[] fees = getFees(chargingStationDto.getRateModelId());
station.setElectricityFee(fees[0]);
station.setServiceFee(fees[1]);
List<EquipmentInfo> piles = getEquipmentInfos(chargingStationDto.getPiles());
station.setEquipmentInfos(piles);
stations.add(station);
@ -135,6 +139,65 @@ public class QueryStationsInfoController {
return resp;
}
private String[] getFees(Long rateModelId) {
CacheRateModel cacheRateModel = REDIS.getCacheObject("rateModel:".concat(rateModelId.toString()));
if (cacheRateModel.getPp() != null) return cacheRateModel.getPp();
String[] tfPricesSeq = cacheRateModel.getTfPricesSeq();
String startTf = "00:00";
String endTf = "";
String previousTf = tfPricesSeq[0];
Integer elecPrice = 0;
Integer svcPrice = 0;
List<String> tfrmes = new ArrayList<>(); //电费
List<String> tfrmss = new ArrayList<>(); // 服务费
for (int i = 1; i < tfPricesSeq.length; i++) {
if (!previousTf.equals(tfPricesSeq[i])) {
if (previousTf.equals("00")) {
elecPrice = cacheRateModel.getT1Price();
svcPrice = cacheRateModel.getT1SvcPrice();
} else if (previousTf.equals("01")) {
elecPrice = cacheRateModel.getT2Price();
svcPrice = cacheRateModel.getT2SvcPrice();
} else if (previousTf.equals("02")) {
elecPrice = cacheRateModel.getT3Price();
svcPrice = cacheRateModel.getT3SvcPrice();
} else { // 03
elecPrice = cacheRateModel.getT4Price();
svcPrice = cacheRateModel.getT4SvcPrice();
}
if (i % 2 != 0) {
endTf = String.format("%02d", i / 2).concat(":30");
} else {
endTf = String.format("%02d", i / 2).concat(":00");
}
String electfrm =
startTf.concat("~").concat(endTf).concat(",").concat(BigDecimal.valueOf(elecPrice).divide(BigDecimal.valueOf(100000L)).setScale(2).toString());
String svcfrm =
startTf.concat("~").concat(endTf).concat(",").concat(BigDecimal.valueOf(svcPrice).divide(BigDecimal.valueOf(100000L)).setScale(2).toString());
previousTf = tfPricesSeq[i];
startTf = endTf;
tfrmes.add(electfrm);
tfrmss.add(svcfrm);
}
if (i == 47 && !endTf.startsWith("24:00")) {
endTf = "24:00";
String electfrm =
startTf.concat("~").concat(endTf).concat(",").concat(BigDecimal.valueOf(elecPrice).divide(BigDecimal.valueOf(100000L)).setScale(2).toString());
String svcfrm =
startTf.concat("~").concat(endTf).concat(",").concat(BigDecimal.valueOf(svcPrice).divide(BigDecimal.valueOf(100000L)).setScale(2).toString());
tfrmes.add(electfrm);
tfrmss.add(svcfrm);
}
}
String[] pp = new String[2];
pp[0] = "电费:".concat(String.join(";", tfrmes));
pp[1] = "服务费:".concat(String.join(";", tfrmss));
cacheRateModel.setPp(pp);
REDIS.setCacheObject("rateModel:".concat(rateModelId.toString()), cacheRateModel);
return pp;
}
private List<EquipmentInfo> getEquipmentInfos(Set<String> pileNoSet) {
List<EquipmentInfo> equipmentInfos = new ArrayList<>();
@ -178,7 +241,7 @@ public class QueryStationsInfoController {
String gunId = pileNo.concat(String.format("%02d", i));
ConnectorInfo connectorInfo = new ConnectorInfo();
connectorInfo.setConnectorID(gunId);
String connectorName = (String) REDIS.getCacheMapValue("gun:".concat(gunId), "terminalName"); //todo setem in redis!
String connectorName = REDIS.getCacheMapValue("gun:".concat(gunId), "terminalName"); //todo setem in redis!
connectorInfo.setConnectorName(connectorName == null ?
Integer.parseInt(pileNo.substring(5, 10)) + "号桩 " + GUNNAMES[i] +
"" : connectorName);

View File

@ -12,6 +12,17 @@ public class CacheRateModel {
private Integer t4SvcPrice; //谷服务费价格
private Integer lossRate; //计损比例
private String[] tfPricesSeq; //48个字符串48个时段,每个时段的值为4个值之一 00: 尖费率 01: 峰费率 02: 平费率 03: 谷费率
private String[] pp; //00:00~07:00,0.16格式电费/服务费
public String[] getPp() {
return pp;
}
public void setPp(String[] pp) {
this.pp = pp;
}
public Integer getT1Price() {