Merge remote-tracking branch 'origin/master'
| | |
| | | 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 io.swagger.annotations.Api; |
| | |
| | | public class CameraSdkController extends BaseController { |
| | | |
| | | @Resource |
| | | private IHikClientService hikClientService; |
| | | @Resource |
| | | private IDhClientService dhClientService; |
| | | private ICameraSdkService cameraSdkService; |
| | | @Resource |
| | | private IArdCamerasService ardCamerasService; |
| | | |
| | | /** |
| | | * @æè¿° åå§å è½½æµ·åº·åºæä»¶ |
| | | * @åæ° [] |
| | | * @æè¿° åå§å è½½SDKåºæä»¶ |
| | | * @è¿åå¼ void |
| | | * @å建人 åèä¹ |
| | | * @å建æ¶é´ 2023/1/17 16:13 |
| | | * @ä¿®æ¹äººåå
¶å®ä¿¡æ¯ if (Platform.isLinux()) |
| | | */ |
| | | @PostConstruct |
| | | public void initHCNetSDK() { |
| | | //åå§åå è½½sdkåºæä»¶ |
| | | hikClientService.loadHCNetSDKLib(); |
| | | //ç»å½ææç¸æº |
| | | hikClientService.loginAll(); |
| | | public void initSDK() { |
| | | cameraSdkService.initSDK(); |
| | | } |
| | | |
| | | @RequestMapping("/preview") |
| | |
| | | @Log(title = "è·åç æµåç¼©åæ°", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult getVideoCompressionCfg(@RequestBody CameraCmd cmd) { |
| | | return AjaxResult.success(hikClientService.getVideoCompressionCfg(cmd)); |
| | | return AjaxResult.success(cameraSdkService.getVideoCompressionCfg(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("å¨çº¿ç¶æ") |
| | |
| | | public @ResponseBody |
| | | AjaxResult getOnlineState(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | boolean onLine = hikClientService.isOnLine(cmd); |
| | | boolean onLine = cameraSdkService.isOnLine(cmd); |
| | | return AjaxResult.success(onLine); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.pTZControlWithSpeed(cmd)); |
| | | return toAjax(cameraSdkService.pTZControl(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("è°ç¨é¢ç½®ç¹") |
| | |
| | | public @ResponseBody |
| | | AjaxResult gotoPreset(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.gotoPreset(cmd)); |
| | | return toAjax(cameraSdkService.gotoPreset(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置é¢ç½®ç¹") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPreset(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setPreset(cmd)); |
| | | return toAjax(cameraSdkService.setPreset(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("è·åèç¦å¼") |
| | |
| | | public @ResponseBody |
| | | AjaxResult getFocusPos(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | Map<String, Object> Map = hikClientService.getFocusPos(cmd); |
| | | Map<String, Object> Map = cameraSdkService.getFocusPos(cmd); |
| | | return AjaxResult.success("è·åèç¦å¼", Map); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult setFocusPos(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setFocusPos(cmd)); |
| | | return toAjax(cameraSdkService.setFocusPos(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("è·åPTZ") |
| | |
| | | public @ResponseBody |
| | | AjaxResult getPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | Map<String, Object> ptzMap = hikClientService.getPtz(cmd); |
| | | Map<String, Object> ptzMap = cameraSdkService.getPtz(cmd); |
| | | return AjaxResult.success("è·åptz", ptzMap); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult getPTZScope(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | Map<String, Object> ptzMap = hikClientService.getPtzScope(cmd); |
| | | Map<String, Object> ptzMap = cameraSdkService.getPtzScope(cmd); |
| | | return AjaxResult.success("è·åptzèå´", ptzMap); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setPtz(cmd)); |
| | | return toAjax(cameraSdkService.setPtz(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("æåç®æ ") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setTargetPosition(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.guideTargetPosition(cmd)); |
| | | return toAjax(cameraSdkService.guideTargetPosition(cmd)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("è®¾ç½®é¶æ¹ä½è§") |
| | | @PostMapping("/setZeroPTZ") |
| | | @Log(title = "è®¾ç½®é¶æ¹ä½è§", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.cmd.chanNo"}) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | public @ResponseBody |
| | | AjaxResult setZeroPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.setZeroPtz(cmd)); |
| | | return toAjax(cameraSdkService.setZeroPtz(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置éå®") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPTZLock(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(hikClientService.controlLock(cmd)); |
| | | return AjaxResult.success(cameraSdkService.controlLock(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置解é") |
| | |
| | | public @ResponseBody |
| | | AjaxResult setPTZUnLock(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(hikClientService.controlUnLock(cmd)); |
| | | return AjaxResult.success(cameraSdkService.controlUnLock(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("è·åäºå°éå®ä¿¡æ¯") |
| | |
| | | public @ResponseBody |
| | | AjaxResult getPTZLockInfo(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | int byWorkMode = hikClientService.getPTZLockInfo(cmd); |
| | | int byWorkMode = cameraSdkService.getPTZLockInfo(cmd); |
| | | if (byWorkMode == 0) { |
| | | return AjaxResult.success("äºå°éå®ç¶æï¼è§£é"); |
| | | } else if (byWorkMode == 1) { |
| | |
| | | public @ResponseBody |
| | | AjaxResult defogcfg(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlDefogcfg(cmd)); |
| | | return toAjax(cameraSdkService.controlDefogcfg(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("红å¤å¼å
³") |
| | |
| | | public @ResponseBody |
| | | AjaxResult infrarecfg(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlInfrarecfg(cmd)); |
| | | return toAjax(cameraSdkService.controlInfrarecfg(cmd)); |
| | | } |
| | | |
| | | @ApiOperation(value = "æå¨/èªå¨èç¦", notes = "trueæå¨flaseèªå¨") |
| | |
| | | public @ResponseBody |
| | | AjaxResult enableFocusMode(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlFocusMode(cmd)); |
| | | return toAjax(cameraSdkService.controlFocusMode(cmd)); |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åèç¦æ¨¡å¼", notes = "1æå¨2èªå¨") |
| | |
| | | public @ResponseBody |
| | | AjaxResult getFocusMode(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String focusMode = hikClientService.getFocusMode(cmd); |
| | | String focusMode = cameraSdkService.getFocusMode(cmd); |
| | | return AjaxResult.success(focusMode); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult heateRpwron(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlPTHeateRpwron(cmd)); |
| | | return toAjax(cameraSdkService.controlPTHeateRpwron(cmd)); |
| | | } |
| | | |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult cameraDeicing(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(hikClientService.controlCameraDeicing(cmd)); |
| | | } |
| | | |
| | | @PostMapping("/captureJPEGPicture") |
| | | public @ResponseBody |
| | | AjaxResult captureJPEGPicture(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String base64Str = hikClientService.captureJPEGPicture(cmd); |
| | | return toAjaxString(base64Str, "ç¸æºæå¾"); |
| | | return toAjax(cameraSdkService.controlCameraDeicing(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("ç¸æºæå¾") |
| | |
| | | public @ResponseBody |
| | | AjaxResult picCutCate(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String path = hikClientService.picCutCate(cmd); |
| | | String path = cameraSdkService.picCutCate(cmd); |
| | | return toAjaxString(path, "ç¸æºæå¾"); |
| | | } |
| | | |
| | | @ApiOperation("æå¨å½å") |
| | | @PostMapping("/record") |
| | | @Log(title = "æå¨å½å", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"}) |
| | | public @ResponseBody |
| | | AjaxResult record(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String path = hikClientService.record(cmd); |
| | | return toAjaxString(path, "æå¨å½å"); |
| | | } |
| | | |
| | | @ApiOperation("è·åç¸æºæ¶è®¾åæ°") |
| | | @PostMapping("/getCameraSetupCFG") |
| | | @PostMapping("/getGisInfo") |
| | | @Log(title = "è·åç¸æºæ¶è®¾åæ°", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"}) |
| | | public @ResponseBody |
| | | AjaxResult getCameraSetupCFG(@RequestBody CameraCmd cmd) { |
| | | AjaxResult getGisInfo(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(hikClientService.getGisInfo(cmd)); |
| | | return AjaxResult.success(cameraSdkService.getGisInfo(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("æå¨å½åå¼å§") |
| | | @PostMapping("/recordStart") |
| | | @Log(title = "æå¨å½åå¼å§", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | public @ResponseBody |
| | | AjaxResult recordStart(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | boolean b = cameraSdkService.recordStart(cmd); |
| | | return toAjax(b); |
| | | } |
| | | @ApiOperation("æå¨å½å忢") |
| | | @PostMapping("/recordStop") |
| | | @Log(title = "æå¨å½å忢", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.recordBucketName", "cmd.recordObjectName"}) |
| | | public @ResponseBody |
| | | AjaxResult recordStop(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String url = cameraSdkService.recordStopToMinio(cmd); |
| | | return AjaxResult.success(url); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.camera.service; |
| | | |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.channel.domain.ArdChannel; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface ICameraSdkService { |
| | | //sdkåå§å |
| | | void initSDK(); |
| | | |
| | | //忥ç»å½ |
| | | void syncLogin(ArdCameras cameras); |
| | | |
| | | //弿¥ç»å½ |
| | | void asyncLogin(ArdCameras cameras); |
| | | |
| | | //注é |
| | | boolean logout(String cameraId); |
| | | |
| | | //å¨çº¿ç¶æ |
| | | boolean isOnLine(CameraCmd cmd); |
| | | |
| | | //äºå°æ§å¶ |
| | | boolean pTZControl(CameraCmd cmd); |
| | | |
| | | //设置èç¦å¼ |
| | | boolean setFocusPos(CameraCmd cmd); |
| | | |
| | | //è·åèç¦å¼ |
| | | Map<String, Object> getFocusPos(CameraCmd cmd); |
| | | |
| | | //设置é¢ç½®ä½ |
| | | boolean setPreset(CameraCmd cmd); |
| | | |
| | | //è°ç¨é¢ç½®ä½ |
| | | boolean gotoPreset(CameraCmd cmd); |
| | | |
| | | //è·åç æµåç¼©åæ° |
| | | Map<String, String> getVideoCompressionCfg(CameraCmd cmd); |
| | | |
| | | //éé¾ |
| | | boolean controlDefogcfg(CameraCmd cmd); |
| | | |
| | | //红� |
| | | boolean controlInfrarecfg(CameraCmd cmd); |
| | | |
| | | //èç¦æ¨¡å¼ |
| | | boolean controlFocusMode(CameraCmd cmd); |
| | | |
| | | //è·åèç¦æ¨¡å¼ |
| | | String getFocusMode(CameraCmd cmd); |
| | | |
| | | //äºå°å ç |
| | | boolean controlPTHeateRpwron(CameraCmd cmd); |
| | | |
| | | //é头é¤å° |
| | | boolean controlCameraDeicing(CameraCmd cmd); |
| | | |
| | | //é
ç½®éå® |
| | | boolean controlLock(CameraCmd cmd); |
| | | |
| | | //é
置解é |
| | | boolean controlUnLock(CameraCmd cmd); |
| | | |
| | | //è·åäºå°éå®ä¿¡æ¯ |
| | | int getPTZLockInfo(CameraCmd cmd); |
| | | |
| | | //æå¾-è¿ç»å端äºè¿å¶æµ |
| | | String captureJPEGPicture(CameraCmd cmd); |
| | | |
| | | //æå¾ |
| | | String picCutCate(CameraCmd cmd); |
| | | |
| | | //ptz ä¸åæ |
| | | Map<String, Object> getPtz(CameraCmd cmd); |
| | | |
| | | //è·åptzèå´ |
| | | Map<String, Object> getPtzScope(CameraCmd cmd); |
| | | |
| | | boolean setPtz(CameraCmd cmd); |
| | | |
| | | //è®¾ç½®é¶æ¹ä½è§ |
| | | boolean setZeroPtz(CameraCmd cmd); |
| | | |
| | | |
| | | //å¼å¯¼ç®æ ä½ç½® |
| | | boolean guideTargetPosition(CameraCmd cmd); |
| | | |
| | | //æå¨å¼å§å½å |
| | | boolean recordStart(CameraCmd cmd); |
| | | |
| | | //æå¨åæ¢å½å-ä¸ä¼ minio-è¿åå½åurl |
| | | String recordStopToMinio(CameraCmd cmd); |
| | | |
| | | //忢å½å-ä¸ä¸ä¼ minio |
| | | void recordStopNotToMinio(CameraCmd cmd); |
| | | |
| | | //è·åç¸æºééä¿¡æ¯ |
| | | public List<ArdChannel> getCameraChannelList(ArdCameras camera); |
| | | |
| | | //è·åGISä¿¡æ¯æ°æ® |
| | | public Map<String, Object> getGisInfo(CameraCmd cmd); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | @Resource
|
| | | private IDhClientService sdk;
|
| | |
|
| | | /**
|
| | | * @æè¿° åå§å 载大ååºæä»¶
|
| | | * @åæ° []
|
| | | * @è¿åå¼ void
|
| | | * @å建人 åèä¹
|
| | | * @å建æ¶é´ 2023/1/17 16:13
|
| | | * @ä¿®æ¹äººåå
¶å®ä¿¡æ¯ if (Platform.isLinux())
|
| | | */
|
| | | @PostConstruct
|
| | | public void initDHSDK() {
|
| | | //åå§åå è½½sdkåºæä»¶
|
| | | if (sdk.init())
|
| | | {
|
| | | //ç»å½ææç¸æº
|
| | | sdk.loginAll();
|
| | | }
|
| | | }
|
| | |
|
| | | @ApiOperation(value = "äºå°æ§å¶", notes = "Code:1-å·¦ä¸ 2-ä¸ 3-å³ä¸ 4-å·¦ 5-å·¡èª 6-å³ 7-å·¦ä¸ 8-ä¸ 9-å³ä¸ 10-ç¦è·å大 11-ç¦è·åå°\n" +
|
| | | "12-ç¦ç¹åè° 13-ç¦ç¹åè° 14-å
忩大 15-å
åç¼©å° ")
|
| | |
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.setZeroPtz(cmd));
|
| | | }
|
| | | @ApiOperation("ç¸æºæå¾")
|
| | | @PostMapping("/picCutCate")
|
| | | @Log(title = "ç¸æºæå¾", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
|
| | | public @ResponseBody
|
| | | AjaxResult picCutCate(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | String url = sdk.picCutCate(cmd);
|
| | | return toAjaxString(url, "ç¸æºæå¾");
|
| | | }
|
| | | @ApiOperation("æå¨å½åå¼å§")
|
| | | @PostMapping("/recordStart")
|
| | | @Log(title = "æå¨å½åå¼å§", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
|
| | | public @ResponseBody
|
| | | AjaxResult recordStart(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | boolean b = sdk.recordStart(cmd);
|
| | | return toAjax(b);
|
| | | }
|
| | | @ApiOperation("æå¨å½å忢")
|
| | | @PostMapping("/recordStop")
|
| | | @Log(title = "æå¨å½å忢", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.recordBucketName", "cmd.recordObjectName"})
|
| | | public @ResponseBody
|
| | | AjaxResult recordStop(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | String url = sdk.recordStopToMinio(cmd);
|
| | | return AjaxResult.success(url);
|
| | | }
|
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.dhsdk.module; |
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib; |
| | | import com.ruoyi.device.dhsdk.lib.ToolKits; |
| | | import com.sun.jna.ptr.IntByReference; |
| | | |
| | | /** |
| | | * \if ENGLISH_LANG |
| | | * Capture Picture Interface |
| | | * contains:localãremoteãtimer and stop capture picture |
| | | * \else |
| | | * æå¾æ¥å£å®ç° |
| | | * å
å«: æ¬å°ãè¿ç¨ã宿¶å忢æå¾ |
| | | * \endif |
| | | */ |
| | | public class CapturePictureModule { |
| | | |
| | | public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE; |
| | | |
| | | /** |
| | | * \if ENGLISH_LANG |
| | | * Local Capture Picture |
| | | * \else |
| | | * æ¬å°æå¾ |
| | | * \endif |
| | | */ |
| | | public static boolean localCapturePicture(NetSDKLib.LLong hPlayHandle, String picFileName) { |
| | | |
| | | if (!netsdk.CLIENT_CapturePictureEx(hPlayHandle, picFileName, NetSDKLib.NET_CAPTURE_FORMATS.NET_CAPTURE_JPEG)) { |
| | | System.err.printf("CLIENT_CapturePicture Failed!" + ToolKits.getErrorCodePrint()); |
| | | return false; |
| | | } else { |
| | | System.out.println("CLIENT_CapturePicture success"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * \if ENGLISH_LANG |
| | | * Remote Capture Picture |
| | | * \else |
| | | * è¿ç¨æå¾ |
| | | * \endif |
| | | */ |
| | | public static boolean remoteCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) { |
| | | return snapPicture(m_hLoginHandle,chn, 0, 0); |
| | | } |
| | | |
| | | /** |
| | | * \if ENGLISH_LANG |
| | | * Timer Capture Picture |
| | | * \else |
| | | * 宿¶æå¾ |
| | | * \endif |
| | | */ |
| | | public static boolean timerCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) { |
| | | return snapPicture(m_hLoginHandle,chn, 1, 2); |
| | | } |
| | | |
| | | /** |
| | | * \if ENGLISH_LANG |
| | | * Stop Timer Capture Picture |
| | | * \else |
| | | * 忢宿¶æå¾ |
| | | * \endif |
| | | */ |
| | | public static boolean stopCapturePicture(NetSDKLib.LLong m_hLoginHandle,int chn) { |
| | | return snapPicture(m_hLoginHandle,chn, -1, 0); |
| | | } |
| | | |
| | | /** |
| | | * \if ENGLISH_LANG |
| | | * Capture Picture (except local capture picture, others all call this interface) |
| | | * \else |
| | | * æå¾ (餿¬å°æå¾å¤, å
¶ä»å
¨é¨è°ç¨æ¤æ¥å£) |
| | | * \endif |
| | | */ |
| | | private static boolean snapPicture(NetSDKLib.LLong m_hLoginHandle,int chn, int mode, int interval) { |
| | | // send caputre picture command to device |
| | | NetSDKLib.SNAP_PARAMS stuSnapParams = new NetSDKLib.SNAP_PARAMS(); |
| | | stuSnapParams.Channel = chn; // channel |
| | | stuSnapParams.mode = mode; // capture picture mode |
| | | stuSnapParams.Quality = 3; // picture quality |
| | | stuSnapParams.InterSnap = interval; // timer capture picture time interval |
| | | stuSnapParams.CmdSerial = 0; // request serial |
| | | |
| | | IntByReference reserved = new IntByReference(0); |
| | | if (!LoginModule.netsdk.CLIENT_SnapPictureEx(m_hLoginHandle, stuSnapParams, reserved)) { |
| | | System.err.printf("CLIENT_SnapPictureEx Failed!" + ToolKits.getErrorCodePrint()); |
| | | return false; |
| | | } else { |
| | | System.out.println("CLIENT_SnapPictureEx success"); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * \if ENGLISH_LANG |
| | | * Set Capture Picture Callback |
| | | * \else |
| | | * 设置æå¾åè°å½æ° |
| | | * \endif |
| | | */ |
| | | public static void setSnapRevCallBack(NetSDKLib.fSnapRev cbSnapReceive){ |
| | | LoginModule.netsdk.CLIENT_SetSnapRevCallBack(cbSnapReceive, null); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib;
|
| | | import com.sun.jna.Structure;
|
| | | import com.sun.jna.ptr.IntByReference;
|
| | | import static com.ruoyi.device.dhsdk.lib.ToolKits.getErrorCodePrint;
|
| | |
|
| | | /**
|
| | | * @Description:
|
| | |
| | | **/
|
| | | public class ConfigModule {
|
| | | public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE;
|
| | | public static NetSDKLib configsdk = NetSDKLib.CONFIG_INSTANCE;
|
| | | /**
|
| | | * æ¥è¯¢è®¾å¤ç¶æ
|
| | | */
|
| | |
| | |
|
| | | IntByReference intRetLen = new IntByReference();
|
| | | stuInfo.write();
|
| | | if (!LoginModule.netsdk.CLIENT_QueryDevState(hLoginHandle, nType, stuInfo.getPointer(), stuInfo.size(), intRetLen, 3000)) {
|
| | | if (!netsdk.CLIENT_QueryDevState(hLoginHandle, nType, stuInfo.getPointer(), stuInfo.size(), intRetLen, 3000)) {
|
| | | return false;
|
| | | }
|
| | | stuInfo.read();
|
| | | return true;
|
| | | }
|
| | | /**
|
| | | * 设置å个é
ç½®
|
| | | * @param hLoginHandle ç»é奿
|
| | | * @param nChn ééå·ï¼-1 表示å
¨éé
|
| | | * @param strCmd é
ç½®åç§°
|
| | | * @param cmdObject é
置对åºçç»æä½å¯¹è±¡
|
| | | * @return æåè¿å true
|
| | | */
|
| | | public static boolean SetDevConfig(NetSDKLib.LLong hLoginHandle, int nChn, String strCmd, Structure cmdObject) {
|
| | | boolean result = false;
|
| | | int nBufferLen = 2*1024*1024;
|
| | | byte szBuffer[] = new byte[nBufferLen];
|
| | | for(int i=0; i<nBufferLen; i++)szBuffer[i]=0;
|
| | | IntByReference error = new IntByReference(0);
|
| | | IntByReference restart = new IntByReference(0);
|
| | | cmdObject.write();
|
| | | if (configsdk.CLIENT_PacketData(strCmd, cmdObject.getPointer(), cmdObject.size(), szBuffer, nBufferLen)) {
|
| | | cmdObject.read();
|
| | | if( configsdk.CLIENT_SetNewDevConfig(hLoginHandle, strCmd , nChn , szBuffer, nBufferLen, error, restart, 3000)) {
|
| | | result = true;
|
| | | } else {
|
| | | System.err.printf("Set %s Config Failed! Last Error = %s\n" , strCmd , getErrorCodePrint());
|
| | | result = false;
|
| | | }
|
| | | } else {
|
| | | System.err.println("Packet " + strCmd + " Config Failed!" + getErrorCodePrint());
|
| | | result = false;
|
| | | }
|
| | |
|
| | | return result;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib.LLong; |
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_IN_LOGIN_WITH_HIGHLEVEL_SECURITY; |
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_OUT_LOGIN_WITH_HIGHLEVEL_SECURITY; |
| | | import com.ruoyi.device.dhsdk.lib.ToolKits; |
| | | import com.sun.jna.Structure; |
| | | import com.sun.jna.ptr.IntByReference; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.io.File; |
| | | |
| | | import static com.ruoyi.device.dhsdk.lib.ToolKits.getErrorCodePrint; |
| | | |
| | | /** |
| | |
| | | public class LoginModule { |
| | | |
| | | public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE; |
| | | public static NetSDKLib configsdk = NetSDKLib.CONFIG_INSTANCE; |
| | | |
| | | // 设å¤ä¿¡æ¯ |
| | | public static NetSDKLib.NET_DEVICEINFO_Ex m_stDeviceInfo = new NetSDKLib.NET_DEVICEINFO_Ex(); |
| | |
| | | * ä¸»è¦æ ï¼å
«ä¸ªæ¹åæ§å¶ãååãåç¦ãå
ååè½ |
| | | */ |
| | | public class PtzControlModule { |
| | | public static NetSDKLib netsdk = NetSDKLib.NETSDK_INSTANCE; |
| | | |
| | | /** |
| | | * åä¸ |
| | | */ |
| | | public static boolean ptzControlUpStart(NetSDKLib.LLong lLoginID,int nChannelID, int lParam1, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | public static boolean ptzControlUpEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åä¸ |
| | | */ |
| | | public static boolean ptzControlDownStart(int nChannelID, int lParam1, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | public static boolean ptzControlDownEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå·¦ |
| | | */ |
| | | public static boolean ptzControlLeftStart(int nChannelID, int lParam1, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | public static boolean ptzControlLeftEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå³ |
| | | */ |
| | | public static boolean ptzControlRightStart(int nChannelID, int lParam1,int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | public static boolean ptzControlRightEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå·¦ä¸ |
| | | */ |
| | | public static boolean ptzControlLeftUpStart(int nChannelID, int lParam1, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | public static boolean ptzControlLeftUpEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå³ä¸ |
| | | */ |
| | | public static boolean ptzControlRightUpStart(int nChannelID, int lParam1, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | public static boolean ptzControlRightUpEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP, |
| | | 0, 0, 0, 1); |
| | | } |
| | | /** |
| | | * åä¸ |
| | | */ |
| | | public static boolean ptzControlUpStart(NetSDKLib.LLong lLoginID, int nChannelID, int lParam1, int lParam2) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | |
| | | /** |
| | | * åå·¦ä¸ |
| | | */ |
| | | public static boolean ptzControlLeftDownStart(int nChannelID, int lParam1, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | public static boolean ptzControlLeftDownEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå³ä¸ |
| | | */ |
| | | public static boolean ptzControlRightDownStart(int nChannelID, int lParam1, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | public static boolean ptzControlRightDownEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | public static boolean ptzControlUpEnd(int nChannelID) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_UP_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åä¸ |
| | | */ |
| | | public static boolean ptzControlDownStart(int nChannelID, int lParam1, int lParam2) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlDownEnd(int nChannelID) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_DOWN_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå·¦ |
| | | */ |
| | | public static boolean ptzControlLeftStart(int nChannelID, int lParam1, int lParam2) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlLeftEnd(int nChannelID) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå³ |
| | | */ |
| | | public static boolean ptzControlRightStart(int nChannelID, int lParam1, int lParam2) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlRightEnd(int nChannelID) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå·¦ä¸ |
| | | */ |
| | | public static boolean ptzControlLeftUpStart(int nChannelID, int lParam1, int lParam2) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlLeftUpEnd(int nChannelID) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTTOP, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå³ä¸ |
| | | */ |
| | | public static boolean ptzControlRightUpStart(int nChannelID, int lParam1, int lParam2) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlRightUpEnd(int nChannelID) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTTOP, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå·¦ä¸ |
| | | */ |
| | | public static boolean ptzControlLeftDownStart(int nChannelID, int lParam1, int lParam2) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlLeftDownEnd(int nChannelID) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_LEFTDOWN, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå³ä¸ |
| | | */ |
| | | public static boolean ptzControlRightDownStart(int nChannelID, int lParam1, int lParam2) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN, |
| | | lParam1, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlRightDownEnd(int nChannelID) { |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RIGHTDOWN, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå+ |
| | | */ |
| | | public static boolean ptzControlZoomAddStart(int nChannelID, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlZoomAddEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL, |
| | | 0, 0, 0, 1); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_ADD_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åå- |
| | | */ |
| | | public static boolean ptzControlZoomDecStart(int nChannelID, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlZoomDecEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL, |
| | | 0, 0, 0, 1); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_ZOOM_DEC_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åç¦+ |
| | | */ |
| | | public static boolean ptzControlFocusAddStart(int nChannelID, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlFocusAddEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL, |
| | | 0, 0, 0, 1); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_ADD_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * åç¦- |
| | | */ |
| | | public static boolean ptzControlFocusDecStart(int nChannelID, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlFocusDecEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL, |
| | | 0, 0, 0, 1); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_FOCUS_DEC_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * å
å+ |
| | | */ |
| | | public static boolean ptzControlIrisAddStart(int nChannelID, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlIrisAddEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL, |
| | | 0, 0, 0, 1); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_ADD_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | |
| | | /** |
| | | * å
å- |
| | | */ |
| | | public static boolean ptzControlIrisDecStart(int nChannelID, int lParam2) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL, |
| | | 0, lParam2, 0, 0); |
| | | } |
| | | |
| | | public static boolean ptzControlIrisDecEnd(int nChannelID) { |
| | | return LoginModule.netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL, |
| | | 0, 0, 0, 1); |
| | | return netsdk.CLIENT_DHPTZControlEx(LoginModule.m_hLoginHandle, nChannelID, |
| | | NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL, |
| | | 0, 0, 0, 1); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.dhsdk.module; |
| | | |
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib; |
| | | import com.ruoyi.device.dhsdk.lib.ToolKits; |
| | | import com.sun.jna.Pointer; |
| | | |
| | | import static com.ruoyi.device.dhsdk.module.LoginModule.netsdk; |
| | | |
| | | /** |
| | | * 宿¶é¢è§æ¥å£å®ç° |
| | | * ä¸»è¦æ ï¼å¼å§ææµãåæ¢ææµåè½ |
| | | */ |
| | | public class RealPlayModule { |
| | | /** |
| | | * \if ENGLISH_LANG |
| | | * Start RealPlay |
| | | * \else |
| | | * å¼å§é¢è§ |
| | | * \endif |
| | | */ |
| | | public static NetSDKLib.LLong startRealPlay(NetSDKLib.LLong m_hLoginHandle, int channel, int stream) { |
| | | NetSDKLib.LLong m_hPlayHandle = netsdk.CLIENT_RealPlayEx(m_hLoginHandle, channel, null, stream); |
| | | if (m_hPlayHandle.longValue() == 0) { |
| | | System.err.println("å¼å§å®æ¶é¢è§å¤±è´¥ï¼é误ç " + ToolKits.getErrorCodePrint()); |
| | | } else { |
| | | System.out.println("Success to start realplay"); |
| | | // netsdk.CLIENT_SetRealDataCallBackEx(m_hPlayHandle, CbfRealDataCallBackEx.getInstance(),null, 0x0000001f); |
| | | } |
| | | return m_hPlayHandle; |
| | | } |
| | | |
| | | public static NetSDKLib.LLong startRealPlay1(NetSDKLib.LLong m_hLoginHandle, int channel, String path) { |
| | | NetSDKLib.NET_IN_REALPLAY_BY_DATA_TYPE net_in_realplay_by_data_type = new NetSDKLib.NET_IN_REALPLAY_BY_DATA_TYPE(); |
| | | net_in_realplay_by_data_type.nChannelID = channel; |
| | | net_in_realplay_by_data_type.hWnd = null; |
| | | net_in_realplay_by_data_type.rType = 0; |
| | | net_in_realplay_by_data_type.emDataType = NetSDKLib.EM_REAL_DATA_TYPE.EM_REAL_DATA_TYPE_MP4; |
| | | net_in_realplay_by_data_type.szSaveFileName = path; |
| | | //net_in_realplay_by_data_type.cbRealData = CbfRealDataCallBackEx.getInstance(); |
| | | NetSDKLib.NET_OUT_REALPLAY_BY_DATA_TYPE net_out_realplay_by_data_type = new NetSDKLib.NET_OUT_REALPLAY_BY_DATA_TYPE(); |
| | | NetSDKLib.LLong m_hPlayHandle = netsdk.CLIENT_RealPlayByDataType(m_hLoginHandle, net_in_realplay_by_data_type, net_out_realplay_by_data_type, 5000); |
| | | if (m_hPlayHandle.longValue() == 0) { |
| | | System.err.println("å¼å§å®æ¶é¢è§å¤±è´¥ï¼é误ç " + ToolKits.getErrorCodePrint()); |
| | | } else { |
| | | System.out.println("Success to start realplay"); |
| | | } |
| | | return m_hPlayHandle; |
| | | } |
| | | |
| | | /** |
| | | * \if ENGLISH_LANG |
| | | * Start RealPlay |
| | | * \else |
| | | * 忢é¢è§ |
| | | * \endif |
| | | */ |
| | | public static void stopRealPlay(NetSDKLib.LLong m_hPlayHandle) { |
| | | if (m_hPlayHandle.longValue() == 0) { |
| | | return; |
| | | } |
| | | boolean bRet = netsdk.CLIENT_StopRealPlayEx(m_hPlayHandle); |
| | | if (bRet) { |
| | | m_hPlayHandle.setValue(0); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 宿¶é¢è§æ°æ®åè°å½æ°--æ©å±(pBufferå
åç±SDKå
é¨ç³è¯·éæ¾) |
| | | */ |
| | | private static class CbfRealDataCallBackEx implements NetSDKLib.fRealDataCallBackEx { |
| | | private CbfRealDataCallBackEx() { |
| | | } |
| | | |
| | | private static class CallBackHolder { |
| | | private static CbfRealDataCallBackEx instance = new CbfRealDataCallBackEx(); |
| | | } |
| | | |
| | | public static CbfRealDataCallBackEx getInstance() { |
| | | return CallBackHolder.instance; |
| | | } |
| | | |
| | | @Override |
| | | public void invoke(NetSDKLib.LLong lRealHandle, int dwDataType, Pointer pBuffer, |
| | | int dwBufSize, int param, Pointer dwUser) { |
| | | int bInput = 0; |
| | | if (0 != lRealHandle.longValue()) { |
| | | switch (dwDataType) { |
| | | case 0: |
| | | System.out.println("ç æµå¤§å°ä¸º" + dwBufSize + "\n" + "ç æµç±»å为åå§é³è§é¢æ··åæ°æ®"); |
| | | break; |
| | | case 1: |
| | | //æ åè§é¢æ°æ® |
| | | System.out.println("ç æµå¤§å°ä¸º" + dwBufSize + "\n" + "ç æµç±»å为æ åè§é¢æ°æ®"); |
| | | break; |
| | | case 2: |
| | | //yuv æ°æ® |
| | | System.out.println("ç æµå¤§å°ä¸º" + dwBufSize + "\n" + "ç æµç±»å为yuvæ°æ®"); |
| | | break; |
| | | case 3: |
| | | //pcm é³é¢æ°æ® |
| | | System.out.println("ç æµå¤§å°ä¸º" + dwBufSize + "\n" + "ç æµç±»å为é³é¢æ°æ®"); |
| | | break; |
| | | case 4: |
| | | //åå§é³é¢æ°æ® |
| | | System.out.println("ç æµå¤§å°ä¸º" + dwBufSize + "\n" + "ç æµç±»å为åå§é³é¢æ°æ®"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | |
|
| | | //设置PTZ
|
| | | boolean setPtz(CameraCmd cmd);
|
| | |
|
| | | //è®¾ç½®é¶æ¹ä½è§
|
| | | boolean setZeroPtz(CameraCmd cmd);
|
| | |
|
| | | //æå¾
|
| | | String picCutCate(CameraCmd cmd);
|
| | |
|
| | | //çæ¶å½å
|
| | | String record(CameraCmd cmd);
|
| | | boolean recordStart(CameraCmd cmd);
|
| | | String recordStopToMinio(CameraCmd cmd);
|
| | |
|
| | | //å¼å¯¼ç®æ ä½ç½®
|
| | | boolean guideTargetPosition(CameraCmd cmd);
|
| | |
|
| | | //è°ç¨é¢ç½®ä½
|
| | | boolean gotoPreset(CameraCmd cmd);
|
| | | //设置é¢ç½®ä½
|
| | | boolean setPreset(CameraCmd cmd);
|
| | | //èç¦æ¨¡å¼
|
| | | boolean controlFocusMode(CameraCmd cmd);
|
| | | }
|
| | |
| | | package com.ruoyi.device.dhsdk.service.impl;
|
| | |
|
| | | import com.ruoyi.common.annotation.SdkOperate;
|
| | | 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.domain.ArdCameras;
|
| | | import com.ruoyi.device.camera.domain.CameraCmd;
|
| | |
| | | import com.ruoyi.device.dhsdk.common.Res;
|
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib;
|
| | | import com.ruoyi.device.dhsdk.lib.NetSDKLib.LLong;
|
| | | import com.ruoyi.device.dhsdk.lib.ToolKits;
|
| | | import com.ruoyi.device.dhsdk.lib.enumeration.EM_NEW_QUERY_SYSTEM_INFO;
|
| | | import com.ruoyi.device.dhsdk.lib.structure.CFG_VIDEO_IN_FOCUS;
|
| | | import com.ruoyi.device.dhsdk.lib.structure.CFG_VIDEO_IN_FOCUS_UNIT;
|
| | | import com.ruoyi.device.dhsdk.module.CapturePictureModule;
|
| | | import com.ruoyi.device.dhsdk.module.ConfigModule;
|
| | | import com.ruoyi.device.dhsdk.module.LoginModule;
|
| | | import com.ruoyi.device.dhsdk.module.PtzControlModule;
|
| | | import com.ruoyi.device.dhsdk.module.RealPlayModule;
|
| | | import com.ruoyi.device.dhsdk.service.IDhClientService;
|
| | | import com.ruoyi.device.hiksdk.common.GlobalVariable;
|
| | | import com.ruoyi.device.hiksdk.sdk.HCNetSDK;
|
| | | import com.ruoyi.utils.gis.GisUtil;
|
| | | import com.ruoyi.utils.minio.MinioUtil;
|
| | | import com.sun.jna.Pointer;
|
| | | import lombok.extern.slf4j.Slf4j;
|
| | | import org.springframework.beans.factory.annotation.Value;
|
| | | import org.springframework.scheduling.annotation.Async;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import java.io.ByteArrayInputStream;
|
| | | import java.io.FileInputStream;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.text.DecimalFormat;
|
| | | import java.util.*;
|
| | |
|
| | | import static com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_DEVSTATE_ONLINE;
|
| | | import static com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_DEVSTATE_PTZ_LOCATION;
|
| | | import static com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_MOVE_CONTROL;
|
| | | import static com.ruoyi.device.dhsdk.lib.NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_SET_CONTROL;
|
| | | import static com.ruoyi.device.dhsdk.lib.ToolKits.getErrorCodePrint;
|
| | | import static com.ruoyi.device.hiksdk.sdk.HCNetSDK.*;
|
| | | import static com.ruoyi.device.dhsdk.module.LoginModule.netsdk;
|
| | | import static com.ruoyi.device.hiksdk.sdk.HCNetSDK.NET_DVR_SET_PTZPOS;
|
| | |
|
| | |
|
| | | /**
|
| | | * @ClassName DhSdkServiceImpl
|
| | |
| | | private IArdCamerasService ardCamerasService;
|
| | | @Resource
|
| | | private IArdChannelService ardChannelService;
|
| | | @Value("${minio.endpoint}")
|
| | | private String minioEndPoint;
|
| | |
|
| | | private Vector<String> chnlist = new Vector<String>();
|
| | | // è®¾å¤æçº¿éç¥åè°
|
| | |
| | | // ç½ç»è¿æ¥æ¢å¤
|
| | | private static HaveReConnect haveReConnect = new HaveReConnect();
|
| | |
|
| | |
|
| | | /**
|
| | | * ç»å½ææç¸æº
|
| | | * åèä¹
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | public void loginAll() {
|
| | | try {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * sdkåå§å
|
| | | * åèä¹
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | public Boolean init() {
|
| | | return LoginModule.init(disConnect, haveReConnect); // æå¼å·¥ç¨ï¼åå§å
|
| | | }
|
| | |
|
| | | /**
|
| | | * ç»å½
|
| | | * åèä¹
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | @Async
|
| | | public Boolean login(ArdCameras camera) {
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 注é
|
| | | * åèä¹
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | public Boolean logout(String cameraId) {
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | |
| | | return LoginModule.logout(loginId);
|
| | | }
|
| | |
|
| | | /**
|
| | | * æ¯å¦å¨çº¿æ£æµ
|
| | | * åèä¹
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | public boolean isOnLine(CameraCmd cmd) {
|
| | | try {
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | /**
|
| | | * äºå°æ§å¶
|
| | | * åèä¹
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | public boolean pTZControl(CameraCmd cmd) {
|
| | | String cameraId = cmd.getCameraId();
|
| | |
| | | dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LEFT_CONTROL;
|
| | | break;
|
| | | case 5:
|
| | | dwPTZCommand = HCNetSDK.RUN_SEQ;
|
| | | dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_POINT_LOOP_CONTROL;
|
| | | break;
|
| | | case 6:
|
| | | dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_RIGHT_CONTROL;
|
| | |
| | | case 15:
|
| | | dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_APERTURE_DEC_CONTROL;
|
| | | break;
|
| | | case 16:
|
| | | dwPTZCommand = NetSDKLib.NET_PTZ_ControlType.NET_PTZ_LAMP_CONTROL;
|
| | | break;
|
| | | }
|
| | | boolean bool = LoginModule.netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, dwPTZCommand, speed, speed, 0, dwStop);
|
| | | boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, dwPTZCommand, speed, speed, 0, dwStop);
|
| | | if (!bool) {
|
| | | log.error("æ§å¶å¤±è´¥,请ç¨åéè¯" + getErrorCodePrint());
|
| | | }
|
| | | return bool;
|
| | | }
|
| | |
|
| | | /**
|
| | | * è·åPTZå¼
|
| | | * åèä¹
|
| | | * 2023/10/17 8:28:13
|
| | | */
|
| | | @Override
|
| | | public Map<String, Object> getPtz(CameraCmd cmd) {
|
| | | Map<String, Object> ptzMap = new HashMap<>();
|
| | |
| | | }
|
| | | return ptzMap;
|
| | | }
|
| | |
|
| | | /**
|
| | | * @æè¿° 设置ptzä¿¡æ¯
|
| | | * @åæ° [userId, channelNum]
|
| | |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return false;
|
| | | }
|
| | | LLong loginId = (LLong)GlobalVariable.loginMap.get(cameraId);
|
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
|
| | | try {
|
| | | int p = (int)(ptz.get("p") * 10);
|
| | | int t = (int)(ptz.get("t") * 10);
|
| | | int p = (int) (ptz.get("p") * 10);
|
| | | int t = (int) (ptz.get("t") * 10);
|
| | | int z = ptz.get("z").intValue();
|
| | | boolean bool = LoginModule.netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_EXACTGOTO, p, t, z, 0 );
|
| | | if (z == 0) {
|
| | | z = 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());
|
| | | }
|
| | |
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return false;
|
| | | }
|
| | | LLong loginId = (LLong)GlobalVariable.loginMap.get(cameraId);
|
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
|
| | | boolean bool = NetSDKLib.NETSDK_INSTANCE.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_RESETZERO, 0, 0, 0, 0);
|
| | | if (!bool) {
|
| | | log.error("æ§å¶å¤±è´¥,请ç¨åéè¯" + getErrorCodePrint());
|
| | |
| | | return bool;
|
| | | }
|
| | |
|
| | | /**
|
| | | * @æè¿° æªå¾ åæå¡å¨
|
| | | * @åæ° [cameraId, channelNum]
|
| | | * @è¿åå¼ java.lang.String
|
| | | * @å建人 åèä¹
|
| | | * @å建æ¶é´ 2023/2/2 14:59
|
| | | * @ä¿®æ¹äººåå
¶å®ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | @SdkOperate
|
| | | public String picCutCate(CameraCmd cmd) {
|
| | | String cameraId = cmd.getCameraId();
|
| | | Integer chanNo = cmd.getChanNo();
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return "";
|
| | | }
|
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
|
| | | String bucketName = "pic";
|
| | | String picUrl = "";
|
| | | String bucketObject = "/capture/" + IdUtils.simpleUUID() + ".jpeg";
|
| | | fCaptureReceiveCB m_CaptureReceiveCB = new fCaptureReceiveCB(minioEndPoint, bucketName, bucketObject);
|
| | | CapturePictureModule.setSnapRevCallBack(m_CaptureReceiveCB);
|
| | | boolean b = CapturePictureModule.remoteCapturePicture(loginId, chanNo - 1);
|
| | | if (b) {
|
| | | picUrl = minioEndPoint + "/" + bucketName + bucketObject;
|
| | | }
|
| | | return picUrl;
|
| | |
|
| | | }
|
| | |
|
| | | // è®¾å¤æçº¿åè°: éè¿ CLIENT_Init 设置该åè°å½æ°ï¼å½è®¾å¤åºç°æçº¿æ¶ï¼SDKä¼è°ç¨è¯¥å½æ°
|
| | | /**
|
| | | * @æè¿° çæ¶å½å
|
| | | * @åæ° [userId, channelNum, enable]
|
| | | * @è¿åå¼ void
|
| | | * @å建人 åèä¹
|
| | | * @å建æ¶é´ 2023/1/20 11:18
|
| | | * @ä¿®æ¹äººåå
¶å®ä¿¡æ¯
|
| | | */
|
| | | @Override
|
| | | public String record(CameraCmd cmd) {
|
| | | try {
|
| | | String url = "";
|
| | | String cameraId = cmd.getCameraId();
|
| | | Integer chanNo = cmd.getChanNo();
|
| | | String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
|
| | | boolean enable = cmd.isEnable();
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return "";
|
| | | }
|
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
|
| | |
|
| | | if (enable) {
|
| | | LLong lRealHandle = new LLong(0);
|
| | | if (!GlobalVariable.previewMap.containsKey(cameraId)) {
|
| | | lRealHandle = RealPlayModule.startRealPlay(loginId, chanNo, 0);
|
| | | if (lRealHandle.longValue() <= 0) {
|
| | | log.error("åæµå¤±è´¥" + getErrorCodePrint());
|
| | | return "";
|
| | | }
|
| | | log.debug("åæµæå");
|
| | | GlobalVariable.previewMap.put(cameraId, lRealHandle.intValue());
|
| | | }
|
| | | if (!netsdk.CLIENT_SaveRealData(lRealHandle, path)) {
|
| | | log.error("ä¿åè§é¢æä»¶å°ä¸´æ¶æä»¶å¤¹å¤±è´¥ é误ç 为: " + getErrorCodePrint());
|
| | | return "";
|
| | | }
|
| | | log.debug("å½åå¼å§");
|
| | | } else {
|
| | | if (GlobalVariable.previewMap.containsKey(cameraId)) {
|
| | | LLong lRealHandle = new LLong(GlobalVariable.previewMap.get(cameraId));
|
| | | boolean b = netsdk.CLIENT_StopSaveRealData(lRealHandle);
|
| | | GlobalVariable.previewMap.remove(cameraId);
|
| | | }
|
| | | log.debug("å½å忢");
|
| | | }
|
| | | return url;
|
| | | } catch (Exception ex) {
|
| | | log.error("å½åå¼å¸¸" + ex.getMessage());
|
| | | return "";
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean recordStart(CameraCmd cmd) {
|
| | | try {
|
| | | String cameraId = cmd.getCameraId();
|
| | | Integer chanNo = cmd.getChanNo();
|
| | | String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return false;
|
| | | }
|
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
|
| | | LLong lRealHandle;
|
| | | if (GlobalVariable.previewMap.containsKey(cameraId)) {
|
| | | lRealHandle = new LLong(GlobalVariable.previewMap.get(cameraId));
|
| | | netsdk.CLIENT_StopRealPlayEx(lRealHandle);
|
| | | GlobalVariable.previewMap.remove(cameraId);
|
| | | log.debug("忢å½åå½å");
|
| | | }
|
| | | lRealHandle = RealPlayModule.startRealPlay1(loginId, chanNo - 1, path);
|
| | | if (lRealHandle.longValue() <= 0) {
|
| | | log.error("åæµå¤±è´¥" + getErrorCodePrint());
|
| | | }
|
| | | log.debug("åæµæå");
|
| | | GlobalVariable.previewMap.put(cameraId, lRealHandle.intValue());
|
| | | GlobalVariable.threadMap.put(cameraId, Thread.currentThread().getName());
|
| | | //if (!netsdk.CLIENT_SaveRealData(lRealHandle, path)) {
|
| | | // log.error("ä¿åè§é¢æä»¶å°ä¸´æ¶æä»¶å¤¹å¤±è´¥ é误ç 为: " +getErrorCodePrint());
|
| | | // return false;
|
| | | //}
|
| | | log.debug("å½åå¼å§");
|
| | | return true;
|
| | | } catch (Exception ex) {
|
| | | log.error("å¼å§å½åå¼å¸¸" + ex.getMessage());
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public String recordStopToMinio(CameraCmd cmd) {
|
| | | String url = "";
|
| | | try {
|
| | | String cameraId = cmd.getCameraId();
|
| | | String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return "";
|
| | | }
|
| | | LLong lRealHandle;
|
| | | if (GlobalVariable.previewMap.containsKey(cameraId)) {
|
| | | lRealHandle = new LLong(GlobalVariable.previewMap.get(cameraId));
|
| | | netsdk.CLIENT_StopRealPlayEx(lRealHandle);
|
| | | GlobalVariable.previewMap.remove(cameraId);
|
| | | log.debug("忢å½åå½å");
|
| | | }
|
| | | //åå
¥minio
|
| | | String BucketName = cmd.getRecordBucketName();
|
| | | String ObjectName = cmd.getRecordObjectName() + ".mp4";
|
| | | FileInputStream stream = new FileInputStream(path);
|
| | | boolean b = MinioUtil.uploadObject(BucketName, ObjectName, stream, stream.available(), "video/MP4");
|
| | | if (b) {
|
| | | url = MinioUtil.getBucketObjectUrl(BucketName, ObjectName);
|
| | | log.debug("ä¸ä¼ æä»¶æå!" + url);
|
| | | }
|
| | | return url;
|
| | | } catch (Exception ex) {
|
| | | log.error("å½åå¼å¸¸" + ex.getMessage());
|
| | | return "";
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * å¼å¯¼ç®æ ä½ç½®
|
| | | * åèä¹
|
| | | * 2023/10/17 8:27:48
|
| | | */
|
| | | @Override
|
| | | public boolean guideTargetPosition(CameraCmd cmd) {
|
| | | String cameraId = cmd.getCameraId();
|
| | | Integer chanNo = cmd.getChanNo();
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return false;
|
| | | }
|
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
|
| | | try {
|
| | | ArdCameras cameras = ardCamerasService.selectArdCamerasById(cameraId);
|
| | | double[] cameraPositon = new double[]{cameras.getLongitude(), cameras.getLatitude(), cameras.getAltitude()};
|
| | | double[] targetPositions = cmd.getTargetPosition();
|
| | | double[] cameraPTZ = GisUtil.getCameraPTZ(cameraPositon, targetPositions, 20, 150);
|
| | | int p = (int) (cameraPTZ[0] * 10);
|
| | | int t = (int) (cameraPTZ[1] * 10);
|
| | | int z = (int) (cameraPTZ[2]);
|
| | | 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 bool;
|
| | | } catch (Exception ex) {
|
| | | log.error("å¼å¯¼å¼å¸¸:" + ex.getMessage());
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | //转è³é¢ç½®ç¹
|
| | | @Override
|
| | | public boolean gotoPreset(CameraCmd cmd) {
|
| | | String cameraId = cmd.getCameraId();
|
| | | Integer chanNo = cmd.getChanNo();
|
| | | Integer PresetIndex = cmd.getPresetIndex();
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return false;
|
| | | }
|
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
|
| | | try {
|
| | |
|
| | | boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NET_PTZ_POINT_MOVE_CONTROL, 0, PresetIndex, 0, 0);
|
| | | if (!bool) {
|
| | | log.error("æ§å¶å¤±è´¥,请ç¨åéè¯" + getErrorCodePrint());
|
| | | }
|
| | | return bool;
|
| | | } catch (Exception ex) {
|
| | | log.error("转è³é¢ç½®ç¹å¼å¸¸:" + ex.getMessage());
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | //设置é¢ç½®ä½
|
| | | public boolean setPreset(CameraCmd cmd) {
|
| | | String cameraId = cmd.getCameraId();
|
| | | Integer chanNo = cmd.getChanNo();
|
| | | Integer PresetIndex = cmd.getPresetIndex();
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return false;
|
| | | }
|
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
|
| | | try {
|
| | |
|
| | | boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NET_PTZ_POINT_SET_CONTROL, 0, PresetIndex, 0, 0);
|
| | | if (!bool) {
|
| | | log.error("æ§å¶å¤±è´¥,请ç¨åéè¯" + getErrorCodePrint());
|
| | | }
|
| | | return bool;
|
| | | } catch (Exception ex) {
|
| | | log.error("设置é¢ç½®ç¹å¼å¸¸:" + ex.getMessage());
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | //忢èç¦æ¨¡å¼
|
| | | @Override
|
| | | public boolean controlFocusMode(CameraCmd cmd) {
|
| | | String cameraId = cmd.getCameraId();
|
| | | Integer chanNo = cmd.getChanNo();
|
| | | boolean enable = cmd.isEnable();
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return false;
|
| | | }
|
| | | LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
|
| | | try {
|
| | | CFG_VIDEO_IN_FOCUS cfg_video_in_focus = new CFG_VIDEO_IN_FOCUS();
|
| | | CFG_VIDEO_IN_FOCUS_UNIT[] stVideoInFocusUnit = new CFG_VIDEO_IN_FOCUS_UNIT[32];
|
| | | if (enable) {
|
| | | stVideoInFocusUnit[0].nMode = 4;//æå¨èç¦
|
| | | } else {
|
| | | stVideoInFocusUnit[0].nMode = 2;//æå¨èç¦
|
| | | }
|
| | | cfg_video_in_focus.nChannelIndex = chanNo - 1;
|
| | | cfg_video_in_focus.stVideoInFocusUnit = stVideoInFocusUnit;
|
| | | boolean bool = ConfigModule.SetDevConfig(loginId, chanNo - 1, NetSDKLib.CFG_CMD_VIDEOIN_FOCUS, cfg_video_in_focus);
|
| | | if (!bool) {
|
| | | log.error("æ§å¶å¤±è´¥,请ç¨åéè¯" + getErrorCodePrint());
|
| | | }
|
| | | return bool;
|
| | | } catch (Exception ex) {
|
| | | log.error("忢èç¦æ¨¡å¼å¼å¸¸:" + ex.getMessage());
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | // è®¾å¤æçº¿åè°: å½è®¾å¤åºç°æçº¿æ¶ï¼SDKä¼è°ç¨è¯¥å½æ°
|
| | | private static class DisConnect implements NetSDKLib.fDisConnect {
|
| | | public void invoke(LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) {
|
| | | System.out.printf("Device[%s] Port[%d] DisConnect!\n", pchDVRIP, nDVRPort);
|
| | | }
|
| | | }
|
| | |
|
| | | // ç½ç»è¿æ¥æ¢å¤ï¼è®¾å¤éè¿æååè°
|
| | | // éè¿ CLIENT_SetAutoReconnect 设置该åè°å½æ°ï¼å½å·²æçº¿ç设å¤éè¿æåæ¶ï¼SDKä¼è°ç¨è¯¥å½æ°
|
| | | // ç½ç»è¿æ¥æ¢å¤åè°:设å¤éè¿æååè°ï¼å½å·²æçº¿ç设å¤éè¿æåæ¶ï¼SDKä¼è°ç¨è¯¥å½æ°
|
| | | private static class HaveReConnect implements NetSDKLib.fHaveReConnect {
|
| | | @Override
|
| | | public void invoke(LLong lLoginID, String pchDVRIP, int nDVRPort, Pointer dwUser) {
|
| | | System.out.printf("ReConnect Device[%s] Port[%d]\n", pchDVRIP, nDVRPort);
|
| | | }
|
| | | }
|
| | |
|
| | | // æå¾æ¥æ¶åè°:彿徿åï¼sdkä¼è°ç¨è¯¥å½æ°
|
| | | public static class fCaptureReceiveCB implements NetSDKLib.fSnapRev {
|
| | | private String minioEndPoint;
|
| | | private String ObjectName;
|
| | | private String bucketName;
|
| | |
|
| | | public fCaptureReceiveCB(String minioEndPoint, String bucketName, String ObjectName) {
|
| | | this.minioEndPoint = minioEndPoint;
|
| | | this.bucketName = bucketName;
|
| | | this.ObjectName = ObjectName;
|
| | | }
|
| | |
|
| | | public void invoke(LLong lLoginID, Pointer pBuf, int RevLen, int EncodeType, int CmdSerial, Pointer dwUser) {
|
| | | if (pBuf != null && RevLen > 0) {
|
| | | byte[] buf = pBuf.getByteArray(0, RevLen);
|
| | | //åå¨å°minio
|
| | | InputStream input = new ByteArrayInputStream(buf);
|
| | |
|
| | | try {
|
| | | boolean b = MinioUtil.uploadObject(bucketName, ObjectName, input, input.available(), MimeTypeUtils.IMAGE_JPEG);
|
| | | if (b) {
|
| | | String url = minioEndPoint + "/" + bucketName + ObjectName;
|
| | | log.debug("ä¸ä¼ æä»¶æå!" + url);
|
| | | }
|
| | | } catch (IOException ex) {
|
| | | log.error("ä¸ä¼ æä»¶å¼å¸¸ï¼" + ex.getMessage());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | } |
ÎļþÃû´Ó ard-work/src/main/java/com/ruoyi/device/hiksdk/controller/SdkController.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.device.hiksdk.controller;
|
| | |
|
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
| | | import com.ruoyi.common.annotation.Log;
|
| | | import com.ruoyi.common.core.controller.BaseController;
|
| | | import com.ruoyi.common.enums.BusinessType;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | | 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.dhsdk.service.IDhClientService;
|
| | | import com.ruoyi.device.hiksdk.service.IHikClientService;
|
| | | import com.ruoyi.common.annotation.Anonymous;
|
| | | import com.ruoyi.common.core.domain.AjaxResult;
|
| | | import io.swagger.annotations.Api;
|
| | | import io.swagger.annotations.ApiOperation;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.*;
|
| | |
|
| | | import javax.annotation.PostConstruct;
|
| | | import javax.annotation.Resource;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | /**
|
| | | * @ClassName: sdkController
|
| | | * @Description:
|
| | | * @Author: Administrator
|
| | | * @Date: 2023å¹´01æ17æ¥ 12:04
|
| | | * @Version: 1.0
|
| | | **/
|
| | | @Api(tags = "海康SDKæ¥å£")
|
| | | @Controller
|
| | | @RequestMapping("/hik")
|
| | | @Anonymous
|
| | | public class SdkController extends BaseController {
|
| | |
|
| | | @Resource
|
| | | private IHikClientService sdk;
|
| | | @Resource
|
| | | private IDhClientService ClientService;
|
| | | @Resource
|
| | | private IArdCamerasService ardCamerasService;
|
| | |
|
| | | /**
|
| | | * @æè¿° åå§å è½½æµ·åº·åºæä»¶
|
| | | * @åæ° []
|
| | | * @è¿åå¼ void
|
| | | * @å建人 åèä¹
|
| | | * @å建æ¶é´ 2023/1/17 16:13
|
| | | * @ä¿®æ¹äººåå
¶å®ä¿¡æ¯ if (Platform.isLinux())
|
| | | */
|
| | | @PostConstruct
|
| | | public void initHCNetSDK() {
|
| | | //åå§åå è½½sdkåºæä»¶
|
| | | sdk.loadHCNetSDKLib();
|
| | | //ç»å½ææç¸æº
|
| | | sdk.loginAll();
|
| | | }
|
| | |
|
| | | @RequestMapping("/preview")
|
| | | private String preview() {
|
| | | return "preview";
|
| | | }
|
| | | @RequestMapping("/index")
|
| | | private String index() {
|
| | | return "test";
|
| | | }
|
| | |
|
| | | @GetMapping("/list")
|
| | | public @ResponseBody
|
| | | AjaxResult list(ArdCameras ardCamera) {
|
| | | List<ArdCameras> list = ardCamerasService.selectArdCamerasListNoDataScope(ardCamera);
|
| | | return AjaxResult.success("ç¸æºå表ï¼", list);
|
| | | }
|
| | |
|
| | | @ApiOperation("è·åç æµåç¼©åæ°")
|
| | | @PostMapping("/getVideoCompressionCfg")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
|
| | | @Log(title = "è·åç æµåç¼©åæ°", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult getVideoCompressionCfg(@RequestBody CameraCmd cmd) {
|
| | | return AjaxResult.success(sdk.getVideoCompressionCfg(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("å¨çº¿ç¶æ")
|
| | | @PostMapping("/state")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId"})
|
| | | @Log(title = "å¨çº¿ç¶æ", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult getOnlineState(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | boolean onLine = sdk.isOnLine(cmd);
|
| | | return AjaxResult.success(onLine);
|
| | | }
|
| | |
|
| | | @ApiOperation(value = "äºå°æ§å¶", notes = "Code:1-å·¦ä¸ 2-ä¸ 3-å³ä¸ 4-å·¦ 5-å·¡èª 6-å³ 7-å·¦ä¸ 8-ä¸ 9-å³ä¸ 10-ç¦è·å大 11-ç¦è·åå°\n" +
|
| | | "12-ç¦ç¹åè° 13-ç¦ç¹åè° 14-å
忩大 15-å
åç¼©å° 16-é¨å·å¼å¯")
|
| | | @PostMapping("/PTZControlWithSpeed")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.speed", "cmd.enable", "cmd.code"})
|
| | | @Log(title = "äºå°æ§å¶", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.pTZControlWithSpeed(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("è°ç¨é¢ç½®ç¹")
|
| | | @PostMapping("/gotoPreset")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.presetIndex"})
|
| | | @Log(title = "è°ç¨é¢ç½®ç¹", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult gotoPreset(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.gotoPreset(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("设置é¢ç½®ç¹")
|
| | | @PostMapping("/setPreset")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.presetIndex"})
|
| | | @Log(title = "设置é¢ç½®ç¹", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult setPreset(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.setPreset(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("è·åèç¦å¼")
|
| | | @PostMapping("/getFocusPos")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
|
| | | @Log(title = "è·åèç¦å¼", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult getFocusPos(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | Map<String, Object> Map = sdk.getFocusPos(cmd);
|
| | | return AjaxResult.success("è·åèç¦å¼", Map);
|
| | | }
|
| | |
|
| | | @ApiOperation("设置èç¦å¼")
|
| | | @PostMapping("/setFocusPos")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.dwFocusPos"})
|
| | | @Log(title = "设置èç¦å¼", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult setFocusPos(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.setFocusPos(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("è·åPTZ")
|
| | | @PostMapping("/getPTZ")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
|
| | | @Log(title = "è·åPTZ", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult getPTZ(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | Map<String, Object> ptzMap = sdk.getPtz(cmd);
|
| | | return AjaxResult.success("è·åptz", ptzMap);
|
| | | }
|
| | |
|
| | | @ApiOperation("è·åPTZèå´")
|
| | | @PostMapping("/getPTZScope")
|
| | | @Log(title = "è·åPTZèå´", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
|
| | | public @ResponseBody
|
| | | AjaxResult getPTZScope(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | Map<String, Object> ptzMap = sdk.getPtzScope(cmd);
|
| | | return AjaxResult.success("è·åptzèå´", ptzMap);
|
| | | }
|
| | |
|
| | | @ApiOperation("设置PTZ")
|
| | | @PostMapping("/setPTZ")
|
| | | @Log(title = "设置PTZ", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.ptzMap"})
|
| | | public @ResponseBody
|
| | | AjaxResult setPTZ(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.setPtz(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("æåç®æ ")
|
| | | @PostMapping("/setTargetPosition")
|
| | | @Log(title = "æåç®æ ", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.targetPosition"})
|
| | | public @ResponseBody
|
| | | AjaxResult setTargetPosition(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.guideTargetPosition(cmd));
|
| | | }
|
| | |
|
| | |
|
| | | @ApiOperation("è®¾ç½®é¶æ¹ä½è§")
|
| | | @PostMapping("/setZeroPTZ")
|
| | | @Log(title = "è®¾ç½®é¶æ¹ä½è§", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
|
| | | public @ResponseBody
|
| | | AjaxResult setZeroPTZ(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.setZeroPtz(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("设置éå®")
|
| | | @PostMapping("/setPTZLock")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.expired"})
|
| | | @Log(title = "设置éå®", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult setPTZLock(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return AjaxResult.success(sdk.controlLock(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("设置解é")
|
| | | @PostMapping("/setPTZUnLock")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId"})
|
| | | @Log(title = "设置解é", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult setPTZUnLock(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return AjaxResult.success(sdk.controlUnLock(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("è·åäºå°éå®ä¿¡æ¯")
|
| | | @PostMapping("/getPTZLockInfo")
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
|
| | | @Log(title = "è·åäºå°éå®ä¿¡æ¯", businessType = BusinessType.CONTROL)
|
| | | public @ResponseBody
|
| | | AjaxResult getPTZLockInfo(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | int byWorkMode = sdk.getPTZLockInfo(cmd);
|
| | | if (byWorkMode == 0) {
|
| | | return AjaxResult.success("äºå°éå®ç¶æï¼è§£é");
|
| | | } else if (byWorkMode == 1) {
|
| | | return AjaxResult.success("äºå°éå®ç¶æï¼éå®");
|
| | | } else {
|
| | | return AjaxResult.error("äºå°éå®ç¶æï¼å¤±è´¥");
|
| | | }
|
| | | }
|
| | |
|
| | | @ApiOperation("éé¾å¼å
³")
|
| | | @PostMapping("/defogcfg")
|
| | | @Log(title = "éé¾å¼å
³", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
|
| | | public @ResponseBody
|
| | | AjaxResult defogcfg(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.controlDefogcfg(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation("红å¤å¼å
³")
|
| | | @PostMapping("/infrarecfg")
|
| | | @Log(title = "红å¤å¼å
³", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
|
| | | public @ResponseBody
|
| | | AjaxResult infrarecfg(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.controlInfrarecfg(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation(value = "æå¨/èªå¨èç¦", notes = "trueæå¨flaseèªå¨")
|
| | | @PostMapping("/focusMode")
|
| | | @Log(title = "æå¨/èªå¨èç¦", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
|
| | | public @ResponseBody
|
| | | AjaxResult enableFocusMode(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.controlFocusMode(cmd));
|
| | | }
|
| | |
|
| | | @ApiOperation(value = "è·åèç¦æ¨¡å¼", notes = "1æå¨2èªå¨")
|
| | | @PostMapping("/getFocusMode")
|
| | | public @ResponseBody
|
| | | AjaxResult getFocusMode(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | String focusMode = sdk.getFocusMode(cmd);
|
| | | return AjaxResult.success(focusMode);
|
| | | }
|
| | |
|
| | | @ApiOperation("äºå°å ç")
|
| | | @PostMapping("/heateRpwron")
|
| | | @Log(title = "äºå°å ç", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
|
| | | public @ResponseBody
|
| | | AjaxResult heateRpwron(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.controlPTHeateRpwron(cmd));
|
| | | }
|
| | |
|
| | |
|
| | | @ApiOperation("é头å ç")
|
| | | @PostMapping("/cameraDeicing")
|
| | | @Log(title = "é头å ç", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
|
| | | public @ResponseBody
|
| | | AjaxResult cameraDeicing(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return toAjax(sdk.controlCameraDeicing(cmd));
|
| | | }
|
| | |
|
| | | @PostMapping("/captureJPEGPicture")
|
| | | public @ResponseBody
|
| | | AjaxResult captureJPEGPicture(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | String base64Str = sdk.captureJPEGPicture(cmd);
|
| | | return toAjaxString(base64Str, "ç¸æºæå¾");
|
| | | }
|
| | |
|
| | | @ApiOperation("ç¸æºæå¾")
|
| | | @PostMapping("/picCutCate")
|
| | | @Log(title = "ç¸æºæå¾", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"})
|
| | | public @ResponseBody
|
| | | AjaxResult picCutCate(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | String path = sdk.picCutCate(cmd);
|
| | | return toAjaxString(path, "ç¸æºæå¾");
|
| | | }
|
| | |
|
| | | @ApiOperation("æå¨å½å")
|
| | | @PostMapping("/record")
|
| | | @Log(title = "æå¨å½å", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
|
| | | public @ResponseBody
|
| | | AjaxResult record(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | String path = sdk.record(cmd);
|
| | | return toAjaxString(path, "æå¨å½å");
|
| | | }
|
| | |
|
| | | @ApiOperation("è·åç¸æºæ¶è®¾åæ°")
|
| | | @PostMapping("/getCameraSetupCFG")
|
| | | @Log(title = "è·åç¸æºæ¶è®¾åæ°", businessType = BusinessType.CONTROL)
|
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"})
|
| | | public @ResponseBody
|
| | | AjaxResult getCameraSetupCFG(@RequestBody CameraCmd cmd) {
|
| | | cmd.setOperator(SecurityUtils.getUserId());
|
| | | return AjaxResult.success(sdk.getGisInfo(cmd));
|
| | | }
|
| | | }
|
| | | package com.ruoyi.device.hiksdk.controller; |
| | | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | 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.dhsdk.service.IDhClientService; |
| | | import com.ruoyi.device.hiksdk.service.IHikClientService; |
| | | import com.ruoyi.common.annotation.Anonymous; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName: sdkController |
| | | * @Description: |
| | | * @Author: Administrator |
| | | * @Date: 2023å¹´01æ17æ¥ 12:04 |
| | | * @Version: 1.0 |
| | | **/ |
| | | @Api(tags = "海康SDKæ¥å£") |
| | | @Controller |
| | | @RequestMapping("/hik") |
| | | @Anonymous |
| | | public class HikSdkController extends BaseController { |
| | | |
| | | @Resource |
| | | private IHikClientService sdk; |
| | | @Resource |
| | | private IArdCamerasService ardCamerasService; |
| | | |
| | | |
| | | @RequestMapping("/preview") |
| | | private String preview() { |
| | | return "preview"; |
| | | } |
| | | @RequestMapping("/index") |
| | | private String index() { |
| | | return "test"; |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | public @ResponseBody |
| | | AjaxResult list(ArdCameras ardCamera) { |
| | | List<ArdCameras> list = ardCamerasService.selectArdCamerasListNoDataScope(ardCamera); |
| | | return AjaxResult.success("ç¸æºå表ï¼", list); |
| | | } |
| | | |
| | | @ApiOperation("è·åç æµåç¼©åæ°") |
| | | @PostMapping("/getVideoCompressionCfg") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | @Log(title = "è·åç æµåç¼©åæ°", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult getVideoCompressionCfg(@RequestBody CameraCmd cmd) { |
| | | return AjaxResult.success(sdk.getVideoCompressionCfg(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("å¨çº¿ç¶æ") |
| | | @PostMapping("/state") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId"}) |
| | | @Log(title = "å¨çº¿ç¶æ", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult getOnlineState(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | boolean onLine = sdk.isOnLine(cmd); |
| | | return AjaxResult.success(onLine); |
| | | } |
| | | |
| | | @ApiOperation(value = "äºå°æ§å¶", notes = "Code:1-å·¦ä¸ 2-ä¸ 3-å³ä¸ 4-å·¦ 5-å·¡èª 6-å³ 7-å·¦ä¸ 8-ä¸ 9-å³ä¸ 10-ç¦è·å大 11-ç¦è·åå°\n" + |
| | | "12-ç¦ç¹åè° 13-ç¦ç¹åè° 14-å
忩大 15-å
åç¼©å° 16-é¨å·å¼å¯") |
| | | @PostMapping("/PTZControlWithSpeed") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.speed", "cmd.enable", "cmd.code"}) |
| | | @Log(title = "äºå°æ§å¶", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.pTZControlWithSpeed(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("è°ç¨é¢ç½®ç¹") |
| | | @PostMapping("/gotoPreset") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.presetIndex"}) |
| | | @Log(title = "è°ç¨é¢ç½®ç¹", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult gotoPreset(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.gotoPreset(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置é¢ç½®ç¹") |
| | | @PostMapping("/setPreset") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.presetIndex"}) |
| | | @Log(title = "设置é¢ç½®ç¹", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult setPreset(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.setPreset(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("è·åèç¦å¼") |
| | | @PostMapping("/getFocusPos") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | @Log(title = "è·åèç¦å¼", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult getFocusPos(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | Map<String, Object> Map = sdk.getFocusPos(cmd); |
| | | return AjaxResult.success("è·åèç¦å¼", Map); |
| | | } |
| | | |
| | | @ApiOperation("设置èç¦å¼") |
| | | @PostMapping("/setFocusPos") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.dwFocusPos"}) |
| | | @Log(title = "设置èç¦å¼", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult setFocusPos(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.setFocusPos(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("è·åPTZ") |
| | | @PostMapping("/getPTZ") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | @Log(title = "è·åPTZ", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult getPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | Map<String, Object> ptzMap = sdk.getPtz(cmd); |
| | | return AjaxResult.success("è·åptz", ptzMap); |
| | | } |
| | | |
| | | @ApiOperation("è·åPTZèå´") |
| | | @PostMapping("/getPTZScope") |
| | | @Log(title = "è·åPTZèå´", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | public @ResponseBody |
| | | AjaxResult getPTZScope(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | Map<String, Object> ptzMap = sdk.getPtzScope(cmd); |
| | | return AjaxResult.success("è·åptzèå´", ptzMap); |
| | | } |
| | | |
| | | @ApiOperation("设置PTZ") |
| | | @PostMapping("/setPTZ") |
| | | @Log(title = "设置PTZ", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.ptzMap"}) |
| | | public @ResponseBody |
| | | AjaxResult setPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.setPtz(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("æåç®æ ") |
| | | @PostMapping("/setTargetPosition") |
| | | @Log(title = "æåç®æ ", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.targetPosition"}) |
| | | public @ResponseBody |
| | | AjaxResult setTargetPosition(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.guideTargetPosition(cmd)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("è®¾ç½®é¶æ¹ä½è§") |
| | | @PostMapping("/setZeroPTZ") |
| | | @Log(title = "è®¾ç½®é¶æ¹ä½è§", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | public @ResponseBody |
| | | AjaxResult setZeroPTZ(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.setZeroPtz(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置éå®") |
| | | @PostMapping("/setPTZLock") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.expired"}) |
| | | @Log(title = "设置éå®", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult setPTZLock(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(sdk.controlLock(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("设置解é") |
| | | @PostMapping("/setPTZUnLock") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId"}) |
| | | @Log(title = "设置解é", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult setPTZUnLock(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(sdk.controlUnLock(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("è·åäºå°éå®ä¿¡æ¯") |
| | | @PostMapping("/getPTZLockInfo") |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | @Log(title = "è·åäºå°éå®ä¿¡æ¯", businessType = BusinessType.CONTROL) |
| | | public @ResponseBody |
| | | AjaxResult getPTZLockInfo(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | int byWorkMode = sdk.getPTZLockInfo(cmd); |
| | | if (byWorkMode == 0) { |
| | | return AjaxResult.success("äºå°éå®ç¶æï¼è§£é"); |
| | | } else if (byWorkMode == 1) { |
| | | return AjaxResult.success("äºå°éå®ç¶æï¼éå®"); |
| | | } else { |
| | | return AjaxResult.error("äºå°éå®ç¶æï¼å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("éé¾å¼å
³") |
| | | @PostMapping("/defogcfg") |
| | | @Log(title = "éé¾å¼å
³", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"}) |
| | | public @ResponseBody |
| | | AjaxResult defogcfg(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.controlDefogcfg(cmd)); |
| | | } |
| | | |
| | | @ApiOperation("红å¤å¼å
³") |
| | | @PostMapping("/infrarecfg") |
| | | @Log(title = "红å¤å¼å
³", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"}) |
| | | public @ResponseBody |
| | | AjaxResult infrarecfg(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.controlInfrarecfg(cmd)); |
| | | } |
| | | |
| | | @ApiOperation(value = "æå¨/èªå¨èç¦", notes = "trueæå¨flaseèªå¨") |
| | | @PostMapping("/focusMode") |
| | | @Log(title = "æå¨/èªå¨èç¦", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"}) |
| | | public @ResponseBody |
| | | AjaxResult enableFocusMode(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.controlFocusMode(cmd)); |
| | | } |
| | | |
| | | @ApiOperation(value = "è·åèç¦æ¨¡å¼", notes = "1æå¨2èªå¨") |
| | | @PostMapping("/getFocusMode") |
| | | public @ResponseBody |
| | | AjaxResult getFocusMode(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String focusMode = sdk.getFocusMode(cmd); |
| | | return AjaxResult.success(focusMode); |
| | | } |
| | | |
| | | @ApiOperation("äºå°å ç") |
| | | @PostMapping("/heateRpwron") |
| | | @Log(title = "äºå°å ç", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"}) |
| | | public @ResponseBody |
| | | AjaxResult heateRpwron(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.controlPTHeateRpwron(cmd)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation("é头å ç") |
| | | @PostMapping("/cameraDeicing") |
| | | @Log(title = "é头å ç", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"}) |
| | | public @ResponseBody |
| | | AjaxResult cameraDeicing(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return toAjax(sdk.controlCameraDeicing(cmd)); |
| | | } |
| | | |
| | | @PostMapping("/captureJPEGPicture") |
| | | public @ResponseBody |
| | | AjaxResult captureJPEGPicture(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String base64Str = sdk.captureJPEGPicture(cmd); |
| | | return toAjaxString(base64Str, "ç¸æºæå¾"); |
| | | } |
| | | |
| | | @ApiOperation("ç¸æºæå¾") |
| | | @PostMapping("/picCutCate") |
| | | @Log(title = "ç¸æºæå¾", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo"}) |
| | | public @ResponseBody |
| | | AjaxResult picCutCate(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String path = sdk.picCutCate(cmd); |
| | | return toAjaxString(path, "ç¸æºæå¾"); |
| | | } |
| | | |
| | | @ApiOperation("æå¨å½å") |
| | | @PostMapping("/record") |
| | | @Log(title = "æå¨å½å", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"}) |
| | | public @ResponseBody |
| | | AjaxResult record(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | String path = sdk.record(cmd); |
| | | return toAjaxString(path, "æå¨å½å"); |
| | | } |
| | | |
| | | @ApiOperation("è·åç¸æºæ¶è®¾åæ°") |
| | | @PostMapping("/getCameraSetupCFG") |
| | | @Log(title = "è·åç¸æºæ¶è®¾åæ°", businessType = BusinessType.CONTROL) |
| | | @ApiOperationSupport(includeParameters = {"cmd.cameraId", "cmd.chanNo", "cmd.enable"}) |
| | | public @ResponseBody |
| | | AjaxResult getCameraSetupCFG(@RequestBody CameraCmd cmd) { |
| | | cmd.setOperator(SecurityUtils.getUserId()); |
| | | return AjaxResult.success(sdk.getGisInfo(cmd)); |
| | | } |
| | | } |
| | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @ClassName: sdkClinet |
| | | * @ClassName: IHikClientService |
| | | * @Description: 海康æä½å®¢æ·ç«¯æ¥å£ç±» |
| | | * @Author: Administrator |
| | | * @Date: 2023å¹´01æ17æ¥ 15:59 |
| | | * @Version: 1.0 |
| | | **/ |
| | | public interface IHikClientService { |
| | | void loadHCNetSDKLib(); |
| | | //sdkåå§å |
| | | boolean init(); |
| | | |
| | | //忥ç»å½ |
| | | void syncLogin(ArdCameras cameras); |
| | |
| | | boolean guideTargetPosition(CameraCmd cmd); |
| | | |
| | | //å¼å§å½å |
| | | void recordStart(CameraCmd cmd); |
| | | boolean recordStart(CameraCmd cmd); |
| | | |
| | | //忢å½å-ä¸ä¼ minio-è¿åå½åurl |
| | | String recordStopToMinio(CameraCmd cmd); |
| | |
| | | private static HCNetSDK hCNetSDK;
|
| | |
|
| | | @Override
|
| | | public void loadHCNetSDKLib() {
|
| | | public boolean init() {
|
| | | try {
|
| | | log.debug("å¼å§å è½½sdkåºæä»¶è·¯å¾");
|
| | | if (Platform.isWindows()) {
|
| | |
| | | ptrByteArraySsl.write();
|
| | | hCNetSDK.NET_DVR_SetSDKInitCfg(4, ptrByteArraySsl.getPointer());
|
| | | }
|
| | | return true;
|
| | | } catch (Exception ex) {
|
| | | log.error("å è½½åºæä»¶å¼å¸¸ï¼" + ex.getMessage());
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | String cameraId = cmd.getCameraId();
|
| | | Integer channelNum = cmd.getChanNo();
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return null;
|
| | | return new HashMap<>();
|
| | | }
|
| | | Integer userId = (Integer)GlobalVariable.loginMap.get(cameraId);
|
| | |
|
| | |
| | | NET_DVR_PTZPOS m_ptzPosCurrent = new NET_DVR_PTZPOS();
|
| | | m_ptzPosCurrent.wAction = 1;
|
| | | try {
|
| | | String p = String.valueOf(ptz.get("p") * 10);
|
| | | String t = String.valueOf(ptz.get("t") * 10);
|
| | | String z = String.valueOf(ptz.get("z") * 10);
|
| | | String p = String.valueOf((int)(ptz.get("p") * 10));
|
| | | String t = String.valueOf((int)(ptz.get("t") * 10));
|
| | | String z = String.valueOf((int)(ptz.get("z") * 10));
|
| | | m_ptzPosCurrent.wPanPos = (short) (Integer.parseInt(p, 16));
|
| | | m_ptzPosCurrent.wTiltPos = (short) (Integer.parseInt(t, 16));
|
| | | m_ptzPosCurrent.wZoomPos = (short) (Integer.parseInt(z, 16));
|
| | |
| | | GlobalVariable.previewMap.remove(cameraId);
|
| | | }
|
| | | log.debug("å½å忢");
|
| | | //åå
¥minio
|
| | | String BucketName = "record";
|
| | | String ObjectName =IdUtils.simpleUUID() + ".mp4";
|
| | | FileInputStream stream = new FileInputStream(path);
|
| | | boolean b = MinioUtil.uploadObject(BucketName, ObjectName, stream, stream.available(), "video/MP4");
|
| | | if (b) {
|
| | | url = MinioUtil.getBucketObjectUrl(BucketName, ObjectName);
|
| | | log.debug("ä¸ä¼ æä»¶æå!" + url);
|
| | | }
|
| | | }
|
| | | return url;
|
| | | } catch (Exception ex) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void recordStart(CameraCmd cmd) {
|
| | | public boolean recordStart(CameraCmd cmd) {
|
| | | try {
|
| | | String cameraId = cmd.getCameraId();
|
| | | Integer channelNum = cmd.getChanNo();
|
| | | String path = FileUtils.createFile("D:/recordTemp/" + cameraId + ".mp4");
|
| | | if (!GlobalVariable.loginMap.containsKey(cameraId)) {
|
| | | return;
|
| | | return false;
|
| | | }
|
| | | Integer userId = (Integer)GlobalVariable.loginMap.get(cameraId);
|
| | | //强å¶Iå¸§ç»æä½å¯¹è±¡
|
| | |
| | | int lRealHandle = hCNetSDK.NET_DVR_RealPlay_V40(userId, previewinfo, null, null);
|
| | | if (lRealHandle == -1) {
|
| | | log.error("åæµå¤±è´¥" + hCNetSDK.NET_DVR_GetLastError());
|
| | | return;
|
| | | return false;
|
| | | }
|
| | | log.debug("åæµæå");
|
| | | GlobalVariable.threadMap.put(cameraId, Thread.currentThread().getName());
|
| | | GlobalVariable.previewMap.put(cameraId, lRealHandle);
|
| | | if (!hCNetSDK.NET_DVR_SaveRealData_V30(GlobalVariable.previewMap.get(cameraId), 2, path)) {
|
| | | log.error("ä¿åè§é¢æä»¶å°ä¸´æ¶æä»¶å¤¹å¤±è´¥ é误ç 为: " + hCNetSDK.NET_DVR_GetLastError());
|
| | | return;
|
| | | return false;
|
| | | }
|
| | | log.debug("å½åå¼å§");
|
| | | return true;
|
| | | } catch (Exception ex) {
|
| | | log.error("å¼å§å½åå¼å¸¸" + ex.getMessage());
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|