| | |
| | | |
| | | 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; |
| | |
| | | import com.ruoyi.inspect.domain.ArdVideoInspectTask; |
| | | import com.ruoyi.inspect.service.IArdVideoInspectTaskService; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | |
| | | @Resource |
| | | private IHikClientService hikClientService; |
| | | |
| | | @PostConstruct |
| | | public void initTask() |
| | | { |
| | | List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(new ArdVideoInspectTask()); |
| | | /*启动后将所有手动任务置为关闭*/ |
| | | for(ArdVideoInspectTask ardVideoInspectTask:ardVideoInspectTasks) |
| | | { |
| | | if(ardVideoInspectTask.getInspectMode().equals("手动")) |
| | | { |
| | | ardVideoInspectTask.setMenualSwitch("关"); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 查询视频巡检任务 |
| | | * |
| | |
| | | public int updateArdVideoInspectTask(ArdVideoInspectTask ardVideoInspectTask) { |
| | | ardVideoInspectTask.setUpdateBy(SecurityUtils.getUsername()); |
| | | ardVideoInspectTask.setUpdateTime(DateUtils.getNowDate()); |
| | | ardVideoInspectTaskMapper.deleteArdVideoInspectTaskStepByTaskId(ardVideoInspectTask.getId()) |
| | | ; |
| | | ardVideoInspectTaskMapper.deleteArdVideoInspectTaskStepByTaskId(ardVideoInspectTask.getId()); |
| | | insertArdVideoInspectTaskStep(ardVideoInspectTask); |
| | | return ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); |
| | | } |
| | | |
| | | /** |
| | | * 修改视频巡检任务,bu更新步骤 |
| | | * |
| | | * @param ardVideoInspectTask 视频巡检任务 |
| | | * @return 结果 |
| | | */ |
| | | @Transactional |
| | | @Override |
| | | public int updateArdVideoInspectTaskSingle(ArdVideoInspectTask ardVideoInspectTask) { |
| | | ardVideoInspectTask.setUpdateBy(SecurityUtils.getUsername()); |
| | | ardVideoInspectTask.setUpdateTime(DateUtils.getNowDate()); |
| | | return ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 手动巡检任务 |
| | | */ |
| | |
| | | /*遍历所有时间满足的自动任务*/ |
| | | 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) { |
| | |
| | | } |
| | | 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); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 自动手动合并,扫库方式,目前不使用 |
| | | */ |
| | | @Override |
| | | public void taskRun() { |
| | | /*扫描所有可执行任务1-时间满足2-自动*/ |
| | | ArdVideoInspectTask ardVideoInspectTask = new ArdVideoInspectTask(); |
| | | List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(ardVideoInspectTask); |
| | | for (ArdVideoInspectTask videoInspectTask : ardVideoInspectTasks) { |
| | |
| | | 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); /*判断当前步骤时间是否过期*/ |
| | |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(avit); |
| | | } else { |
| | | cmd.setEnable(false);//停止录像 |
| | | cmd.setUploadMinio(true); |
| | | hikClientService.recordToMinio(cmd); |
| | | /*控制失败,当前步骤启动时间置null*/ |
| | | ArdVideoInspectTask avit = new ArdVideoInspectTask(); |
| | |
| | | String recordName = cameraId + "/" + time + "/" + uuid + ".mp4"; |
| | | cmd.setRecordBucketName("record"); |
| | | cmd.setRecordObjectName(recordName); |
| | | cmd.setUploadMinio(true); |
| | | hikClientService.recordToMinio(cmd); |
| | | /*插入巡检记录*/ |
| | | ArdVideoInspectRecord ardVideoInspectRecord = new ArdVideoInspectRecord(); |