‘liusuyi’
2024-03-16 e58507190b23f09a5f4bb184164382cc519f33c4
ard-work/src/main/java/com/ruoyi/inspect/controller/TaskController.java
@@ -1,18 +1,25 @@
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.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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
@@ -29,19 +36,35 @@
    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)
        {
        if (enablemanualTask) {
            // 开启巡检任务
            inspectionTaskManager.startInspectionTask(taskId);
            return AjaxResult.success();
        } else {
            return AjaxResult.error();
        }
        else
        {
    }
    @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();
        }
@@ -55,6 +78,15 @@
        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")
@@ -63,4 +95,30 @@
        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);
    }
}