| | |
| | | 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; |
| | | } |
| | | |
| | | /** |