‘liusuyi’
2024-03-16 e58507190b23f09a5f4bb184164382cc519f33c4
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
package com.ruoyi.inspect.controller;
 
 
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.inspect.service.IArdVideoInspectTaskService;
import com.ruoyi.inspect.service.impl.InspectionTaskManager;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.utils.gis.GisUtil;
import com.ruoyi.utils.gis.Point;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
 
/**
 * @Description: 巡检任务controller
 * @ClassName: TaskController
 * @Author: 刘苏义
 * @Date: 2023年06月01日9:19
 * @Version: 1.0
 **/
@RestController
@Api(tags = "巡检任务")
@RequestMapping("/inspect/control")
public class TaskController {
    @Autowired
    private InspectionTaskManager inspectionTaskManager;
    @Autowired
    IArdVideoInspectTaskService ardVideoInspectTaskService;
    @Autowired
    IArdAlarmpointsWellService ardAlarmpointsWellService;
    @Autowired
    private ISysDeptService deptService;
 
    @PreAuthorize("@ss.hasPermi('inspect:control:manual')")
    @GetMapping("/startTask/{taskId}")
    @ApiOperation("手动开启巡检")
    AjaxResult startTask(@PathVariable String taskId) {
        boolean enablemanualTask = ardVideoInspectTaskService.isEnablemanualTask(taskId);
        if (enablemanualTask) {
            // 开启巡检任务
            inspectionTaskManager.startInspectionTask(taskId);
            return AjaxResult.success();
        } else {
            return AjaxResult.error();
        }
 
    }
 
    @GetMapping("/startTask/{taskId}/noPerm")
    @ApiOperation("手动开启巡检-不校验权限")
    AjaxResult startTaskNoPerm(@PathVariable String taskId) {
        boolean enablemanualTask = ardVideoInspectTaskService.isEnablemanualTask(taskId);
        if (enablemanualTask) {
            // 开启巡检任务
            inspectionTaskManager.startInspectionTask(taskId);
            return AjaxResult.success();
        } else {
            return AjaxResult.error();
        }
 
    }
 
    @PreAuthorize("@ss.hasPermi('inspect:control:manual')")
    @ApiOperation("手动停止巡检")
    @GetMapping("/stopTask/{taskId}")
    AjaxResult stopTask(@PathVariable String taskId) {
        // 停止巡检任务
        inspectionTaskManager.stopInspectionTask(taskId);
        return AjaxResult.success();
    }
 
    @ApiOperation("手动停止巡检-不校验权限")
    @GetMapping("/stopTask/{taskId}/noPerm")
    AjaxResult stopTaskNoPerm(@PathVariable String taskId) {
        // 停止巡检任务
        inspectionTaskManager.stopInspectionTask(taskId);
        return AjaxResult.success();
    }
 
    @PreAuthorize("@ss.hasPermi('inspect:control:manual')")
    @ApiOperation("查询已启动任务")
    @GetMapping("/getTaskList")
    AjaxResult getTaskList() {
        // 停止巡检任务
        Set<String> taskIds = inspectionTaskManager.getTaskMap().keySet();
        return AjaxResult.success(taskIds);
    }
 
    @ApiOperation("查询已启动任务-不校验权限")
    @GetMapping("/getTaskList/noPerm")
    AjaxResult getTaskListNoPerm() {
        // 停止巡检任务
        Set<String> taskIds = inspectionTaskManager.getTaskMap().keySet();
        return AjaxResult.success(taskIds);
    }
 
    @ApiOperation("查询范围内的井")
    @PostMapping("/getWellListByPolygon")
    AjaxResult getWellListByPolygon(@RequestBody List<Point> points) {
        List<ArdAlarmpointsWell> inPolygonWellList = deptService.selectDeptList(new SysDept()).stream()
                .map(dept -> {
                    ArdAlarmpointsWell ardAlarmpointsWell = new ArdAlarmpointsWell();
                    ardAlarmpointsWell.setDeptId(dept.getDeptId());
                    return ardAlarmpointsWellService.selectArdAlarmpointsWellList(ardAlarmpointsWell).stream()
                            .filter(well -> well.getLongitude() != null && well.getLatitude() != null)
                            .filter(well -> GisUtil.isInPolygon(new Point(well.getLongitude(), well.getLatitude()), points))
                            .collect(Collectors.toList());
                })
                .flatMap(List::stream)
                .collect(Collectors.toList());
 
        return AjaxResult.success(inPolygonWellList);
    }
}