Pu Zhibing
2024-12-25 b34f41fe5d510df413077ff9c5846955843f9e94
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package com.stylefeng.guns.modular.api;
 
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.JwtConstants;
import com.stylefeng.guns.core.page.PageInfoBT;
import com.stylefeng.guns.core.util.JwtTokenUtil;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.model.enums.ImageModelEnum;
import com.stylefeng.guns.modular.system.model.enums.VideoChannelEnum;
import com.stylefeng.guns.modular.system.model.vo.*;
import com.stylefeng.guns.modular.system.service.IPatrolTaskService;
import com.stylefeng.guns.modular.system.service.ITaskDetailService;
import com.stylefeng.guns.modular.system.util.ResultUtil;
import com.stylefeng.guns.modular.system.util.videoGateway.VideoGateway;
import com.stylefeng.guns.modular.system.util.videoGateway.model.Ship;
import com.stylefeng.guns.modular.system.util.videoGateway.model.Vehicle;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
 
/**
 * @author zhibing.pu
 * @Date 2024/12/17 20:18
 */
@RestController
@RequestMapping("/api/patrolTask")
public class PatrolTaskController extends BaseController {
 
    @Resource
    private IPatrolTaskService patrolTaskService;
    
    @Resource
    private ITaskDetailService taskDetailService;
    
    
    
    @GetMapping("/getTaskDetailList")
    @ApiOperation(value = "获取任务列表数据", tags = {"任务管理"})
    public PageInfoBT<TaskDetailList> getTaskDetailList(TaskDetailListVo vo){
        Page<TaskDetailList> pageInfo = new Page(vo.getLimit(), vo.getOffset());
        List<TaskDetailList> taskDetailList = taskDetailService.getTaskDetailList(pageInfo, vo);
        pageInfo.setRecords(taskDetailList);
        PageInfoBT<TaskDetailList> taskDetailListPageInfoBT = super.packForBT(pageInfo);
        taskDetailListPageInfoBT.setSize(vo.getOffset());
        taskDetailListPageInfoBT.setCurrent(vo.getLimit());
        return taskDetailListPageInfoBT;
    }
    
    
    
    @DeleteMapping("/delTaskDetail")
    @ApiOperation(value = "删除任务", tags = {"任务管理"})
    public ResultUtil delTaskDetail(String ids){
        List<String> id = Arrays.asList(ids.split(","));
        taskDetailService.delTaskDetail(id);
        return ResultUtil.success();
    }
    
    
    
    @PostMapping("/addPatrolTask")
    @ApiOperation(value = "添加巡查任务", tags = {"任务管理"})
    public ResultUtil addPatrolTask(@RequestBody PatrolTaskVo vo, HttpServletRequest request){
        String token = request.getHeader(JwtConstants.AUTH_HEADER);
        if (token != null && token.startsWith("Bearer ")) {
            token = token.substring(token.indexOf(" ") + 1);
        }
        String userId = JwtTokenUtil.getPrivateClaimFromToken(token, "userId");
        patrolTaskService.addPatrolTask(vo, userId);
        return ResultUtil.success();
    }
    
    @GetMapping("/getImageModel")
    @ApiOperation(value = "获取图片模型", tags = {"任务管理"})
    public ResultUtil<List<Map<String, Object>>> getImageModel(){
        ImageModelEnum[] values = ImageModelEnum.values();
        List<Map<String, Object>> list = new ArrayList<>();
        for (ImageModelEnum modelEnum : values) {
            String name = modelEnum.getName();
            String code = modelEnum.getCode();
            Map<String, Object> map = new HashMap<>();
            map.put("name", name);
            map.put("code", code);
            list.add(map);
        }
        return ResultUtil.success(list);
    }
    
    
    
    @GetMapping("/getVideoChannel")
    @ApiOperation(value = "获取视频通道", tags = {"任务管理"})
    public ResultUtil<List<Map<String, Object>>> getVideoChannel(){
        VideoChannelEnum[] values = VideoChannelEnum.values();
        List<Map<String, Object>> list = new ArrayList<>();
        for (VideoChannelEnum modelEnum : values) {
            String name = modelEnum.getName();
            Integer id = modelEnum.getId();
            Map<String, Object> map = new HashMap<>();
            map.put("name", name);
            map.put("id", id);
            list.add(map);
        }
        return ResultUtil.success(list);
    }
    
    
    @GetMapping("/getVehicleList")
    @ApiOperation(value = "获取车辆列表", tags = {"任务管理"})
    public ResultUtil<List<Vehicle>> getVehicleList(Integer year){
        List<Vehicle> vehicleList = VideoGateway.getVehicleList(null, null, null, 0);
        List<Vehicle> list = new ArrayList<>();
        if(null != year){
            for (Vehicle vehicle : vehicleList) {
                String vehicleGpsProtocol = vehicle.getVehicleGpsProtocol();
                if(2023 == year && null != vehicleGpsProtocol && vehicleGpsProtocol.equals("2")){
                    list.add(vehicle);
                }
            }
        }else{
            list = vehicleList;
        }
        return ResultUtil.success(list);
    }
    
    
    
