桩号白名单done.计费模型设置逻辑todo..
This commit is contained in:
parent
dc8773fc85
commit
db1e7397cb
@ -1,14 +1,11 @@
|
||||
package com.xhpc.common.api.dto;
|
||||
|
||||
import com.xhpc.common.data.redis.CacheRateModel;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ChargingStationDto {
|
||||
|
||||
private Long stationId;
|
||||
private Set<String> piles;
|
||||
private Set<String> pilesSettingRateModel;
|
||||
private Long rateModelId;
|
||||
|
||||
public Long getStationId() {
|
||||
@ -31,16 +28,6 @@ public class ChargingStationDto {
|
||||
this.piles = piles;
|
||||
}
|
||||
|
||||
public Set<String> getPilesSettingRateModel() {
|
||||
|
||||
return pilesSettingRateModel;
|
||||
}
|
||||
|
||||
public void setPilesSettingRateModel(Set<String> pilesSettingRateModel) {
|
||||
|
||||
this.pilesSettingRateModel = pilesSettingRateModel;
|
||||
}
|
||||
|
||||
public Long getRateModelId() {
|
||||
|
||||
return rateModelId;
|
||||
|
||||
@ -2,9 +2,9 @@ package com.xhpc.pp.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xhpc.common.api.PowerPileService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.utils.HttpUtils;
|
||||
import com.xhpc.common.api.PowerPileService;
|
||||
import com.xhpc.common.data.down.StartChargingData;
|
||||
import com.xhpc.pp.server.ChargingPileServer;
|
||||
import com.xhpc.pp.tx.ServiceResult;
|
||||
@ -49,8 +49,8 @@ public class ChargingController {
|
||||
public Object startCharging(@Validated @RequestBody StartChargingData startChargingData) {
|
||||
|
||||
String pileNo = startChargingData.getPileNo();
|
||||
String pileKey = "pile:".concat(pileNo);
|
||||
Map<String, String> cachePile = REDIS.getCacheMap(pileKey);
|
||||
String pkey = "pile:".concat(pileNo);
|
||||
Map<String, String> cachePile = REDIS.getCacheMap(pkey);
|
||||
if (cachePile.isEmpty()) {
|
||||
return R.fail("充电桩未注册");
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package com.xhpc.pp.controller;
|
||||
|
||||
import com.xhpc.common.api.dto.ChargingPileDto;
|
||||
import com.xhpc.common.api.dto.ChargingStationDto;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -30,17 +30,19 @@ public class PileController {
|
||||
Set<String> stationPiles = cacheStation.getPiles();
|
||||
if (stationPiles == null) {
|
||||
cacheStation.setPiles(pileNoSet);
|
||||
cacheStation.setPilesSettingRateModel(pileNoSet);
|
||||
} else {
|
||||
cacheStation.getPiles().addAll(pileNoSet);
|
||||
cacheStation.getPilesSettingRateModel().addAll(pileNoSet);
|
||||
}
|
||||
REDIS.setCacheObject(stationKey, cacheStation);
|
||||
String rmskey = "rateModelStation:".concat(stationId.toString());
|
||||
Set<String> cacheSettingRateModelSet = REDIS.getCacheSet(rmskey);
|
||||
cacheSettingRateModelSet.addAll(pileNoSet);
|
||||
REDIS.setCacheSet(rmskey, cacheSettingRateModelSet);
|
||||
for (String pileNo : pileNoSet) {
|
||||
String pileKey = "pile:".concat(pileNo);
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap(pileKey);
|
||||
String pkey = "pile:".concat(pileNo);
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
||||
cachePile.put("stationId", stationId);
|
||||
REDIS.setCacheMap(pileKey, cachePile);
|
||||
REDIS.setCacheMap(pkey, cachePile);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
@ -54,8 +56,11 @@ public class PileController {
|
||||
String stationKey = "station:".concat(stationId.toString());
|
||||
ChargingStationDto cacheStation = REDIS.getCacheObject(stationKey);
|
||||
cacheStation.getPiles().removeAll(pileNoSet);
|
||||
cacheStation.getPilesSettingRateModel().removeAll(pileNoSet);
|
||||
REDIS.setCacheObject(stationKey, cacheStation);
|
||||
String rmskey = "rateModelStation:".concat(stationId.toString());
|
||||
Set<String> cacheSettingRateModelSet = REDIS.getCacheSet(rmskey);
|
||||
cacheSettingRateModelSet.removeAll(pileNoSet);
|
||||
REDIS.setCacheSet(rmskey, cacheSettingRateModelSet);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -8,11 +8,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.xhpc.pp.server.ChargingPileServer.REDIS;
|
||||
|
||||
@RestController
|
||||
@ -27,10 +22,8 @@ public class StationController {
|
||||
REDIS.setCacheObject(skey, cacheStation);
|
||||
String rkey = "rateModel:".concat(rateModelId.toString());
|
||||
REDIS.setCacheObject(rkey, rateModel);
|
||||
String srmkey = "settingRateModel:".concat(stationId.toString());
|
||||
Map<String, Object> rateModelPilesMap = new HashMap<>();
|
||||
rateModelPilesMap.put(rateModelId.toString(), cacheStation.getPiles());
|
||||
REDIS.setCacheMap(srmkey, rateModelPilesMap);
|
||||
String rmskey = "rateModelStation:".concat(stationId.toString());
|
||||
REDIS.setCacheSet(rmskey, cacheStation.getPiles());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -104,11 +104,11 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
||||
}
|
||||
ChargingPileServer.putHandler(pileNo, handler);
|
||||
ChargingPileServer.putVersion(handler.getName(), (String) req.get("version"));
|
||||
String pileKey = "pile:".concat(pileNo);
|
||||
Map<String, Object> pileCache = REDIS.getCacheMap(pileKey);
|
||||
String pkey = "pile:".concat(pileNo);
|
||||
Map<String, Object> pileCache = REDIS.getCacheMap(pkey);
|
||||
pileCache.put("status", REGISTERED);
|
||||
pileCache.put("svcSrv", getLocalIPAndPort());
|
||||
REDIS.setCacheMap(pileKey, pileCache);
|
||||
REDIS.setCacheMap(pkey, pileCache);
|
||||
cachePileGunSvcSrv("svcSrvPile:", pileNo);
|
||||
int gunNum = Integer.parseInt(req.get("gunNum").toString());
|
||||
for (int gunN = 1; gunN <= gunNum; gunN++) {
|
||||
|
||||
@ -87,10 +87,10 @@ public class ChargingPileServer {
|
||||
public static void removeHandler(String pileNo) {
|
||||
|
||||
ClientHandler handler = handlerMap.remove(pileNo);
|
||||
String pileKey = "pile:".concat(pileNo);
|
||||
Map<String, Object> cacheMap = REDIS.getCacheMap(pileKey);
|
||||
String pkey = "pile:".concat(pileNo);
|
||||
Map<String, Object> cacheMap = REDIS.getCacheMap(pkey);
|
||||
cacheMap.put("status", DISCONNECTED);
|
||||
REDIS.setCacheMap(pileKey, cacheMap);
|
||||
REDIS.setCacheMap(pkey, cacheMap);
|
||||
if (handler != null) {
|
||||
log.info("remove handler [{}] for [{}]", handler.getName(), pileNo);
|
||||
pileMap.remove(handler.getName());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user