package com.ard.web.controller.sample.wayline;
|
|
import com.ard.common.core.domain.model.LoginUser;
|
import com.ard.common.utils.SecurityUtils;
|
import com.ard.sample.common.model.PaginationData;
|
import com.ard.sample.common.model.ResponseResult;
|
import com.ard.sample.wayline.model.dto.WaylineJobDTO;
|
import com.ard.sample.wayline.model.param.CreateJobParam;
|
import com.ard.sample.wayline.service.IWaylineJobService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import javax.validation.Valid;
|
import java.sql.SQLException;
|
import java.util.Optional;
|
import java.util.Set;
|
|
/**
|
* @author sean
|
* @version 1.1
|
* @date 2022/6/1
|
*/
|
@Api(tags = "航线任务")
|
@RequestMapping("/dock/wayline")
|
@RestController
|
public class WaylineJobController {
|
|
@Autowired
|
private IWaylineJobService waylineJobService;
|
|
/**
|
* Create a wayline task for the Dock.
|
* @param param
|
* @return
|
* @throws SQLException
|
*/
|
@ApiOperation("创建航线任务")
|
@PostMapping("/flight-tasks")
|
public ResponseResult createJob(@Valid @RequestBody CreateJobParam param) throws SQLException {
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
return waylineJobService.publishFlightTask(param, loginUser);
|
}
|
|
@ApiOperation("获取航线任务")
|
@PostMapping("/flight-id")
|
public ResponseResult<WaylineJobDTO> getJob(@RequestParam(name = "job_id") String jobId) {
|
try {
|
if(jobId == null){
|
return ResponseResult.error("任务ID不能为空");
|
}
|
Optional<WaylineJobDTO> waylineJobDTO = waylineJobService.getJobByJobId(jobId);
|
if(waylineJobDTO.isEmpty()) {
|
return ResponseResult.error("任务不存在");
|
}
|
return ResponseResult.success(waylineJobDTO.get());
|
} catch (Exception e) {
|
return ResponseResult.error(e.getMessage());
|
}
|
}
|
|
/**
|
* Paginate through all jobs.
|
* @param page
|
* @param pageSize
|
* @return
|
*/
|
@ApiOperation("航线任务列表")
|
@GetMapping("/jobs")
|
public ResponseResult<PaginationData<WaylineJobDTO>> getJobs(@RequestParam(defaultValue = "1") Long page,
|
@RequestParam(name = "page_size", defaultValue = "10") Long pageSize,
|
@RequestParam(required = false) Integer status,
|
@RequestParam(required = false) Long startTime,
|
@RequestParam(required = false) Long endTime,
|
@RequestParam(required = false) Integer taskType,
|
@RequestParam(required = false) String name,
|
@RequestParam(required = false) Boolean isComplete) {
|
try {
|
// PaginationData<WaylineJobDTO> data = waylineJobService.getJobsByWorkspaceId(page, pageSize);defaultValue
|
PaginationData<WaylineJobDTO> data = waylineJobService.getJobsList(page, pageSize, status, startTime, endTime, taskType, name, isComplete);
|
return ResponseResult.success(data);
|
}
|
catch (Exception e) {
|
return ResponseResult.error(e.getMessage());
|
}
|
}
|
|
/**
|
* Send the command to cancel the jobs.
|
* @param jobIds
|
* @return
|
* @throws SQLException
|
*/
|
@ApiOperation("取消航线任务")
|
@DeleteMapping("/jobs")
|
public ResponseResult publishCancelJob(@RequestParam(name = "job_id") Set<String> jobIds){
|
return waylineJobService.cancelFlightTask(jobIds);
|
}
|
|
/**
|
* Set the media files for this job to upload immediately.
|
* @param jobId
|
* @return
|
*/
|
@ApiOperation("设置航线任务上传最高优先级")
|
@PostMapping("/{workspace_id}/jobs/{job_id}/media-highest")
|
public ResponseResult uploadMediaHighestPriority(@PathVariable(name = "job_id") String jobId) {
|
waylineJobService.uploadMediaHighestPriority(jobId);
|
return ResponseResult.success();
|
}
|
}
|