Browse Source

while finish

main
maochaoying 2 years ago
parent
commit
fd5888558d
  1. 4
      src/main/java/com/iflytop/nuclear/controller/CheckController.java
  2. 4
      src/main/java/com/iflytop/nuclear/service/CheckService.java
  3. 25
      src/main/java/com/iflytop/nuclear/service/impl/CheckServiceImpl.java

4
src/main/java/com/iflytop/nuclear/controller/CheckController.java

@ -8,6 +8,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
/**
* @author cool
* @date 2023/7/2 09:41
@ -22,7 +24,7 @@ public class CheckController {
CheckService checkService;
@GetMapping("/auto/{id}")
public ResponseData checkAuto(@PathVariable(name = "id") int taskId) {
public ResponseData checkAuto(@PathVariable(name = "id") int taskId) throws IOException {
CheckInfo checkInfo = checkService.getCheckInfoByTaskId(taskId);
int order = checkInfo.getOrder();
String startIndex = checkInfo.getCurrentCoord();

4
src/main/java/com/iflytop/nuclear/service/CheckService.java

@ -4,6 +4,8 @@ import com.iflytop.nuclear.entity.CheckInfo;
import com.iflytop.nuclear.entity.CheckResult;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
/**
* @author cool
* @date 2023/7/2 09:43
@ -13,5 +15,5 @@ public interface CheckService {
CheckInfo getCheckInfoByTaskId(int taskId);
CheckResult autoCheck(int order, String startIndex, int taskId);
CheckResult autoCheck(int order, String startIndex, int taskId) throws IOException;
}

25
src/main/java/com/iflytop/nuclear/service/impl/CheckServiceImpl.java

@ -8,9 +8,13 @@ import com.iflytop.nuclear.model.Account;
import com.iflytop.nuclear.model.Task;
import com.iflytop.nuclear.service.CheckService;
import com.iflytop.nuclear.service.TaskService;
import com.iflytop.nuclear.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.Date;
/**
* @author cool
* @date 2023/7/2 09:44
@ -20,6 +24,8 @@ public class CheckServiceImpl implements CheckService {
@Autowired
TaskService taskService;
@Autowired
WebSocketServer webSocketServer;
@Override
public CheckInfo getCheckInfoByTaskId(int taskId) {
@ -38,23 +44,30 @@ public class CheckServiceImpl implements CheckService {
Task task = new Task();
task.setCurrentCoord(currentCoord);
task.setStatus(status);
task.setStartTime(new Date());
boolean update = taskService.update(task, taskUpdateWrapper);
return update;
}
@Override
public CheckResult autoCheck(int order, String startIndex, int taskId) {
public CheckResult autoCheck(int order, String startIndex, int taskId) throws IOException {
if (order == 0) {
if (startIndex == null) {
if (startIndex == null || "".equals(startIndex)) {
// 指定初始化index为1-6
this.updateCoordAndStatus(taskId, "1-6", 1);
// 开始检测
// 检测完毕后获取下一个坐标
webSocketServer.sendMessage("开始检测 1-6");
String nextCoord = "1-6";
// 检测完毕后获取下一个坐标 用messagehandler处理检测完毕的消息 从而启动以下流程
// TODO
// 检测下一个坐标 while
// 如果中间终止 则退出返回
// 如果中间终止 则退出返回 与messagehandler 处理逻辑相同 外部控制while的终止
// 下一次进入后则进入其他流程
String nextCoord = this.getNextCoord("1-6", 0);
while (!"finish".equals(nextCoord)) {
nextCoord = this.getNextCoord(nextCoord, 0);
this.updateCoordAndStatus(taskId, nextCoord, 1);
System.out.println(nextCoord);
}
// !!! 记录规则路径上的路过但是不检测的坐标 进行排除即可
}else {
@ -171,7 +184,7 @@ public class CheckServiceImpl implements CheckService {
if (minorLine < 8){
return mainLine + "-" + (minorLine + 1);
}else {
return null;
return "finish";
}
}
}

Loading…
Cancel
Save