| | |
| | | * @date 2023-05-30 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | @Slf4j(topic = "PatrolInspectionTask") |
| | | public class ArdVideoInspectTaskServiceImpl implements IArdVideoInspectTaskService { |
| | | @Resource |
| | | private ArdVideoInspectTaskMapper ardVideoInspectTaskMapper; |
| | |
| | | //开始下一步骤 |
| | | videoInspectTask.setCurrentStepId(nextStepId); |
| | | startRunStep(videoInspectTask); |
| | | }else{ |
| | | //未过期尝试引导,引导失败清空当前步骤开始时间,标记中断 |
| | | tryGuide(videoInspectTask); |
| | | } |
| | | } |
| | | } |
| | |
| | | //开始下一步骤 |
| | | videoInspectTask.setCurrentStepId(nextStepId); |
| | | startRunStep(videoInspectTask); |
| | | } |
| | | }else{tryGuide(videoInspectTask);} |
| | | } |
| | | } |
| | | } else { |
| | |
| | | log.info("当前开始巡检步骤id为空"); |
| | | return; |
| | | } |
| | | log.info("步骤:" + currentStepId + "开始"); |
| | | log.debug("巡检步骤:" + currentStepId + "尝试开始"); |
| | | String cameraId = ardVideoInspectTask.getCameraId(); |
| | | Integer channel = ardVideoInspectTask.getChannel(); |
| | | Optional<ArdVideoInspectTaskStep> objectOptional = ardVideoInspectTask.getArdVideoInspectTaskStepList().stream() |
| | |
| | | cmd.setChannelNum(channel); |
| | | cmd.setTargetPosition(targetPositon); |
| | | cmd.setOperator("sys_patrol_inspect"); |
| | | cmd.setExpired(step.getRecordingTime()); |
| | | cmd.setExpired(step.getRecordingTime()*60); |
| | | boolean setTargetPosition = hikClientService.setTargetPosition(cmd); |
| | | if (setTargetPosition) { |
| | | /*控制相机巡检成功,开始录像*/ |
| | | cmd.setEnable(true);//启动录像 |
| | | hikClientService.recordToMinio(cmd); |
| | | } else { |
| | | cmd.setEnable(false);//停止录像 |
| | | cmd.setUploadMinio(true); |
| | | hikClientService.recordToMinio(cmd); |
| | | /*控制失败,当前步骤启动时间置null*/ |
| | | ardVideoInspectTask.setCurrentStepStartTime(""); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); |
| | |
| | | log.error("巡检开始异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | //尝试控制引导 |
| | | private void tryGuide(ArdVideoInspectTask ardVideoInspectTask) { |
| | | try { |
| | | String currentStepId = ardVideoInspectTask.getCurrentStepId(); |
| | | if (StringUtils.isNull(currentStepId)) { |
| | | log.info("当前开始巡检步骤id为空"); |
| | | return; |
| | | } |
| | | 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(); |
| | | 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); |
| | | 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.setChannelNum(channel); |
| | | cmd.setTargetPosition(targetPositon); |
| | | cmd.setOperator("sys_patrol_inspect"); |
| | | cmd.setExpired(step.getRecordingTime()*60); |
| | | boolean setTargetPosition = hikClientService.setTargetPosition(cmd); |
| | | if (!setTargetPosition) { |
| | | /*控制失败,当前步骤启动时间置null*/ |
| | | ardVideoInspectTask.setCurrentStepStartTime(""); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("巡检尝试引导异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | //步骤停止 |
| | | private void stopRunStep(ArdVideoInspectTask ardVideoInspectTask) { |
| | | try { |
| | | String currentStepId = ardVideoInspectTask.getCurrentStepId(); |
| | | log.info("步骤:" + currentStepId + "停止"); |
| | | log.debug("巡检步骤:" + currentStepId + "停止"); |
| | | if (StringUtils.isNull(currentStepId)) { |
| | | log.info("当前停止巡检步骤id为空"); |
| | | return; |