修改socket连接异常处理
This commit is contained in:
@@ -52,7 +52,11 @@ public class TagInReadThread implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
while (true) {
|
while (true) {
|
||||||
try (Socket socket = getSocket(ip)) {
|
try (Socket socket = getSocket(ip)) {
|
||||||
|
if (socket==null){
|
||||||
|
log.info("电子标签服务器连接失败,请检查ip:{}", ip);
|
||||||
|
Thread.sleep(5000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
BasTag param = new BasTag();
|
BasTag param = new BasTag();
|
||||||
param.setIp(ip);
|
param.setIp(ip);
|
||||||
param.setSpare3("2");
|
param.setSpare3("2");
|
||||||
@@ -131,6 +135,8 @@ public class TagInReadThread implements Runnable {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ public class TagOutReadThread implements Runnable {
|
|||||||
|
|
||||||
try (Socket socket = getSocket(ip)) {
|
try (Socket socket = getSocket(ip)) {
|
||||||
//下发标签
|
//下发标签
|
||||||
|
if (socket==null){
|
||||||
|
log.info("电子标签服务器连接失败,请检查ip:{}", ip);
|
||||||
|
Thread.sleep(5000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (Long tagId : collect.keySet()) {
|
for (Long tagId : collect.keySet()) {
|
||||||
List<TagTask> allTagTasks = collect.get(tagId);
|
List<TagTask> allTagTasks = collect.get(tagId);
|
||||||
Optional<TagTask> first = allTagTasks.stream().filter(x -> "0".equals(x.getStatus())).findFirst();
|
Optional<TagTask> first = allTagTasks.stream().filter(x -> "0".equals(x.getStatus())).findFirst();
|
||||||
@@ -134,6 +139,8 @@ public class TagOutReadThread implements Runnable {
|
|||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user