|
@ -1,10 +1,8 @@ |
|
|
package com.iflytop.nuclear.service.impl; |
|
|
package com.iflytop.nuclear.service.impl; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|
|
import com.iflytop.nuclear.entity.CheckInfo; |
|
|
import com.iflytop.nuclear.entity.CheckInfo; |
|
|
import com.iflytop.nuclear.entity.CheckResult; |
|
|
import com.iflytop.nuclear.entity.CheckResult; |
|
|
import com.iflytop.nuclear.model.Account; |
|
|
|
|
|
import com.iflytop.nuclear.model.Task; |
|
|
import com.iflytop.nuclear.model.Task; |
|
|
import com.iflytop.nuclear.service.CheckService; |
|
|
import com.iflytop.nuclear.service.CheckService; |
|
|
import com.iflytop.nuclear.service.TaskService; |
|
|
import com.iflytop.nuclear.service.TaskService; |
|
@ -24,8 +22,24 @@ public class CheckServiceImpl implements CheckService { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
TaskService taskService; |
|
|
TaskService taskService; |
|
|
@Autowired |
|
|
|
|
|
WebSocketServer webSocketServer; |
|
|
|
|
|
|
|
|
// @Autowired |
|
|
|
|
|
// WebSocketServer webSocketServer; |
|
|
|
|
|
|
|
|
|
|
|
private static boolean messageReceived = false; |
|
|
|
|
|
|
|
|
|
|
|
private static boolean breakOff = false; |
|
|
|
|
|
|
|
|
|
|
|
private static int currentTaskId = 0; |
|
|
|
|
|
|
|
|
|
|
|
// !!! 记录规则路径上的路过但是不检测的坐标 进行排除即可 |
|
|
|
|
|
|
|
|
|
|
|
public void changeMessageReceived(boolean flag) { |
|
|
|
|
|
messageReceived = flag; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void changeBreakOff(boolean flag) { |
|
|
|
|
|
breakOff = flag; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public CheckInfo getCheckInfoByTaskId(int taskId) { |
|
|
public CheckInfo getCheckInfoByTaskId(int taskId) { |
|
@ -49,26 +63,43 @@ public class CheckServiceImpl implements CheckService { |
|
|
return update; |
|
|
return update; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean isMessageReceived() { |
|
|
|
|
|
return messageReceived; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public CheckResult autoCheck(int order, String startIndex, int taskId) throws IOException { |
|
|
public CheckResult autoCheck(int order, String startIndex, int taskId) throws IOException { |
|
|
|
|
|
currentTaskId = taskId; |
|
|
if (order == 0) { |
|
|
if (order == 0) { |
|
|
if (startIndex == null || "".equals(startIndex)) { |
|
|
if (startIndex == null || "".equals(startIndex)) { |
|
|
// 指定初始化index为1-6 |
|
|
// 指定初始化index为1-6 |
|
|
this.updateCoordAndStatus(taskId, "1-6", 1); |
|
|
this.updateCoordAndStatus(taskId, "1-6", 1); |
|
|
// 开始检测 |
|
|
|
|
|
webSocketServer.sendMessage("开始检测 1-6"); |
|
|
|
|
|
String nextCoord = "1-6"; |
|
|
String nextCoord = "1-6"; |
|
|
// 检测完毕后获取下一个坐标 用messagehandler处理检测完毕的消息 从而启动以下流程 |
|
|
|
|
|
// TODO |
|
|
|
|
|
// 检测下一个坐标 while |
|
|
|
|
|
|
|
|
// 开始检测 |
|
|
|
|
|
// webSocketServer.sendMessage("开始检测 1-6"); |
|
|
// 如果中间终止 则退出返回 与messagehandler 处理逻辑相同 外部控制while的终止 |
|
|
// 如果中间终止 则退出返回 与messagehandler 处理逻辑相同 外部控制while的终止 |
|
|
// 下一次进入后则进入其他流程 |
|
|
// 下一次进入后则进入其他流程 |
|
|
while (!"finish".equals(nextCoord)) { |
|
|
while (!"finish".equals(nextCoord)) { |
|
|
|
|
|
// 需要一个中断的接口, 中途暂停本次流程 |
|
|
|
|
|
if (this.breakOff) { |
|
|
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 2); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
// 用messagehandler处理检测完毕的消息 从而启动以下流程 |
|
|
|
|
|
while (true) { |
|
|
|
|
|
if (this.isMessageReceived()) { |
|
|
|
|
|
messageReceived = false; |
|
|
|
|
|
break; // 跳出循环 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 检测完毕后获取下一个坐标 |
|
|
nextCoord = this.getNextCoord(nextCoord, 0); |
|
|
nextCoord = this.getNextCoord(nextCoord, 0); |
|
|
this.updateCoordAndStatus(taskId, nextCoord, 1); |
|
|
this.updateCoordAndStatus(taskId, nextCoord, 1); |
|
|
|
|
|
if ("finish".equals(nextCoord)) { |
|
|
|
|
|
this.updateCoordAndStatus(taskId, nextCoord, 3); |
|
|
|
|
|
} |
|
|
System.out.println(nextCoord); |
|
|
System.out.println(nextCoord); |
|
|
} |
|
|
} |
|
|
// !!! 记录规则路径上的路过但是不检测的坐标 进行排除即可 |
|
|
|
|
|
}else { |
|
|
}else { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
@ -83,6 +114,13 @@ public class CheckServiceImpl implements CheckService { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void breakOffByTaskId(int taskId) { |
|
|
|
|
|
if (taskId == currentTaskId) { |
|
|
|
|
|
this.changeBreakOff(true); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 传入当前检查的坐标点 |
|
|
* 传入当前检查的坐标点 |
|
|
* @return 获取下一个坐标点 |
|
|
* @return 获取下一个坐标点 |
|
|