异步登录增加延迟时间避免接口频繁
修改大华通道数量获取
| | |
| | | private IArdCamerasService ardCamerasService;
|
| | |
|
| | |
|
| | | // //初始登录所有相机
|
| | | // @PostConstruct
|
| | | // public void initLoginAll() {
|
| | | // cameraSdkService.loginAll();
|
| | | // }
|
| | |
|
| | | @RequestMapping("/preview")
|
| | | private String preview() {
|
| | | return "preview";
|
| | |
| | | package com.ruoyi.device.camera.service.impl; |
| | | |
| | | import com.ruoyi.common.utils.Threads; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.dhsdk.service.IDhClientService; |
| | | import com.ruoyi.device.hiksdk.service.IHikClientService; |
| | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @ClassName test |
| | | * @ClassName 异步登录 |
| | | * @Description: |
| | | * @Author 刘苏义 |
| | | * @Date 2023/10/23 21:39 |
| | |
| | | |
| | | @Async |
| | | public void hikLogin(ArdCameras ardCameras) { |
| | | Threads.sleep(200); |
| | | hikClientService.login(ardCameras); |
| | | } |
| | | |
| | | @Async |
| | | public void dhLogin(ArdCameras ardCameras) { |
| | | Threads.sleep(200); |
| | | dhClientService.login(ardCameras); |
| | | } |
| | | } |
| | |
| | | if (ardCamera != null) {
|
| | | String factory = ardCamera.getFactory();
|
| | | if (factory.equals("1")) {
|
| | | hikClientService.login(ardCamera);
|
| | | asyncLogin.hikLogin(ardCamera);
|
| | | result = true;
|
| | | } else if (factory.equals("2")) {
|
| | | result = dhClientService.login(ardCamera);
|
| | | asyncLogin.dhLogin(ardCamera);
|
| | | result = true;
|
| | | }
|
| | | }
|
| | | } catch (Exception ex) {
|
| | |
| | | cmdObject.read();
|
| | | result = true;
|
| | | } else {
|
| | | log.error("Parse " + strCmd + " Config Failed!" + ToolKits.getErrorCodePrint());
|
| | | log.error("Parse [" + strCmd + "] Config Failed!" + ToolKits.getErrorCodePrint());
|
| | | result = false;
|
| | | }
|
| | | } else {
|
| | | log.error("Get %s Config Failed!Last Error = %s\n", strCmd, getErrorCodePrint());
|
| | | log.error("Get [" + strCmd + "] Config Failed!Last Error = " + getErrorCodePrint());
|
| | | result = false;
|
| | | }
|
| | |
|
| | |
| | | if (bRet) {
|
| | | cmdObject.read();
|
| | | } else {
|
| | | log.error("Get %s Config Failed!Last Error = %s\n", strCmd, getErrorCodePrint());
|
| | | log.error("Get ["+strCmd+"] Config Failed!Last Error = " + getErrorCodePrint());
|
| | | result = false;
|
| | | }
|
| | | return result;
|
| | | }
|
| | |
|
| | | // 获取配置
|
| | | public static boolean GetConfig(NetSDKLib.LLong hLoginHandle, int nChn,int type,Structure cmdObject) {
|
| | | boolean result = false;
|
| | |
| | | }
|
| | | return result;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 设置单个配置
|
| | | *
|
| | |
| | | if (netsdk.CLIENT_SetNewDevConfig(hLoginHandle, strCmd, nChn, szBuffer, nBufferLen, error, restart, 3000)) {
|
| | | result = true;
|
| | | } else {
|
| | | log.error("Set %s Config Failed! Last Error = %s\n", strCmd, getErrorCodePrint());
|
| | | log.error("Set [" + strCmd + "] Config Failed! Last Error = " + getErrorCodePrint());
|
| | |
|
| | | result = false;
|
| | | }
|
| | | } else {
|
| | | log.error("Packet " + strCmd + " Config Failed!" + getErrorCodePrint());
|
| | | log.error("Parse [" + strCmd + "] Config Failed!" + ToolKits.getErrorCodePrint());
|
| | | result = false;
|
| | | }
|
| | |
|
| | |
| | | public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE;
|
| | |
|
| | | // 设备信息
|
| | | public static NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex();
|
| | | // public static NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex();
|
| | |
|
| | | // 登陆句柄
|
| | | public static LLong m_hLoginHandle = new LLong(0);//
|
| | |
| | | int tryTimes = 1; //登录时尝试建立链接1次
|
| | | netsdk.CLIENT_SetConnectTime(waitTime, tryTimes);
|
| | |
|
| | |
|
| | | // 设置更多网络参数,NET_PARAM的nWaittime,nConnectTryNum成员与CLIENT_SetConnectTime
|
| | | // 接口设置的登录设备超时时间和尝试次数意义相同,可选
|
| | | NetSDKLib.NET_PARAM netParam = new NetSDKLib.NET_PARAM();
|
| | |
| | | * 登录设备
|
| | | * \endif
|
| | | */
|
| | | public static LLong login(String m_strIp, int m_nPort, String m_strUser, String m_strPassword) {
|
| | | public static LLong login(String m_strIp, int m_nPort, String m_strUser, String m_strPassword, NetSDKLib.NET_DEVICEINFO_Ex lpDeviceInfo) {
|
| | | IntByReference nError = new IntByReference(0);
|
| | | //入参
|
| | | NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY pstInParam = new NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY();
|
| | |
| | | pstInParam.szPassword = m_strPassword.getBytes();
|
| | | pstInParam.szUserName = m_strUser.getBytes();
|
| | | //出参
|
| | | NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY pstOutParam = new NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY();
|
| | | pstOutParam.stuDeviceInfo = m_stDeviceInfo;
|
| | | LLong m_hLoginHandle = netsdk.CLIENT_LoginEx2(m_strIp, m_nPort, m_strUser, m_strPassword, 0, null, m_stDeviceInfo, nError);
|
| | | //NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY pstOutParam = new NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY();
|
| | | LLong m_hLoginHandle = netsdk.CLIENT_LoginEx2(m_strIp, m_nPort, m_strUser, m_strPassword, 0, null, lpDeviceInfo, nError);
|
| | | //m_hLoginHandle=netsdk.CLIENT_LoginWithHighLevelSecurity(pstInParam, pstOutParam);
|
| | | if (m_hLoginHandle.longValue() == 0) {
|
| | | log.debug("Login Device[%s] Port[%d]Failed. %s\n", m_strIp, m_nPort, getErrorCodePrint());
|
| | |
| | | @Override
|
| | | public Boolean login(ArdCameras camera) {
|
| | | LoginModule.init(disConnect, haveReConnect);
|
| | | LLong loginId = LoginModule.login(camera.getIp(), camera.getPort(), camera.getUsername(), camera.getPassword());
|
| | | NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex();
|
| | | LLong loginId = LoginModule.login(camera.getIp(), camera.getPort(), camera.getUsername(), camera.getPassword(), m_stDeviceInfo);
|
| | | if (loginId.longValue() > 0) {
|
| | | //log.debug(camera.getIp() + ":" + camera.getPort() + "登录成功");
|
| | | if (GlobalVariable.loginMap.containsKey(camera.getId())) {
|
| | |
| | | //删除管理通道
|
| | | ardChannelService.deleteArdChannelByDeviceId(camera.getId());
|
| | | camera.setState("1");
|
| | | camera.setChanNum(LoginModule.m_stDeviceInfo.byChanNum);
|
| | | camera.setChanNum(m_stDeviceInfo.byChanNum);
|
| | | camera.setStartDChan(1);
|
| | | camera.setLoginId((int) loginId.longValue());
|
| | | ardCamerasService.updateArdCameras(camera);
|
| | | GlobalVariable.loginMap.put(camera.getId(), loginId);
|
| | |
|
| | | //获取最新通道
|
| | | for (int i = 1; i < LoginModule.m_stDeviceInfo.byChanNum + 1; i++) {
|
| | | for (int i = 1; i < m_stDeviceInfo.byChanNum + 1; i++) {
|
| | | ArdChannel channel = new ArdChannel();
|
| | | AV_CFG_ChannelName av_cfg_channelName = new AV_CFG_ChannelName();
|
| | | boolean b = ConfigModule.GetNewDevConfig(loginId, i - 1, CFG_CMD_CHANNELTITLE, av_cfg_channelName);
|
| | |
| | | if (vtdu != null) {
|
| | | vtduService.deleteVtduByName(name);
|
| | | }
|
| | |
|
| | | //添加到流媒体
|
| | | CameraCmd cmd = new CameraCmd(camera.getId(), channel.getChanNo());
|
| | | Map<String, Object> videoCompressionCfg = getVideoCompressionCfg(cmd);
|
| | |
| | | @Override
|
| | | public Map<String, Object> getVideoCompressionCfg(CameraCmd cmd) {
|
| | | Map<String, Object> map = new HashMap<>();
|
| | | try {
|
| | | String cameraId = cmd.getCameraId();
|
| | | Integer chanNo = cmd.getChanNo();
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | |
| | | map.put("videoEncType", videoEncType);//编码
|
| | | map.put("nFrameRate", String.valueOf(nFrameRate));//帧率
|
| | | }
|
| | | } catch (Exception ex) {
|
| | | log.error("取码流压缩参数异常:" + ex.getMessage());
|
| | | }
|
| | | return map;
|
| | | }
|
| | |
|
| | |
| | | for (ArdVideoInspectTaskStep ardVideoInspectTaskStep : ardVideoInspectTaskStepList) { |
| | | if (ardVideoInspectTaskStep.getId() == null) { |
| | | //新的步骤,添加 |
| | | ardVideoInspectTaskStep.setId(IdUtils.simpleUUID()); |
| | | ardVideoInspectTaskStepMapper.insertArdVideoInspectTaskStep(ardVideoInspectTaskStep); |
| | | } else { |
| | | //已有步骤,更新 |
| | |
| | | for (Items item : items) { |
| | | nameList.add(item.getName()); |
| | | } |
| | | } catch (ForestRuntimeException ex) { |
| | | }catch (ForestNetworkException ex) { |
| | | log.error("获取流媒体name列表异常:"+ex.getMessage()); |
| | | } |
| | | catch (ForestRuntimeException ex) { |
| | | log.error("获取流媒体name列表异常:"+ex.getMessage()); |
| | | } |
| | | return nameList; |
| | |
| | | */ |
| | | @Override |
| | | public int deleteVtduByName(String name) { |
| | | log.debug("流媒体【" + name + "】通道删除"); |
| | | mediaService.removePath(name); |
| | | log.debug("流媒体【" + name + "】通道删除"); |
| | | return vtduMapper.deleteVtduByName(name); |
| | | } |
| | | |
| | |
| | | /** |
| | | * 增加路径 |
| | | */ |
| | | @Post(url = "/config/paths/add/{name}") |
| | | @Post(url = "/config/paths/add/{name}",async = true) |
| | | public String addPath(@Var("name") String name, @JSONBody Conf body); |
| | | |
| | | /** |