    @GetMapping("/getShipList")
    @ApiOperation(value = "获取船舶列表", tags = {"任务管理"})
    public ResultUtil<List<Ship>> getShipList(Integer year){
        List<Ship> shipList = VideoGateway.getShipList(null, null, null, 0);
        List<Ship> list = new ArrayList<>();
        if(null != year){
            for (Ship ship : shipList) {
                String vehicleGpsProtocol = ship.getVehicleGpsProtocol();
                if(2023 == year && null != vehicleGpsProtocol && vehicleGpsProtocol.equals("2")){
                    list.add(ship);
                }
            }
        }else{
            list = shipList;
        }
        return ResultUtil.success(list);
    }
    
    
    
    @GetMapping("/getTaskRecordList")
    @ApiOperation(value = "获取任务记录列表", tags = {"任务记录"})
    public PageInfoBT<TaskRecordList> getTaskRecordList(TaskRecordListVo vo){
        Page<TaskRecordList> pageInfo = new Page(vo.getLimit(), vo.getOffset());
        List<TaskRecordList> taskRecordList = taskDetailService.getTaskRecordList(pageInfo, vo);
        pageInfo.setRecords(taskRecordList);
        PageInfoBT<TaskRecordList> taskRecordListPageInfoBT = super.packForBT(pageInfo);
        taskRecordListPageInfoBT.setSize(vo.getOffset());
        taskRecordListPageInfoBT.setCurrent(vo.getLimit());
        return taskRecordListPageInfoBT;
    }
    
    
    
    @GetMapping("/getTaskRecordInfo")
    @ApiOperation(value = "获取任务记录详情", tags = {"任务记录"})
    public ResultUtil<TaskRecordInfo> getTaskRecordInfo(Integer id){
        TaskRecordInfo taskRecordInfo = taskDetailService.getTaskRecordInfo(id);
        return ResultUtil.success(taskRecordInfo);
    }
    
    @PostMapping("/getPictureDetailsVehicle")
    @ApiOperation(value = "获取任务记录详情中的车船数据", tags = {"任务记录"})
    public ResultUtil<PictureDetailsVehicle> getPictureDetailsVehicle(@RequestBody PictureDetailsVo vo){
        PictureDetailsVehicle pictureDetailsVehicle = taskDetailService.getPictureDetailsVehicle(vo);
        return ResultUtil.success(pictureDetailsVehicle);
    }
    
    
    
    @PostMapping("/getPictureDetails")
    @ApiOperation(value = "获取任务记录详情中的视频通道数据", tags = {"任务记录"})
    public PageInfoBT<PictureDetails> getPictureDetails(@RequestBody PictureDetailsVo vo){
        Page<PictureDetails> pageInfo = new Page(vo.getLimit(), vo.getOffset());
        List<PictureDetails> pictureDetails = taskDetailService.getPictureDetails(pageInfo, vo);
        pageInfo.setRecords(pictureDetails);
        PageInfoBT<PictureDetails> pictureDetailsPageInfoBT = super.packForBT(pageInfo);
        pictureDetailsPageInfoBT.setSize(vo.getOffset());
        pictureDetailsPageInfoBT.setCurrent(vo.getLimit());
        return pictureDetailsPageInfoBT;
    }
    
    
    
    @PostMapping("/manualAudit")
    @ApiOperation(value = "人工审核视频通道数据", tags = {"任务记录"})
    public ResultUtil manualAudit(@RequestBody ManualAuditVo vo){
        return taskDetailService.manualAudit(vo);
    }
    
    
    
    @GetMapping("/downloadTaskRecord")
    @ApiOperation(value = "下载任务记录数据", tags = {"任务记录"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "列表数据id,多个逗号分隔", name = "ids", dataType = "String"),
            @ApiImplicitParam(value = "状态(1=待执行,2=进行中,3=成功,4=失败)", name = "status", dataType = "int"),
            @ApiImplicitParam(value = "规则编号", name = "code", dataType = "String"),
    })
    public void downloadTaskRecord(String ids, String code, Integer status, HttpServletResponse response){
        List<String> id = null;
        if(ToolUtil.isNotEmpty(ids)){
            String[] split = ids.split(",");
            id = Arrays.asList(split);
        }
        taskDetailService.downloadTaskRecord(id, code, status, response);
    }
}