|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
|
|
|
import com.hnac.hzims.bigmodel.api.feign.IBigModelAnalysisClient; |
|
|
|
import com.hnac.hzinfo.datasearch.soe.ISoeClient; |
|
|
|
import com.hnac.hzinfo.datasearch.soe.ISoeClient; |
|
|
|
import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO; |
|
|
|
import com.hnac.hzinfo.datasearch.soe.vo.DeviceSoeVO; |
|
|
|
import com.hnac.hzinfo.inspect.ai.entity.CameraInfoEntity; |
|
|
|
import com.hnac.hzinfo.inspect.ai.entity.CameraInfoEntity; |
|
|
@ -13,6 +14,8 @@ import com.hnac.hzinfo.inspect.ai.service.ICameraInfoService; |
|
|
|
import com.hnac.hzinfo.inspect.ai.service.IRobotTaskService; |
|
|
|
import com.hnac.hzinfo.inspect.ai.service.IRobotTaskService; |
|
|
|
import com.hnac.hzinfo.inspect.areamonthly.vo.TaskObjectVO; |
|
|
|
import com.hnac.hzinfo.inspect.areamonthly.vo.TaskObjectVO; |
|
|
|
import com.hnac.hzinfo.inspect.hikVideo.service.IHikApiService; |
|
|
|
import com.hnac.hzinfo.inspect.hikVideo.service.IHikApiService; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.obj.entity.ContentEntity; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.inspect.obj.services.ContentService; |
|
|
|
import com.hnac.hzinfo.inspect.plan.PlanContants; |
|
|
|
import com.hnac.hzinfo.inspect.plan.PlanContants; |
|
|
|
import com.hnac.hzinfo.inspect.task.TaskContants; |
|
|
|
import com.hnac.hzinfo.inspect.task.TaskContants; |
|
|
|
import com.hnac.hzinfo.inspect.task.entity.EventEntity; |
|
|
|
import com.hnac.hzinfo.inspect.task.entity.EventEntity; |
|
|
@ -34,12 +37,14 @@ import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
|
|
|
import org.springblade.resource.feign.IOssClient; |
|
|
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
|
|
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.transaction.TransactionDefinition; |
|
|
|
import org.springframework.transaction.TransactionDefinition; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
@ -63,9 +68,13 @@ public class VideoTaskSchedule { |
|
|
|
private final ISoeClient soeClient; |
|
|
|
private final ISoeClient soeClient; |
|
|
|
private final DataSourceTransactionManager dataSourceTransactionManager; |
|
|
|
private final DataSourceTransactionManager dataSourceTransactionManager; |
|
|
|
private final TransactionDefinition transactionDefinition; |
|
|
|
private final TransactionDefinition transactionDefinition; |
|
|
|
|
|
|
|
private final IOssClient ossClient; |
|
|
|
|
|
|
|
private final ContentService contentService; |
|
|
|
|
|
|
|
private final IBigModelAnalysisClient bigModelClient; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 视频巡检任务执行 |
|
|
|
* 视频巡检任务执行 |
|
|
|
|
|
|
|
* |
|
|
|
* @param params 任务ID |
|
|
|
* @param params 任务ID |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -74,15 +83,14 @@ public class VideoTaskSchedule { |
|
|
|
public ReturnT<String> execute(String params) throws InterruptedException { |
|
|
|
public ReturnT<String> execute(String params) throws InterruptedException { |
|
|
|
List<TaskEntity> taskList = Lists.newArrayList(); |
|
|
|
List<TaskEntity> taskList = Lists.newArrayList(); |
|
|
|
// 获取待执行的任务
|
|
|
|
// 获取待执行的任务
|
|
|
|
if(StringUtil.isBlank(params)) { |
|
|
|
if (StringUtil.isBlank(params)) { |
|
|
|
LambdaQueryWrapper<TaskEntity> queryWrapper = Wrappers.<TaskEntity>lambdaQuery() |
|
|
|
LambdaQueryWrapper<TaskEntity> queryWrapper = Wrappers.<TaskEntity>lambdaQuery() |
|
|
|
.eq(TaskEntity::getStatus, TaskContants.TaskStatusEnum.INIT_STATUS.getStatus()) |
|
|
|
.eq(TaskEntity::getStatus, TaskContants.TaskStatusEnum.INIT_STATUS.getStatus()) |
|
|
|
.le(TaskEntity::getPlanStartTime, LocalDateTime.now()) |
|
|
|
.le(TaskEntity::getPlanStartTime, LocalDateTime.now()) |
|
|
|
.ge(TaskEntity::getPlanEndTime, LocalDateTime.now()) |
|
|
|
.ge(TaskEntity::getPlanEndTime, LocalDateTime.now()) |
|
|
|
.eq(TaskEntity::getAutoVideo, PlanContants.InspectTypeEnum.VIDEO.getVal()); |
|
|
|
.eq(TaskEntity::getAutoVideo, PlanContants.InspectTypeEnum.VIDEO.getVal()); |
|
|
|
taskList.addAll(taskService.list(queryWrapper)); |
|
|
|
taskList.addAll(taskService.list(queryWrapper)); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
LambdaQueryWrapper<TaskEntity> queryWrapper = Wrappers.<TaskEntity>lambdaQuery() |
|
|
|
LambdaQueryWrapper<TaskEntity> queryWrapper = Wrappers.<TaskEntity>lambdaQuery() |
|
|
|
.in(TaskEntity::getId, Func.toLongList(",", params)) |
|
|
|
.in(TaskEntity::getId, Func.toLongList(",", params)) |
|
|
|
.eq(TaskEntity::getStatus, TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus()) |
|
|
|
.eq(TaskEntity::getStatus, TaskContants.TaskStatusEnum.UNDERWAY_STATUS.getStatus()) |
|
|
@ -95,6 +103,7 @@ public class VideoTaskSchedule { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 执行视频巡检任务 |
|
|
|
* 执行视频巡检任务 |
|
|
|
|
|
|
|
* |
|
|
|
* @param task 视频巡检任务 |
|
|
|
* @param task 视频巡检任务 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void executeVideoTask(TaskEntity task) { |
|
|
|
private void executeVideoTask(TaskEntity task) { |
|
|
@ -105,16 +114,15 @@ public class VideoTaskSchedule { |
|
|
|
this.fillEvent(task); |
|
|
|
this.fillEvent(task); |
|
|
|
// 更新视频巡检任务状态
|
|
|
|
// 更新视频巡检任务状态
|
|
|
|
taskService.update(Wrappers.<TaskEntity>lambdaUpdate() |
|
|
|
taskService.update(Wrappers.<TaskEntity>lambdaUpdate() |
|
|
|
.set(TaskEntity::getStatus,TaskContants.TaskStatusEnum.FINISH_STATUS.getStatus()) |
|
|
|
.set(TaskEntity::getStatus, TaskContants.TaskStatusEnum.FINISH_STATUS.getStatus()) |
|
|
|
.set(TaskEntity::getEndTime,LocalDateTime.now()) |
|
|
|
.set(TaskEntity::getEndTime, LocalDateTime.now()) |
|
|
|
.eq(TaskEntity::getId,task.getId())); |
|
|
|
.eq(TaskEntity::getId, task.getId())); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
catch(Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
XxlJobLogger.log("【taskId:"+task.getId()+"】视频巡检任务执行失败,报错信息为:"+e.getMessage()); |
|
|
|
XxlJobLogger.log("【taskId:" + task.getId() + "】视频巡检任务执行失败,报错信息为:" + e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
try { |
|
|
|
try { |
|
|
|
Thread.sleep(3*1000); |
|
|
|
Thread.sleep(3 * 1000); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
} catch (InterruptedException e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
} |
|
|
@ -122,11 +130,12 @@ public class VideoTaskSchedule { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 填充视频巡检执行情况 |
|
|
|
* 填充视频巡检执行情况 |
|
|
|
|
|
|
|
* |
|
|
|
* @param task 视频巡检任务 |
|
|
|
* @param task 视频巡检任务 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void fillEvent(TaskEntity task) { |
|
|
|
private void fillEvent(TaskEntity task) { |
|
|
|
List<com.hnac.hzinfo.inspect.task.vo.TaskObjectVO> taskObjects = taskService.getTaskById(task.getId()); |
|
|
|
List<com.hnac.hzinfo.inspect.task.vo.TaskObjectVO> taskObjects = taskService.getTaskById(task.getId()); |
|
|
|
List<TaskObjectVO> taskObjectList = JSONArray.parseArray(JSON.toJSONString(taskObjects),TaskObjectVO.class); |
|
|
|
List<TaskObjectVO> taskObjectList = JSONArray.parseArray(JSON.toJSONString(taskObjects), TaskObjectVO.class); |
|
|
|
taskObjectList.forEach(object -> object.getProjects().forEach(project -> { |
|
|
|
taskObjectList.forEach(object -> object.getProjects().forEach(project -> { |
|
|
|
EventEntity event = new EventEntity(); |
|
|
|
EventEntity event = new EventEntity(); |
|
|
|
event.setTaskId(task.getId()); |
|
|
|
event.setTaskId(task.getId()); |
|
|
@ -150,17 +159,17 @@ public class VideoTaskSchedule { |
|
|
|
record.setUpdateUser(task.getUpdateUser()); |
|
|
|
record.setUpdateUser(task.getUpdateUser()); |
|
|
|
record.setCurrentStatus("1"); |
|
|
|
record.setCurrentStatus("1"); |
|
|
|
CameraInfoEntity camera = this.getCameraByProIdAndConId(project.getProjectId(), content.getContentId()); |
|
|
|
CameraInfoEntity camera = this.getCameraByProIdAndConId(project.getProjectId(), content.getContentId()); |
|
|
|
if(Func.isNotEmpty(camera)) { |
|
|
|
if (Func.isNotEmpty(camera)) { |
|
|
|
// 获取计划时间段内视频的告警信息设置是否异常
|
|
|
|
// 获取计划时间段内视频的告警信息设置是否异常
|
|
|
|
if(Func.isNotEmpty(camera.getEmCode())) { |
|
|
|
if (Func.isNotEmpty(camera.getEmCode())) { |
|
|
|
Result<HzPage<DeviceSoeVO>> deviceSoeR = soeClient.getDeviceCodeByTaosSoe(DateUtil.formatDateTime(task.getPlanStartTime()), DateUtil.formatDateTime(task.getPlanEndTime()), camera.getEmCode(), 0, String.valueOf(-1)); |
|
|
|
Result<HzPage<DeviceSoeVO>> deviceSoeR = soeClient.getDeviceCodeByTaosSoe(DateUtil.formatDateTime(task.getPlanStartTime()), DateUtil.formatDateTime(task.getPlanEndTime()), camera.getEmCode(), 0, String.valueOf(-1)); |
|
|
|
if(deviceSoeR.isSuccess() && CollectionUtil.isNotEmpty(deviceSoeR.getData().getRecords())) { |
|
|
|
if (deviceSoeR.isSuccess() && CollectionUtil.isNotEmpty(deviceSoeR.getData().getRecords())) { |
|
|
|
record.setCurrentStatus("0"); |
|
|
|
record.setCurrentStatus("0"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 调用海康威视api实现手动截屏回传至fileUrl
|
|
|
|
// 调用海康威视api实现手动截屏回传至fileUrl
|
|
|
|
if(Func.isNotEmpty(camera.getPointCode())) { |
|
|
|
if (Func.isNotEmpty(camera.getPointCode())) { |
|
|
|
String picUrl = hikApiService.manualCapture(camera.getPointCode()); |
|
|
|
String picUrl = hikApiService.manualCapture(camera.getPointCode()); |
|
|
|
record.setFileUrl(picUrl); |
|
|
|
record.setFileUrl(picUrl); |
|
|
|
record.setCurrentValue(picUrl); |
|
|
|
record.setCurrentValue(picUrl); |
|
|
@ -169,14 +178,15 @@ public class VideoTaskSchedule { |
|
|
|
return record; |
|
|
|
return record; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
eventRecordService.saveBatch(recordList); |
|
|
|
eventRecordService.saveBatch(recordList); |
|
|
|
if(recordList.stream().anyMatch(r -> TaskContants.CurrentStatusEnum.abnormal.getType().equals(r.getCurrentStatus()))) { |
|
|
|
if (recordList.stream().anyMatch(r -> TaskContants.CurrentStatusEnum.abnormal.getType().equals(r.getCurrentStatus()))) { |
|
|
|
eventService.update(Wrappers.<EventEntity>lambdaUpdate().set(EventEntity::getIsProblem,"1").eq(EventEntity::getId,event.getId())); |
|
|
|
eventService.update(Wrappers.<EventEntity>lambdaUpdate().set(EventEntity::getIsProblem, "1").eq(EventEntity::getId, event.getId())); |
|
|
|
} |
|
|
|
} |
|
|
|
})); |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 登记任务 |
|
|
|
* 登记任务 |
|
|
|
|
|
|
|
* |
|
|
|
* @param task 视频巡检任务 |
|
|
|
* @param task 视频巡检任务 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void registration(TaskEntity task) { |
|
|
|
private void registration(TaskEntity task) { |
|
|
@ -188,7 +198,7 @@ public class VideoTaskSchedule { |
|
|
|
taskUserEntity.setClaimStatus(TaskContants.ClaimStatusEnum.COLLECT.getStatus()); |
|
|
|
taskUserEntity.setClaimStatus(TaskContants.ClaimStatusEnum.COLLECT.getStatus()); |
|
|
|
taskUserEntity.setClaimTime(LocalDateTime.now()); |
|
|
|
taskUserEntity.setClaimTime(LocalDateTime.now()); |
|
|
|
taskUserService.updateById(taskUserEntity); |
|
|
|
taskUserService.updateById(taskUserEntity); |
|
|
|
if(PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { |
|
|
|
if (PlanContants.PlanMethodEnum.SEIZE.getMethod().equals(task.getMethod())) { |
|
|
|
taskUserService.removeByIds(taskUserList.stream().map(TaskUserEntity::getId).filter(id -> !taskUserEntity.getId().equals(id)).collect(Collectors.toList())); |
|
|
|
taskUserService.removeByIds(taskUserList.stream().map(TaskUserEntity::getId).filter(id -> !taskUserEntity.getId().equals(id)).collect(Collectors.toList())); |
|
|
|
} |
|
|
|
} |
|
|
|
// 更改任务状态
|
|
|
|
// 更改任务状态
|
|
|
@ -199,19 +209,31 @@ public class VideoTaskSchedule { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 根据项目ID以及内容ID获取摄像头编号 |
|
|
|
* 根据项目ID以及内容ID获取摄像头编号 |
|
|
|
|
|
|
|
* |
|
|
|
* @param projectId 项目ID |
|
|
|
* @param projectId 项目ID |
|
|
|
* @param contentId 内容ID |
|
|
|
* @param contentId 内容ID |
|
|
|
* @return 摄像头编号 |
|
|
|
* @return 摄像头编号 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private CameraInfoEntity getCameraByProIdAndConId(Long projectId,Long contentId) { |
|
|
|
private CameraInfoEntity getCameraByProIdAndConId(Long projectId, Long contentId) { |
|
|
|
RobotTaskEntity robotTaskEntity = robotTaskService.getOne(Wrappers.<RobotTaskEntity>lambdaQuery() |
|
|
|
RobotTaskEntity robotTaskEntity = robotTaskService.getOne(Wrappers.<RobotTaskEntity>lambdaQuery() |
|
|
|
.eq(RobotTaskEntity::getProjectId, projectId) |
|
|
|
.eq(RobotTaskEntity::getProjectId, projectId) |
|
|
|
.like(RobotTaskEntity::getContentIds, String.valueOf(contentId)) |
|
|
|
.like(RobotTaskEntity::getContentIds, String.valueOf(contentId)) |
|
|
|
); |
|
|
|
); |
|
|
|
if(Func.isNotEmpty(robotTaskEntity)) { |
|
|
|
if (Func.isNotEmpty(robotTaskEntity)) { |
|
|
|
return cameraInfoService.getById(robotTaskEntity.getCameraId()); |
|
|
|
return cameraInfoService.getById(robotTaskEntity.getCameraId()); |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void pictureHandle(String url, Long contentId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ContentEntity content = contentService.getById(contentId); |
|
|
|
|
|
|
|
if (StringUtil.isBlank(content.getMultiCheckTypeSon())) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String[] typeArray = content.getMultiCheckTypeSon().split(","); |
|
|
|
|
|
|
|
List<String> checkTypeSonList = Arrays.asList(typeArray); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|