From 07cac52e0b64a78361ce4a353604c94bd1186a6c Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期四, 07 九月 2023 10:50:00 +0800 Subject: [PATCH] 更新webrtc-streamer版本 为了避免通道数和通道号混淆修改sdk请求参数channelNum为chanNo sdk接口增加聚焦值获取 --- ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java | 428 ++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 308 insertions(+), 120 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java b/ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java index 3f1c570..4ad799a 100644 --- a/ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java +++ b/ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java @@ -1,17 +1,17 @@ package com.ruoyi.inspect.service.impl; -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; +import com.ruoyi.common.utils.uuid.IdUtils; 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.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.mapper.ArdVideoInspectTaskStepMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import com.ruoyi.common.utils.StringUtils; @@ -21,7 +21,6 @@ import com.ruoyi.inspect.mapper.ArdVideoInspectTaskMapper; import com.ruoyi.inspect.domain.ArdVideoInspectTask; import com.ruoyi.inspect.service.IArdVideoInspectTaskService; - import javax.annotation.PostConstruct; import javax.annotation.Resource; @@ -32,10 +31,12 @@ * @date 2023-05-30 */ @Service -@Slf4j +@Slf4j(topic = "patrolInspectionTask") public class ArdVideoInspectTaskServiceImpl implements IArdVideoInspectTaskService { @Resource private ArdVideoInspectTaskMapper ardVideoInspectTaskMapper; + @Resource + private ArdVideoInspectTaskStepMapper ardVideoInspectTaskStepMapper; @Resource private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper; @Resource @@ -44,21 +45,23 @@ private ArdCamerasMapper ardCamerasMapper; @Resource private IHikClientService hikClientService; + @Resource + private ArdCamerasMapper camerasMapper; @PostConstruct - public void initTask() - { + public void initTask() { List<ArdVideoInspectTask> ardVideoInspectTasks = ardVideoInspectTaskMapper.selectArdVideoInspectTaskList(new ArdVideoInspectTask()); - /*鍚姩鍚庡皢鎵�鏈夋墜鍔ㄤ换鍔$疆涓哄叧闂�*/ - for(ArdVideoInspectTask ardVideoInspectTask:ardVideoInspectTasks) - { - if(ardVideoInspectTask.getInspectMode().equals("鎵嬪姩")) - { + for (ArdVideoInspectTask ardVideoInspectTask : ardVideoInspectTasks) { + /*鍚姩鍚庡皢鎵�鏈夋墜鍔ㄤ换鍔$疆涓哄叧闂�,鎵�鏈変换鍔″綋鍓嶆楠や俊鎭竻绌�*/ + if (ardVideoInspectTask.getInspectMode().equals("鎵嬪姩")) { ardVideoInspectTask.setMenualSwitch("鍏�"); - ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); } + ardVideoInspectTask.setCurrentStepId(""); + ardVideoInspectTask.setCurrentStepStartTime(""); + ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); } } + /** * 鏌ヨ瑙嗛宸℃浠诲姟 * @@ -90,6 +93,7 @@ @Transactional @Override public int insertArdVideoInspectTask(ArdVideoInspectTask ardVideoInspectTask) { + ardVideoInspectTask.setId(IdUtils.simpleUUID()); ardVideoInspectTask.setCreateBy(SecurityUtils.getUsername()); ardVideoInspectTask.setCreateTime(DateUtils.getNowDate()); ardVideoInspectTask.setUserId(SecurityUtils.getUserId()); @@ -109,7 +113,7 @@ 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); } @@ -166,15 +170,24 @@ */ public void insertArdVideoInspectTaskStep(ArdVideoInspectTask ardVideoInspectTask) { List<ArdVideoInspectTaskStep> ardVideoInspectTaskStepList = ardVideoInspectTask.getArdVideoInspectTaskStepList(); - String id = ardVideoInspectTask.getId(); + //鑾峰彇鐩告満 + ArdCameras camera = camerasMapper.selectArdCamerasById(ardVideoInspectTask.getCameraId()); + Collections.sort(ardVideoInspectTaskStepList, new ArdVideoInspectTaskStepComparator(this.ardAlarmpointsWellMapper, camera.getLongitude(), camera.getLatitude())); + String taskId = ardVideoInspectTask.getId(); + for (int i = 0; i < ardVideoInspectTaskStepList.size(); i++) { + ArdVideoInspectTaskStep step = ardVideoInspectTaskStepList.get(i); + step.setTaskId(taskId); + step.setOrderNumber(new Integer(i + 1)); + } 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); + } } } } @@ -184,35 +197,82 @@ */ @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.getMenualSwitch().equals("寮�")) { + return; } - } else /*褰撳墠浠诲姟宸茬粡鎵ц锛屽垽鏂槸鍚﹀埌鏈�*/ { - if (StringUtils.isNull(currentStepStartTime)||StringUtils.isEmpty(currentStepStartTime)) { - //褰撳墠浠诲姟鍚姩鏃堕棿涓簄ull锛屽垯璇存槑褰撳墠姝ラ琚腑鏂紝鐩存帴鍚姩褰撳墠姝ラ - startRunStep(videoInspectTask); - } else { - boolean expird = isExpirdStep(videoInspectTask); /*鍒ゆ柇褰撳墠姝ラ鏃堕棿鏄惁杩囨湡*/ - if (expird) { - //鍋滄褰曞儚 - stopRunStep(videoInspectTask); - //鍒囨崲姝ラ - String nextStepId = changeNextStep(videoInspectTask); - //寮�濮嬩笅涓�姝ラ - videoInspectTask.setCurrentStepId(nextStepId); + 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); + } + } else /*褰撳墠浠诲姟宸茬粡鎵ц锛屽垽鏂槸鍚﹀埌鏈�*/ { + if (StringUtils.isNull(currentStepStartTime) || StringUtils.isEmpty(currentStepStartTime)) { + //褰撳墠浠诲姟鍚姩鏃堕棿涓簄ull锛屽垯璇存槑褰撳墠姝ラ琚腑鏂紝鐩存帴鍚姩褰撳墠姝ラ + startRunStep(videoInspectTask); + } else { + boolean expird = isExpirdStep(videoInspectTask); /*鍒ゆ柇褰撳墠姝ラ鏃堕棿鏄惁杩囨湡*/ + if (expird) { + //鍋滄褰曞儚 + stopRunStep(videoInspectTask); + //鍒囨崲姝ラ + String nextStepId = changeNextStep(videoInspectTask); + //寮�濮嬩笅涓�姝ラ + videoInspectTask.setCurrentStepId(nextStepId); + startRunStep(videoInspectTask); + } else { + //鏈繃鏈熷皾璇曞紩瀵硷紝寮曞澶辫触娓呯┖褰撳墠姝ラ寮�濮嬫椂闂达紝鏍囪涓柇 + tryGuide(videoInspectTask); + } + } + } + } catch (Exception ex) { + log.error("鎵嬪姩宸℃寮傚父锛�" + ex.getMessage()); + } + } + + /** + * 鍒ゆ柇褰撳墠鎵嬪姩浠诲姟鑳藉惁寮�鍚� + */ + @Override + public boolean isEnablemanualTask(String TaskId) { + /*鎵弿褰撳墠鎵嬪姩寮�鐨勪换鍔★紝鑾峰彇鎵嬪姩鎺у埗鐨勭浉鏈篿dList*/ + 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; } /** @@ -220,48 +280,85 @@ */ @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(); - 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); - } + try { + /*鎵弿褰撳墠鎵嬪姩寮�鐨勪换鍔★紝鑾峰彇鎵嬪姩鎺у埗鐨勭浉鏈篿dList*/ + 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 { + tryGuide(videoInspectTask); + } + } + } + } else { + if (StringUtils.isNotEmpty(videoInspectTask.getCurrentStepId())) { + videoInspectTask.setCurrentStepId(""); + ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(videoInspectTask); + } + if (StringUtils.isNotEmpty(videoInspectTask.getCurrentStepStartTime())) { + videoInspectTask.setCurrentStepId(""); + ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(videoInspectTask); + } + } + } + } catch (Exception ex) { + log.error("鑷姩宸℃浠诲姟寮傚父锛�" + ex.getMessage()); } } + /** * 鑷姩鎵嬪姩鍚堝苟锛屾壂搴撴柟寮忥紝鐩墠涓嶄娇鐢� */ @@ -288,12 +385,12 @@ videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList); String currentStepId = videoInspectTask.getCurrentStepId();//褰撳墠姝ラid String currentStepStartTime = videoInspectTask.getCurrentStepStartTime();//褰撳墠姝ラ鍚姩鏃堕棿 - if (StringUtils.isNull(currentStepId)||StringUtils.isEmpty(currentStepId)) { + if (StringUtils.isNull(currentStepId) || StringUtils.isEmpty(currentStepId)) { //寮�濮嬬涓�涓楠� videoInspectTask.setCurrentStepId(ardVideoInspectTaskStepList.get(0).getId()); startRunStep(videoInspectTask); } else { - if (StringUtils.isNull(currentStepStartTime)||StringUtils.isEmpty(currentStepStartTime)) { + if (StringUtils.isNull(currentStepStartTime) || StringUtils.isEmpty(currentStepStartTime)) { //褰撳墠浠诲姟鍚姩鏃堕棿涓虹┖锛屽垯璇存槑褰撳墠姝ラ琚腑鏂紝鐩存帴鍚姩褰撳墠姝ラ startRunStep(videoInspectTask); } else { @@ -317,10 +414,72 @@ try { String currentStepId = ardVideoInspectTask.getCurrentStepId(); if (StringUtils.isNull(currentStepId)) { - log.info("褰撳墠寮�濮嬪贰妫�姝ラid涓虹┖"); + log.debug("褰撳墠寮�濮嬪贰妫�姝ラid涓虹┖"); return; } - log.info("姝ラ锛�" + currentStepId + "寮�濮�"); + log.debug("宸℃姝ラ锛�" + currentStepId + "灏濊瘯寮�濮�"); + String cameraId = ardVideoInspectTask.getCameraId(); + Integer channel = ardVideoInspectTask.getChannel(); + Optional<ArdVideoInspectTaskStep> objectOptional = ardVideoInspectTask.getArdVideoInspectTaskStepList().stream() + .filter(obj -> obj.getId().equals(currentStepId)) + .findFirst(); + if (objectOptional.isPresent()) { + ArdVideoInspectTaskStep step = objectOptional.get(); + /*鏇存柊浠诲姟褰撳墠姝ラid鍜屾楠ゅ惎鍔ㄦ椂闂�*/ + ardVideoInspectTask.setCurrentStepId(step.getId()); + ardVideoInspectTask.setCurrentStepStartTime(DateUtils.getTime()); + ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); + String wellId = step.getWellId(); + if (!StringUtils.isNull(wellId)) { + /*鑾峰彇浜曞潗鏍�*/ + ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellById(wellId); + double[] targetPositon = new double[3]; + targetPositon[0] = ardAlarmpointsWell.getLongitude(); + targetPositon[1] = ardAlarmpointsWell.getLatitude(); + targetPositon[2] = ardAlarmpointsWell.getAltitude(); + /*鑾峰彇鐩告満鍧愭爣*/ + ArdCameras cameras = ardCamerasMapper.selectArdCamerasById(cameraId); + if(StringUtils.isNull(cameras)) + { + log.debug("鎵句笉鍒扮浉鏈�:"+cameraId); + return; + } + double[] cameraPositon = new double[3]; + cameraPositon[0] = cameras.getLongitude(); + cameraPositon[1] = cameras.getLatitude(); + cameraPositon[2] = cameras.getAltitude(); + /*鎺у埗鐩告満宸℃*/ + CameraCmd cmd = new CameraCmd(); + cmd.setCameraId(cameraId); + cmd.setChanNo(channel); + cmd.setTargetPosition(targetPositon); + cmd.setOperator("sys_patrol_inspect"); + cmd.setExpired(step.getRecordingTime() * 60); + boolean setTargetPosition = hikClientService.guideTargetPosition(cmd); + if (setTargetPosition) { + /*鎺у埗鐩告満宸℃鎴愬姛锛屽紑濮嬪綍鍍�*/ + hikClientService.recordStart(cmd); + } else { + /*鎺у埗澶辫触,褰撳墠姝ラ鍚姩鏃堕棿缃畁ull*/ + ardVideoInspectTask.setCurrentStepStartTime(""); + ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); + } + } + } + } catch (Exception ex) { + log.error("宸℃寮�濮嬪紓甯革細" + ex.getMessage()); + } + } + + //灏濊瘯鎺у埗寮曞 + private void tryGuide(ArdVideoInspectTask ardVideoInspectTask) { + try { + String currentStepId = ardVideoInspectTask.getCurrentStepId(); + if (StringUtils.isNull(currentStepId)) { + log.debug("褰撳墠寮�濮嬪贰妫�姝ラid涓虹┖"); + return; + } + log.debug("宸℃姝e父锛屽皾璇曞紩瀵硷細" + currentStepId); String cameraId = ardVideoInspectTask.getCameraId(); Integer channel = ardVideoInspectTask.getChannel(); Optional<ArdVideoInspectTaskStep> objectOptional = ardVideoInspectTask.getArdVideoInspectTaskStepList().stream() @@ -338,6 +497,11 @@ targetPositon[2] = ardAlarmpointsWell.getAltitude(); /*鑾峰彇鐩告満鍧愭爣*/ ArdCameras cameras = ardCamerasMapper.selectArdCamerasById(cameraId); + if(StringUtils.isNull(cameras)) + { + log.debug("鎵句笉鍒扮浉鏈�:"+cameraId); + return; + } double[] cameraPositon = new double[3]; cameraPositon[0] = cameras.getLongitude(); cameraPositon[1] = cameras.getLatitude(); @@ -345,37 +509,22 @@ /*鎺у埗鐩告満宸℃*/ CameraCmd cmd = new CameraCmd(); cmd.setCameraId(cameraId); - cmd.setChannelNum(channel); - cmd.setCamPosition(cameraPositon); + cmd.setChanNo(channel); cmd.setTargetPosition(targetPositon); cmd.setOperator("sys_patrol_inspect"); - cmd.setExpired(step.getRecordingTime()); - boolean setTargetPosition = hikClientService.setTargetPosition(cmd); - if (setTargetPosition) { - /*鎺у埗鐩告満宸℃鎴愬姛锛屽紑濮嬪綍鍍�*/ - cmd.setEnable(true);//鍚姩褰曞儚 - hikClientService.recordToMinio(cmd); - /*鏇存柊浠诲姟褰撳墠姝ラid鍜屾楠ゅ惎鍔ㄦ椂闂�*/ - ArdVideoInspectTask avit = new ArdVideoInspectTask(); - avit.setId(ardVideoInspectTask.getId()); - avit.setCurrentStepId(step.getId()); - avit.setCurrentStepStartTime(DateUtils.getTime()); - ardVideoInspectTaskMapper.updateArdVideoInspectTask(avit); - } else { - cmd.setEnable(false);//鍋滄褰曞儚 - cmd.setUploadMinio(true); - hikClientService.recordToMinio(cmd); + cmd.setExpired(step.getRecordingTime() * 60); + boolean setTargetPosition = hikClientService.guideTargetPosition(cmd); + if (!setTargetPosition) { /*鎺у埗澶辫触,褰撳墠姝ラ鍚姩鏃堕棿缃畁ull*/ - ArdVideoInspectTask avit = new ArdVideoInspectTask(); - avit.setId(ardVideoInspectTask.getId()); - avit.setCurrentStepId(step.getId()); - avit.setCurrentStepStartTime(""); - ardVideoInspectTaskMapper.updateArdVideoInspectTask(avit); + ardVideoInspectTask.setCurrentStepStartTime(""); + ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); + } else { + log.debug("寮曞鎴愬姛!"); } } } } catch (Exception ex) { - log.error("宸℃寮�濮嬪紓甯革細" + ex.getMessage()); + log.error("宸℃灏濊瘯寮曞寮傚父锛�" + ex.getMessage()); } } @@ -383,7 +532,7 @@ private void stopRunStep(ArdVideoInspectTask ardVideoInspectTask) { try { String currentStepId = ardVideoInspectTask.getCurrentStepId(); - log.info("姝ラ锛�" + currentStepId + "鍋滄"); + log.debug("宸℃姝ラ锛�" + currentStepId + "鍋滄"); if (StringUtils.isNull(currentStepId)) { log.info("褰撳墠鍋滄宸℃姝ラid涓虹┖"); return; @@ -399,24 +548,22 @@ /*鍋滄褰曞儚*/ CameraCmd cmd = new CameraCmd(); cmd.setCameraId(cameraId); - cmd.setChannelNum(channel); + cmd.setChanNo(channel); cmd.setOperator("sys_patrol_inspect"); - cmd.setEnable(false);//鍋滄褰曞儚 - String uuid = UUID.randomUUID().toString().replace("-", ""); - String time = new SimpleDateFormat("yyyyMMdd").format(new Date()); - String recordName = cameraId + "/" + time + "/" + uuid + ".mp4"; cmd.setRecordBucketName("record"); - cmd.setRecordObjectName(recordName); - cmd.setUploadMinio(true); - hikClientService.recordToMinio(cmd); + cmd.setRecordObjectName("inspect_" + IdUtils.fastSimpleUUID()); + String url = hikClientService.recordStopToMinio(cmd); /*鎻掑叆宸℃璁板綍*/ ArdVideoInspectRecord ardVideoInspectRecord = new ArdVideoInspectRecord(); ardVideoInspectRecord.setStepId(step.getId()); + ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellById(step.getWellId()); + if (StringUtils.isNotNull(ardAlarmpointsWell)) { + ardVideoInspectRecord.setWellName(ardAlarmpointsWell.getWellId()); + } Date currentStepStartDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS, currentStepStartTime); Date currentStepStopDate = DateUtils.addMinutes(currentStepStartDate, step.getRecordingTime()); ardVideoInspectRecord.setStartTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, currentStepStartDate)); ardVideoInspectRecord.setEndTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, currentStepStopDate)); - String url = MinioClientSingleton.domainUrl + "/" + cmd.getRecordBucketName() + "/" + recordName; ardVideoInspectRecord.setRecordFilePath(url); ardVideoInspectRecordMapper.insertArdVideoInspectRecord(ardVideoInspectRecord); } @@ -484,7 +631,7 @@ .findFirst() .orElse(null); avit.setCurrentStepId(nextStepId); - ardVideoInspectTaskMapper.updateArdVideoInspectTask(avit); + ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(avit); log.info("姝ラ锛�" + currentStepId + "鍒囨崲涓�" + nextStepId); return nextStepId; } @@ -493,4 +640,45 @@ } return ""; } + + public List getTaskUsedCameraPeriods(String cameraId) { + return ardVideoInspectTaskMapper.getTaskUsedCameraPeriods(cameraId); + } + + /** + * 鑾峰彇鐩告満鐨勭┖闂叉椂娈� + * @param cameraId + * @return + */ + 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.size() > 0) { + if ("00:00:00".equals(timeList.getFirst())) { + timeList.removeFirst(); + } else { + timeList.addFirst("00:00:00"); + } + //鍒ゆ柇鏈�鍚庝竴涓粨鏉熸椂闂� + if ("23:59:59".equals(timeList.getLast())) { + timeList.removeLast(); + } else { + timeList.addLast("23:59:59"); + } + //浜嬩欢娈典负绌�,鍒欏叏澶╀綔涓轰竴涓椂闂存 + if (timeList.size() == 0) { + timeList.add("00:00:00"); + timeList.add("23:59:59"); + } + + } + + return timeList; + } } -- Gitblit v1.9.3