ard-work/src/main/java/com/ruoyi/inspect/mapper/ArdVideoInspectTaskMapper.java
@@ -37,13 +37,19 @@ public int insertArdVideoInspectTask(ArdVideoInspectTask ardVideoInspectTask); /** * 修改视频巡检任务 * 修改视频巡检任务-不带带当前步骤信息 * * @param ardVideoInspectTask 视频巡检任务 * @return 结果 */ public int updateArdVideoInspectTask(ArdVideoInspectTask ardVideoInspectTask); /** * 修改视频巡检任务-带当前步骤信息 * * @param ardVideoInspectTask 视频巡检任务 * @return 结果 */ public int updateArdVideoInspectTaskWithCurrentSetpInfo(ArdVideoInspectTask ardVideoInspectTask); /** * 删除视频巡检任务 * ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java
@@ -2,6 +2,7 @@ import java.text.SimpleDateFormat; import java.util.*; import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell; import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper; import com.ruoyi.common.utils.DateUtils; @@ -115,7 +116,7 @@ ardVideoInspectTask.setUpdateBy(SecurityUtils.getUsername()); ardVideoInspectTask.setUpdateTime(DateUtils.getNowDate()); // ardVideoInspectTaskMapper.deleteArdVideoInspectTaskStepByTaskId(ardVideoInspectTask.getId()); // insertArdVideoInspectTaskStep(ardVideoInspectTask); insertArdVideoInspectTaskStep(ardVideoInspectTask); return ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); } @@ -193,8 +194,7 @@ public void manualTaskRun(String TaskId) { try { ArdVideoInspectTask videoInspectTask = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(TaskId); if(!videoInspectTask.getMenualSwitch().equals("开")) { if (!videoInspectTask.getMenualSwitch().equals("开")) { return; } if (videoInspectTask.getArdVideoInspectTaskStepList().size() == 0) { @@ -308,6 +308,7 @@ continue; } videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList); String currentStepId = videoInspectTask.getCurrentStepId(); String currentStepStartTime = videoInspectTask.getCurrentStepStartTime(); if (StringUtils.isNull(currentStepId) || StringUtils.isEmpty(currentStepId)) { @@ -333,29 +334,30 @@ } } } else { if(Global.task_record.contains(videoInspectTask.getId())) { /*停止录像*/ CameraCmd cmd = new CameraCmd(); cmd.setCameraId(videoInspectTask.getCameraId()); cmd.setChannelNum(videoInspectTask.getChannel()); cmd.setOperator("sys_patrol_inspect"); cmd.setEnable(false);//停止录像 String uuid = UUID.randomUUID().toString().replace("-", ""); String time = new SimpleDateFormat("yyyyMMdd").format(new Date()); String recordName = videoInspectTask.getCameraId() + "/" + time + "/" + uuid + ".mp4"; cmd.setRecordBucketName("record"); cmd.setRecordObjectName(recordName); cmd.setUploadMinio(true); hikClientService.recordToMinio(cmd); // if(Global.task_record.contains(videoInspectTask.getId())) // { // /*停止录像*/ // CameraCmd cmd = new CameraCmd(); // cmd.setCameraId(videoInspectTask.getCameraId()); // cmd.setChannelNum(videoInspectTask.getChannel()); // cmd.setOperator("sys_patrol_inspect"); // cmd.setEnable(false);//停止录像 // String uuid = UUID.randomUUID().toString().replace("-", ""); // String time = new SimpleDateFormat("yyyyMMdd").format(new Date()); // String recordName = videoInspectTask.getCameraId() + "/" + time + "/" + uuid + ".mp4"; // cmd.setRecordBucketName("record"); // cmd.setRecordObjectName(recordName); // cmd.setUploadMinio(true); // hikClientService.recordToMinio(cmd); // } if (StringUtils.isNotEmpty(videoInspectTask.getCurrentStepId())) { videoInspectTask.setCurrentStepId(""); ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(videoInspectTask); } if (StringUtils.isEmpty(videoInspectTask.getCurrentStepId()) || StringUtils.isEmpty(videoInspectTask.getCurrentStepStartTime())) { continue; if (StringUtils.isNotEmpty(videoInspectTask.getCurrentStepStartTime())) { videoInspectTask.setCurrentStepId(""); ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(videoInspectTask); } /*过期的任务清空当前步骤信息*/ videoInspectTask.setCurrentStepId(""); videoInspectTask.setCurrentStepStartTime(""); ardVideoInspectTaskMapper.updateArdVideoInspectTask(videoInspectTask); } } } catch (Exception ex) { @@ -432,7 +434,7 @@ /*更新任务当前步骤id和步骤启动时间*/ ardVideoInspectTask.setCurrentStepId(step.getId()); ardVideoInspectTask.setCurrentStepStartTime(DateUtils.getTime()); ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); String wellId = step.getWellId(); if (!StringUtils.isNull(wellId)) { /*获取井坐标*/ @@ -457,8 +459,7 @@ cmd.setExpired(step.getRecordingTime()); boolean setTargetPosition = hikClientService.setTargetPosition(cmd); if (setTargetPosition) { if(!Global.task_record.contains(ardVideoInspectTask.getId())) { if (!Global.task_record.contains(ardVideoInspectTask.getId())) { /*控制相机巡检成功,开始录像*/ cmd.setEnable(true);//启动录像 hikClientService.recordToMinio(cmd); @@ -470,7 +471,7 @@ hikClientService.recordToMinio(cmd); /*控制失败,当前步骤启动时间置null*/ ardVideoInspectTask.setCurrentStepStartTime(""); ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); } } } @@ -478,6 +479,7 @@ log.error("巡检开始异常:" + ex.getMessage()); } } //步骤停止 private void stopRunStep(ArdVideoInspectTask ardVideoInspectTask) { try { @@ -524,6 +526,7 @@ log.error("巡检停止异常:" + ex.getMessage()); } } //步骤判断是否过期 private boolean isExpirdStep(ArdVideoInspectTask ardVideoInspectTask) { try { @@ -554,6 +557,7 @@ return false; } } //步骤切换 private String changeNextStep(ArdVideoInspectTask ardVideoInspectTask) { try { @@ -582,7 +586,7 @@ .findFirst() .orElse(null); avit.setCurrentStepId(nextStepId); ardVideoInspectTaskMapper.updateArdVideoInspectTask(avit); ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(avit); log.info("步骤:" + currentStepId + "切换为" + nextStepId); return nextStepId; } ard-work/src/main/java/com/ruoyi/inspect/service/impl/InspectionTaskManager.java
@@ -13,6 +13,7 @@ import javax.annotation.Resource; import java.util.HashMap; import java.util.List; import java.util.Map; /** @@ -46,43 +47,44 @@ public void startInspectionTask(String taskId) { if(taskMap.containsKey(taskId)) { log.info("巡检任务已启动:" + taskId); log.info("手动巡检任务已启动:" + taskId); return; } /*每次启动任务清空任务当前步骤信息*/ // /*每次启动任务清空任务当前步骤信息*/ ArdVideoInspectTask ardVideoInspectTask = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(taskId); ardVideoInspectTask.setCurrentStepId(""); ardVideoInspectTask.setCurrentStepStartTime(""); ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); /*将关联的相机录像关闭*/ if( Global.task_record.contains(taskId)) { // Integer userId = GlobalVariable.loginMap.get(ardVideoInspectTask.getCameraId());//获取当前相机的登录ID // if( GlobalVariable.user_real_Map.containsKey(userId)) // { //当前相机正在录像,则停止录像 // CameraCmd cmd = new CameraCmd(); // cmd.setCameraId(ardVideoInspectTask.getCameraId()); // cmd.setChannelNum(ardVideoInspectTask.getChannel()); // cmd.setEnable(false);//停止录像 // cmd.setUploadMinio(false); // hikClientService.recordToMinio(cmd); // } Global.task_record.remove(taskId); // ardVideoInspectTask.setCurrentStepId(""); // ardVideoInspectTask.setCurrentStepStartTime(""); // ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); String cameraId = ardVideoInspectTask.getCameraId(); /*将当前相机的所有任务当前时间置空*/ ardVideoInspectTask=new ArdVideoInspectTask(); ardVideoInspectTask.setCameraId(cameraId); List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(ardVideoInspectTask); if(ardVideoInspectTasks.size()>0) { for (ArdVideoInspectTask VideoInspectTask : ardVideoInspectTasks) { VideoInspectTask.setCurrentStepStartTime(""); ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(VideoInspectTask); /*清楚任务录像记录*/ if(Global.task_record.contains(VideoInspectTask.getId())) { Global.task_record.remove(VideoInspectTask.getId()); } } } /*开启任务*/ 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 String cameraId = ardVideoInspectTask.getCameraId(); Integer userId = GlobalVariable.loginMap.get(cameraId);//获取当前相机的登录ID if( GlobalVariable.user_real_Map.containsKey(userId)) { //当前相机正在录像,则停止录像 CameraCmd cmd = new CameraCmd(); @@ -93,14 +95,20 @@ hikClientService.recordToMinio(cmd); GlobalVariable.user_real_Map.remove(userId); } /*停止任务*/ InspectionTask task = taskMap.get(taskId); if (task != null) { task.stop(); taskMap.remove(taskId); log.info("巡检任务已停止:" + taskId); Global.task_record.remove(taskId); log.info("手动巡检任务已停止:" + taskId); /*将任务步骤信息清空*/ ardVideoInspectTask.setCurrentStepId(""); ardVideoInspectTask.setCurrentStepStartTime(""); ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); } else { log.info("找不到指定的巡检任务:" + taskId); log.info("找不到指定的手动巡检任务:" + taskId); } } } ard-work/src/main/resources/mapper/inspect/ArdVideoInspectTaskMapper.xml
@@ -121,12 +121,33 @@ <if test="channel != null">channel = #{channel},</if> <if test="deptId != null">dept_id = #{deptId},</if> <if test="userId != null">user_id = #{userId},</if> <!-- <if test="currentStepId != null">current_step_id = #{currentStepId},</if>--> <!-- <if test="currentStepStartTime != null">current_step_start_time = #{currentStepStartTime},</if>--> </trim> where id = #{id} </update> <update id="updateArdVideoInspectTaskWithCurrentSetpInfo" parameterType="ArdVideoInspectTask"> update ard_video_inspect_task <trim prefix="SET" suffixOverrides=","> <if test="taskName != null">task_name = #{taskName},</if> <if test="startTime != null">start_time = #{startTime},</if> <if test="endTime != null">end_time = #{endTime},</if> <if test="repeatPeriod != null">repeat_period = #{repeatPeriod},</if> <if test="inspectMode != null">inspect_mode = #{inspectMode},</if> <if test="menualSwitch != null">menual_switch = #{menualSwitch},</if> <if test="createBy != null">create_by = #{createBy},</if> <if test="createTime != null">create_time = #{createTime},</if> <if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateTime != null">update_time = #{updateTime},</if> <if test="cameraId != null">camera_id = #{cameraId},</if> <if test="channel != null">channel = #{channel},</if> <if test="deptId != null">dept_id = #{deptId},</if> <if test="userId != null">user_id = #{userId},</if> <if test="currentStepId != null">current_step_id = #{currentStepId},</if> <if test="currentStepStartTime != null">current_step_start_time = #{currentStepStartTime},</if> </trim> where id = #{id} </update> <delete id="deleteArdVideoInspectTaskById" parameterType="String"> delete from ard_video_inspect_task where id = #{id} </delete> @@ -157,7 +178,7 @@ </insert> <!--查询任务中相机已使用时段--> <select id="getTaskUsedCameraPeriods" parameterType="String" resultType="java.util.HashMap"> <select id="getTaskUsedCameraPeriods" parameterType="String" resultType="java.util.List"> select t.start_time,t.end_time from ard_video_inspect_task t where t.camera_id=#{startMonth} ORDER BY t.start_time