|
|
@@ -3,12 +3,15 @@ package com.zd.netty.sdk;
|
|
|
import com.gg.reader.api.dal.GClient;
|
|
|
import com.gg.reader.api.dal.GServer;
|
|
|
import com.gg.reader.api.protocol.gx.MsgBaseStop;
|
|
|
+import com.zd.common.core.enums.HardwareOperate;
|
|
|
import com.zd.common.core.exception.ServiceException;
|
|
|
import com.zd.netty.service.IService;
|
|
|
+import com.zd.system.api.laboratory.RemoteLaboratoryService;
|
|
|
import com.zd.system.api.laboratory.domain.RemoteLabHardware;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
@@ -18,6 +21,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
public class DeJuRFIDListenerService implements IService {
|
|
|
|
|
|
private final Map<String, GServer> serverMap = new ConcurrentHashMap<>();
|
|
|
+ @Resource
|
|
|
+ private RemoteLaboratoryService remoteLaboratoryService;
|
|
|
|
|
|
@Override
|
|
|
public void start(RemoteLabHardware hardware) {
|
|
|
@@ -34,7 +39,7 @@ public class DeJuRFIDListenerService implements IService {
|
|
|
} else {
|
|
|
log.info("监听失败");
|
|
|
start(hardware);
|
|
|
- throw new ServiceException("监听失败");
|
|
|
+ throw new ServiceException("监听失败,请等待设备重连。。。");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -58,6 +63,7 @@ public class DeJuRFIDListenerService implements IService {
|
|
|
DeJuRFIDService.setPower(hardware, client);
|
|
|
DeJuRFIDService.setInventory(hardware, client);
|
|
|
DeJuRFIDService.subscribeHandler(client);
|
|
|
+ remoteLaboratoryService.update(HardwareOperate.OPEN,hardware.getIpAddress());
|
|
|
};
|
|
|
}
|
|
|
|
|
|
@@ -66,7 +72,9 @@ public class DeJuRFIDListenerService implements IService {
|
|
|
client.onDisconnected = s -> {
|
|
|
log.info("连接" + s + "已断开");
|
|
|
client.close();//释放当前连接资源
|
|
|
+ remoteLaboratoryService.update(HardwareOperate.CLOSE,hardware.getIpAddress());
|
|
|
start(hardware);
|
|
|
+ log.info("连接" + s + "重连中。。。");
|
|
|
};
|
|
|
}
|
|
|
|