断开连接但不修改充电桩状态和handler对应关系

This commit is contained in:
ZZ 2021-08-31 19:22:41 +08:00
parent bf3ee19374
commit 79686e62d2

View File

@ -7,11 +7,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Map;
import static com.xhpc.common.data.redis.StaticBeanUtil.REDIS;
import static com.xhpc.pp.logic.RegisterLogic.DISCONNECTED;
@Lazy(false) @Lazy(false)
@Component @Component
public class ChargingPileEventHandler implements ClientEventHandler { public class ChargingPileEventHandler implements ClientEventHandler {
@ -43,11 +38,11 @@ public class ChargingPileEventHandler implements ClientEventHandler {
public void closingConnection(ClientHandler handler) { public void closingConnection(ClientHandler handler) {
String pileNo = ChargingPileServer.getPileNo(handler); String pileNo = ChargingPileServer.getPileNo(handler);
ChargingPileServer.removeHandler(pileNo); // ChargingPileServer.removeHandler(pileNo);
String pkey = "pile:".concat(pileNo); // String pkey = "pile:".concat(pileNo);
Map<String, Object> cachePile = REDIS.getCacheMap(pkey); // Map<String, Object> cachePile = REDIS.getCacheMap(pkey);
cachePile.put("status", DISCONNECTED); // cachePile.put("status", DISCONNECTED);
REDIS.setCacheMap(pkey, cachePile); // REDIS.setCacheMap(pkey, cachePile);
handler.closeConnection(); handler.closeConnection();
log.info("-> ({}) - [{}] <- {}", pileNo, handler.getName(), handler.getSocket().getRemoteSocketAddress().toString()); log.info("-> ({}) - [{}] <- {}", pileNo, handler.getName(), handler.getSocket().getRemoteSocketAddress().toString());
} }