|
|
@@ -1,23 +1,17 @@
|
|
|
package com.zd.netty.sdk;
|
|
|
|
|
|
import com.gg.reader.api.dal.GClient;
|
|
|
-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.utils.SpringUtils;
|
|
|
import com.zd.netty.service.ISendService;
|
|
|
import com.zd.netty.service.IService;
|
|
|
-import com.zd.netty.thread.ThreadPoolTaskConfig;
|
|
|
import com.zd.system.api.domain.InventoryTag;
|
|
|
import com.zd.system.api.laboratory.domain.RemoteLabHardware;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
-import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
@@ -54,7 +48,7 @@ public class DeJuRFIDService implements IService {
|
|
|
}
|
|
|
if (client.openTcp(ipAddress + ":"+PORT, 2000)) {
|
|
|
// 订阅标签上报事件
|
|
|
- subscribeHandler(client);
|
|
|
+ subscribeHandler(client,hardware);
|
|
|
// 功率配置, 将4个天线功率都设置为30dBm.
|
|
|
MsgBaseSetPower msgBaseSetPower = setPower(hardware, client);
|
|
|
if (0 != msgBaseSetPower.getRtCode()) {
|
|
|
@@ -134,6 +128,21 @@ public class DeJuRFIDService implements IService {
|
|
|
close(hardware);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void alarm(RemoteLabHardware hardware) {
|
|
|
+ //灯带设置
|
|
|
+ String ipAddress = hardware.getIpAddress();
|
|
|
+ if (clientMap.containsKey(ipAddress)){
|
|
|
+ GClient client = clientMap.get(ipAddress);
|
|
|
+ if (!isAlarm.get()) {
|
|
|
+ scheduledExecutorService.execute(() -> {
|
|
|
+ isAlarm.set(true);
|
|
|
+ changeGpo(1, client, 10);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private static void close(RemoteLabHardware hardware) {
|
|
|
String ipAddress = hardware.getIpAddress();
|
|
|
if (clientMap.containsKey(ipAddress)) {
|
|
|
@@ -151,7 +160,6 @@ public class DeJuRFIDService implements IService {
|
|
|
MsgAppSetGpo msgAppSetGpo = new MsgAppSetGpo();
|
|
|
msgAppSetGpo.setGpo1(state);
|
|
|
msgAppSetGpo.setGpo2(state);
|
|
|
-
|
|
|
client.sendSynMsg(msgAppSetGpo);
|
|
|
String status = state == 1 ? "start" : "stop";
|
|
|
if (0 == msgAppSetGpo.getRtCode()) {
|
|
|
@@ -181,21 +189,19 @@ public class DeJuRFIDService implements IService {
|
|
|
* 订阅6c标签信息上报
|
|
|
*
|
|
|
* @param client 客户端
|
|
|
+ * @param hardware 设备数据
|
|
|
*/
|
|
|
- public static void subscribeHandler(GClient client) {
|
|
|
+ public static void subscribeHandler(GClient client, RemoteLabHardware hardware) {
|
|
|
+ String ipAddress = hardware.getIpAddress();
|
|
|
+ if (!clientMap.containsKey(ipAddress)){
|
|
|
+ clientMap.put(ipAddress,client);
|
|
|
+ }
|
|
|
client.onTagEpcLog = (s, logBaseEpcInfo) -> {
|
|
|
if (logBaseEpcInfo.getResult() == 0) {
|
|
|
log.info("===========》{}", logBaseEpcInfo.getbEpc());
|
|
|
- //灯带设置
|
|
|
- if (!isAlarm.get()) {
|
|
|
- scheduledExecutorService.execute(() -> {
|
|
|
- isAlarm.set(true);
|
|
|
- changeGpo(1, client, 10);
|
|
|
- });
|
|
|
- }
|
|
|
InventoryTag tag = new InventoryTag();
|
|
|
BeanUtils.copyProperties(logBaseEpcInfo, tag);
|
|
|
- sendService.send(tag);
|
|
|
+ sendService.send(tag,hardware);
|
|
|
}
|
|
|
};
|
|
|
client.onTagEpcOver = (s, logBaseEpcOver) -> log.info("HandlerTagEpcOver");
|