|
@@ -1,10 +1,9 @@
|
|
|
package com.zd.netty.sdk;
|
|
package com.zd.netty.sdk;
|
|
|
|
|
|
|
|
import com.gg.reader.api.dal.GClient;
|
|
import com.gg.reader.api.dal.GClient;
|
|
|
-import com.gg.reader.api.protocol.gx.EnumG;
|
|
|
|
|
-import com.gg.reader.api.protocol.gx.MsgBaseInventoryEpc;
|
|
|
|
|
-import com.gg.reader.api.protocol.gx.MsgBaseSetPower;
|
|
|
|
|
-import com.gg.reader.api.protocol.gx.MsgBaseStop;
|
|
|
|
|
|
|
+import com.gg.reader.api.dal.HandlerTagEpcLog;
|
|
|
|
|
+import com.gg.reader.api.dal.HandlerTagEpcOver;
|
|
|
|
|
+import com.gg.reader.api.protocol.gx.*;
|
|
|
import com.zd.common.core.exception.ServiceException;
|
|
import com.zd.common.core.exception.ServiceException;
|
|
|
import com.zd.netty.service.ISendService;
|
|
import com.zd.netty.service.ISendService;
|
|
|
import com.zd.netty.service.IService;
|
|
import com.zd.netty.service.IService;
|
|
@@ -41,22 +40,7 @@ public class DeJuRFIDService implements IService {
|
|
|
Integer port = hardware.getPort();
|
|
Integer port = hardware.getPort();
|
|
|
if (client.openTcp(ipAddress+":8160", 2000)) {
|
|
if (client.openTcp(ipAddress+":8160", 2000)) {
|
|
|
// 订阅标签上报事件
|
|
// 订阅标签上报事件
|
|
|
- client.onTagEpcLog = (readName, logBaseEpcInfo) -> {
|
|
|
|
|
- // 回调内部如有阻塞,会影响API正常使用
|
|
|
|
|
- // 标签回调数量较多,请将标签数据先缓存起来再作业务处理
|
|
|
|
|
- log.error("=======================>"+logBaseEpcInfo.getEpc());
|
|
|
|
|
- if (0 == logBaseEpcInfo.getResult()) {
|
|
|
|
|
- InventoryTag tag=new InventoryTag();
|
|
|
|
|
- BeanUtils.copyProperties(logBaseEpcInfo,tag);
|
|
|
|
|
- sendService.send(tag);
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
- //标签上报结束
|
|
|
|
|
- client.onTagEpcOver = (readName, logBaseEpcOver) -> {
|
|
|
|
|
- if (null != logBaseEpcOver) {
|
|
|
|
|
- log.info("Epc log over.");
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ subscribeHandler(client);
|
|
|
// 停止指令,空闲态
|
|
// 停止指令,空闲态
|
|
|
MsgBaseStop msgBaseStop = new MsgBaseStop();
|
|
MsgBaseStop msgBaseStop = new MsgBaseStop();
|
|
|
client.sendSynMsg(msgBaseStop);
|
|
client.sendSynMsg(msgBaseStop);
|
|
@@ -122,4 +106,24 @@ public class DeJuRFIDService implements IService {
|
|
|
clientMap.remove(ipAddress);
|
|
clientMap.remove(ipAddress);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //订阅6c标签信息上报
|
|
|
|
|
+ private static void subscribeHandler(GClient client) {
|
|
|
|
|
+ client.onTagEpcLog = new HandlerTagEpcLog() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void log(String s, LogBaseEpcInfo logBaseEpcInfo) {
|
|
|
|
|
+ log.error("=======================>"+logBaseEpcInfo.getEpc());
|
|
|
|
|
+ if (logBaseEpcInfo.getResult() == 0) {
|
|
|
|
|
+ System.out.println(logBaseEpcInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ client.onTagEpcOver = new HandlerTagEpcOver() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void log(String s, LogBaseEpcOver logBaseEpcOver) {
|
|
|
|
|
+ System.out.println("HandlerTagEpcOver");
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|