添加controller层
This commit is contained in:
parent
e080c719d5
commit
2854ca20b1
|
|
@ -0,0 +1,154 @@
|
||||||
|
package com.ruoyi.task.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||||
|
import com.ruoyi.task.service.dto.TaskDTO;
|
||||||
|
import com.ruoyi.task.service.dto.TaskQueryDTO;
|
||||||
|
import com.ruoyi.task.api.enums.StatusEnum;
|
||||||
|
import com.ruoyi.task.service.api.ITaskService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/task")
|
||||||
|
public class TaskController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ITaskService taskService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建无关联计划的任务
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult createTaskWithoutPlan(@RequestBody TaskDTO taskDTO)
|
||||||
|
{
|
||||||
|
Long taskId = taskService.createTaskWithoutPlan(taskDTO);
|
||||||
|
return success(taskId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取任务详细信息
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/{taskId}")
|
||||||
|
public AjaxResult getTaskById(@PathVariable("taskId") Long taskId)
|
||||||
|
{
|
||||||
|
TaskDTO taskDTO = taskService.getTaskById(taskId);
|
||||||
|
return success(taskDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复杂条件查询任务列表
|
||||||
|
*/
|
||||||
|
@PostMapping("/list")
|
||||||
|
public TableDataInfo list(@RequestBody TaskQueryDTO queryDTO)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<TaskDTO> list = taskService.getTaskList(queryDTO);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新任务
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult updateTask(@RequestBody TaskDTO taskDTO)
|
||||||
|
{
|
||||||
|
boolean result = taskService.updateTask(taskDTO);
|
||||||
|
return success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{taskId}")
|
||||||
|
public AjaxResult deleteTask(@PathVariable("taskId") Long taskId)
|
||||||
|
{
|
||||||
|
boolean result = taskService.deleteTask(taskId);
|
||||||
|
return success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据无人机ID查询任务列表
|
||||||
|
*/
|
||||||
|
@GetMapping("/uav/{uavId}")
|
||||||
|
public AjaxResult getTaskByUavId(@PathVariable("uavId") Long uavId)
|
||||||
|
{
|
||||||
|
List<TaskDTO> taskList = taskService.getTaskByUavId(uavId);
|
||||||
|
return success(taskList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据无人机ID获取最新的一条任务
|
||||||
|
*/
|
||||||
|
@GetMapping("/uav/current/{uavId}")
|
||||||
|
public AjaxResult getCurrentTaskByUavId(@PathVariable("uavId") Long uavId)
|
||||||
|
{
|
||||||
|
TaskDTO taskDTO = taskService.getCurrentTaskByUavId(uavId);
|
||||||
|
return success(taskDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改执行状态
|
||||||
|
*/
|
||||||
|
@PutMapping("/status/{taskId}")
|
||||||
|
public AjaxResult updateTaskStatus(@PathVariable("taskId") Long taskId, @RequestParam("status") StatusEnum status)
|
||||||
|
{
|
||||||
|
boolean result = taskService.updateTaskStatus(taskId, status);
|
||||||
|
return success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部调用 - 获取任务详细信息
|
||||||
|
*/
|
||||||
|
@InnerAuth
|
||||||
|
@GetMapping(value = "/inner/{taskId}")
|
||||||
|
public R<TaskDTO> getTaskByIdInner(@PathVariable("taskId") Long taskId)
|
||||||
|
{
|
||||||
|
TaskDTO taskDTO = taskService.getTaskById(taskId);
|
||||||
|
return R.ok(taskDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部调用 - 复杂条件查询任务列表
|
||||||
|
*/
|
||||||
|
@InnerAuth
|
||||||
|
@PostMapping("/inner/list")
|
||||||
|
public R<List<TaskDTO>> listInner(@RequestBody TaskQueryDTO queryDTO)
|
||||||
|
{
|
||||||
|
List<TaskDTO> list = taskService.getTaskList(queryDTO);
|
||||||
|
return R.ok(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部调用 - 根据无人机ID查询任务列表
|
||||||
|
*/
|
||||||
|
@InnerAuth
|
||||||
|
@GetMapping("/inner/uav/{uavId}")
|
||||||
|
public R<List<TaskDTO>> getTaskByUavIdInner(@PathVariable("uavId") Long uavId)
|
||||||
|
{
|
||||||
|
List<TaskDTO> taskList = taskService.getTaskByUavId(uavId);
|
||||||
|
return R.ok(taskList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部调用 - 根据无人机ID获取最新的一条任务
|
||||||
|
*/
|
||||||
|
@InnerAuth
|
||||||
|
@GetMapping("/inner/uav/current/{uavId}")
|
||||||
|
public R<TaskDTO> getCurrentTaskByUavIdInner(@PathVariable("uavId") Long uavId)
|
||||||
|
{
|
||||||
|
TaskDTO taskDTO = taskService.getCurrentTaskByUavId(uavId);
|
||||||
|
return R.ok(taskDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
package com.ruoyi.task.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.security.annotation.InnerAuth;
|
||||||
|
import com.ruoyi.task.service.dto.TaskPlanDTO;
|
||||||
|
import com.ruoyi.task.service.dto.TaskPlanQueryDTO;
|
||||||
|
import com.ruoyi.task.service.api.ITaskPlanService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务计划Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2026-01-17
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/task/plan")
|
||||||
|
public class TaskPlanController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ITaskPlanService taskPlanService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建定时任务计划
|
||||||
|
*/
|
||||||
|
@PostMapping("/timed")
|
||||||
|
public AjaxResult createTimedTaskPlan(@RequestBody TaskPlanDTO taskPlanDTO)
|
||||||
|
{
|
||||||
|
Long planId = taskPlanService.createTimedTaskPlan(taskPlanDTO);
|
||||||
|
return success(planId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建周期任务计划
|
||||||
|
*/
|
||||||
|
@PostMapping("/cycle")
|
||||||
|
public AjaxResult createCycleTaskPlan(@RequestBody TaskPlanDTO taskPlanDTO)
|
||||||
|
{
|
||||||
|
Long planId = taskPlanService.createCycleTaskPlan(taskPlanDTO);
|
||||||
|
return success(planId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取任务计划详细信息
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/{planId}")
|
||||||
|
public AjaxResult getTaskPlanById(@PathVariable("planId") Long planId)
|
||||||
|
{
|
||||||
|
TaskPlanDTO taskPlanDTO = taskPlanService.getTaskPlanById(planId);
|
||||||
|
return success(taskPlanDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 复杂条件查询任务计划列表
|
||||||
|
*/
|
||||||
|
@PostMapping("/list")
|
||||||
|
public TableDataInfo list(@RequestBody TaskPlanQueryDTO queryDTO)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<TaskPlanDTO> list = taskPlanService.getTaskPlanList(queryDTO);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新任务计划
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult updateTaskPlan(@RequestBody TaskPlanDTO taskPlanDTO)
|
||||||
|
{
|
||||||
|
boolean result = taskPlanService.updateTaskPlan(taskPlanDTO);
|
||||||
|
return success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除任务计划
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{planId}")
|
||||||
|
public AjaxResult deleteTaskPlan(@PathVariable("planId") Long planId)
|
||||||
|
{
|
||||||
|
boolean result = taskPlanService.deleteTaskPlan(planId);
|
||||||
|
return success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部调用 - 获取任务计划详细信息
|
||||||
|
*/
|
||||||
|
@InnerAuth
|
||||||
|
@GetMapping(value = "/inner/{planId}")
|
||||||
|
public R<TaskPlanDTO> getTaskPlanByIdInner(@PathVariable("planId") Long planId)
|
||||||
|
{
|
||||||
|
TaskPlanDTO taskPlanDTO = taskPlanService.getTaskPlanById(planId);
|
||||||
|
return R.ok(taskPlanDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内部调用 - 复杂条件查询任务计划列表
|
||||||
|
*/
|
||||||
|
@InnerAuth
|
||||||
|
@PostMapping("/inner/list")
|
||||||
|
public R<List<TaskPlanDTO>> listInner(@RequestBody TaskPlanQueryDTO queryDTO)
|
||||||
|
{
|
||||||
|
List<TaskPlanDTO> list = taskPlanService.getTaskPlanList(queryDTO);
|
||||||
|
return R.ok(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue