|
|
@@ -30,15 +30,22 @@ public class DeJuRFIDService implements IService {
|
|
|
|
|
|
@Override
|
|
|
public void start(RemoteLabHardware hardware) {
|
|
|
- GClient client = new GClient();
|
|
|
+ GClient client;
|
|
|
String ipAddress = hardware.getIpAddress();
|
|
|
+ if (clientMap.containsKey(ipAddress)){
|
|
|
+ client=clientMap.get(ipAddress);
|
|
|
+ }else {
|
|
|
+ client = new GClient();
|
|
|
+ clientMap.put(ipAddress,client);
|
|
|
+ }
|
|
|
Integer port = hardware.getPort();
|
|
|
- if (client.openTcp(ipAddress+":"+port, 2000)) {
|
|
|
+ if (client.openTcp(ipAddress+":8160", 2000)) {
|
|
|
// 订阅标签上报事件
|
|
|
client.onTagEpcLog = (readName, logBaseEpcInfo) -> {
|
|
|
// 回调内部如有阻塞,会影响API正常使用
|
|
|
// 标签回调数量较多,请将标签数据先缓存起来再作业务处理
|
|
|
- if (null != logBaseEpcInfo && 0 == logBaseEpcInfo.getResult()) {
|
|
|
+ log.error("=======================>"+logBaseEpcInfo.getEpc());
|
|
|
+ if (0 == logBaseEpcInfo.getResult()) {
|
|
|
InventoryTag tag=new InventoryTag();
|
|
|
BeanUtils.copyProperties(logBaseEpcInfo,tag);
|
|
|
sendService.send(tag);
|
|
|
@@ -92,7 +99,6 @@ public class DeJuRFIDService implements IService {
|
|
|
} else {
|
|
|
log.info("Inventory epc error.");
|
|
|
}
|
|
|
- clientMap.put(ipAddress,client);
|
|
|
} else {
|
|
|
throw new ServiceException("Connect failure.");
|
|
|
}
|