| | |
| | | log.debug("加载lib完成!"); |
| | | List<ArdCameras> ardCameras = ardCamerasMapper.selectArdCamerasListNoDataScope(new ArdCameras()); |
| | | for (ArdCameras camera : ardCameras) { |
| | | Thread.sleep(100); |
| | | Thread.sleep(500); |
| | | login(camera); |
| | | } |
| | | } catch (Exception ex) { |
| | |
| | | double p = b.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | double t = c.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | double z = d.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue(); |
| | | log.debug("T垂直参数为: " + p + "P水平参数为: " + t + "Z变倍参数为: " + z); |
| | | // log.debug("T垂直参数为: " + p + "P水平参数为: " + t + "Z变倍参数为: " + z); |
| | | Map<String, Object> ptzMap = new HashMap<>(); |
| | | ptzMap.put("p", p); |
| | | ptzMap.put("t", t); |
| | |
| | | } else { |
| | | int code = hCNetSDK.NET_DVR_GetLastError(); |
| | | log.info("控制失败,请稍后重试" + code); |
| | | return null; |
| | | return new HashMap<>(); |
| | | } |
| | | |
| | | } |
| | |
| | | * @修改人和其它信息 0-解锁 1-锁定 |
| | | */ |
| | | @Override |
| | | @SdkOperate |
| | | public boolean controlLock(CameraCmd cmd) { |
| | | String cameraId = cmd.getCameraId();//申请锁的相机 |
| | | ArdCameras ardCameras = ardCamerasMapper.selectArdCamerasById(cameraId); |
| | | if (StringUtils.isNull(ardCameras)) { |
| | | return false;//找不到相机拒绝操控 |
| | | } |
| | | Integer expired = cmd.getExpired();//申请控制时长 |
| | | Date now = new Date(); |
| | | now.setTime(now.getTime() + cmd.getExpired() * 60); |
| | | ardCameras.setOperatorExpired(now);//设置当前过期时间 |
| | | ardCamerasMapper.updateArdCameras(ardCameras); |
| | | // String cameraId = cmd.getCameraId();//申请锁的相机 |
| | | // ArdCameras ardCameras = ardCamerasMapper.selectArdCamerasById(cameraId); |
| | | // if (StringUtils.isNull(ardCameras)) { |
| | | // return false;//找不到相机拒绝操控 |
| | | // } |
| | | // Integer expired = cmd.getExpired();//申请控制时长 |
| | | // String operator = cmd.getOperator();//申请者 |
| | | // String currentOperator = ardCameras.getOperatorId();//相机当前控制者 |
| | | // Date currentExpired = ardCameras.getOperatorExpired();//相机当前过期时间 |
| | | // if (currentExpired == null) { |
| | | // //设置当前操作用户ID |
| | | // ardCameras.setOperatorId(operator); |
| | | // //设置当前过期时间 |
| | | // Date now = new Date(); |
| | | // now.setTime(now.getTime() + expired * 1000); |
| | | // ardCameras.setOperatorExpired(now); |
| | | // ardCamerasMapper.updateArdCameras(ardCameras); |
| | | // } else { |
| | | // //如果过期时间有值 |
| | | // //如果是本人直接修改 |
| | | // if (currentOperator.equals(operator)) { |
| | | // //设置当前过期时间 |
| | | // Date now = new Date(); |
| | | // now.setTime(now.getTime() + expired * 1000); |
| | | // ardCameras.setOperatorExpired(now); |
| | | // ardCamerasMapper.updateArdCameras(ardCameras); |
| | | // } else { |
| | | // //如果非本人比较优先级 |
| | | // Integer currentLevel = 0;//当前操作者的优先级 |
| | | // if (CamPriority.priorityMap.containsKey(currentOperator)) { |
| | | // /*当前控制者为系统报警用户*/ |
| | | // currentLevel = (Integer) CamPriority.priorityMap.get(currentOperator); |
| | | // } else { |
| | | // /*当前控制者为普通用户*/ |
| | | // SysUser sysUser = sysUserMapper.selectUserById(currentOperator); |
| | | // currentLevel = sysUser.getCameraPriority(); |
| | | // } |
| | | // Integer operatorLevel = 0;//获取申请者的优先级 |
| | | // if (CamPriority.priorityMap.containsKey(operator)) { |
| | | // /*包含说明当前申请控制者为系统报警用户*/ |
| | | // operatorLevel = (Integer) CamPriority.priorityMap.get(operator); |
| | | // } else { |
| | | // /*否则申请控制者为当前登录用户*/ |
| | | // LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | // SysUser user = loginUser.getUser();//获取登录用户的信息 |
| | | // operatorLevel = user.getCameraPriority(); |
| | | // } |
| | | // //判断优先级 |
| | | // if (operatorLevel > currentLevel) { |
| | | // Date now = new Date(); |
| | | // now.setTime(now.getTime() + expired * 60); |
| | | // ardCameras.setOperatorExpired(now);//设置当前过期时间 |
| | | // ardCameras.setOperatorId(operator);//设置当前用户 |
| | | // ardCamerasMapper.updateArdCameras(ardCameras); |
| | | // } else { |
| | | // return false;//优先级低无法上锁 |
| | | // } |
| | | // } |
| | | // } |
| | | return true; |
| | | } |
| | | /** |
| | | * @描述 操控解锁 |
| | | * @参数 [userId, channelNum] |
| | | * @返回值 boolean |
| | | * @创建人 刘苏义 |
| | | * @创建时间 2023/6/30 15:36 |
| | | * @修改人和其它信息 |
| | | */ |
| | | @Override |
| | | public boolean controlUnLock(CameraCmd cmd) { |
| | | String cameraId = cmd.getCameraId();//申请解锁的相机 |
| | | String operator = cmd.getOperator();//申请者 |
| | | String currentOperator = ardCameras.getOperatorId();//相机当前控制者 |
| | | Date currentExpired = ardCameras.getOperatorExpired();//相机当前过期时间 |
| | | if (currentExpired == null) { |
| | | //设置当前操作用户ID |
| | | ardCameras.setOperatorId(operator); |
| | | //设置当前过期时间 |
| | | Date now = new Date(); |
| | | now.setTime(now.getTime() + expired * 1000); |
| | | ardCameras.setOperatorExpired(now); |
| | | ardCamerasMapper.updateArdCameras(ardCameras); |
| | | } else { |
| | | //如果过期时间有值 |
| | | //如果是本人直接修改 |
| | | if (currentOperator.equals(operator)) { |
| | | //设置当前过期时间 |
| | | Date now = new Date(); |
| | | now.setTime(now.getTime() + expired * 1000); |
| | | ardCameras.setOperatorExpired(now); |
| | | ardCamerasMapper.updateArdCameras(ardCameras); |
| | | } else { |
| | | //如果非本人比较优先级 |
| | | Integer currentLevel = 0;//当前操作者的优先级 |
| | | if (CamPriority.priorityMap.containsKey(currentOperator)) { |
| | | /*当前控制者为系统报警用户*/ |
| | | currentLevel = (Integer) CamPriority.priorityMap.get(currentOperator); |
| | | } else { |
| | | /*当前控制者为普通用户*/ |
| | | SysUser sysUser = sysUserMapper.selectUserById(currentOperator); |
| | | currentLevel = sysUser.getCameraPriority(); |
| | | } |
| | | Integer operatorLevel = 0;//获取申请者的优先级 |
| | | if (CamPriority.priorityMap.containsKey(operator)) { |
| | | /*包含说明当前申请控制者为系统报警用户*/ |
| | | operatorLevel = (Integer) CamPriority.priorityMap.get(operator); |
| | | } else { |
| | | /*否则申请控制者为当前登录用户*/ |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | SysUser user = loginUser.getUser();//获取登录用户的信息 |
| | | operatorLevel = user.getCameraPriority(); |
| | | } |
| | | //判断优先级 |
| | | if (operatorLevel > currentLevel) { |
| | | Date now = new Date(); |
| | | now.setTime(now.getTime() + expired * 60); |
| | | ardCameras.setOperatorExpired(now);//设置当前过期时间 |
| | | ardCameras.setOperatorId(operator);//设置当前用户 |
| | | ardCamerasMapper.updateArdCameras(ardCameras); |
| | | } else { |
| | | return false;//优先级低无法上锁 |
| | | } |
| | | ArdCameras ardCameras = ardCamerasMapper.selectArdCamerasById(cameraId); |
| | | if(ardCameras.getOperatorId().equals(operator)) |
| | | { |
| | | //如果解锁相机的当前用户是申请者,则清空该相机的过期时间 |
| | | ardCameras.setOperatorExpired(null); |
| | | int i = ardCamerasMapper.updateArdCameras(ardCameras); |
| | | if(i>0) |
| | | { |
| | | log.debug(cameraId+"--解锁成功"); |
| | | } |
| | | } |
| | | return true; |
| | |
| | | return bool; |
| | | } |
| | | |
| | | public String getFocusMode(CameraCmd cmd) |
| | | { |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer channelNum = cmd.getChannelNum(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return ""; |
| | | } |
| | | Integer userId = GlobalVariable.loginMap.get(cameraId); |
| | | NET_DVR_FOCUSMODE_CFG struFocusMode = new NET_DVR_FOCUSMODE_CFG(); |
| | | Pointer point = struFocusMode.getPointer(); |
| | | IntByReference ibrBytesReturned = new IntByReference(0); |
| | | boolean b_GetCameraParam = hCNetSDK.NET_DVR_GetDVRConfig(userId, NET_DVR_GET_FOCUSMODECFG, channelNum, point, struFocusMode.size(), ibrBytesReturned); |
| | | if (!b_GetCameraParam) { |
| | | System.out.println("获取前端参数失败,错误码:" + hCNetSDK.NET_DVR_GetLastError()); |
| | | } |
| | | struFocusMode.read(); |
| | | log.info("当前聚焦模式:" + struFocusMode.byFocusMode); |
| | | return String.valueOf(struFocusMode.byFocusMode); |
| | | } |
| | | /** |
| | | * @描述 云台加热开关 |
| | | * @参数 [userId, channelNum, enable] |