From afa8fc57084c423218c6816b710dfb2f0b87ea89 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期四, 14 十一月 2024 15:55:48 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/DevCameraDahuaTask.java | 35 +++++++++++++++++++++-------------- 1 files changed, 21 insertions(+), 14 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/DevCameraDahuaTask.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/DevCameraDahuaTask.java index 5eed5c8..133d990 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/DevCameraDahuaTask.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/job/task/DevCameraDahuaTask.java @@ -1,13 +1,15 @@ package com.iailab.module.data.job.task; -import com.iailab.module.data.dev.controller.admin.camera.vo.DevCameraPageReqVO; -import com.iailab.module.data.dev.dahua.DHCapturePictureClient; -import com.iailab.module.data.dev.dahua.DHClientFactory; -import com.iailab.module.data.dev.dto.DevCameraDTO; -import com.iailab.module.data.dev.enums.CaptureTypeEnum; -import com.iailab.module.data.dev.service.DevCameraService; +import com.iailab.framework.tenant.core.context.TenantContextHolder; +import com.iailab.module.data.video.controller.admin.camera.vo.CameraPageReqVO; +import com.iailab.module.data.video.dahua.DHCapturePictureClient; +import com.iailab.module.data.video.dahua.DHClientFactory; +import com.iailab.module.data.video.dto.CameraDTO; +import com.iailab.module.data.video.enums.CaptureTypeEnum; +import com.iailab.module.data.video.service.CameraService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -29,23 +31,27 @@ private Logger logger = LoggerFactory.getLogger(getClass()); @Resource - private DevCameraService devCameraService; + private CameraService cameraService; - @Resource + @Autowired private DHClientFactory dhClientFactory; @Override public void run(String params) { logger.info("devCameraDahuaTask定时任务正在执行,参数为:{}", params); + //传递租户id + System.out.println(TenantContextHolder.getTenantId()); + String tenantId = String.valueOf(TenantContextHolder.getTenantId()); try { - DevCameraPageReqVO cameraPageReqVO = new DevCameraPageReqVO(); - List<DevCameraDTO> list = devCameraService.list(cameraPageReqVO); + CameraPageReqVO cameraPageReqVO = new CameraPageReqVO(); + cameraPageReqVO.setType("2"); + List<CameraDTO> list = cameraService.list(cameraPageReqVO); if (CollectionUtils.isEmpty(list)) { logger.info("Alarm List 为空"); return; } - Map<String, List<DevCameraDTO>> alarmGroup = list.stream().collect(Collectors.groupingBy(DevCameraDTO::getNvrId)); - for (Map.Entry<String, List<DevCameraDTO>> nvr : alarmGroup.entrySet()) { + Map<String, List<CameraDTO>> alarmGroup = list.stream().collect(Collectors.groupingBy(CameraDTO::getNvrId)); + for (Map.Entry<String, List<CameraDTO>> nvr : alarmGroup.entrySet()) { DHCapturePictureClient client = dhClientFactory.getClient(nvr.getKey()); try { if(!client.isLogin()) { @@ -54,9 +60,9 @@ if(!client.isLogin()) { continue; } - List<DevCameraDTO> cameraList = nvr.getValue(); + List<CameraDTO> cameraList = nvr.getValue(); for (int i = 0; i < cameraList.size(); i++) { - DevCameraDTO camera = cameraList.get(i); + CameraDTO camera = cameraList.get(i); boolean captureResult = false; if (CaptureTypeEnum.LOCAL.getCode().equals(camera.getCaptureType())) { captureResult = client.localCapturePicture(camera.getChannel(), camera.getCode()); @@ -71,6 +77,7 @@ } } logger.info("devCameraDahuaTask定时任务执行完成:" + LocalDateTime.now()); + } catch (Exception ex) { ex.printStackTrace(); logger.info("devCameraDahuaTask定时任务失败时间:" + LocalDateTime.now()); -- Gitblit v1.9.3