|
|
@ -72,6 +72,7 @@ public class CheckServiceImpl implements CheckService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public CheckResult autoCheck(int order, String startIndex, int taskId) throws IOException { |
|
|
|
this.changeBreakOff(false); |
|
|
|
currentTaskId = taskId; |
|
|
|
if (order == 0) { |
|
|
|
if (startIndex == null || "".equals(startIndex)) { |
|
|
@ -89,17 +90,66 @@ public class CheckServiceImpl implements CheckService { |
|
|
|
// 下一次进入后则进入其他流程 |
|
|
|
while (!"finish".equals(nextCoord)) { |
|
|
|
// 需要一个中断的接口, 中途暂停本次流程 |
|
|
|
if (this.breakOff) { |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 2); |
|
|
|
// 用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, 0); |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 1); |
|
|
|
DetectionMessage detectionMessage = DetectionMessage.builder() |
|
|
|
.messageId(IdUtil.randomUUID()) |
|
|
|
.coord(nextCoord) |
|
|
|
.taskId(taskId) |
|
|
|
.build(); |
|
|
|
JSONObject from = JSONObject.from(detectionMessage); |
|
|
|
webSocketServer.sendMessage(from.toString()); |
|
|
|
if ("finish".equals(nextCoord)) { |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 3); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
// 被中断过,需要从中断的currentCoord坐标继续 |
|
|
|
// 首先需要读取数据库,获得当前taskId的信息 |
|
|
|
Task task = taskService.getById(taskId); |
|
|
|
String nextCoord = task.getCurrentCoord(); |
|
|
|
DetectionMessage startMessage = DetectionMessage.builder() |
|
|
|
.messageId(IdUtil.randomUUID()) |
|
|
|
.coord(nextCoord) |
|
|
|
.taskId(taskId) |
|
|
|
.build(); |
|
|
|
webSocketServer.sendMessage(startMessage.toString()); |
|
|
|
// 得到的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, 0); |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 1); |
|
|
@ -113,13 +163,10 @@ public class CheckServiceImpl implements CheckService { |
|
|
|
if ("finish".equals(nextCoord)) { |
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 3); |
|
|
|
} |
|
|
|
System.out.println(nextCoord); |
|
|
|
} |
|
|
|
}else { |
|
|
|
|
|
|
|
} |
|
|
|
}else if (order == 1) { |
|
|
|
if (startIndex == null) { |
|
|
|
if (startIndex == null || "".equals(startIndex)) { |
|
|
|
// 指定初始化index为6-1 |
|
|
|
this.updateCoordAndStatus(taskId, "6-1", 1); |
|
|
|
}else { |
|
|
|