|
|
@ -55,7 +55,7 @@ public class CheckServiceImpl implements CheckService { |
|
|
|
return checkInfo; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean updateCoordAndStatus(int taskId, String currentCoord, int status) { |
|
|
|
public boolean updateCoordAndStatus(int taskId, String currentCoord, int status) throws IOException { |
|
|
|
UpdateWrapper<Task> taskUpdateWrapper = new UpdateWrapper<>(); |
|
|
|
taskUpdateWrapper.eq("id",taskId); |
|
|
|
Task task = new Task(); |
|
|
@ -64,6 +64,7 @@ public class CheckServiceImpl implements CheckService { |
|
|
|
} |
|
|
|
task.setStatus(status); |
|
|
|
boolean update = taskService.update(task, taskUpdateWrapper); |
|
|
|
this.sendMessageToPage(); |
|
|
|
return update; |
|
|
|
} |
|
|
|
|
|
|
@ -71,27 +72,25 @@ public class CheckServiceImpl implements CheckService { |
|
|
|
return messageReceived; |
|
|
|
} |
|
|
|
|
|
|
|
public void sendMessageToClient(String nextCoord, int taskId) throws IOException { |
|
|
|
DetectionMessage startMessage = DetectionMessage.builder() |
|
|
|
.messageId(IdUtil.randomUUID()) |
|
|
|
.coord(nextCoord) |
|
|
|
.taskId(taskId) |
|
|
|
.build(); |
|
|
|
webSocketServer.sendMessage(startMessage.toString()); |
|
|
|
public void sendMessageToDevice(String nextCoord, int taskId) throws IOException { |
|
|
|
// DetectionMessage startMessage = DetectionMessage.builder() |
|
|
|
// .messageId(IdUtil.randomUUID()) |
|
|
|
// .coord(nextCoord) |
|
|
|
// .taskId(taskId) |
|
|
|
// .build(); |
|
|
|
// webSocketServer.sendMessage(startMessage.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public CheckResult autoCheck(int order, String startIndex, int taskId) throws IOException { |
|
|
|
this.changeBreakOff(false); |
|
|
|
this.updateCoordAndStatus(taskId, null, 1); |
|
|
|
currentTaskId = taskId; |
|
|
|
if (order == 0) { |
|
|
|
if (startIndex == null || "".equals(startIndex)) { |
|
|
|
public void sendMessageToPage() throws IOException { |
|
|
|
webSocketServer.sendMessage("update"); |
|
|
|
} |
|
|
|
|
|
|
|
public void initCheck(String initNextCoord,int order, int taskId) throws IOException { |
|
|
|
// 指定初始化index为1-6 |
|
|
|
String nextCoord = "1-6"; |
|
|
|
String nextCoord = initNextCoord; |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 1); |
|
|
|
// 开始检测 |
|
|
|
this.sendMessageToClient(nextCoord, taskId); |
|
|
|
this.sendMessageToDevice(nextCoord, taskId); |
|
|
|
// 如果中间终止 则退出返回 与messagehandler 处理逻辑相同 外部控制while的终止 |
|
|
|
// 下一次进入后则进入其他流程 |
|
|
|
while (!"finish".equals(nextCoord)) { |
|
|
@ -113,19 +112,21 @@ public class CheckServiceImpl implements CheckService { |
|
|
|
break; |
|
|
|
} |
|
|
|
// 检测完毕后获取下一个坐标 |
|
|
|
nextCoord = this.getNextCoord(nextCoord, 0); |
|
|
|
nextCoord = this.getNextCoord(nextCoord, order); |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 1); |
|
|
|
this.sendMessageToClient(nextCoord, taskId); |
|
|
|
this.sendMessageToDevice(nextCoord, taskId); |
|
|
|
if ("finish".equals(nextCoord)) { |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 3); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
} |
|
|
|
|
|
|
|
public void continueCheck(int taskId, int order) throws IOException { |
|
|
|
// 被中断过,需要从中断的currentCoord坐标继续 |
|
|
|
// 首先需要读取数据库,获得当前taskId的信息 |
|
|
|
Task task = taskService.getById(taskId); |
|
|
|
String nextCoord = task.getCurrentCoord(); |
|
|
|
this.sendMessageToClient(nextCoord, taskId); |
|
|
|
this.sendMessageToDevice(nextCoord, taskId); |
|
|
|
// 得到的currentCoord已经检测过,直接进入下一流程 |
|
|
|
while (!"finish".equals(nextCoord)) { |
|
|
|
// 需要一个中断的接口, 中途暂停本次流程 |
|
|
@ -146,82 +147,31 @@ public class CheckServiceImpl implements CheckService { |
|
|
|
break; |
|
|
|
} |
|
|
|
// 检测完毕后获取下一个坐标 |
|
|
|
nextCoord = this.getNextCoord(nextCoord, 0); |
|
|
|
nextCoord = this.getNextCoord(nextCoord, order); |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 1); |
|
|
|
this.sendMessageToClient(nextCoord, taskId); |
|
|
|
this.sendMessageToDevice(nextCoord, taskId); |
|
|
|
if ("finish".equals(nextCoord)) { |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 3); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else if (order == 1) { |
|
|
|
|
|
|
|
@Override |
|
|
|
public CheckResult autoCheck(int order, String startIndex, int taskId) throws IOException { |
|
|
|
this.changeBreakOff(false); |
|
|
|
this.updateCoordAndStatus(taskId, null, 1); |
|
|
|
currentTaskId = taskId; |
|
|
|
if (order == 0) { |
|
|
|
if (startIndex == null || "".equals(startIndex)) { |
|
|
|
// 指定初始化index为6-1 |
|
|
|
String nextCoord = "6-1"; |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 1); |
|
|
|
// 开始检测 |
|
|
|
this.sendMessageToClient(nextCoord, taskId); |
|
|
|
// 如果中间终止 则退出返回 与messagehandler 处理逻辑相同 外部控制while的终止 |
|
|
|
// 下一次进入后则进入其他流程 |
|
|
|
while (!"finish".equals(nextCoord)) { |
|
|
|
// 需要一个中断的接口, 中途暂停本次流程 |
|
|
|
// 用messagehandler处理检测完毕的消息 从而启动以下流程 |
|
|
|
boolean breakFirst = false; |
|
|
|
while (true) { |
|
|
|
if (this.breakOff) { |
|
|
|
breakFirst = true; |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 2); |
|
|
|
break; |
|
|
|
} |
|
|
|
if (this.isMessageReceived()) { |
|
|
|
messageReceived = false; |
|
|
|
break; // 跳出循环 |
|
|
|
} |
|
|
|
} |
|
|
|
if (breakFirst) { |
|
|
|
break; |
|
|
|
} |
|
|
|
// 检测完毕后获取下一个坐标 |
|
|
|
nextCoord = this.getNextCoord(nextCoord, 1); |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 1); |
|
|
|
this.sendMessageToClient(nextCoord, taskId); |
|
|
|
if ("finish".equals(nextCoord)) { |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 3); |
|
|
|
} |
|
|
|
} |
|
|
|
this.initCheck("1-6", order, taskId); |
|
|
|
}else { |
|
|
|
// 被中断过,需要从中断的currentCoord坐标继续 |
|
|
|
// 首先需要读取数据库,获得当前taskId的信息 |
|
|
|
Task task = taskService.getById(taskId); |
|
|
|
String nextCoord = task.getCurrentCoord(); |
|
|
|
this.sendMessageToClient(nextCoord, taskId); |
|
|
|
// 得到的currentCoord已经检测过,直接进入下一流程 |
|
|
|
while (!"finish".equals(nextCoord)) { |
|
|
|
// 需要一个中断的接口, 中途暂停本次流程 |
|
|
|
// 用messagehandler处理检测完毕的消息 从而启动以下流程 |
|
|
|
boolean breakFirst = false; |
|
|
|
while (true) { |
|
|
|
if (this.breakOff) { |
|
|
|
breakFirst = true; |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 2); |
|
|
|
break; |
|
|
|
} |
|
|
|
if (this.isMessageReceived()) { |
|
|
|
messageReceived = false; |
|
|
|
break; // 跳出循环 |
|
|
|
} |
|
|
|
} |
|
|
|
if (breakFirst){ |
|
|
|
break; |
|
|
|
} |
|
|
|
// 检测完毕后获取下一个坐标 |
|
|
|
nextCoord = this.getNextCoord(nextCoord, 1); |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 1); |
|
|
|
this.sendMessageToClient(nextCoord, taskId); |
|
|
|
if ("finish".equals(nextCoord)) { |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 3); |
|
|
|
} |
|
|
|
this.continueCheck(taskId, order); |
|
|
|
} |
|
|
|
}else if (order == 1) { |
|
|
|
if (startIndex == null || "".equals(startIndex)) { |
|
|
|
this.initCheck("6-1", order, taskId); |
|
|
|
}else { |
|
|
|
this.continueCheck(taskId, order); |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|