还是简单拒绝比较好
This commit is contained in:
parent
78d9a4ccc1
commit
73d0e67213
@ -173,11 +173,11 @@ public class ChargingController {
|
||||
}
|
||||
|
||||
@PostMapping("native/charging/balance/refresh")
|
||||
public R nativeRefreshBalance(@Validated @RequestBody StartChargingData refreshBalanceData) throws InterruptedException {
|
||||
public R nativeRefreshBalance(@Validated @RequestBody StartChargingData refreshBalanceData) {
|
||||
|
||||
String pileNo = refreshBalanceData.getPileNo();
|
||||
String gunkey = "gun:".concat(pileNo).concat(refreshBalanceData.getGunId());
|
||||
if (CacheDataUtils.hori(gunkey)) Thread.sleep(500L);// return R.fail("等待上一条指令响应");
|
||||
if (CacheDataUtils.hori(gunkey)) return R.fail("等待上一条指令响应");
|
||||
String skey = gunkey.concat(".seqhex");
|
||||
String seq = seqHex(skey);
|
||||
String refreshBalanceMsg = "6817".concat(seq).concat("0042").concat(pileNo)
|
||||
@ -212,7 +212,7 @@ public class ChargingController {
|
||||
if (!"空闲".equals(gunstatus)) {
|
||||
return R.fail("充电桩不在空闲正常状态,稍后再试");
|
||||
}
|
||||
if (CacheDataUtils.hori(gunkey)) Thread.sleep(500L); //return R.fail("等待上一条指令响应");
|
||||
if (CacheDataUtils.hori(gunkey)) return R.fail("等待上一条指令响应");
|
||||
String skey = gunkey.concat(".seqhex");
|
||||
String seq = seqHex(skey);
|
||||
byte[] msg = translateStart(startChargingData, seq);
|
||||
@ -232,7 +232,7 @@ public class ChargingController {
|
||||
cacheGun.put("orderkey", orderkey);
|
||||
REDIS.setCacheMap(gunkey, cacheGun);
|
||||
return R.ok("指令已下发至充电桩");
|
||||
} catch (IOException | InterruptedException e) {
|
||||
} catch (IOException e) {
|
||||
log.error("send message failed. " + e.getMessage(), e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
@ -245,7 +245,7 @@ public class ChargingController {
|
||||
if (clientHandler == null) return R.fail("充电桩没有连接到上次注册的服务器");
|
||||
try {
|
||||
String gunkey = "gun:".concat(pileNo).concat(gunId);
|
||||
if (CacheDataUtils.hori(gunkey)) Thread.sleep(500L);//return R.fail("等待上一条指令响应");
|
||||
if (CacheDataUtils.hori(gunkey)) return R.fail("等待上一条指令响应");
|
||||
String skey = gunkey.concat(".seqhex");
|
||||
String seq = seqHex(skey);
|
||||
byte[] msg = translateStop(pileNo, gunId, version, seq);
|
||||
@ -253,7 +253,7 @@ public class ChargingController {
|
||||
Map<String, Object> cacheGun = REDIS.getCacheMap(gunkey);
|
||||
REDIS.setCacheMap(gunkey, cacheGun);
|
||||
return R.ok("指令已下发至充电桩");
|
||||
} catch (IOException | InterruptedException e) {
|
||||
} catch (IOException e) {
|
||||
log.error("send message failed. " + e.getMessage(), e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
|
||||
@ -106,8 +106,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
||||
if (result.getBinary() != null) {
|
||||
String gunId = (String) req.get("gunId");
|
||||
if (gunId != null) {
|
||||
String gunkey = "gun:".concat(pileNo).concat(gunId);
|
||||
hori2(gunkey);
|
||||
hori2(pileNo, gunId);
|
||||
}
|
||||
log.info("server send msg >>>> ({}) |{}|", pileNo, toHex(result.getBinary()));
|
||||
handler.sendClientBinary(result.getBinary());
|
||||
@ -123,6 +122,9 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
||||
REDIS.setCacheMap(pilekey, cachePile);
|
||||
log.info("server send time config msg >>>> ({}) |{}|", pileNo, timebin);
|
||||
handler.sendClientBinary(HexUtils.toBytes(timebin));
|
||||
if (gunId != null) {
|
||||
hori2(pileNo, gunId);
|
||||
}
|
||||
cachePile.put("tcfg", true);
|
||||
REDIS.setCacheMap(pilekey, cachePile);
|
||||
}
|
||||
|
||||
@ -40,9 +40,9 @@ public class CacheDataUtils {
|
||||
return tarobj;
|
||||
}
|
||||
|
||||
public static void hori2(String gunkey) {
|
||||
public static void hori2(String pileNo, String gunId) {
|
||||
|
||||
String hori = gunkey.concat(".hori");
|
||||
String hori = "gun:".concat(pileNo).concat(gunId).concat(".hori");
|
||||
REDIS.setCacheObject(hori, "protection film", 300L, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user