| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.camera.service.impl; |
| | | |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.camera.service.ICameraSdkService; |
| | | import com.ruoyi.device.channel.domain.ArdChannel; |
| | | import com.ruoyi.device.dhsdk.service.IDhClientService; |
| | | import com.ruoyi.device.hiksdk.common.GlobalVariable; |
| | | import com.ruoyi.device.hiksdk.service.IHikClientService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static com.ruoyi.device.hiksdk.sdk.HCNetSDK.NET_DVR_CHECK_USER_STATUS; |
| | | |
| | | |
| | | /** |
| | | * @Description: ç¸æºsdkä¸å¡ |
| | | * @ClassName: CameraSdkServiceImpl |
| | | * @Author: åèä¹ |
| | | * @Date: 2023å¹´10æ16æ¥15:21:01 |
| | | **/ |
| | | @Service |
| | | @Slf4j(topic = "SDK") |
| | | public class CameraSdkServiceImpl implements ICameraSdkService { |
| | | @Resource |
| | | IHikClientService hikClientService; |
| | | @Resource |
| | | IDhClientService dhClientService; |
| | | @Resource |
| | | RedisCache redisCache; |
| | | |
| | | @Override |
| | | public void initSDK() { |
| | | //åå§åå è½½sdkåºæä»¶ |
| | | boolean initHIK = hikClientService.init(); |
| | | if (initHIK) { |
| | | hikClientService.loginAll();//ç»å½å
¨é¨æµ·åº·ç¸æº |
| | | } |
| | | Boolean initDH = dhClientService.init(); |
| | | if (initDH) { |
| | | dhClientService.loginAll();//ç»å½å
¨é¨å¤§åç¸æº |
| | | } |
| | | } |
| | | @Override |
| | | public void syncLogin(ArdCameras cameras) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void asyncLogin(ArdCameras cameras) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public boolean logout(String cameraId) { |
| | | return false; |
| | | } |
| | | //å¨çº¿æ£æµ |
| | | @Override |
| | | public boolean isOnLine(CameraCmd cmd) { |
| | | try { |
| | | boolean onLine = false; |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | return onLine; |
| | | } catch (Exception ex) { |
| | | log.error("æ£æµå¨çº¿å¼å¸¸ï¼" + ex.getMessage()); |
| | | return false; |
| | | } |
| | | } |
| | | //äºå°æ§å¶ |
| | | @Override |
| | | public boolean pTZControl(CameraCmd cmd) { |
| | | try { |
| | | boolean result = false; |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | return result; |
| | | } catch (Exception ex) { |
| | | log.error("ptzæ§å¶å¼å¸¸ï¼" + ex.getMessage()); |
| | | return false; |
| | | } |
| | | } |
| | | //设置èç¦å¼ |
| | | @Override |
| | | public boolean setFocusPos(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("设置èç¦å¼å¼å¸¸ï¼" + ex.getMessage()); |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | //è·åèç¦å¼ |
| | | @Override |
| | | public Map<String, Object> getFocusPos(CameraCmd cmd) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId); |
| | | if (ardCamera != null) { |
| | | String factory = ardCamera.getFactory(); |
| | | if (factory.equals("1")) { |
| | | map = hikClientService.getFocusPos(cmd); |
| | | } else if (factory.equals("2")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("è·åèç¦å¼å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return map; |
| | | } |
| | | //设置é¢ç½®ä½ |
| | | @Override |
| | | public boolean setPreset(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("设置é¢ç½®ä½å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //è°ç¨é¢ç½®ä½ |
| | | @Override |
| | | public boolean gotoPreset(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("è°ç¨é¢ç½®ä½å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //è·åç æµåç¼©åæ° |
| | | @Override |
| | | public Map<String, String> getVideoCompressionCfg(CameraCmd cmd) { |
| | | Map<String, String> map = new HashMap<>(); |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("è·åç æµåç¼©åæ°å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return map; |
| | | } |
| | | //éé¾å¼å
³ |
| | | @Override |
| | | public boolean controlDefogcfg(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("ææ§éé¾å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //红å¤å¼å
³ |
| | | @Override |
| | | public boolean controlInfrarecfg(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("ææ§çº¢å¤å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //æå¨/èªå¨èç¦ |
| | | @Override |
| | | public boolean controlFocusMode(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("ææ§èç¦æ¨¡å¼å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //è·åèç¦æ¨¡å¼ |
| | | @Override |
| | | public String getFocusMode(CameraCmd cmd) { |
| | | String result = ""; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("è·åèç¦æ¨¡å¼å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //äºå°å ç |
| | | @Override |
| | | public boolean controlPTHeateRpwron(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("ææ§äºå°å çå¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //é头å ç |
| | | @Override |
| | | public boolean controlCameraDeicing(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("ææ§äºå°å çå¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //ææ§éå® |
| | | @Override |
| | | public boolean controlLock(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId); |
| | | if (ardCamera != null) { |
| | | String factory = ardCamera.getFactory(); |
| | | if (factory.equals("1")) { |
| | | result = hikClientService.controlLock(cmd); |
| | | } else if (factory.equals("2")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("ææ§éå®å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //设置解é |
| | | @Override |
| | | public boolean controlUnLock(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId); |
| | | if (ardCamera != null) { |
| | | String factory = ardCamera.getFactory(); |
| | | if (factory.equals("1")) { |
| | | result = hikClientService.controlUnLock(cmd); |
| | | } else if (factory.equals("2")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("设置解éå¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //è·åäºå°éå®ä¿¡æ¯ |
| | | @Override |
| | | public int getPTZLockInfo(CameraCmd cmd) { |
| | | int result = 99; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("è·åäºå°éå®ä¿¡æ¯å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public String captureJPEGPicture(CameraCmd cmd) { |
| | | return null; |
| | | } |
| | | //æå¾ |
| | | @Override |
| | | public String picCutCate(CameraCmd cmd) { |
| | | String url = ""; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId); |
| | | if (ardCamera != null) { |
| | | String factory = ardCamera.getFactory(); |
| | | if (factory.equals("1")) { |
| | | url = hikClientService.picCutCate(cmd); |
| | | } else if (factory.equals("2")) { |
| | | url = dhClientService.picCutCate(cmd); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("æå¾å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return url; |
| | | } |
| | | //è·åptz |
| | | @Override |
| | | public Map<String, Object> getPtz(CameraCmd cmd) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("è·åptzå¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return map; |
| | | } |
| | | //è·åptzèå´ |
| | | @Override |
| | | public Map<String, Object> getPtzScope(CameraCmd cmd) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("è·åptzèå´å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return map; |
| | | } |
| | | //设置ptz |
| | | @Override |
| | | public boolean setPtz(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("设置ptzå¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //è®¾ç½®é¶æ¹ä½è§ |
| | | @Override |
| | | public boolean setZeroPtz(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("è®¾ç½®é¶æ¹ä½è§å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //å¼å¯¼æåç®æ |
| | | @Override |
| | | public boolean guideTargetPosition(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("å¼å¯¼æåç®æ å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //å¼å§å½å |
| | | @Override |
| | | public boolean recordStart(CameraCmd cmd) { |
| | | boolean result = false; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("å¼å§å½åå¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return result; |
| | | } |
| | | //忢å½åå¹¶åå
¥minio |
| | | @Override |
| | | public String recordStopToMinio(CameraCmd cmd) { |
| | | String url = ""; |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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); |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("忢å½åå¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return url; |
| | | } |
| | | //忢å½åå¹¶ä¸åå
¥minio |
| | | @Override |
| | | public void recordStopNotToMinio(CameraCmd cmd) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public List<ArdChannel> getCameraChannelList(ArdCameras camera) { |
| | | return null; |
| | | } |
| | | |
| | | //è·åç¸æºæ¶è®¾åæ° |
| | | @Override |
| | | public Map<String, Object> getGisInfo(CameraCmd cmd) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | try { |
| | | String cameraId = cmd.getCameraId(); |
| | | 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")) { |
| | | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | log.error("è·åç¸æºæ¶è®¾åæ°å¼å¸¸ï¼" + ex.getMessage()); |
| | | } |
| | | return map; |
| | | } |
| | | } |