liusuyi
2024-07-10 016aa105789fca71e86cdbb0d26a181812f200f9
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;
@@ -68,6 +74,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 +85,24 @@
        for (ArdCameras ardCamera : ardCameras) {
            redisCache.setCacheObject(getCacheKey(ardCamera.getId()), ardCamera);
        }
        //清空流媒体
        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 +318,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();
@@ -444,7 +478,8 @@
            childMap.put("name", childDept.getDeptName());
            childMap.put("deptId", childDept.getDeptId());
            childMap.put("disabled", disabled);
            Map<String, Object> map1 = fetchChildDepartments(childDept, disabled);
            //Map<String, Object> map1 = fetchChildDepartments(childDept, disabled);
            Map<String, Object> map1 = fetchChildDepartments(ownDeptIdList,childDept, disabled);
            childMap.putAll(map1);
            childList.add(childMap);
        }