| | |
| | | import java.time.LocalTime; |
| | | import java.util.*; |
| | | |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.hiksdk.common.GlobalVariable; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | |
| | | @Resource |
| | | private RedisCache redisCache; |
| | | |
| | | |
| | | @PostConstruct |
| | | public void loadCameras() { |
| | | List<ArdCameras> ardCameras = selectArdCamerasListNoDataScope(new ArdCameras()); |
| | | for (ArdCameras ardCamera : ardCameras) { |
| | | redisCache.setCacheObject(getCacheKey(ardCamera.getId()), ardCamera); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * @param configKey 参数键 |
| | | * @return 缓存键key |
| | | */ |
| | | private String getCacheKey(String configKey) { |
| | | return CacheConstants.CAMERA_LIST_KEY + configKey; |
| | | } |
| | | |
| | | /** |
| | | * 查询相机设备 |
| | |
| | | */ |
| | | @Override |
| | | public int insertArdCameras(ArdCameras ardCameras) { |
| | | ardCameras.setId(IdUtils.simpleUUID()); |
| | | ardCameras.setCreateBy(SecurityUtils.getUsername()); |
| | | ardCameras.setCreateTime(DateUtils.getNowDate()); |
| | | ardCameras.setUserId(SecurityUtils.getUserId()); |
| | | redisCache.setCacheObject(getCacheKey(ardCameras.getId()), ardCameras); |
| | | return ardCamerasMapper.insertArdCameras(ardCameras); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public int updateArdCameras(ArdCameras ardCameras) { |
| | | ardCameras.setUpdateTime(DateUtils.getNowDate()); |
| | | return ardCamerasMapper.updateArdCameras(ardCameras); |
| | | int res = ardCamerasMapper.updateArdCameras(ardCameras); |
| | | if (res > 0) { |
| | | redisCache.deleteObject(getCacheKey(ardCameras.getId())); |
| | | redisCache.setCacheObject(getCacheKey(ardCameras.getId()), ardCameras); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int deleteArdCamerasByIds(String[] ids) { |
| | | return ardCamerasMapper.deleteArdCamerasByIds(ids); |
| | | int res = ardCamerasMapper.deleteArdCamerasByIds(ids); |
| | | if(res>0) |
| | | { |
| | | for(String id:ids) |
| | | { |
| | | redisCache.deleteObject(getCacheKey(id)); |
| | | } |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | /** |
| | |
| | | public Map getChildDeptAndCamera(Boolean disabled) { |
| | | Long deptId = SecurityUtils.getDeptId(); |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(deptId); |
| | | Map<String, Object> map = fetchChildDepartments(sysDept,disabled); |
| | | Map<String, Object> map = fetchChildDepartments(sysDept, disabled); |
| | | return map; |
| | | } |
| | | |
| | |
| | | * @创建时间 2023/6/2 14:38 |
| | | * @修改人和其它信息 |
| | | */ |
| | | public Map<String, Object> fetchChildDepartments(SysDept sysDept,Boolean disabled) { |
| | | public Map<String, Object> fetchChildDepartments(SysDept sysDept, Boolean disabled) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", sysDept.getDeptName()); |
| | | map.put("deptId", sysDept.getDeptId()); |
| | |
| | | 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); |
| | | childMap.putAll(map1); |
| | | childList.add(childMap); |
| | | } |