| | |
| | | |
| | | 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.constant.Global; |
| | | 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 com.ruoyi.inspect.mapper.ArdVideoInspectTaskStepMapper; |
| | | import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer; |
| | | 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 ArdVideoInspectTaskMapper ardVideoInspectTaskMapper; |
| | | @Resource |
| | | private ArdVideoInspectTaskStepMapper ardVideoInspectTaskStepMapper; |
| | | @Resource |
| | | private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper; |
| | | @Resource |
| | | private ArdVideoInspectRecordMapper ardVideoInspectRecordMapper; |
| | |
| | | private ArdCamerasMapper ardCamerasMapper; |
| | | @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("关"); |
| | | } |
| | | ardVideoInspectTask.setCurrentStepId(""); |
| | | ardVideoInspectTask.setCurrentStepStartTime(""); |
| | | 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); |
| | | } |
| | | |
| | |
| | | if (StringUtils.isNotNull(ardVideoInspectTaskStepList)) { |
| | | List<ArdVideoInspectTaskStep> list = new ArrayList<ArdVideoInspectTaskStep>(); |
| | | for (ArdVideoInspectTaskStep ardVideoInspectTaskStep : ardVideoInspectTaskStepList) { |
| | | ardVideoInspectTaskStep.setTaskId(id); |
| | | list.add(ardVideoInspectTaskStep); |
| | | } |
| | | if (list.size() > 0) { |
| | | ardVideoInspectTaskMapper.batchArdVideoInspectTaskStep(list); |
| | | if (ardVideoInspectTaskStep.getId() == null) { |
| | | //新的步骤,添加 |
| | | ardVideoInspectTaskStepMapper.insertArdVideoInspectTaskStep(ardVideoInspectTaskStep); |
| | | } else { |
| | | //已有步骤,更新 |
| | | ardVideoInspectTaskStepMapper.updateArdVideoInspectTaskStep(ardVideoInspectTaskStep); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 手动巡检任务 |
| | | */ |
| | | @Override |
| | | public void manualTaskRun(String TaskId) { |
| | | ArdVideoInspectTask videoInspectTask = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(TaskId); |
| | | if (videoInspectTask.getArdVideoInspectTaskStepList().size() == 0) { |
| | | return; |
| | | } |
| | | String currentStepId = videoInspectTask.getCurrentStepId(); |
| | | String currentStepStartTime = videoInspectTask.getCurrentStepStartTime(); |
| | | if (StringUtils.isNull(currentStepId)||StringUtils.isEmpty(currentStepId)) { |
| | | //从1号步骤开始 |
| | | videoInspectTask.setCurrentStepId(videoInspectTask.getArdVideoInspectTaskStepList().get(0).getId()); |
| | | if(InspectionTaskManager.taskMap.containsKey(TaskId)) { |
| | | startRunStep(videoInspectTask); |
| | | try { |
| | | ArdVideoInspectTask videoInspectTask = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(TaskId); |
| | | if (videoInspectTask.getArdVideoInspectTaskStepList().size() == 0) { |
| | | return; |
| | | } |
| | | } else /*当前任务已经执行,判断是否到期*/ { |
| | | if (StringUtils.isNull(currentStepStartTime)||StringUtils.isEmpty(currentStepStartTime)) { |
| | | //当前任务启动时间为null,则说明当前步骤被中断,直接启动当前步骤 |
| | | startRunStep(videoInspectTask); |
| | | } else { |
| | | boolean expird = isExpirdStep(videoInspectTask); /*判断当前步骤时间是否过期*/ |
| | | if (expird) { |
| | | //停止录像 |
| | | stopRunStep(videoInspectTask); |
| | | //切换步骤 |
| | | String nextStepId = changeNextStep(videoInspectTask); |
| | | //开始下一步骤 |
| | | videoInspectTask.setCurrentStepId(nextStepId); |
| | | String currentStepId = videoInspectTask.getCurrentStepId(); |
| | | String currentStepStartTime = videoInspectTask.getCurrentStepStartTime(); |
| | | if (StringUtils.isNull(currentStepId) || StringUtils.isEmpty(currentStepId)) { |
| | | //从1号步骤开始 |
| | | videoInspectTask.setCurrentStepId(videoInspectTask.getArdVideoInspectTaskStepList().get(0).getId()); |
| | | if (InspectionTaskManager.taskMap.containsKey(TaskId)) { |
| | | startRunStep(videoInspectTask); |
| | | } |
| | | } else /*当前任务已经执行,判断是否到期*/ { |
| | | if (StringUtils.isNull(currentStepStartTime) || StringUtils.isEmpty(currentStepStartTime)) { |
| | | //当前任务启动时间为null,则说明当前步骤被中断,直接启动当前步骤 |
| | | startRunStep(videoInspectTask); |
| | | } else { |
| | | boolean expird = isExpirdStep(videoInspectTask); /*判断当前步骤时间是否过期*/ |
| | | if (expird) { |
| | | //停止录像 |
| | | stopRunStep(videoInspectTask); |
| | | //切换步骤 |
| | | String nextStepId = changeNextStep(videoInspectTask); |
| | | //开始下一步骤 |
| | | videoInspectTask.setCurrentStepId(nextStepId); |
| | | startRunStep(videoInspectTask); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("手动巡检异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断当前手动任务能否开启 |
| | | */ |
| | | @Override |
| | | public boolean isEnablemanualTask(String TaskId) { |
| | | /*扫描当前手动开的任务,获取手动控制的相机idList*/ |
| | | List<String> menualCameraId = new ArrayList<>(); |
| | | ArdVideoInspectTask menualTask = new ArdVideoInspectTask(); |
| | | menualTask.setInspectMode("手动"); |
| | | menualTask.setMenualSwitch("开"); |
| | | List<ArdVideoInspectTask> menualTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(menualTask); |
| | | if (menualTasks.size() > 0) { |
| | | for (ArdVideoInspectTask task : menualTasks) { |
| | | if (StringUtils.isNull(task.getCameraId()) || StringUtils.isEmpty(task.getCameraId())) { |
| | | continue; |
| | | } |
| | | if (!menualCameraId.contains(task.getCameraId())) { |
| | | menualCameraId.add(task.getCameraId()); |
| | | } |
| | | } |
| | | } |
| | | /*判断相机是否已经被人手动控制*/ |
| | | ArdVideoInspectTask videoInspectTask = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(TaskId); |
| | | if (StringUtils.isNull(videoInspectTask)) { |
| | | return false; |
| | | } |
| | | String cameraId = videoInspectTask.getCameraId(); |
| | | if (StringUtils.isEmpty(cameraId)) { |
| | | return false; |
| | | } |
| | | if (menualCameraId.contains(cameraId)) { |
| | | /*如果当前任务关联的相机已经有人手动控制,则不允许控制*/ |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void autoTaskRun() { |
| | | /*扫描所有可执行任务1-时间满足2-自动*/ |
| | | ArdVideoInspectTask ardVideoInspectTask = new ArdVideoInspectTask(); |
| | | ardVideoInspectTask.setInspectMode("自动"); |
| | | List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(ardVideoInspectTask); |
| | | for (ArdVideoInspectTask videoInspectTask : ardVideoInspectTasks) { |
| | | /*遍历所有时间满足的自动任务*/ |
| | | boolean timeCompare = DateUtils.TimeCompare(videoInspectTask.getStartTime(), videoInspectTask.getEndTime()); |
| | | if (timeCompare) { |
| | | log.info("自动任务启动:" + videoInspectTask.getId()); |
| | | /*获取当前任务的所有巡检步骤*/ |
| | | List<ArdVideoInspectTaskStep> ardVideoInspectTaskStepList = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(videoInspectTask.getId()).getArdVideoInspectTaskStepList(); |
| | | if (ardVideoInspectTaskStepList.size() == 0) { |
| | | continue; |
| | | } |
| | | videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList); |
| | | String currentStepId = videoInspectTask.getCurrentStepId(); |
| | | if (StringUtils.isNull(currentStepId)) { |
| | | videoInspectTask.setCurrentStepId(ardVideoInspectTaskStepList.get(0).getId()); |
| | | startRunStep(videoInspectTask);//开始当前任务的第一个步骤 |
| | | } else /*当前任务已经执行,判断是否到期*/ { |
| | | if (StringUtils.isNull(videoInspectTask.getCurrentStepStartTime())) { |
| | | //当前任务启动时间为null,则说明当前步骤被中断,直接启动当前步骤 |
| | | startRunStep(videoInspectTask); |
| | | } else { |
| | | boolean expird = isExpirdStep(videoInspectTask); /*判断当前步骤时间是否过期*/ |
| | | if (expird) { |
| | | //停止录像 |
| | | stopRunStep(videoInspectTask); |
| | | //切换步骤 |
| | | String nextStepId = changeNextStep(videoInspectTask); |
| | | //开始下一步骤 |
| | | videoInspectTask.setCurrentStepId(nextStepId); |
| | | startRunStep(videoInspectTask); |
| | | } |
| | | try { |
| | | /*扫描当前手动开的任务,获取手动控制的相机idList*/ |
| | | List<String> menualCameraId = new ArrayList<>(); |
| | | ArdVideoInspectTask menualTask = new ArdVideoInspectTask(); |
| | | menualTask.setInspectMode("手动"); |
| | | menualTask.setMenualSwitch("开"); |
| | | List<ArdVideoInspectTask> menualTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(menualTask); |
| | | if (menualTasks.size() > 0) { |
| | | for (ArdVideoInspectTask task : menualTasks) { |
| | | if (StringUtils.isNull(task.getCameraId()) || StringUtils.isEmpty(task.getCameraId())) { |
| | | continue; |
| | | } |
| | | if (!menualCameraId.contains(task.getCameraId())) { |
| | | menualCameraId.add(task.getCameraId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /*扫描所有自动任务*/ |
| | | ArdVideoInspectTask autoTask = new ArdVideoInspectTask(); |
| | | autoTask.setInspectMode("自动"); |
| | | List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(autoTask); |
| | | for (ArdVideoInspectTask videoInspectTask : ardVideoInspectTasks) { |
| | | /*遍历所有时间满足的自动任务*/ |
| | | boolean timeCompare = DateUtils.TimeCompare(videoInspectTask.getStartTime(), videoInspectTask.getEndTime()); |
| | | if (timeCompare) { |
| | | if (menualCameraId.contains(videoInspectTask.getCameraId())) { |
| | | /*若当前相机正在有任务手动执行,则不执行*/ |
| | | continue; |
| | | } |
| | | /*获取当前任务的所有巡检步骤*/ |
| | | List<ArdVideoInspectTaskStep> ardVideoInspectTaskStepList = ardVideoInspectTaskMapper.selectArdVideoInspectTaskById(videoInspectTask.getId()).getArdVideoInspectTaskStepList(); |
| | | if (ardVideoInspectTaskStepList.size() == 0) { |
| | | continue; |
| | | } |
| | | videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList); |
| | | String currentStepId = videoInspectTask.getCurrentStepId(); |
| | | String currentStepStartTime = videoInspectTask.getCurrentStepStartTime(); |
| | | if (StringUtils.isNull(currentStepId) || StringUtils.isEmpty(currentStepId)) { |
| | | //开始当前任务的第一个步骤 |
| | | videoInspectTask.setCurrentStepId(ardVideoInspectTaskStepList.get(0).getId()); |
| | | startRunStep(videoInspectTask); |
| | | } else /*当前任务已经执行,判断是否到期*/ { |
| | | if (StringUtils.isNull(currentStepStartTime) || StringUtils.isEmpty(currentStepStartTime)) { |
| | | //当前任务启动时间为空,则说明当前步骤被中断,直接启动当前步骤 |
| | | startRunStep(videoInspectTask); |
| | | } else { |
| | | //判断当前步骤时间是否过期 |
| | | boolean expird = isExpirdStep(videoInspectTask); |
| | | if (expird) { |
| | | //停止录像 |
| | | stopRunStep(videoInspectTask); |
| | | //切换步骤 |
| | | String nextStepId = changeNextStep(videoInspectTask); |
| | | //开始下一步骤 |
| | | videoInspectTask.setCurrentStepId(nextStepId); |
| | | startRunStep(videoInspectTask); |
| | | } |
| | | } |
| | | } |
| | | } 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 (StringUtils.isEmpty(videoInspectTask.getCurrentStepId()) || StringUtils.isEmpty(videoInspectTask.getCurrentStepStartTime())) { |
| | | continue; |
| | | } |
| | | /*过期的任务清空当前步骤信息*/ |
| | | videoInspectTask.setCurrentStepId(""); |
| | | videoInspectTask.setCurrentStepStartTime(""); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(videoInspectTask); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("自动巡检任务异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 自动手动合并,扫库方式,目前不使用 |
| | | */ |
| | | @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); /*判断当前步骤时间是否过期*/ |
| | |
| | | cmd.setExpired(step.getRecordingTime()); |
| | | boolean setTargetPosition = hikClientService.setTargetPosition(cmd); |
| | | if (setTargetPosition) { |
| | | /*控制相机巡检成功,开始录像*/ |
| | | cmd.setEnable(true);//启动录像 |
| | | hikClientService.recordToMinio(cmd); |
| | | if(!Global.task_record.contains(ardVideoInspectTask.getId())) |
| | | { |
| | | /*控制相机巡检成功,开始录像*/ |
| | | cmd.setEnable(true);//启动录像 |
| | | hikClientService.recordToMinio(cmd); |
| | | Global.task_record.add(ardVideoInspectTask.getId()); |
| | | } |
| | | /*更新任务当前步骤id和步骤启动时间*/ |
| | | ArdVideoInspectTask avit = new ArdVideoInspectTask(); |
| | | avit.setId(ardVideoInspectTask.getId()); |
| | | avit.setCurrentStepId(step.getId()); |
| | | avit.setCurrentStepStartTime(DateUtils.getTime()); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(avit); |
| | | ardVideoInspectTask.setCurrentStepId(step.getId()); |
| | | ardVideoInspectTask.setCurrentStepStartTime(DateUtils.getTime()); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); |
| | | } else { |
| | | cmd.setEnable(false);//停止录像 |
| | | cmd.setUploadMinio(true); |
| | | hikClientService.recordToMinio(cmd); |
| | | /*控制失败,当前步骤启动时间置null*/ |
| | | ArdVideoInspectTask avit = new ArdVideoInspectTask(); |
| | | avit.setId(ardVideoInspectTask.getId()); |
| | | avit.setCurrentStepId(step.getId()); |
| | | avit.setCurrentStepStartTime(""); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(avit); |
| | | ardVideoInspectTask.setCurrentStepStartTime(""); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); |
| | | } |
| | | } |
| | | } |
| | |
| | | log.error("巡检开始异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | //步骤停止 |
| | | private void stopRunStep(ArdVideoInspectTask ardVideoInspectTask) { |
| | | try { |
| | |
| | | String recordName = cameraId + "/" + time + "/" + uuid + ".mp4"; |
| | | cmd.setRecordBucketName("record"); |
| | | cmd.setRecordObjectName(recordName); |
| | | cmd.setUploadMinio(true); |
| | | hikClientService.recordToMinio(cmd); |
| | | Global.task_record.remove(ardVideoInspectTask.getId()); |
| | | /*插入巡检记录*/ |
| | | ArdVideoInspectRecord ardVideoInspectRecord = new ArdVideoInspectRecord(); |
| | | ardVideoInspectRecord.setStepId(step.getId()); |
| | |
| | | } |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | public List getTaskUsedCameraPeriods(String cameraId) { |
| | | return ardVideoInspectTaskMapper.getTaskUsedCameraPeriods(cameraId); |
| | | } |
| | | |
| | | public List getCameraIdleTimeList(String cameraId) { |
| | | LinkedList<String> timeList = new LinkedList(); |
| | | List<Map> usedPeriods = this.getTaskUsedCameraPeriods(cameraId); |
| | | for (Map p : |
| | | usedPeriods) { |
| | | timeList.add((String) p.get("start_time")); |
| | | timeList.add((String) p.get("end_time")); |
| | | } |
| | | //判断第一个起始点 |
| | | if (timeList.getFirst().equals("00:00:00")) { |
| | | timeList.removeFirst(); |
| | | } else { |
| | | timeList.addFirst("00:00:00"); |
| | | } |
| | | //判断最后一个结束时间 |
| | | if (timeList.getLast().equals("23:59:59")) { |
| | | timeList.removeLast(); |
| | | } else { |
| | | timeList.addLast("23:59:59"); |
| | | } |
| | | //事件段为空,则全天作为一个时间段 |
| | | if (timeList.size() == 0) { |
| | | timeList.add("00:00:00"); |
| | | timeList.add("23:59:59"); |
| | | } |
| | | |
| | | return timeList; |
| | | } |
| | | } |