充电桩状态字段处理逻辑完善
This commit is contained in:
parent
0b2de8b5a4
commit
19c5590271
@ -203,13 +203,16 @@ public class ChargingController {
|
||||
|
||||
String pileNo = startChargingData.getPileNo();
|
||||
ClientHandler clientHandler = ChargingPileServer.getHandler(pileNo);
|
||||
if (clientHandler == null) return R.fail("充电桩没有连接到上次注册的服务器");
|
||||
if (clientHandler == null) {
|
||||
ChargingPileServer.removeHandler(pileNo);
|
||||
return R.fail("充电桩没有连接到上次注册的服务器,请稍后再试一次");
|
||||
}
|
||||
try {
|
||||
String gunkey = "gun:".concat(pileNo).concat(startChargingData.getGunId());
|
||||
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
||||
String gunstatus = (String) cacheGun.get("status");
|
||||
if (!"空闲".equals(gunstatus)) {
|
||||
return R.fail("充电桩不在空闲正常状态,稍后再试");
|
||||
return R.fail("充电桩不在空闲或正常状态,稍后再试");
|
||||
}
|
||||
if (CacheDataUtils.hori(gunkey)) return R.fail("等待上一条指令响应");
|
||||
String skey = gunkey.concat(".seqhex");
|
||||
@ -241,7 +244,10 @@ public class ChargingController {
|
||||
public R nativeStopCharging(@PathVariable("pileNo") String pileNo, @PathVariable("gunId") String gunId, @PathVariable("version") String version) {
|
||||
|
||||
ClientHandler clientHandler = ChargingPileServer.getHandler(pileNo);
|
||||
if (clientHandler == null) return R.fail("充电桩没有连接到上次注册的服务器");
|
||||
if (clientHandler == null) {
|
||||
ChargingPileServer.removeHandler(pileNo);
|
||||
return R.fail("充电桩没有连接到上次注册的服务器,请稍后再试一次");
|
||||
}
|
||||
try {
|
||||
String gunkey = "gun:".concat(pileNo).concat(gunId);
|
||||
if (CacheDataUtils.hori(gunkey)) return R.fail("等待上一条指令响应");
|
||||
|
||||
@ -48,8 +48,9 @@ public class RegisterLogic implements ServiceLogic {
|
||||
cachePile.put("status", REGISTERED);
|
||||
String localIPAndPort = getLocalIPAndPort();
|
||||
cachePile.put("svcSrv", localIPAndPort);
|
||||
REDIS.setCacheMap("pile:".concat(pileNo), cachePile);
|
||||
int gunNum = Integer.parseInt(req.get("gunNum").toString());
|
||||
cachePile.put("gunNum", gunNum);
|
||||
REDIS.setCacheMap("pile:".concat(pileNo), cachePile);
|
||||
for (int gunN = 1; gunN <= gunNum; gunN++) {
|
||||
String gunId = String.format("%02d", gunN);
|
||||
String gunkey = "gun:".concat(pileNo.concat(gunId));
|
||||
|
||||
@ -91,10 +91,10 @@ public class ChargingPileServer {
|
||||
Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
|
||||
cachePile.put("status", DISCONNECTED);
|
||||
REDIS.setCacheMap(pkey, cachePile);
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
for (int i = 1; i <= (int) cachePile.get("gunNum"); i++) {
|
||||
String gunkey = "gun:".concat(pileNo).concat(String.format("%02d", i));
|
||||
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
||||
if (cacheGun != null && !cacheGun.isEmpty()) {
|
||||
if (!cacheGun.isEmpty()) {
|
||||
cacheGun.put("status", DISCONNECTED);
|
||||
REDIS.setCacheMap(gunkey, cacheGun);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user