Xiajijian
2026-03-16 ca80eded674104e580a22e6bdbea72125ba996b7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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("获取航线任务")
    @GetMapping("/flight-id")
    public ResponseResult<WaylineJobDTO> getJob(@RequestParam(name = "job_id") String jobId) {
        try {
            if(jobId == null){
                return ResponseResult.error(98,"任务ID不能为空");
            }
            Optional<WaylineJobDTO> waylineJobDTO = waylineJobService.getJobByJobId(jobId);
            if(waylineJobDTO.isEmpty()) {
                return ResponseResult.error(99,"任务不存在");
            }
            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();
    }
}