diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/dto/ChargingStationDto.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/dto/ChargingStationDto.java index a18abdda..16987d28 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/dto/ChargingStationDto.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/dto/ChargingStationDto.java @@ -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 piles; - private Set pilesSettingRateModel; private Long rateModelId; public Long getStationId() { @@ -31,16 +28,6 @@ public class ChargingStationDto { this.piles = piles; } - public Set getPilesSettingRateModel() { - - return pilesSettingRateModel; - } - - public void setPilesSettingRateModel(Set pilesSettingRateModel) { - - this.pilesSettingRateModel = pilesSettingRateModel; - } - public Long getRateModelId() { return rateModelId; diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java index 3b154739..2b8e9e12 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/ChargingController.java @@ -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 cachePile = REDIS.getCacheMap(pileKey); + String pkey = "pile:".concat(pileNo); + Map cachePile = REDIS.getCacheMap(pkey); if (cachePile.isEmpty()) { return R.fail("充电桩未注册"); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java index 26c34db1..60a4bffd 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/PileController.java @@ -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 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 cacheSettingRateModelSet = REDIS.getCacheSet(rmskey); + cacheSettingRateModelSet.addAll(pileNoSet); + REDIS.setCacheSet(rmskey, cacheSettingRateModelSet); for (String pileNo : pileNoSet) { - String pileKey = "pile:".concat(pileNo); - Map cachePile = REDIS.getCacheMap(pileKey); + String pkey = "pile:".concat(pileNo); + Map 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 cacheSettingRateModelSet = REDIS.getCacheSet(rmskey); + cacheSettingRateModelSet.removeAll(pileNoSet); + REDIS.setCacheSet(rmskey, cacheSettingRateModelSet); return R.ok(); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java index 12591812..f2c61f44 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/controller/StationController.java @@ -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 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(); } diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java index acf3fc29..04e236c9 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileBinaryHandler.java @@ -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 pileCache = REDIS.getCacheMap(pileKey); + String pkey = "pile:".concat(pileNo); + Map 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++) { diff --git a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileServer.java b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileServer.java index 65be7c4d..668a9404 100644 --- a/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileServer.java +++ b/xhpc-modules/xhpc-power-pile/src/main/java/com/xhpc/pp/server/ChargingPileServer.java @@ -87,10 +87,10 @@ public class ChargingPileServer { public static void removeHandler(String pileNo) { ClientHandler handler = handlerMap.remove(pileNo); - String pileKey = "pile:".concat(pileNo); - Map cacheMap = REDIS.getCacheMap(pileKey); + String pkey = "pile:".concat(pileNo); + Map 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());