‘liusuyi’
2023-06-01 eb0f13efdbd48b88411b4ff214bb92169202d157
优化光电巡检手动控制
已修改4个文件
71 ■■■■■ 文件已修改
ard-work/src/main/java/com/ruoyi/inspect/controller/TaskController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/inspect/service/impl/InspectionTaskManager.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/logback.xml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/inspect/controller/TaskController.java
@@ -8,8 +8,10 @@
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 java.util.Map;
@@ -24,11 +26,12 @@
 **/
@RestController
@Api(tags = "巡检任务")
@Anonymous
@RequestMapping("/inspect/control")
public class TaskController {
    @Autowired
    private InspectionTaskManager inspectionTaskManager;
    @PreAuthorize("@ss.hasPermi('inspect:control:manual')")
    @GetMapping("/startTask/{taskId}")
    @ApiOperation("手动开启巡检")
    AjaxResult startTask(@PathVariable String taskId) {
@@ -36,6 +39,8 @@
        inspectionTaskManager.startInspectionTask(taskId);
        return AjaxResult.success();
    }
    @PreAuthorize("@ss.hasPermi('inspect:control:manual')")
    @ApiOperation("手动停止巡检")
    @GetMapping("/stopTask/{taskId}")
    AjaxResult stopTask(@PathVariable String taskId) {
@@ -43,6 +48,7 @@
        inspectionTaskManager.stopInspectionTask(taskId);
        return AjaxResult.success();
    }
    @PreAuthorize("@ss.hasPermi('inspect:control:manual')")
    @ApiOperation("查询已启动任务")
    @GetMapping("/getTaskList")
    AjaxResult getTaskList() {
ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java
@@ -2,25 +2,18 @@
import java.text.SimpleDateFormat;
import java.util.*;
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper;
import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.camera.mapper.ArdCamerasMapper;
import com.ruoyi.device.camera.service.IArdCamerasService;
import com.ruoyi.device.hiksdk.config.MinioClientSingleton;
import com.ruoyi.device.hiksdk.service.IHikClientService;
import com.ruoyi.inspect.domain.ArdVideoInspectRecord;
import com.ruoyi.inspect.mapper.ArdVideoInspectRecordMapper;
import com.ruoyi.inspect.service.IArdVideoInspectRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.transaction.annotation.Transactional;
@@ -28,7 +21,6 @@
import com.ruoyi.inspect.mapper.ArdVideoInspectTaskMapper;
import com.ruoyi.inspect.domain.ArdVideoInspectTask;
import com.ruoyi.inspect.service.IArdVideoInspectTaskService;
import javax.annotation.Resource;
/**
@@ -158,7 +150,6 @@
        }
    }
    /**
     * 手动巡检任务
     */
@@ -208,7 +199,7 @@
            /*遍历所有时间满足的自动任务*/
            boolean timeCompare = DateUtils.TimeCompare(videoInspectTask.getStartTime(), videoInspectTask.getEndTime());
            if (timeCompare) {
                log.info("自动任务启动:" + videoInspectTask.getId());
                //log.info("自动任务启动:" + videoInspectTask.getId());
                /*获取当前任务的所有巡检步骤*/
                List<ArdVideoInspectTaskStep> ardVideoInspectTaskStepList = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(videoInspectTask.getId()).getArdVideoInspectTaskStepList();
                if (ardVideoInspectTaskStepList.size() == 0) {
@@ -216,15 +207,18 @@
                }
                videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList);
                String currentStepId = videoInspectTask.getCurrentStepId();
                if (StringUtils.isNull(currentStepId)) {
                String currentStepStartTime = videoInspectTask.getCurrentStepStartTime();
                if (StringUtils.isNull(currentStepId)||StringUtils.isEmpty(currentStepId)) {
                    //开始当前任务的第一个步骤
                    videoInspectTask.setCurrentStepId(ardVideoInspectTaskStepList.get(0).getId());
                    startRunStep(videoInspectTask);//开始当前任务的第一个步骤
                    startRunStep(videoInspectTask);
                } else /*当前任务已经执行,判断是否到期*/ {
                    if (StringUtils.isNull(videoInspectTask.getCurrentStepStartTime())) {
                        //当前任务启动时间为null,则说明当前步骤被中断,直接启动当前步骤
                    if (StringUtils.isNull(currentStepStartTime)||StringUtils.isEmpty(currentStepStartTime)) {
                        //当前任务启动时间为空,则说明当前步骤被中断,直接启动当前步骤
                        startRunStep(videoInspectTask);
                    } else {
                        boolean expird = isExpirdStep(videoInspectTask); /*判断当前步骤时间是否过期*/
                        //判断当前步骤时间是否过期
                        boolean expird = isExpirdStep(videoInspectTask);
                        if (expird) {
                            //停止录像
                            stopRunStep(videoInspectTask);
@@ -239,10 +233,11 @@
            }
        }
    }
    /**
     * 自动手动合并,扫库方式,目前不使用
     */
    @Override
    public void taskRun() {
        /*扫描所有可执行任务1-时间满足2-自动*/
        ArdVideoInspectTask ardVideoInspectTask = new ArdVideoInspectTask();
        List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(ardVideoInspectTask);
        for (ArdVideoInspectTask videoInspectTask : ardVideoInspectTasks) {
@@ -262,13 +257,15 @@
                continue;
            }
            videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList);
            String currentStepId = videoInspectTask.getCurrentStepId();
            if (StringUtils.isNull(currentStepId)) {
            String currentStepId = videoInspectTask.getCurrentStepId();//当前步骤id
            String currentStepStartTime = videoInspectTask.getCurrentStepStartTime();//当前步骤启动时间
            if (StringUtils.isNull(currentStepId)||StringUtils.isEmpty(currentStepId)) {
                //开始第一个步骤
                videoInspectTask.setCurrentStepId(ardVideoInspectTaskStepList.get(0).getId());
                startRunStep(videoInspectTask);//开始当前任务的第一个步骤
            } else /*当前任务已经执行,判断是否到期*/ {
                if (StringUtils.isNull(videoInspectTask.getCurrentStepStartTime())) {
                    //当前任务启动时间为null,则说明当前步骤被中断,直接启动当前步骤
                startRunStep(videoInspectTask);
            } else {
                if (StringUtils.isNull(currentStepStartTime)||StringUtils.isEmpty(currentStepStartTime)) {
                    //当前任务启动时间为空,则说明当前步骤被中断,直接启动当前步骤
                    startRunStep(videoInspectTask);
                } else {
                    boolean expird = isExpirdStep(videoInspectTask); /*判断当前步骤时间是否过期*/
ard-work/src/main/java/com/ruoyi/inspect/service/impl/InspectionTaskManager.java
@@ -15,7 +15,7 @@
import java.util.Map;
/**
 * @Description:
 * @Description: 巡检任务管理
 * @ClassName: InspectionTaskManager
 * @Author: 刘苏义
 * @Date: 2023年06月01日10:40
@@ -31,7 +31,7 @@
    @Resource
    private IHikClientService hikClientService;
    public static Map<String, InspectionTask> taskMap;
    public static Map<String, InspectionTask> taskMap;//已启动任务map
    public InspectionTaskManager() {
        taskMap = new HashMap<>();
@@ -41,7 +41,14 @@
        return taskMap;
    }
    /*启动任务*/
    public void startInspectionTask(String taskId) {
        if(taskMap.containsKey(taskId))
        {
            log.info("巡检任务已启动:" + taskId);
            return;
        }
        /*每次启动任务清空任务当前步骤信息*/
        ArdVideoInspectTask ardVideoInspectTask = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(taskId);
        ardVideoInspectTask.setCurrentStepId("");
        ardVideoInspectTask.setCurrentStepStartTime("");
@@ -50,15 +57,16 @@
        InspectionTask task = new InspectionTask(taskId);
        task.start();
        taskMap.put(taskId, task);
        log.info("巡检任务已启动:" + taskId);
        log.info("巡检任务启动:" + taskId);
    }
    /*停止任务*/
    public void stopInspectionTask(String taskId) {
        /*将任务步骤信息清空*/
        ArdVideoInspectTask ardVideoInspectTask = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(taskId);
        ardVideoInspectTask.setCurrentStepId("");
        ardVideoInspectTask.setCurrentStepStartTime("");
        ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask);
        /*将关联的相机录像关闭*/
        Integer userId = GlobalVariable.loginMap.get(ardVideoInspectTask.getCameraId());//获取当前相机的登录ID
        if( GlobalVariable.user_real_Map.containsKey(userId))
        {   //当前相机正在录像,则停止录像
ruoyi-admin/src/main/resources/logback.xml
@@ -69,7 +69,6 @@
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
    <!-- Authorize日志输出  -->
    <appender name="Authorize" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/Authorize.log</file>
@@ -83,7 +82,6 @@
            <pattern>${log.pattern}</pattern>
        </encoder>
    </appender>
    <!--hikSdk日志输出-->
    <appender name="hikSdk" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${log.path}/hikSdk.log</file>