| | |
| | | |
| | | 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; |
| | |
| | | private ArdCamerasMapper ardCamerasMapper; |
| | | @Resource |
| | | private IHikClientService hikClientService; |
| | | @Resource |
| | | private ArdCamerasMapper camerasMapper; |
| | | |
| | | @PostConstruct |
| | | public void initTask() { |
| | |
| | | } |
| | | ardVideoInspectTask.setCurrentStepId(""); |
| | | ardVideoInspectTask.setCurrentStepStartTime(""); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); |
| | | } |
| | | } |
| | | |
| | |
| | | ardVideoInspectTask.setUpdateBy(SecurityUtils.getUsername()); |
| | | ardVideoInspectTask.setUpdateTime(DateUtils.getNowDate()); |
| | | // ardVideoInspectTaskMapper.deleteArdVideoInspectTaskStepByTaskId(ardVideoInspectTask.getId()); |
| | | // insertArdVideoInspectTaskStep(ardVideoInspectTask); |
| | | insertArdVideoInspectTaskStep(ardVideoInspectTask); |
| | | return ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); |
| | | } |
| | | |
| | |
| | | */ |
| | | 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) { |
| | | if (ardVideoInspectTaskStep.getId() == null) { |
| | | //新的步骤,添加 |
| | |
| | | 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) { |
| | |
| | | continue; |
| | | } |
| | | videoInspectTask.setArdVideoInspectTaskStepList(ardVideoInspectTaskStepList); |
| | | |
| | | String currentStepId = videoInspectTask.getCurrentStepId(); |
| | | String currentStepStartTime = videoInspectTask.getCurrentStepStartTime(); |
| | | if (StringUtils.isNull(currentStepId) || StringUtils.isEmpty(currentStepId)) { |
| | |
| | | } |
| | | } |
| | | } 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) { |
| | |
| | | /*更新任务当前步骤id和步骤启动时间*/ |
| | | ardVideoInspectTask.setCurrentStepId(step.getId()); |
| | | ardVideoInspectTask.setCurrentStepStartTime(DateUtils.getTime()); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); |
| | | String wellId = step.getWellId(); |
| | | if (!StringUtils.isNull(wellId)) { |
| | | /*获取井坐标*/ |
| | |
| | | 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); |
| | |
| | | hikClientService.recordToMinio(cmd); |
| | | /*控制失败,当前步骤启动时间置null*/ |
| | | ardVideoInspectTask.setCurrentStepStartTime(""); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(ardVideoInspectTask); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask); |
| | | } |
| | | } |
| | | } |
| | |
| | | log.error("巡检开始异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | //步骤停止 |
| | | private void stopRunStep(ArdVideoInspectTask ardVideoInspectTask) { |
| | | try { |
| | |
| | | /*插入巡检记录*/ |
| | | 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)); |
| | |
| | | log.error("巡检停止异常:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | //步骤判断是否过期 |
| | | private boolean isExpirdStep(ArdVideoInspectTask ardVideoInspectTask) { |
| | | try { |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | //步骤切换 |
| | | private String changeNextStep(ArdVideoInspectTask ardVideoInspectTask) { |
| | | try { |
| | |
| | | .findFirst() |
| | | .orElse(null); |
| | | avit.setCurrentStepId(nextStepId); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTask(avit); |
| | | ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(avit); |
| | | log.info("步骤:" + currentStepId + "切换为" + nextStepId); |
| | | return nextStepId; |
| | | } |
| | |
| | | |
| | | return timeList; |
| | | } |
| | | } |
| | | } |