|
|
@@ -36,12 +36,12 @@ public class DeJuRFIDListenerService implements IService {
|
|
|
if (serverMap.containsKey(ipAddress)) {
|
|
|
server = serverMap.get(ipAddress);
|
|
|
boolean listen = server.isListend();
|
|
|
- if (listen){
|
|
|
+ if (listen) {
|
|
|
server.close();
|
|
|
}
|
|
|
} else {
|
|
|
server = new GServer();
|
|
|
- serverMap.put(ipAddress,server);
|
|
|
+ serverMap.put(ipAddress, server);
|
|
|
}
|
|
|
if (server.open(DeJuRFIDService.PORT)) {
|
|
|
subscribeServerHandler(server, hardware);
|
|
|
@@ -57,11 +57,13 @@ public class DeJuRFIDListenerService implements IService {
|
|
|
String ipAddress = hardware.getIpAddress();
|
|
|
if (serverMap.containsKey(ipAddress)) {
|
|
|
GServer server = serverMap.get(ipAddress);
|
|
|
- server.onGClientConnected= (client, s) -> {
|
|
|
- DeJuRFIDService.stopGpo(client,0);
|
|
|
+ server.onGClientConnected = (client, s) -> {
|
|
|
+ DeJuRFIDService.stopGpo(client, 0);
|
|
|
MsgBaseStop msg = new MsgBaseStop();
|
|
|
// 停止读卡,空闲态
|
|
|
client.sendSynMsg(msg);
|
|
|
+ String result = msg.getRtCode() == 0 ? "成功" : "失败";
|
|
|
+ log.info("客户端停止读卡{}", result);
|
|
|
client.close();
|
|
|
};
|
|
|
server.close();
|
|
|
@@ -77,7 +79,8 @@ public class DeJuRFIDListenerService implements IService {
|
|
|
|
|
|
/**
|
|
|
* 订阅监听上报
|
|
|
- * @param server 服务对象
|
|
|
+ *
|
|
|
+ * @param server 服务对象
|
|
|
* @param hardware 设备对象
|
|
|
*/
|
|
|
private void subscribeServerHandler(GServer server, RemoteLabHardware hardware) {
|
|
|
@@ -85,24 +88,25 @@ public class DeJuRFIDListenerService implements IService {
|
|
|
log.info(client.getName() + "---监听成功");
|
|
|
client.setSendHeartBeat(true);//开启心跳检测Tcp连接状态
|
|
|
client.setPrint(true);
|
|
|
- subscribeTcpHandler(client,hardware);//订阅Tcp断连上报
|
|
|
+ subscribeTcpHandler(client, hardware);//订阅Tcp断连上报
|
|
|
DeJuRFIDService.setPower(hardware, client);
|
|
|
DeJuRFIDService.setInventory(hardware, client);
|
|
|
DeJuRFIDService.subscribeHandler(client, hardware);
|
|
|
- remoteLaboratoryService.update(HardwareOperate.OPEN,hardware.getIpAddress());
|
|
|
+ remoteLaboratoryService.update(HardwareOperate.OPEN, hardware.getIpAddress());
|
|
|
};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 订阅TCP断开连接上报
|
|
|
- * @param client 客户端对象
|
|
|
+ *
|
|
|
+ * @param client 客户端对象
|
|
|
* @param hardware 设备对象
|
|
|
*/
|
|
|
private void subscribeTcpHandler(GClient client, RemoteLabHardware hardware) {
|
|
|
client.onDisconnected = s -> {
|
|
|
log.info("连接" + s + "已断开");
|
|
|
disconnect(hardware);
|
|
|
- remoteLaboratoryService.update(HardwareOperate.CLOSE,hardware.getIpAddress());
|
|
|
+ remoteLaboratoryService.update(HardwareOperate.CLOSE, hardware.getIpAddress());
|
|
|
log.info("连接" + s + "重连中。。。");
|
|
|
start(hardware);
|
|
|
};
|