|
@@ -33,8 +33,8 @@ public class DeJuRFIDServerImpl implements IService {
|
|
|
private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
|
|
private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
private final Map<String, Boolean> alarmMap = new ConcurrentHashMap<>();
|
|
private final Map<String, Boolean> alarmMap = new ConcurrentHashMap<>();
|
|
|
- static AtomicInteger stopCount = new AtomicInteger();
|
|
|
|
|
|
|
|
|
|
|
|
+ private final Map<String, Integer> stopMap = new ConcurrentHashMap<>();
|
|
|
public static final Integer PORT = 8160;
|
|
public static final Integer PORT = 8160;
|
|
|
|
|
|
|
|
private static final String HTTP_SEPARATOR = ":";
|
|
private static final String HTTP_SEPARATOR = ":";
|
|
@@ -191,21 +191,24 @@ public class DeJuRFIDServerImpl implements IService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public void alarm(RemoteLabHardware hardware) {
|
|
|
|
|
|
|
+ public boolean alarm(RemoteLabHardware hardware) {
|
|
|
//灯带设置
|
|
//灯带设置
|
|
|
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);
|
|
|
boolean alarm = false;
|
|
boolean alarm = false;
|
|
|
- if (alarmMap.containsKey(ipAddress)) {
|
|
|
|
|
- alarm = alarmMap.get(ipAddress);
|
|
|
|
|
- }
|
|
|
|
|
- log.info("报警状态:==============》{},设备IP:{}", alarm, ipAddress);
|
|
|
|
|
- if (!alarm) {
|
|
|
|
|
- alarmMap.putIfAbsent(ipAddress,true);
|
|
|
|
|
- changeGpo(ipAddress, 1, client, 10);
|
|
|
|
|
|
|
+ synchronized (this.alarmMap){
|
|
|
|
|
+ if (alarmMap.containsKey(ipAddress)) {
|
|
|
|
|
+ alarm = alarmMap.get(ipAddress);
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("报警状态:==============》{},设备IP:{}", alarm, ipAddress);
|
|
|
|
|
+ if (!alarm) {
|
|
|
|
|
+ alarmMap.putIfAbsent(ipAddress,true);
|
|
|
|
|
+ return changeGpo(ipAddress, 1, client, 10);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void close(RemoteLabHardware hardware) {
|
|
public void close(RemoteLabHardware hardware) {
|
|
@@ -227,7 +230,7 @@ public class DeJuRFIDServerImpl implements IService {
|
|
|
log.info("客户端停止读卡{}", result);
|
|
log.info("客户端停止读卡{}", result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void changeGpo(String ipAddress, int state, GClient client, int delayTime) {
|
|
|
|
|
|
|
+ private boolean changeGpo(String ipAddress, int state, GClient client, int delayTime) {
|
|
|
MsgAppSetGpo msgAppSetGpo = new MsgAppSetGpo();
|
|
MsgAppSetGpo msgAppSetGpo = new MsgAppSetGpo();
|
|
|
msgAppSetGpo.setGpo1(state);
|
|
msgAppSetGpo.setGpo1(state);
|
|
|
msgAppSetGpo.setGpo2(state);
|
|
msgAppSetGpo.setGpo2(state);
|
|
@@ -241,12 +244,20 @@ public class DeJuRFIDServerImpl implements IService {
|
|
|
stopGpo(ipAddress, client, delayTime);
|
|
stopGpo(ipAddress, client, delayTime);
|
|
|
} else {
|
|
} else {
|
|
|
alarmMap.remove(ipAddress);
|
|
alarmMap.remove(ipAddress);
|
|
|
|
|
+ stopMap.remove(ipAddress);
|
|
|
}
|
|
}
|
|
|
|
|
+ return true;
|
|
|
} else {
|
|
} else {
|
|
|
log.info("Gpo epc {} error.", status);
|
|
log.info("Gpo epc {} error.", status);
|
|
|
- if (stopCount.getAndIncrement() < MAX_RETRY) {
|
|
|
|
|
|
|
+ if (stopMap.containsKey(ipAddress)){
|
|
|
|
|
+ stopMap.put(ipAddress,stopMap.get(ipAddress)+1);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ stopMap.put(ipAddress,1);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (stopMap.get(ipAddress) <= MAX_RETRY) {
|
|
|
stopGpo(ipAddress, client, delayTime);
|
|
stopGpo(ipAddress, client, delayTime);
|
|
|
}
|
|
}
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -277,6 +288,7 @@ public class DeJuRFIDServerImpl implements IService {
|
|
|
Long replySerialNumber = logBaseEpcInfo.getReplySerialNumber();
|
|
Long replySerialNumber = logBaseEpcInfo.getReplySerialNumber();
|
|
|
log.info("===========》读取器设备编码:{},replySerialNumber: {}", readerSerialNumber, replySerialNumber);
|
|
log.info("===========》读取器设备编码:{},replySerialNumber: {}", readerSerialNumber, replySerialNumber);
|
|
|
tag.setSerialNumber(client.getSerialNumber());
|
|
tag.setSerialNumber(client.getSerialNumber());
|
|
|
|
|
+ tag.setRemoteLabHardware(redisTemplate.opsForValue().get(client.getSerialNumber()));
|
|
|
sendService.send(tag);
|
|
sendService.send(tag);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|