Browse Source

启动时修改进行状态

main
maochaoying 2 years ago
parent
commit
471d5d6250
  1. 5
      src/main/java/com/iflytop/nuclear/controller/TaskController.java
  2. 6
      src/main/java/com/iflytop/nuclear/service/impl/CheckServiceImpl.java
  3. 12
      src/main/java/com/iflytop/nuclear/service/impl/TaskServiceImpl.java

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

@ -8,6 +8,7 @@ import com.iflytop.nuclear.model.NuclearCoreConfig;
import com.iflytop.nuclear.model.Task; import com.iflytop.nuclear.model.Task;
import com.iflytop.nuclear.service.NuclearCoreConfigService; import com.iflytop.nuclear.service.NuclearCoreConfigService;
import com.iflytop.nuclear.service.TaskService; import com.iflytop.nuclear.service.TaskService;
import com.iflytop.nuclear.service.impl.CheckServiceImpl;
import com.iflytop.nuclear.utils.JwtTokenUtils; import com.iflytop.nuclear.utils.JwtTokenUtils;
import com.iflytop.nuclear.utils.ResponseData; import com.iflytop.nuclear.utils.ResponseData;
import com.iflytop.nuclear.vo.TaskVO; import com.iflytop.nuclear.vo.TaskVO;
@ -39,6 +40,8 @@ public class TaskController {
NuclearCoreConfigService nuclearCoreConfigService; NuclearCoreConfigService nuclearCoreConfigService;
@Autowired @Autowired
HttpServletRequest request; HttpServletRequest request;
@Autowired
CheckServiceImpl checkServiceImpl;
@PostMapping("/create") @PostMapping("/create")
public ResponseData createTask(@RequestBody Task taskInfo) { public ResponseData createTask(@RequestBody Task taskInfo) {
@ -82,6 +85,8 @@ public class TaskController {
QueryWrapper<NuclearCoreConfig> nuclearCoreConfigQueryWrapper = new QueryWrapper<>(); QueryWrapper<NuclearCoreConfig> nuclearCoreConfigQueryWrapper = new QueryWrapper<>();
nuclearCoreConfigQueryWrapper.eq("task_id", id); nuclearCoreConfigQueryWrapper.eq("task_id", id);
boolean remove = nuclearCoreConfigService.remove(nuclearCoreConfigQueryWrapper); boolean remove = nuclearCoreConfigService.remove(nuclearCoreConfigQueryWrapper);
// 将当前任务状态修改为0
checkServiceImpl.updateCoordAndStatus(id, null, 0);
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
jo.put("result", remove); jo.put("result", remove);
return ResponseData.success(jo); return ResponseData.success(jo);

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

@ -59,9 +59,10 @@ public class CheckServiceImpl implements CheckService {
UpdateWrapper<Task> taskUpdateWrapper = new UpdateWrapper<>(); UpdateWrapper<Task> taskUpdateWrapper = new UpdateWrapper<>();
taskUpdateWrapper.eq("id",taskId); taskUpdateWrapper.eq("id",taskId);
Task task = new Task(); Task task = new Task();
task.setCurrentCoord(currentCoord);
if (currentCoord != null){
task.setCurrentCoord(currentCoord);
}
task.setStatus(status); task.setStatus(status);
task.setStartTime(new Date());
boolean update = taskService.update(task, taskUpdateWrapper); boolean update = taskService.update(task, taskUpdateWrapper);
return update; return update;
} }
@ -82,6 +83,7 @@ public class CheckServiceImpl implements CheckService {
@Override @Override
public CheckResult autoCheck(int order, String startIndex, int taskId) throws IOException { public CheckResult autoCheck(int order, String startIndex, int taskId) throws IOException {
this.changeBreakOff(false); this.changeBreakOff(false);
this.updateCoordAndStatus(taskId, null, 1);
currentTaskId = taskId; currentTaskId = taskId;
if (order == 0) { if (order == 0) {
if (startIndex == null || "".equals(startIndex)) { if (startIndex == null || "".equals(startIndex)) {

12
src/main/java/com/iflytop/nuclear/service/impl/TaskServiceImpl.java

@ -4,10 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iflytop.nuclear.mapper.TaskMapper; import com.iflytop.nuclear.mapper.TaskMapper;
import com.iflytop.nuclear.model.*; import com.iflytop.nuclear.model.*;
import com.iflytop.nuclear.service.NuclearCoreConfigService;
import com.iflytop.nuclear.service.NuclearCoreService;
import com.iflytop.nuclear.service.NuclearStationService;
import com.iflytop.nuclear.service.TaskService;
import com.iflytop.nuclear.service.*;
import com.iflytop.nuclear.vo.TaskVO; import com.iflytop.nuclear.vo.TaskVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -28,6 +25,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
NuclearCoreService nuclearCoreService; NuclearCoreService nuclearCoreService;
@Autowired @Autowired
NuclearStationService nuclearStationService; NuclearStationService nuclearStationService;
@Autowired
AccountService accountService;
@Override @Override
public List<TaskVO> getTaskInfoByUsername(String username, String user_role) { public List<TaskVO> getTaskInfoByUsername(String username, String user_role) {
@ -53,6 +52,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
Long nuclearCoreId = task.getNuclearCoreId(); Long nuclearCoreId = task.getNuclearCoreId();
NuclearCore nuclearCore = nuclearCoreService.getById(nuclearCoreId); NuclearCore nuclearCore = nuclearCoreService.getById(nuclearCoreId);
NuclearStation nuclearStation = nuclearStationService.getById(nuclearStationId); NuclearStation nuclearStation = nuclearStationService.getById(nuclearStationId);
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("username", task.getOperatorId());
Account account = accountService.getOne(queryWrapper);
TaskVO taskVO = TaskVO.builder() TaskVO taskVO = TaskVO.builder()
.taskName(task.getTaskName()) .taskName(task.getTaskName())
.checkOrder(task.getCheckOrder()) .checkOrder(task.getCheckOrder())
@ -61,7 +63,7 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
.nuclearCoreName(nuclearCore.getName()) .nuclearCoreName(nuclearCore.getName())
.nuclearStationName(nuclearStation.getName()) .nuclearStationName(nuclearStation.getName())
.publishTime(task.getPublishTime()) .publishTime(task.getPublishTime())
.operatorName(task.getOperatorId())
.operatorName(account.getNickname())
.startTime(task.getStartTime()) .startTime(task.getStartTime())
.endTime(task.getEndTime()) .endTime(task.getEndTime())
.canUpload(canUpload) .canUpload(canUpload)

Loading…
Cancel
Save