|
|
@ -6,15 +6,22 @@ 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.NuclearCoreConfig; |
|
|
|
import com.iflytop.nuclear.model.Path; |
|
|
|
import com.iflytop.nuclear.model.Task; |
|
|
|
import com.iflytop.nuclear.service.CheckService; |
|
|
|
import com.iflytop.nuclear.service.NuclearCoreConfigService; |
|
|
|
import com.iflytop.nuclear.service.PathService; |
|
|
|
import com.iflytop.nuclear.service.TaskService; |
|
|
|
import com.iflytop.nuclear.utils.ImageUtils; |
|
|
|
import com.iflytop.nuclear.utils.ResponseData; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
@ -31,6 +38,13 @@ public class CheckController { |
|
|
|
CheckService checkService; |
|
|
|
@Autowired |
|
|
|
NuclearCoreConfigService nuclearCoreConfigService; |
|
|
|
@Autowired |
|
|
|
@Lazy |
|
|
|
TaskService taskService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Lazy |
|
|
|
PathService pathService; |
|
|
|
|
|
|
|
@GetMapping("/auto/{id}") |
|
|
|
public ResponseData checkAuto(@PathVariable(name = "id") int taskId) throws IOException { |
|
|
@ -59,6 +73,24 @@ public class CheckController { |
|
|
|
String taskId = taskInfo.get("taskId"); |
|
|
|
String resultSerial = taskInfo.get("result_serial"); |
|
|
|
String resultImg = taskInfo.get("result_img"); |
|
|
|
|
|
|
|
// 如果当前配置中所有项都为0 则刚开始核查 |
|
|
|
QueryWrapper<NuclearCoreConfig> queryWrapper3 = new QueryWrapper(); |
|
|
|
queryWrapper3.eq("task_id", taskId); |
|
|
|
List<NuclearCoreConfig> list2 = nuclearCoreConfigService.list(queryWrapper3); |
|
|
|
boolean isStart = true; |
|
|
|
for(int k = 0; k < list2.size(); k++) { |
|
|
|
if (list2.get(k).getResult() != 0) { |
|
|
|
isStart = false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isStart) { |
|
|
|
// 更新开始时间 |
|
|
|
Task byId = taskService.getById(taskId); |
|
|
|
byId.setStartTime(new Date()); |
|
|
|
taskService.updateById(byId); |
|
|
|
} |
|
|
|
|
|
|
|
UpdateWrapper<NuclearCoreConfig> updateWrapper = new UpdateWrapper(); |
|
|
|
updateWrapper.eq("task_id", taskId).eq("serial_number", checkNumber); |
|
|
|
// 对结果进行判断 而后存入result |
|
|
@ -86,6 +118,39 @@ public class CheckController { |
|
|
|
.taskId(Integer.parseInt(taskId)) |
|
|
|
.build(); |
|
|
|
boolean update = nuclearCoreConfigService.update(nuclearCoreConfig, updateWrapper); |
|
|
|
// 核查完一个坐标后要查看当前已核查坐标数是否等于规划路径数 如果等于需要将task表中的状态改为已完成 |
|
|
|
Task byId = taskService.getById(taskId); |
|
|
|
// 查询config表中已经检查过的 长度 |
|
|
|
QueryWrapper<NuclearCoreConfig> nuclearCoreConfigQueryWrapper1 = new QueryWrapper<>(); |
|
|
|
nuclearCoreConfigQueryWrapper1.eq("task_id", taskId); |
|
|
|
List<NuclearCoreConfig> list1 = nuclearCoreConfigService.list(nuclearCoreConfigQueryWrapper1); |
|
|
|
int num = 0; |
|
|
|
for(int i = 0; i < list1.size(); i++) { |
|
|
|
if (list1.get(i).getResult() != 0) { |
|
|
|
num++; |
|
|
|
} |
|
|
|
} |
|
|
|
int checkOrder = byId.getCheckOrder(); |
|
|
|
if (checkOrder == 2) { |
|
|
|
// 复杂路径 |
|
|
|
QueryWrapper<Path> queryWrap= new QueryWrapper<>(); |
|
|
|
queryWrap.eq("task_id", taskId); |
|
|
|
List<Path> list = pathService.list(queryWrap); |
|
|
|
int allLength = list.size(); |
|
|
|
if (num == allLength) { |
|
|
|
// 已完成 |
|
|
|
byId.setStatus(3); |
|
|
|
byId.setEndTime(new Date()); |
|
|
|
taskService.updateById(byId); |
|
|
|
} |
|
|
|
}else { |
|
|
|
if (num == list1.size()) { |
|
|
|
// 已完成 |
|
|
|
byId.setStatus(3); |
|
|
|
byId.setEndTime(new Date()); |
|
|
|
taskService.updateById(byId); |
|
|
|
} |
|
|
|
} |
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
jo.put("result", update); |
|
|
|
return ResponseData.success(jo); |
|
|
|