9 changed files with 364 additions and 1 deletions
-
38src/main/java/com/iflytop/nuclear/controller/CheckController.java
-
5src/main/java/com/iflytop/nuclear/controller/TaskController.java
-
29src/main/java/com/iflytop/nuclear/entity/CheckInfo.java
-
21src/main/java/com/iflytop/nuclear/entity/CheckResult.java
-
32src/main/java/com/iflytop/nuclear/model/Path.java
-
3src/main/java/com/iflytop/nuclear/model/Task.java
-
17src/main/java/com/iflytop/nuclear/service/CheckService.java
-
220src/main/java/com/iflytop/nuclear/service/impl/CheckServiceImpl.java
-
BINuploadfiles/xlsx/20230702/堆芯模版.xlsx
@ -0,0 +1,38 @@ |
|||
package com.iflytop.nuclear.controller; |
|||
|
|||
import com.iflytop.nuclear.entity.CheckInfo; |
|||
import com.iflytop.nuclear.entity.CheckResult; |
|||
import com.iflytop.nuclear.service.CheckService; |
|||
import com.iflytop.nuclear.utils.ResponseData; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
/** |
|||
* @author cool |
|||
* @date 2023/7/2 09:41 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@CrossOrigin |
|||
@RequestMapping("/check") |
|||
public class CheckController { |
|||
|
|||
@Autowired |
|||
CheckService checkService; |
|||
|
|||
@GetMapping("/auto/{id}") |
|||
public ResponseData checkAuto(@PathVariable(name = "id") int taskId) { |
|||
CheckInfo checkInfo = checkService.getCheckInfoByTaskId(taskId); |
|||
int order = checkInfo.getOrder(); |
|||
String startIndex = checkInfo.getCurrentCoord(); |
|||
int status = checkInfo.getStatus(); |
|||
if (status == 3) { |
|||
// 已经完成 |
|||
return ResponseData.fail("该任务已经完成,无法自动检测"); |
|||
} |
|||
// 判断当前order 0为横向检查 1为纵向检查 |
|||
CheckResult checkResult = checkService.autoCheck(order, startIndex, taskId); |
|||
return ResponseData.success(); |
|||
} |
|||
} |
@ -0,0 +1,29 @@ |
|||
package com.iflytop.nuclear.entity; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
/** |
|||
* @author cool |
|||
* @date 2023/7/2 09:49 |
|||
*/ |
|||
@Data |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class CheckInfo { |
|||
|
|||
private int order; |
|||
|
|||
/** |
|||
* 0 未开始 |
|||
* 1 进行中 |
|||
* 2 任务中断 可以继续 |
|||
* 3 已完成 |
|||
*/ |
|||
private int status; |
|||
|
|||
private String currentCoord; |
|||
} |
@ -0,0 +1,21 @@ |
|||
package com.iflytop.nuclear.entity; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
/** |
|||
* @author cool |
|||
* @date 2023/7/2 09:55 |
|||
*/ |
|||
@Data |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class CheckResult { |
|||
|
|||
private boolean isFinished; |
|||
|
|||
private String currentTestCoord; |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.iflytop.nuclear.model; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
/** |
|||
* @author cool |
|||
* @date 2023/7/2 09:59 |
|||
*/ |
|||
@Data |
|||
@TableName("path") |
|||
@Builder |
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
public class Path { |
|||
|
|||
@TableId |
|||
private int id; |
|||
@TableField("order") |
|||
private String order; |
|||
|
|||
/** |
|||
* 规则的路径可以通过代码实现得出下一个坐标,不规则的则需要记录 |
|||
*/ |
|||
@TableField("path") |
|||
private String path; |
|||
} |
@ -0,0 +1,17 @@ |
|||
package com.iflytop.nuclear.service; |
|||
|
|||
import com.iflytop.nuclear.entity.CheckInfo; |
|||
import com.iflytop.nuclear.entity.CheckResult; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
/** |
|||
* @author cool |
|||
* @date 2023/7/2 09:43 |
|||
*/ |
|||
@Transactional |
|||
public interface CheckService { |
|||
|
|||
CheckInfo getCheckInfoByTaskId(int taskId); |
|||
|
|||
CheckResult autoCheck(int order, String startIndex, int taskId); |
|||
} |
@ -0,0 +1,220 @@ |
|||
package com.iflytop.nuclear.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
|||
import com.iflytop.nuclear.entity.CheckInfo; |
|||
import com.iflytop.nuclear.entity.CheckResult; |
|||
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 org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* @author cool |
|||
* @date 2023/7/2 09:44 |
|||
*/ |
|||
@Service |
|||
public class CheckServiceImpl implements CheckService { |
|||
|
|||
@Autowired |
|||
TaskService taskService; |
|||
|
|||
@Override |
|||
public CheckInfo getCheckInfoByTaskId(int taskId) { |
|||
Task byId = taskService.getById(taskId); |
|||
CheckInfo checkInfo = CheckInfo.builder() |
|||
.order(byId.getCheckOrder()) |
|||
.status(byId.getStatus()) |
|||
.currentCoord(byId.getCurrentCoord()) |
|||
.build(); |
|||
return checkInfo; |
|||
} |
|||
|
|||
public boolean updateCoordAndStatus(int taskId, String currentCoord, int status) { |
|||
UpdateWrapper<Task> taskUpdateWrapper = new UpdateWrapper<>(); |
|||
taskUpdateWrapper.eq("id",taskId); |
|||
Task task = new Task(); |
|||
task.setCurrentCoord(currentCoord); |
|||
task.setStatus(status); |
|||
boolean update = taskService.update(task, taskUpdateWrapper); |
|||
return update; |
|||
} |
|||
|
|||
@Override |
|||
public CheckResult autoCheck(int order, String startIndex, int taskId) { |
|||
if (order == 0) { |
|||
if (startIndex == null) { |
|||
// 指定初始化index为1-6 |
|||
this.updateCoordAndStatus(taskId, "1-6", 1); |
|||
// 开始检测 |
|||
// 检测完毕后获取下一个坐标 |
|||
// 检测下一个坐标 while |
|||
// 如果中间终止 则退出返回 |
|||
// 下一次进入后则进入其他流程 |
|||
|
|||
// !!! 记录规则路径上的路过但是不检测的坐标 进行排除即可 |
|||
}else { |
|||
|
|||
} |
|||
}else if (order == 1) { |
|||
if (startIndex == null) { |
|||
// 指定初始化index为6-1 |
|||
this.updateCoordAndStatus(taskId, "6-1", 1); |
|||
}else { |
|||
|
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* 传入当前检查的坐标点 |
|||
* @return 获取下一个坐标点 |
|||
*/ |
|||
public String getNextCoord(String current, int order) { |
|||
if (current == null ) { |
|||
return null; |
|||
} |
|||
String[] split = current.split("-"); |
|||
int mainLine = Integer.parseInt(split[0]); |
|||
int minorLine = Integer.parseInt(split[1]); |
|||
// 横向一套规则 纵向一套规则 |
|||
if (order == 0) { |
|||
if (mainLine == 1) { |
|||
if (minorLine < 10){ |
|||
return mainLine + "-" + (minorLine + 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 2) { |
|||
if (minorLine > 3){ |
|||
return mainLine + "-" + (minorLine - 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 3) { |
|||
if (minorLine < 12){ |
|||
return mainLine + "-" + (minorLine + 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 4) { |
|||
if (minorLine > 2){ |
|||
return mainLine + "-" + (minorLine - 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 5) { |
|||
if (minorLine < 13){ |
|||
return mainLine + "-" + (minorLine + 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 6) { |
|||
if (minorLine > 1){ |
|||
return mainLine + "-" + (minorLine - 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 7) { |
|||
if (minorLine < 13){ |
|||
return mainLine + "-" + (minorLine + 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 8) { |
|||
if (minorLine > 1){ |
|||
return mainLine + "-" + (minorLine - 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 9) { |
|||
if (minorLine < 12){ |
|||
return mainLine + "-" + (minorLine + 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 10) { |
|||
if (minorLine > 2){ |
|||
return mainLine + "-" + (minorLine - 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 11) { |
|||
if (minorLine < 11){ |
|||
return mainLine + "-" + (minorLine + 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 12) { |
|||
if (minorLine > 4){ |
|||
return mainLine + "-" + (minorLine - 1); |
|||
}else { |
|||
return (mainLine + 1) + "-" + minorLine; |
|||
} |
|||
} |
|||
if (mainLine == 13) { |
|||
if (minorLine < 8){ |
|||
return mainLine + "-" + (minorLine + 1); |
|||
}else { |
|||
return null; |
|||
} |
|||
} |
|||
} |
|||
if (order == 1) { |
|||
if (mainLine == 1) { |
|||
|
|||
} |
|||
if (mainLine == 2) { |
|||
|
|||
} |
|||
if (mainLine == 3) { |
|||
|
|||
} |
|||
if (mainLine == 4) { |
|||
|
|||
} |
|||
if (mainLine == 5) { |
|||
|
|||
} |
|||
if (mainLine == 6) { |
|||
|
|||
} |
|||
if (mainLine == 7) { |
|||
|
|||
} |
|||
if (mainLine == 8) { |
|||
|
|||
} |
|||
if (mainLine == 9) { |
|||
|
|||
} |
|||
if (mainLine == 10) { |
|||
|
|||
} |
|||
if (mainLine == 11) { |
|||
|
|||
} |
|||
if (mainLine == 12) { |
|||
|
|||
} |
|||
if (mainLine == 13) { |
|||
|
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue