From 5b017324148ea92d96f9f16ade215463d6c712e5 Mon Sep 17 00:00:00 2001 From: liusuyi <1951119284@qq.com> Date: 星期六, 10 八月 2024 14:15:02 +0800 Subject: [PATCH] 优化:海康大华sdk断线重连机制 --- ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java index a9f53ab..39e9b5c 100644 --- a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java +++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java @@ -1,13 +1,17 @@ package com.ruoyi.device.camera.service.impl; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; import com.ruoyi.alarm.global.domain.GuidePoint; import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell; +import com.ruoyi.common.config.ARDConfig; import com.ruoyi.common.constant.CacheConstants; import com.ruoyi.common.constant.CameraConstants; +import com.ruoyi.common.constant.Constants; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.redis.RedisCache; @@ -16,6 +20,7 @@ import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.BeanValidators; +import com.ruoyi.common.utils.file.FileUtils; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.device.camera.domain.CameraCmd; @@ -35,6 +40,7 @@ import com.ruoyi.utils.gis.Point; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; @@ -67,7 +73,9 @@ @PostConstruct public void loadCameras() { - + //娓呯悊鏈湴褰曞儚缂撳瓨鏂囦欢 + String tempPath = ARDConfig.getProfile() + Constants.LOCAL_RECORD_TEMP_PREFIX; + FileUtils.deleteFolder(tempPath); //娓呯┖鐩告満缂撳瓨 Collection<String> cacheKeys = redisCache.keys(getCacheKey("*")); redisCache.deleteObject(cacheKeys); @@ -76,7 +84,26 @@ for (ArdCameras ardCamera : ardCameras) { redisCache.setCacheObject(getCacheKey(ardCamera.getId()), ardCamera); } + //娓呯┖閫氶亾 + ardChannelMapper.clearArdChannel(); + //娓呯┖娴佸獟浣� + vtduService.clearVtdu(); + } + /** + * @Author 鍒樿嫃涔� + * @Description 瀹氭椂娓呯悊鏈湴褰曞儚缂撳瓨鏂囦欢锛堣秴杩�1澶╋級 + * @Date 2024/6/21 8:13 + * @Param + * @return + */ + //@Scheduled(cron = "0 0/10 * * * ?") + public void clearRecordTemp() + { + log.debug("瀹氭椂娓呯悊鏈湴褰曞儚缂撳瓨鏂囦欢锛堣秴杩�1澶╋級"); + String tempPath = ARDConfig.getProfile() + Constants.LOCAL_RECORD_TEMP_PREFIX; + Path folderPath = Paths.get(tempPath); + FileUtils.deleteNonTodayFiles(folderPath); } /** @@ -292,7 +319,15 @@ } public List findOptions(ArdCameras ardCameras) { - List<ArdCameras> options = ardCamerasMapper.findOptions(ardCameras); + //List<ArdCameras> options = ardCamerasMapper.findOptions(ardCameras); + List<Long> subDeptIdList = sysDeptMapper.selectDeptIdBySub(SecurityUtils.getDeptId());//涓嬪睘鍙婃湰鏉冮檺 + List<Long> ownDeptIdList= sysDeptMapper.selectRoleDeptIdByUsersId(SecurityUtils.getUserId());//鑷畾涔夋潈闄� + HashSet<Long> deptIdSet = new HashSet();//鍘婚噸 + deptIdSet.addAll(subDeptIdList); + deptIdSet.addAll(ownDeptIdList); + List<Long> deptIdList = new ArrayList(); + deptIdList.addAll(deptIdSet);//绗﹀悎鏉′欢鐨勫叏閮ㄦ潈闄� + List<ArdCameras> options = ardCamerasMapper.findTowerCamerasBySubAndOwnDeptIds(deptIdList); for (ArdCameras camera : options) { ArdChannel ardChannel = new ArdChannel(); @@ -726,4 +761,9 @@ } } } + + @Override + public int resetCameraLoginId() { + return ardCamerasMapper.resetCameraLoginId(); + } } -- Gitblit v1.9.3