| | |
| | | import com.ruoyi.common.annotation.SdkOperate;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.core.redis.RedisCache;
|
| | | import com.ruoyi.common.utils.Threads;
|
| | | import com.ruoyi.device.camera.domain.ArdCameras;
|
| | | import com.ruoyi.device.camera.domain.CameraCmd;
|
| | | import com.ruoyi.device.camera.service.IArdCamerasService;
|
| | | import com.ruoyi.device.camera.service.ICameraSdkService;
|
| | | import com.ruoyi.device.dhsdk.service.IDhClientService;
|
| | | import com.ruoyi.device.hiksdk.service.IHikClientService;
|
| | | import com.ruoyi.device.camera.strategy.SdkStrategy;
|
| | | import com.ruoyi.device.camera.strategy.SdkStrategyFactory;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.factory.SmartInitializingSingleton;
|
| | | import org.springframework.boot.ApplicationArguments;
|
| | | import org.springframework.boot.ApplicationRunner;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import javax.annotation.PostConstruct;
|
| | | import javax.annotation.Resource;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | |
| | | @Resource
|
| | | private IArdCamerasService ardCamerasService;
|
| | | @Resource
|
| | | IHikClientService hikClientService;
|
| | | private RedisCache redisCache;
|
| | | @Resource
|
| | | IDhClientService dhClientService;
|
| | | @Resource
|
| | | RedisCache redisCache;
|
| | | private SdkStrategyFactory sdkStrategyFactory;
|
| | |
|
| | | /**
|
| | | * 启动线程方法,用于执行初始化登录相机的逻辑
|
| | | *
|
| | | * @param args 命令行参数
|
| | | */
|
| | | @Override
|
| | | public void run(ApplicationArguments args) throws Exception {
|
| | | public void run(ApplicationArguments args) {
|
| | |
|
| | | try {
|
| | | // 从ardCamerasService中获取ArdCameras列表
|
| | | List<ArdCameras> ardCameras = ardCamerasService.selectArdCamerasListNoDataScope(new ArdCameras());
|
| | | for (ArdCameras camera : ardCameras) {
|
| | | if ("1".equals(camera.getFactory())) {
|
| | | hikClientService.login(camera);
|
| | | } else if ("2".equals(camera.getFactory())) {
|
| | | dhClientService.login(camera);
|
| | | }
|
| | | login(camera);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | // 初始化登录相机异常,记录错误日志
|
| | | log.error("初始化登录相机异常:" + ex.getMessage());
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | //登录
|
| | | @Override
|
| | |
| | | try {
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | hikClientService.login(ardCamera);
|
| | | result = true;
|
| | | } else if (factory.equals("2")) {
|
| | | dhClientService.login(ardCamera);
|
| | | result = true;
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | //sdkStrategy.login(ardCamera);//同步登录
|
| | | sdkStrategy.asyncLogin(ardCamera);//异步登录
|
| | | result=true;
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("登录异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.logout(cameraId);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.logout(cameraId);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.logout(cameraId);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("注销异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | onLine = hikClientService.isOnLine(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | onLine = dhClientService.isOnLine(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | onLine = sdkStrategy.isOnLine(cmd);
|
| | | }
|
| | | return onLine;
|
| | | } catch (Exception ex) {
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.pTZControlWithSpeed(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.pTZControl(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.pTZControl(cmd);
|
| | | }
|
| | | return result;
|
| | | } catch (Exception ex) {
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.setFocusPos(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.setFocusPos(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.setFocusPos(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("设置聚焦值异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.getFocusPos(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.getFocusPos(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.getFocusPos(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("获取聚焦值异常:" + ex.getMessage());
|
| | |
| | |
|
| | | //设置预置位
|
| | | @Override
|
| | | @SdkOperate
|
| | | public boolean setPreset(CameraCmd cmd) {
|
| | | boolean result = false;
|
| | | try {
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.setPreset(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.setPreset(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.setPreset(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("设置预置位异常:" + ex.getMessage());
|
| | |
| | |
|
| | | //调用预置位
|
| | | @Override
|
| | | @SdkOperate
|
| | | public boolean gotoPreset(CameraCmd cmd) {
|
| | | boolean result = false;
|
| | | try {
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.gotoPreset(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.gotoPreset(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.gotoPreset(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("调用预置位异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | map = hikClientService.getVideoCompressionCfg(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | map = dhClientService.getVideoCompressionCfg(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | map = sdkStrategy.getVideoCompressionCfg(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("获取码流压缩参数异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.controlDefogcfg(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | //不支持
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.controlDefogcfg(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("操控透雾异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.controlInfrarecfg(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.controlInfrarecfg(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.controlInfrarecfg(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("操控红外异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.controlFocusMode(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.controlFocusMode(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.controlFocusMode(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("操控聚焦模式异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.getFocusMode(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.getFocusMode(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.getFocusMode(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("获取聚焦模式异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.controlPTHeateRpwron(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | //不支持
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.controlPTHeateRpwron(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("操控云台加热异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.controlCameraDeicing(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | //不支持
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.controlCameraDeicing(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("操控云台加热异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.getPTZLockInfo(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | |
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.getPTZLockInfo(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("获取云台锁定信息异常:" + ex.getMessage());
|
| | |
| | | if (ardCamera != null) {
|
| | | //获取摄像头工厂
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | //调用hikClientService的picCutCate方法
|
| | | url = hikClientService.picCutCate(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | //调用dhClientService的picCutCate方法
|
| | | url = dhClientService.picCutCate(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | url = sdkStrategy.picCutCate(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("抓图异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | map = hikClientService.getPtz(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | map = dhClientService.getPtz(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | map = sdkStrategy.getPtz(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("获取ptz异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | map = hikClientService.getPtzScope(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | |
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | map = sdkStrategy.getPtzScope(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("获取ptz范围异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.setPtz(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.setPtz(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.setPtz(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("设置ptz异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.setZeroPtz(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.setZeroPtz(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.setZeroPtz(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("设置零方位角异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.guideTargetPosition(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.guideTargetPosition(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.guideTargetPosition(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("引导指向目标异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | url = hikClientService.record(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | url = dhClientService.record(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | url = sdkStrategy.record(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("录像异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.recordStart(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.recordStart(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.recordStart(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("开始录像异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | url = hikClientService.recordStopToMinio(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | url = dhClientService.recordStopToMinio(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | url = sdkStrategy.recordStopToMinio(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("停止录像异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | result = hikClientService.recordStopNotToMinio(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.recordStopNotToMinio(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | result = sdkStrategy.recordStopNotToMinio(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("停止录像异常:" + ex.getMessage());
|
| | |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
|
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | map = hikClientService.getGisInfo(cmd);
|
| | | } else if (factory.equals("2")) {
|
| | | map = dhClientService.getGisInfo(cmd);
|
| | | }
|
| | | SdkStrategy sdkStrategy = sdkStrategyFactory.getSdkStrategy(factory);
|
| | | map = sdkStrategy.getGisInfo(cmd);
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("获取相机架设参数异常:" + ex.getMessage());
|