| | |
| | | |
| | | import com.ruoyi.alarm.global.domain.GuidePriorityQueue; |
| | | import com.ruoyi.alarm.global.domain.GuideTask; |
| | | import com.ruoyi.alarm.global.service.impl.QueueHandler; |
| | | import com.ruoyi.common.annotation.SdkOperate; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.file.FileUtils; |
| | | import com.ruoyi.common.utils.file.MimeTypeUtils; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.device.camera.factory.CameraSDK; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | |
| | | import com.ruoyi.utils.gis.GisUtil; |
| | | import com.ruoyi.utils.minio.MinioUtil; |
| | | import com.ruoyi.utils.sdk.common.GlobalVariable; |
| | | import com.ruoyi.utils.sdk.dhsdk.common.ErrorCode; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.NetSDKLib; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.enumeration.EM_NEW_CONFIG; |
| | | import com.ruoyi.utils.sdk.dhsdk.lib.enumeration.NET_EM_CFG_OPERATE_TYPE; |
| | |
| | | private IVtduService vtduService; |
| | | @Value("${minio.endpoint}") |
| | | private String minioEndPoint; |
| | | |
| | | @Resource |
| | | private QueueHandler queueHandler; |
| | | |
| | | // 设备断线通知回调 |
| | | private static DisConnect disConnect = new DisConnect(); |
| | |
| | | * 登录 |
| | | * 刘苏义 |
| | | * 2023/10/17 8:28:13 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | } |
| | | |
| | | //创建引导队列 |
| | | if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) { |
| | | Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator(); |
| | | PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator); |
| | | GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue); |
| | | //创建引导队列 |
| | | if (camera.getCamAlarmGuideEnable() == 1) { |
| | | if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) { |
| | | Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator(); |
| | | PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator); |
| | | GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue); |
| | | } |
| | | //启动队列处理器 |
| | | queueHandler.process(camera.getId()); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | @Async("loginExecutor") |
| | | public void asyncLogin(ArdCameras camera){ |
| | | public void asyncLogin(ArdCameras camera) { |
| | | LoginModule.init(disConnect, haveReConnect); |
| | | NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex(); |
| | | NetSDKLib.LLong loginId = LoginModule.login(camera.getIp(), camera.getPort(), camera.getUsername(), camera.getPassword(), m_stDeviceInfo); |
| | |
| | | ardChannelService.insertArdChannel(channel); |
| | | } |
| | | //配置到流媒体 |
| | | for (int i = 1; i < m_stDeviceInfo.byChanNum + 1; i++) { |
| | | addVtdu(camera); |
| | | //创建引导队列 |
| | | createGuideQueue(camera); |
| | | } |
| | | |
| | | //添加到流媒体 |
| | | private void addVtdu(ArdCameras camera) { |
| | | for (int i = 1; i < camera.getChanNum() + 1; i++) { |
| | | String name = camera.getId() + "_" + i; |
| | | String rtspSource = "rtsp://" + camera.getUsername() + ":" + camera.getPassword() + "@" + camera.getIp() + ":" + camera.getRtspPort() + "/cam/realmonitor?channel=" + i + "&subtype=0"; |
| | | Vtdu vtdu = vtduService.selectVtduByName(name); |
| | |
| | | vtdu.setCameraId(camera.getId()); |
| | | vtduService.insertVtdu(vtdu); |
| | | } |
| | | } |
| | | |
| | | //创建引导队列 |
| | | if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) { |
| | | Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator(); |
| | | PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator); |
| | | GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue); |
| | | //创建引导队列 |
| | | private void createGuideQueue(ArdCameras camera) { |
| | | if (camera.getCamAlarmGuideEnable() != null) { |
| | | if (camera.getCamAlarmGuideEnable() == 1) { |
| | | if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) { |
| | | Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator(); |
| | | PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator); |
| | | GuidePriorityQueue.cameraQueueMap.put(camera.getId(), priorityQueue); |
| | | //启动队列处理器 |
| | | queueHandler.process(camera.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | * 注销 |
| | | * 刘苏义 |
| | | * 2023/10/17 8:28:13 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | * 2023/10/17 8:28:13 |
| | | */ |
| | | @Override |
| | | public boolean pTZControl(CameraCmd cmd) { |
| | | @SdkOperate |
| | | public AjaxResult pTZControl(CameraCmd cmd) { |
| | | String cameraId = cmd.getCameraId(); |
| | | boolean enable = cmd.isEnable(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | Integer speed = cmd.getSpeed(); |
| | | Integer code = cmd.getCode(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return false; |
| | | return AjaxResult.error("设备未登录"); |
| | | } |
| | | NetSDKLib.LLong loginId = (NetSDKLib.LLong) GlobalVariable.loginMap.get(cameraId); |
| | | int dwStop; |
| | |
| | | boolean bool = PtzControlModule.ptzControl(loginId, chanNo - 1, dwPTZCommand, speed, speed, 0, dwStop); |
| | | if (!bool) { |
| | | log.error("控制失败,请稍后重试" + getErrorCodePrint()); |
| | | return AjaxResult.error(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | } |
| | | return bool; |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult setPtz1(CameraCmd cmd) { |
| | | return setPtz(cmd) ; |
| | | } |
| | | |
| | | /** |
| | | * @描述 设置ptz信息 |
| | | * @参数 [userId, channelNum] |
| | |
| | | * @修改人和其它信息 注意俯仰角度负值需要加上360得到的正值进行设置 |
| | | */ |
| | | @Override |
| | | public boolean setPtz(CameraCmd cmd) { |
| | | @SdkOperate |
| | | public AjaxResult setPtz(CameraCmd cmd) { |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | | Map<String, Double> ptz = cmd.getPtzMap(); |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) { |
| | | return false; |
| | | return AjaxResult.error("设备未登录"); |
| | | } |
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId); |
| | | try { |
| | | if(ptz.get("p")==null||ptz.get("t")==null||ptz.get("z")==null) |
| | | { |
| | | return AjaxResult.error("ptz参数不能为空"); |
| | | } |
| | | int p = (int) (ptz.get("p") * 10); |
| | | int t = (int) (ptz.get("t") * 10); |
| | | t = t > 900 ? 3600 - t : t * -1; |
| | |
| | | boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_EXACTGOTO, p, t, z, 0); |
| | | if (!bool) { |
| | | log.error("控制失败,请稍后重试" + getErrorCodePrint()); |
| | | return AjaxResult.error(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError())); |
| | | } |
| | | return bool; |
| | | return AjaxResult.success(); |
| | | } catch (Exception ex) { |
| | | log.error(ex.getMessage()); |
| | | return false; |
| | | return AjaxResult.error(ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | * @修改人和其它信息 注意俯仰角度负值需要加上360得到的正值进行设置 |
| | | */ |
| | | @Override |
| | | @SdkOperate |
| | | public boolean setZeroPtz(CameraCmd cmd) { |
| | | String cameraId = cmd.getCameraId(); |
| | | Integer chanNo = cmd.getChanNo(); |
| | |
| | | } |
| | | return picUrl; |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getPtz1(CameraCmd cmd) { |
| | | return getPtz(cmd); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |