From 740f379847e21878429b7cb48bebfa9d2b72ab94 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期三, 20 九月 2023 11:38:57 +0800
Subject: [PATCH] 设备健康列表
---
ard-work/src/main/java/com/ruoyi/inspect/service/impl/ArdVideoInspectTaskServiceImpl.java | 97 ++++++++++++++++++++++++++++--------------------
1 files changed, 56 insertions(+), 41 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 df4af33..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,15 +1,13 @@
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;
@@ -23,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;
@@ -34,7 +31,7 @@
* @date 2023-05-30
*/
@Service
-@Slf4j(topic = "PatrolInspectionTask")
+@Slf4j(topic = "patrolInspectionTask")
public class ArdVideoInspectTaskServiceImpl implements IArdVideoInspectTaskService {
@Resource
private ArdVideoInspectTaskMapper ardVideoInspectTaskMapper;
@@ -96,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());
@@ -229,7 +227,7 @@
//寮�濮嬩笅涓�姝ラ
videoInspectTask.setCurrentStepId(nextStepId);
startRunStep(videoInspectTask);
- }else{
+ } else {
//鏈繃鏈熷皾璇曞紩瀵硷紝寮曞澶辫触娓呯┖褰撳墠姝ラ寮�濮嬫椂闂达紝鏍囪涓柇
tryGuide(videoInspectTask);
}
@@ -340,7 +338,9 @@
//寮�濮嬩笅涓�姝ラ
videoInspectTask.setCurrentStepId(nextStepId);
startRunStep(videoInspectTask);
- }else{tryGuide(videoInspectTask);}
+ } else {
+ tryGuide(videoInspectTask);
+ }
}
}
} else {
@@ -414,7 +414,7 @@
try {
String currentStepId = ardVideoInspectTask.getCurrentStepId();
if (StringUtils.isNull(currentStepId)) {
- log.info("褰撳墠寮�濮嬪贰妫�姝ラid涓虹┖");
+ log.debug("褰撳墠寮�濮嬪贰妫�姝ラid涓虹┖");
return;
}
log.debug("宸℃姝ラ锛�" + currentStepId + "灏濊瘯寮�濮�");
@@ -439,6 +439,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();
@@ -446,15 +451,14 @@
/*鎺у埗鐩告満宸℃*/
CameraCmd cmd = new CameraCmd();
cmd.setCameraId(cameraId);
- cmd.setChannelNum(channel);
+ cmd.setChanNo(channel);
cmd.setTargetPosition(targetPositon);
cmd.setOperator("sys_patrol_inspect");
- cmd.setExpired(step.getRecordingTime()*60);
- boolean setTargetPosition = hikClientService.setTargetPosition(cmd);
+ cmd.setExpired(step.getRecordingTime() * 60);
+ boolean setTargetPosition = hikClientService.guideTargetPosition(cmd);
if (setTargetPosition) {
/*鎺у埗鐩告満宸℃鎴愬姛锛屽紑濮嬪綍鍍�*/
- cmd.setEnable(true);//鍚姩褰曞儚
- hikClientService.recordToMinio(cmd);
+ hikClientService.recordStart(cmd);
} else {
/*鎺у埗澶辫触,褰撳墠姝ラ鍚姩鏃堕棿缃畁ull*/
ardVideoInspectTask.setCurrentStepStartTime("");
@@ -466,12 +470,13 @@
log.error("宸℃寮�濮嬪紓甯革細" + ex.getMessage());
}
}
+
//灏濊瘯鎺у埗寮曞
private void tryGuide(ArdVideoInspectTask ardVideoInspectTask) {
try {
String currentStepId = ardVideoInspectTask.getCurrentStepId();
if (StringUtils.isNull(currentStepId)) {
- log.info("褰撳墠寮�濮嬪贰妫�姝ラid涓虹┖");
+ log.debug("褰撳墠寮�濮嬪贰妫�姝ラid涓虹┖");
return;
}
log.debug("宸℃姝e父锛屽皾璇曞紩瀵硷細" + currentStepId);
@@ -492,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();
@@ -499,15 +509,17 @@
/*鎺у埗鐩告満宸℃*/
CameraCmd cmd = new CameraCmd();
cmd.setCameraId(cameraId);
- cmd.setChannelNum(channel);
+ cmd.setChanNo(channel);
cmd.setTargetPosition(targetPositon);
cmd.setOperator("sys_patrol_inspect");
- cmd.setExpired(step.getRecordingTime()*60);
- boolean setTargetPosition = hikClientService.setTargetPosition(cmd);
+ cmd.setExpired(step.getRecordingTime() * 60);
+ boolean setTargetPosition = hikClientService.guideTargetPosition(cmd);
if (!setTargetPosition) {
/*鎺у埗澶辫触,褰撳墠姝ラ鍚姩鏃堕棿缃畁ull*/
ardVideoInspectTask.setCurrentStepStartTime("");
ardVideoInspectTaskMapper.updateArdVideoInspectTaskWithCurrentSetpInfo(ardVideoInspectTask);
+ } else {
+ log.debug("寮曞鎴愬姛!");
}
}
}
@@ -515,6 +527,7 @@
log.error("宸℃灏濊瘯寮曞寮傚父锛�" + ex.getMessage());
}
}
+
//姝ラ鍋滄
private void stopRunStep(ArdVideoInspectTask ardVideoInspectTask) {
try {
@@ -535,16 +548,11 @@
/*鍋滄褰曞儚*/
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());
@@ -556,7 +564,6 @@
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);
}
@@ -638,6 +645,11 @@
return ardVideoInspectTaskMapper.getTaskUsedCameraPeriods(cameraId);
}
+ /**
+ * 鑾峰彇鐩告満鐨勭┖闂叉椂娈�
+ * @param cameraId
+ * @return
+ */
public List getCameraIdleTimeList(String cameraId) {
LinkedList<String> timeList = new LinkedList();
List<Map> usedPeriods = this.getTaskUsedCameraPeriods(cameraId);
@@ -647,21 +659,24 @@
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");
+ 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