|
@@ -5,6 +5,7 @@ import com.gg.reader.api.dal.HandlerTagEpcLog;
|
|
|
import com.gg.reader.api.dal.HandlerTagEpcOver;
|
|
import com.gg.reader.api.dal.HandlerTagEpcOver;
|
|
|
import com.gg.reader.api.protocol.gx.*;
|
|
import com.gg.reader.api.protocol.gx.*;
|
|
|
import com.zd.common.core.exception.ServiceException;
|
|
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.ISendService;
|
|
|
import com.zd.netty.service.IService;
|
|
import com.zd.netty.service.IService;
|
|
|
import com.zd.netty.thread.ThreadPoolTaskConfig;
|
|
import com.zd.netty.thread.ThreadPoolTaskConfig;
|
|
@@ -12,13 +13,15 @@ import com.zd.system.api.domain.InventoryTag;
|
|
|
import com.zd.system.api.laboratory.domain.RemoteLabHardware;
|
|
import com.zd.system.api.laboratory.domain.RemoteLabHardware;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.Hashtable;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
+import java.util.concurrent.ScheduledExecutorService;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
@@ -29,8 +32,7 @@ public class DeJuRFIDService implements IService {
|
|
|
|
|
|
|
|
private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
|
|
private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
- @Resource
|
|
|
|
|
- private ThreadPoolTaskConfig threadPoolTaskConfig;
|
|
|
|
|
|
|
+ private final ScheduledExecutorService scheduledExecutorService= SpringUtils.getBean("scheduledExecutorService");
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void start(RemoteLabHardware hardware) {
|
|
public void start(RemoteLabHardware hardware) {
|
|
@@ -66,10 +68,14 @@ public class DeJuRFIDService implements IService {
|
|
|
log.info("Power configuration successful.");
|
|
log.info("Power configuration successful.");
|
|
|
} else {
|
|
} else {
|
|
|
log.info("Power configuration error.");
|
|
log.info("Power configuration error.");
|
|
|
|
|
+ disconnect(hardware);
|
|
|
|
|
+ start(hardware);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
log.info("Power configuration error.");
|
|
log.info("Power configuration error.");
|
|
|
|
|
+ disconnect(hardware);
|
|
|
|
|
+ start(hardware);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//蜂鸣器设置
|
|
//蜂鸣器设置
|
|
@@ -107,6 +113,8 @@ public class DeJuRFIDService implements IService {
|
|
|
log.info("Inventory epc successful.");
|
|
log.info("Inventory epc successful.");
|
|
|
} else {
|
|
} else {
|
|
|
log.info("Inventory epc error.");
|
|
log.info("Inventory epc error.");
|
|
|
|
|
+ disconnect(hardware);
|
|
|
|
|
+ start(hardware);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
throw new ServiceException("Connect failure.");
|
|
throw new ServiceException("Connect failure.");
|
|
@@ -118,22 +126,7 @@ public class DeJuRFIDService implements IService {
|
|
|
String ipAddress = hardware.getIpAddress();
|
|
String ipAddress = hardware.getIpAddress();
|
|
|
if (clientMap.containsKey(ipAddress)) {
|
|
if (clientMap.containsKey(ipAddress)) {
|
|
|
GClient client = clientMap.get(ipAddress);
|
|
GClient client = clientMap.get(ipAddress);
|
|
|
- MsgAppSetGpo msgAppSetGpo=new MsgAppSetGpo();
|
|
|
|
|
- msgAppSetGpo.setGpo1(0);
|
|
|
|
|
- msgAppSetGpo.setGpo2(0);
|
|
|
|
|
- msgAppSetGpo.setGpo3(0);
|
|
|
|
|
- msgAppSetGpo.setGpo4(0);
|
|
|
|
|
- msgAppSetGpo.setGpo5(0);
|
|
|
|
|
- msgAppSetGpo.setGpo6(0);
|
|
|
|
|
- msgAppSetGpo.setGpo7(0);
|
|
|
|
|
- msgAppSetGpo.setGpo8(0);
|
|
|
|
|
-
|
|
|
|
|
- client.sendSynMsg(msgAppSetGpo);
|
|
|
|
|
- if (0 == msgAppSetGpo.getRtCode()) {
|
|
|
|
|
- log.info("Gpo epc stop successful.");
|
|
|
|
|
- } else {
|
|
|
|
|
- log.error("Gpo epc stop error.");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ changeGpo(0, client);
|
|
|
MsgBaseStop msg = new MsgBaseStop();
|
|
MsgBaseStop msg = new MsgBaseStop();
|
|
|
// 停止读卡,空闲态
|
|
// 停止读卡,空闲态
|
|
|
client.sendSynMsg(msg);
|
|
client.sendSynMsg(msg);
|
|
@@ -148,6 +141,35 @@ public class DeJuRFIDService implements IService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void changeGpo(int state, GClient client) {
|
|
|
|
|
+ MsgAppSetGpo msgAppSetGpo=new MsgAppSetGpo();
|
|
|
|
|
+ msgAppSetGpo.setGpo1(state);
|
|
|
|
|
+ msgAppSetGpo.setGpo2(state);
|
|
|
|
|
+ msgAppSetGpo.setGpo3(state);
|
|
|
|
|
+ msgAppSetGpo.setGpo4(state);
|
|
|
|
|
+ msgAppSetGpo.setGpo5(state);
|
|
|
|
|
+ msgAppSetGpo.setGpo6(state);
|
|
|
|
|
+ msgAppSetGpo.setGpo7(state);
|
|
|
|
|
+ msgAppSetGpo.setGpo8(state);
|
|
|
|
|
+
|
|
|
|
|
+ client.sendSynMsg(msgAppSetGpo);
|
|
|
|
|
+ String status = state == 1 ? "start" : "stop";
|
|
|
|
|
+ if (0 == msgAppSetGpo.getRtCode()) {
|
|
|
|
|
+ log.info("Gpo epc {} successful.",status);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.error("Gpo epc {} error.",status);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void stopGpo(GClient client){
|
|
|
|
|
+ scheduledExecutorService.schedule(new TimerTask() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ changeGpo(0, client);
|
|
|
|
|
+ }
|
|
|
|
|
+ },10, TimeUnit.SECONDS);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 订阅6c标签信息上报
|
|
* 订阅6c标签信息上报
|
|
|
*
|
|
*
|
|
@@ -158,37 +180,8 @@ public class DeJuRFIDService implements IService {
|
|
|
if (logBaseEpcInfo.getResult() == 0) {
|
|
if (logBaseEpcInfo.getResult() == 0) {
|
|
|
log.info("===========》{}",logBaseEpcInfo.getbEpc());
|
|
log.info("===========》{}",logBaseEpcInfo.getbEpc());
|
|
|
//灯带设置
|
|
//灯带设置
|
|
|
- MsgAppSetGpo msgAppSetGpo=new MsgAppSetGpo();
|
|
|
|
|
- msgAppSetGpo.setGpo1(1);
|
|
|
|
|
- msgAppSetGpo.setGpo2(1);
|
|
|
|
|
- msgAppSetGpo.setGpo3(1);
|
|
|
|
|
- msgAppSetGpo.setGpo4(1);
|
|
|
|
|
- msgAppSetGpo.setGpo5(1);
|
|
|
|
|
- msgAppSetGpo.setGpo6(1);
|
|
|
|
|
- msgAppSetGpo.setGpo7(1);
|
|
|
|
|
- msgAppSetGpo.setGpo8(1);
|
|
|
|
|
- client.sendSynMsg(msgAppSetGpo);
|
|
|
|
|
- if (0 == msgAppSetGpo.getRtCode()) {
|
|
|
|
|
- log.info("Gpo epc successful.");
|
|
|
|
|
- } else {
|
|
|
|
|
- log.error("Gpo epc error.");
|
|
|
|
|
- }
|
|
|
|
|
- threadPoolTaskConfig.getAsyncExecutor().execute(() -> {
|
|
|
|
|
- msgAppSetGpo.setGpo1(0);
|
|
|
|
|
- msgAppSetGpo.setGpo2(0);
|
|
|
|
|
- msgAppSetGpo.setGpo3(0);
|
|
|
|
|
- msgAppSetGpo.setGpo4(0);
|
|
|
|
|
- msgAppSetGpo.setGpo5(0);
|
|
|
|
|
- msgAppSetGpo.setGpo6(0);
|
|
|
|
|
- msgAppSetGpo.setGpo7(0);
|
|
|
|
|
- msgAppSetGpo.setGpo8(0);
|
|
|
|
|
- client.sendSynMsg(msgAppSetGpo);
|
|
|
|
|
- if (0 == msgAppSetGpo.getRtCode()) {
|
|
|
|
|
- log.info("Gpo epc stop successful.");
|
|
|
|
|
- } else {
|
|
|
|
|
- log.error("Gpo epc stop error.");
|
|
|
|
|
- }
|
|
|
|
|
- },8*1000);
|
|
|
|
|
|
|
+ changeGpo(1, client);
|
|
|
|
|
+ stopGpo(client);
|
|
|
InventoryTag tag = new InventoryTag();
|
|
InventoryTag tag = new InventoryTag();
|
|
|
BeanUtils.copyProperties(logBaseEpcInfo, tag);
|
|
BeanUtils.copyProperties(logBaseEpcInfo, tag);
|
|
|
sendService.send(tag);
|
|
sendService.send(tag);
|