Browse Source

横向路径规划

main
maochaoying 2 years ago
parent
commit
f7dd691d91
  1. 38
      src/main/java/com/iflytop/nuclear/controller/CheckController.java
  2. 5
      src/main/java/com/iflytop/nuclear/controller/TaskController.java
  3. 29
      src/main/java/com/iflytop/nuclear/entity/CheckInfo.java
  4. 21
      src/main/java/com/iflytop/nuclear/entity/CheckResult.java
  5. 32
      src/main/java/com/iflytop/nuclear/model/Path.java
  6. 3
      src/main/java/com/iflytop/nuclear/model/Task.java
  7. 17
      src/main/java/com/iflytop/nuclear/service/CheckService.java
  8. 220
      src/main/java/com/iflytop/nuclear/service/impl/CheckServiceImpl.java
  9. BIN
      uploadfiles/xlsx/20230702/堆芯模版.xlsx

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

@ -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();
}
}

5
src/main/java/com/iflytop/nuclear/controller/TaskController.java

@ -66,6 +66,10 @@ public class TaskController {
@PostMapping("/delete/{id}")
public ResponseData deleteTask(@PathVariable(name = "id") int id) {
boolean b = taskService.removeById(id);
// 同时将对应的excel 配置删除
QueryWrapper<NuclearCoreConfig> nuclearCoreConfigQueryWrapper = new QueryWrapper<>();
nuclearCoreConfigQueryWrapper.eq("task_id", id);
boolean remove = nuclearCoreConfigService.remove(nuclearCoreConfigQueryWrapper);
JSONObject jo = new JSONObject();
jo.put("result", b);
return ResponseData.success(jo);
@ -81,5 +85,4 @@ public class TaskController {
return ResponseData.success(jo);
}
}

29
src/main/java/com/iflytop/nuclear/entity/CheckInfo.java

@ -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;
}

21
src/main/java/com/iflytop/nuclear/entity/CheckResult.java

@ -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;
}

32
src/main/java/com/iflytop/nuclear/model/Path.java

@ -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;
}

3
src/main/java/com/iflytop/nuclear/model/Task.java

@ -51,4 +51,7 @@ public class Task {
@TableField("end_time")
private Date endTime;
@TableField("current_coord")
private String currentCoord;
}

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

@ -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);
}

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

@ -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;
}
}

BIN
uploadfiles/xlsx/20230702/堆芯模版.xlsx

Loading…
Cancel
Save