From 38eaaa87743252da53851047bd15b089ccf9697b Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期四, 07 三月 2024 11:00:40 +0800
Subject: [PATCH] SDK云台控制和setptz增加错误码返回 增加部门和相机按角色数据权限查询
---
ard-work/src/main/java/com/ruoyi/alarm/radar/service/impl/ArdRadarServiceImpl.java | 10
ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/controller/HikSdkController.java | 4
ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java | 8
ard-work/src/main/java/com/ruoyi/device/camera/service/IArdCamerasService.java | 19 +-
ard-work/src/main/java/com/ruoyi/utils/sdk/common/SdkErrorCodeEnum.java | 73 ++++++++
ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/lib/ToolKits.java | 194 ++++++++++----------
ard-work/src/main/java/com/ruoyi/device/camera/factory/CameraSDK.java | 7
ard-work/src/main/java/com/ruoyi/device/camera/controller/CameraSdkController.java | 4
ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java | 64 ++----
ard-work/src/main/java/com/ruoyi/device/camera/domain/DeptAndCamerasDto.java | 18 ++
ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java | 40 ++-
ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/controller/DhSdkController.java | 6
ard-work/src/main/java/com/ruoyi/device/camera/service/ICameraSdkService.java | 4
ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java | 30 +++
ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java | 20 +
15 files changed, 311 insertions(+), 190 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/alarm/radar/service/impl/ArdRadarServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarm/radar/service/impl/ArdRadarServiceImpl.java
index 791557b..b19c33f 100644
--- a/ard-work/src/main/java/com/ruoyi/alarm/radar/service/impl/ArdRadarServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/alarm/radar/service/impl/ArdRadarServiceImpl.java
@@ -4,6 +4,7 @@
import com.ruoyi.alarm.radar.domain.ArdAlarmRadar;
import com.ruoyi.alarm.radar.domain.RadarAlarmData;
import com.ruoyi.alarm.radar.service.ArdRadarService;
+import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
@@ -69,12 +70,7 @@
ptzMap.put("t", t);
ptzMap.put("z", cameraPTZ[2]);
cmd.setPtzMap(ptzMap);
- boolean res = iCameraSdkService.setPtz(cmd);
- if (res) {
- log.debug("寮哄埗寮曞鎴愬姛");
- } else {
- log.debug("寮哄埗寮曞澶辫触");
- }
+ iCameraSdkService.setPtz(cmd);
} else {
log.debug("鏈幏鍙栧埌闆疯揪濉斾笂鐨勫厜鐢�");
}
@@ -127,4 +123,4 @@
log.error("闆疯揪杩借釜寮曞寮傚父:" + ex.getMessage());
}
}
-}
\ No newline at end of file
+}
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java b/ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java
index bc16215..6434b46 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/controller/ArdCamerasController.java
@@ -7,6 +7,7 @@
import com.ruoyi.common.constant.CameraConstants;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
+import com.ruoyi.device.camera.domain.DeptAndCamerasDto;
import com.ruoyi.device.camera.service.IArdCamerasService;
import com.ruoyi.device.camera.service.ICameraSdkService;
import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -193,7 +194,12 @@
Map deptAndCamera = ardCamerasService.getChildDeptAndCamera(true);
return AjaxResult.success(deptAndCamera);
}
-
+ @GetMapping("/getDeptAndCamera1")
+ @ApiOperation("鑾峰彇閮ㄩ棬鍜岀浉鏈�1")
+ public AjaxResult getDeptAndCamera1() {
+ List<DeptAndCamerasDto> deptAndCamera = ardCamerasService.getChildDeptAndCamera();
+ return AjaxResult.success(deptAndCamera);
+ }
@GetMapping("/getDeptAndCameraWithCheckBox")
@ApiOperation("鑾峰彇閮ㄩ棬鍜岀浉鏈�(寮�鍚閫夋)")
public AjaxResult getDeptAndCameraWithCheckBox() {
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/controller/CameraSdkController.java b/ard-work/src/main/java/com/ruoyi/device/camera/controller/CameraSdkController.java
index 45dffb9..fe446ef 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/controller/CameraSdkController.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/controller/CameraSdkController.java
@@ -94,7 +94,7 @@
public @ResponseBody
AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(cameraSdkService.pTZControl(cmd));
+ return cameraSdkService.pTZControl(cmd);
}
@ApiOperation("璋冪敤棰勭疆鐐�")
@@ -167,7 +167,7 @@
public @ResponseBody
AjaxResult setPTZ(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(cameraSdkService.setPtz(cmd));
+ return cameraSdkService.setPtz(cmd);
}
@ApiOperation("鎸囧悜鐩爣")
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/domain/DeptAndCamerasDto.java b/ard-work/src/main/java/com/ruoyi/device/camera/domain/DeptAndCamerasDto.java
new file mode 100644
index 0000000..785f6cc
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/domain/DeptAndCamerasDto.java
@@ -0,0 +1,18 @@
+package com.ruoyi.device.camera.domain;
+
+import com.ruoyi.common.core.domain.entity.SysDept;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @ClassName: deptAndCamerasDto
+ * @Author: 鍒樿嫃涔�
+ * @Date: 2024骞�03鏈�05鏃�8:21:22
+ **/
+@Data
+public class DeptAndCamerasDto {
+ SysDept sysDept;
+ List<ArdCameras> ardCamerasList;
+}
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/factory/CameraSDK.java b/ard-work/src/main/java/com/ruoyi/device/camera/factory/CameraSDK.java
index fed0ade..84407f2 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/factory/CameraSDK.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/factory/CameraSDK.java
@@ -1,5 +1,6 @@
package com.ruoyi.device.camera.factory;
+import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.channel.domain.ArdChannel;
@@ -26,7 +27,7 @@
boolean isOnLine(CameraCmd cmd);
//浜戝彴鎺у埗
- boolean pTZControl(CameraCmd cmd);
+ AjaxResult pTZControl(CameraCmd cmd);
//璁剧疆鑱氱劍鍊�
boolean setFocusPos(CameraCmd cmd);
@@ -78,10 +79,10 @@
Map<String, Object> getPtzScope(CameraCmd cmd);
//璁剧疆ptz1(涓嶆敮鎸�2閫氶亾鐨刏鍊艰缃拰鑾峰彇)
- boolean setPtz1(CameraCmd cmd);
+ AjaxResult setPtz1(CameraCmd cmd);
//璁剧疆ptz(楂樼簿搴tz璁剧疆)
- boolean setPtz(CameraCmd cmd);
+ AjaxResult setPtz(CameraCmd cmd);
//璁剧疆闆舵柟浣嶈
boolean setZeroPtz(CameraCmd cmd);
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/IArdCamerasService.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/IArdCamerasService.java
index cdacba2..ae22d43 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/service/IArdCamerasService.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/IArdCamerasService.java
@@ -8,19 +8,20 @@
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
+import com.ruoyi.device.camera.domain.DeptAndCamerasDto;
import com.ruoyi.scheduling.domian.SchedulingParam;
/**
* 鐩告満璁惧Service鎺ュ彛
- *
+ *
* @author 鍒樿嫃涔�
* @date 2023-02-11
*/
-public interface IArdCamerasService
+public interface IArdCamerasService
{
/**
* 鏌ヨ鐩告満璁惧
- *
+ *
* @param id 鐩告満璁惧涓婚敭
* @return 鐩告満璁惧
*/
@@ -28,7 +29,7 @@
/**
* 鏌ヨ鐩告満璁惧鍒楄〃
- *
+ *
* @param ardCameras 鐩告満璁惧
* @return 鐩告満璁惧闆嗗悎
*/
@@ -42,7 +43,7 @@
public List<ArdCameras> selectArdCamerasListNoDataScope(ArdCameras ardCameras);
/**
* 鏂板鐩告満璁惧
- *
+ *
* @param ardCameras 鐩告満璁惧
* @return 缁撴灉
*/
@@ -50,7 +51,7 @@
/**
* 淇敼鐩告満璁惧
- *
+ *
* @param ardCameras 鐩告満璁惧
* @return 缁撴灉
*/
@@ -58,7 +59,7 @@
/**
* 鎵归噺鍒犻櫎鐩告満璁惧
- *
+ *
* @param ids 闇�瑕佸垹闄ょ殑鐩告満璁惧涓婚敭闆嗗悎
* @return 缁撴灉
*/
@@ -66,7 +67,7 @@
/**
* 鍒犻櫎鐩告満璁惧淇℃伅
- *
+ *
* @param id 鐩告満璁惧涓婚敭
* @return 缁撴灉
*/
@@ -106,7 +107,7 @@
* @淇敼浜哄拰鍏跺畠淇℃伅
*/
public Map getChildDeptAndCamera(Boolean disabled);
-
+ public List<DeptAndCamerasDto> getChildDeptAndCamera();
public TreeMap getNearCamerasBycoordinate(CameraCmd cmd);
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/ICameraSdkService.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/ICameraSdkService.java
index f941580..9f30817 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/service/ICameraSdkService.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/ICameraSdkService.java
@@ -19,7 +19,7 @@
boolean isOnLine(CameraCmd cmd);
//浜戝彴鎺у埗
- boolean pTZControl(CameraCmd cmd);
+ AjaxResult pTZControl(CameraCmd cmd);
//璁剧疆鑱氱劍鍊�
boolean setFocusPos(CameraCmd cmd);
@@ -76,7 +76,7 @@
Map<String, Object> getPtzScope(CameraCmd cmd);
//璁剧疆ptz
- boolean setPtz(CameraCmd cmd);
+ AjaxResult setPtz(CameraCmd cmd);
//璁剧疆闆舵柟浣嶈
boolean setZeroPtz(CameraCmd cmd);
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
index a8265ea..97d071c 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
@@ -17,10 +17,12 @@
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.device.camera.domain.CameraCmd;
+import com.ruoyi.device.camera.domain.DeptAndCamerasDto;
import com.ruoyi.device.channel.domain.ArdChannel;
import com.ruoyi.device.channel.mapper.ArdChannelMapper;
import com.ruoyi.media.service.IVtduService;
import com.ruoyi.scheduling.domian.SchedulingParam;
+import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.utils.gis.GisUtil;
import com.ruoyi.utils.tools.ArdTool;
import com.ruoyi.device.camera.domain.ArdCameras;
@@ -52,7 +54,8 @@
private SysDeptMapper sysDeptMapper;
@Resource
private RedisCache redisCache;
-
+ @Autowired
+ private ISysDeptService deptService;
@Resource
private ArdChannelMapper ardChannelMapper;
@Resource
@@ -306,7 +309,6 @@
* @鍒涘缓鏃堕棿 2023/6/2 10:58
* @淇敼浜哄拰鍏跺畠淇℃伅
*/
-
@Override
public Map getChildDeptAndCamera(Boolean disabled) {
Long deptId = SecurityUtils.getDeptId();
@@ -315,6 +317,11 @@
return map;
}
+ @Override
+ public List<DeptAndCamerasDto> getChildDeptAndCamera() {
+ List<SysDept> depts = deptService.selectDeptList(new SysDept());
+ return fetchChildDepartments(depts);
+ }
/**
* @鎻忚堪 閫掑綊鏌ヨ
* @鍙傛暟 [sysDept]
@@ -354,7 +361,26 @@
}
map.put("children", childList);
return map;
+ }
+ /**
+ * 鑾峰彇鎵�鏈夐儴闂ㄥ強閮ㄩ棬涓嬬殑鐩告満
+ * 鍒樿嫃涔�
+ * 2024/3/4 14:45:03
+ */
+ public List<DeptAndCamerasDto> fetchChildDepartments(List<SysDept> sysDepts) {
+
+ List<DeptAndCamerasDto> deptAndCamerasList = sysDepts.stream()
+ .map(sysDept -> {
+ List<ArdCameras> ardCameras = ardCamerasMapper.selectArdCamerasByDeptId(sysDept.getDeptId());
+ DeptAndCamerasDto deptAndCamerasDto = new DeptAndCamerasDto();
+ deptAndCamerasDto.setSysDept(sysDept);
+ deptAndCamerasDto.setArdCamerasList(ardCameras);
+ return deptAndCamerasDto;
+ })
+ .collect(Collectors.toList());
+
+ return deptAndCamerasList;
}
/**
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java
index b5b4ad5..895723b 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/CameraSdkServiceImpl.java
@@ -130,20 +130,15 @@
//浜戝彴鎺у埗
@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();
- CameraSDK cameraSDK = cameraSDKFactory.createCameraSDK(factory);
- result = cameraSDK.pTZControl(cmd);
- }
- return result;
- } catch (Exception ex) {
- log.error("ptz鎺у埗寮傚父锛�" + ex.getMessage());
- return false;
+ public AjaxResult pTZControl(CameraCmd cmd) {
+ String cameraId = cmd.getCameraId();
+ ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
+ if (ardCamera != null) {
+ String factory = ardCamera.getFactory();
+ CameraSDK cameraSDK = cameraSDKFactory.createCameraSDK(factory);
+ return cameraSDK.pTZControl(cmd);
+ } else {
+ return AjaxResult.error("鎽勫儚澶翠笉瀛樺湪");
}
}
@@ -403,9 +398,7 @@
String gdtype = ardCamera.getGdtype();
if (gdtype.equals("1")) {
map = cameraSDK.getPtz(cmd);
- }
- else
- {
+ } else {
map = cameraSDK.getPtz1(cmd);
}
}
@@ -435,27 +428,27 @@
//璁剧疆ptz
@Override
- public boolean setPtz(CameraCmd cmd) {
- boolean result = false;
+ public AjaxResult setPtz(CameraCmd cmd) {
try {
String cameraId = cmd.getCameraId();
ArdCameras ardCamera = redisCache.getCacheObject(CacheConstants.CAMERA_LIST_KEY + cameraId);
- if (ardCamera != null) {
- String factory = ardCamera.getFactory();
- CameraSDK cameraSDK = cameraSDKFactory.createCameraSDK(factory);
- String gdtype = ardCamera.getGdtype();
- if (gdtype.equals("1")) {
- //澶у厜鐢典娇鐢ㄩ珮绮惧害ptz璁剧疆
- result = cameraSDK.setPtz(cmd);
- } else {
- result = cameraSDK.setPtz1(cmd);
- }
-
+ if (ardCamera == null) {
+ return AjaxResult.error("鎽勫儚澶翠笉瀛樺湪");
}
+ CameraSDK cameraSDK = cameraSDKFactory.createCameraSDK(ardCamera.getFactory());
+ String gdtype = ardCamera.getGdtype();
+ if (gdtype.equals("1")) {
+ //澶у厜鐢典娇鐢ㄩ珮绮惧害ptz璁剧疆
+ return cameraSDK.setPtz(cmd);
+ } else {
+ return cameraSDK.setPtz1(cmd);
+ }
+
} catch (Exception ex) {
log.error("璁剧疆ptz寮傚父锛�" + ex.getMessage());
+ AjaxResult.error("璁剧疆ptz寮傚父:" + ex.getMessage());
}
- return result;
+ return AjaxResult.success();
}
//璁剧疆闆舵柟浣嶈
@@ -529,8 +522,7 @@
cmd.setCameraId(cameraId);
//鑾峰彇鏈�杩戠浉鏈虹殑瀵硅薄
Optional<ArdWellGuideCamera> first = ardWellGuideCameraList.stream().filter(s -> s.getCameraId().equals(cameraId)).findFirst();
- if(first.isPresent())
- {
+ if (first.isPresent()) {
ArdWellGuideCamera ardWellGuideCamera = first.get();
Map<String, Double> ptzMap = null;
//閫氳繃閫氶亾鑾峰彇棰勭疆浣�
@@ -557,11 +549,7 @@
if (ptzMap != null) {
//浣跨敤ptz寮曞
cmd.setPtzMap(ptzMap);
- boolean res = setPtz(cmd);
- if (!res) {
- return AjaxResult.error("ptz寮曞澶辫触", "cameraId:" + cameraId);
- }
- return AjaxResult.success("ptz寮曞鎴愬姛", "cameraId:" + cameraId);
+ return setPtz(cmd);
}
}
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/common/SdkErrorCodeEnum.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/common/SdkErrorCodeEnum.java
new file mode 100644
index 0000000..fdd08ce
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/common/SdkErrorCodeEnum.java
@@ -0,0 +1,73 @@
+package com.ruoyi.utils.sdk.common;
+
+
+import com.ruoyi.common.utils.StringUtils;
+
+/**
+ * sdk閿欒鐮佹灇涓�
+ * 鍒樿嫃涔�
+ * 2024/3/7 10:50:52
+ */
+public enum SdkErrorCodeEnum {
+
+ NET_DVR_PASSWORD_ERROR(1, "鐢ㄦ埛鍚嶅瘑鐮侀敊璇�傛敞鍐屾椂杈撳叆鐨勭敤鎴峰悕鎴栬�呭瘑鐮侀敊璇�"),
+ NET_DVR_NOINIT(3, "SDK鏈垵濮嬪寲"),
+ NET_DVR_NETWORK_FAIL_CONNECT(7, "杩炴帴璁惧澶辫触銆傝澶囦笉鍦ㄧ嚎鎴栫綉缁滃師鍥犲紩璧风殑杩炴帴瓒呮椂绛�");
+ /**
+ * 鏋氫妇鐮�
+ */
+ private Integer code;
+ /**
+ * 鏋氫妇鎻忚堪
+ */
+ private String desc;
+
+ private SdkErrorCodeEnum(Integer code, String desc) {
+ this.code = code;
+ this.desc = desc;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ /**
+ * 鏍规嵁鏋氫妇鐮佽幏鍙栨灇涓�
+ *
+ * @param code 鏋氫妇鐮�
+ * @return 鏋氫妇
+ */
+ public static final SdkErrorCodeEnum getByCode(Integer code) {
+ if (StringUtils.isNull(code)) {
+ return null;
+ }
+ for (SdkErrorCodeEnum item : SdkErrorCodeEnum.values()) {
+ if (item.getCode() == code) {
+ return item;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * 鏍规嵁鏋氫妇鐮佽幏鍙栨灇涓炬弿杩�
+ *
+ * @param code 鏋氫妇鐮�
+ * @return 鏋氫妇鎻忚堪
+ */
+ public static final String getDescByCode(Integer code) {
+ if (StringUtils.isNull(code)) {
+ return "閿欒鐮佷负绌�";
+ }
+ for (SdkErrorCodeEnum item : SdkErrorCodeEnum.values()) {
+ if (item.getCode() == code) {
+ return item.getDesc();
+ }
+ }
+ return "鎵句笉鍒伴敊璇爜瀵瑰簲鐨勯敊璇弿杩�,璇疯仈绯荤鐞嗗憳";
+ }
+}
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/controller/DhSdkController.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/controller/DhSdkController.java
index 5ad5f7a..cd06c9c 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/controller/DhSdkController.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/controller/DhSdkController.java
@@ -47,7 +47,7 @@
public @ResponseBody
AjaxResult pTZControl(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.pTZControl(cmd));
+ return sdk.pTZControl(cmd);
}
@ApiOperation("鑾峰彇PTZ")
@@ -79,7 +79,7 @@
public @ResponseBody
AjaxResult setPTZ(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.setPtz(cmd));
+ return sdk.setPtz(cmd);
}
@ApiOperation("璁剧疆闆舵柟浣嶈")
@@ -124,4 +124,4 @@
String url = sdk.recordStopToMinio(cmd);
return AjaxResult.success(url);
}
-}
\ No newline at end of file
+}
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/lib/ToolKits.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/lib/ToolKits.java
index cbdfe1f..a8a2d28 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/lib/ToolKits.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/lib/ToolKits.java
@@ -32,7 +32,7 @@
public class ToolKits {
static NetSDKLib netsdkapi = NetSDKLib.NETSDK_INSTANCE;
static NetSDKLib configapi = NetSDKLib.CONFIG_INSTANCE;
-
+
/***************************************************************************************************
* 宸ュ叿鏂规硶 *
***************************************************************************************************/
@@ -48,7 +48,7 @@
pJavaStu.size());
pJavaStu.read();
}
-
+
public static void GetPointerDataToStructArr(Pointer pNativeData, Structure []pJavaStuArr) {
long offset = 0;
for (int i=0; i<pJavaStuArr.length; ++i)
@@ -57,10 +57,10 @@
offset += pJavaStuArr[i].size();
}
}
-
+
/**
* 灏嗙粨鏋勪綋鏁扮粍鎷疯礉鍒板唴瀛�
- * @param pNativeData
+ * @param pNativeData
* @param pJavaStuArr
*/
public static void SetStructArrToPointerData(Structure []pJavaStuArr, Pointer pNativeData) {
@@ -70,41 +70,41 @@
offset += pJavaStuArr[i].size();
}
}
-
+
public static void SetStructDataToPointer(Structure pJavaStu, Pointer pNativeData, long OffsetOfpNativeData){
pJavaStu.write();
Pointer pJavaMem = pJavaStu.getPointer();
pNativeData.write(OffsetOfpNativeData, pJavaMem.getByteArray(0, pJavaStu.size()), 0, pJavaStu.size());
}
-
+
public static void savePicture(byte[] pBuf, String sDstFile) throws IOException
{
FileOutputStream fos=null;
try
{
fos = new FileOutputStream(sDstFile);
- fos.write(pBuf);
+ fos.write(pBuf);
} catch (Exception e){
e.printStackTrace();
}finally{
- fos.close();
+ fos.close();
}
}
-
+
public static void savePicture(byte[] pBuf, int dwBufOffset, int dwBufSize, String sDstFile) throws IOException
{
FileOutputStream fos=null;
try
- {
+ {
fos = new FileOutputStream(sDstFile);
fos.write(pBuf, dwBufOffset, dwBufSize);
} catch (Exception e){
e.printStackTrace();
}finally{
- fos.close();
+ fos.close();
}
}
-
+
public static void savePicture(Pointer pBuf, int dwBufSize, String sDstFile) throws IOException
{
FileOutputStream fos=null;
@@ -115,10 +115,10 @@
} catch (Exception e){
e.printStackTrace();
}finally{
- fos.close();
+ fos.close();
}
}
-
+
public static void savePicture(Pointer pBuf, int dwBufOffset, int dwBufSize, String sDstFile) throws IOException
{
FileOutputStream fos=null;
@@ -129,12 +129,12 @@
} catch (Exception e){
e.printStackTrace();
}finally{
- fos.close();
+ fos.close();
}
}
-
+
// 灏哖ointer鍊艰浆涓篵yte[]
- public static String GetPointerDataToByteArr(Pointer pointer) {
+ public static String GetPointerDataToByteArr(Pointer pointer) {
String str = "";
if(pointer == null) {
return str;
@@ -143,14 +143,14 @@
int length = 0;
byte[] bufferPlace = new byte[1];
- for(int i = 0; i < 2048; i++) {
- pointer.read(i, bufferPlace, 0, 1);
+ for(int i = 0; i < 2048; i++) {
+ pointer.read(i, bufferPlace, 0, 1);
if(bufferPlace[0] == '\0') {
length = i;
break;
}
}
-
+
if(length > 0) {
byte[] buffer = new byte[length];
pointer.read(0, buffer, 0, length);
@@ -159,58 +159,58 @@
} catch (UnsupportedEncodingException e) {
return str;
}
- }
+ }
return str;
}
-
+
// 鑾峰彇褰撳墠鏃堕棿
public static String getDate() {
SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = simpleDate.format(new java.util.Date()).replace(" ", "_").replace(":", "-");
-
+
return date;
}
-
+
// 鑾峰彇褰撳墠鏃堕棿
public static String getDay() {
SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd");
- String date = simpleDate.format(new java.util.Date());
+ String date = simpleDate.format(new java.util.Date());
return date;
}
-
+
// 闄愬埗JTextField 闀垮害锛屼互鍙婂唴瀹�
public static void limitTextFieldLength(final JTextField jTextField, final int size) {
jTextField.addKeyListener(new KeyListener() {
-
+
@Override
- public void keyTyped(KeyEvent e) {
- String number = "0123456789" + (char)8;
+ public void keyTyped(KeyEvent e) {
+ String number = "0123456789" + (char)8;
if(number.indexOf(e.getKeyChar()) < 0 || jTextField.getText().trim().length() >= size) {
e.consume();
return;
- }
+ }
}
-
+
@Override
- public void keyReleased(KeyEvent e) {
+ public void keyReleased(KeyEvent e) {
}
-
+
@Override
- public void keyPressed(KeyEvent e) {
+ public void keyPressed(KeyEvent e) {
}
});
}
-
+
// 鑾峰彇褰撳墠绐楀彛
public static JFrame getFrame(ActionEvent e) {
JButton btn = (JButton)e.getSource();
JFrame frame = (JFrame)btn.getRootPane().getParent();
-
+
return frame;
}
-
+
// 鑾峰彇鎿嶄綔骞冲彴淇℃伅
public static String getLoadLibrary(String library) {
String path = "";
@@ -223,7 +223,7 @@
return (path + library);
}
-
+
public static String getOsName() {
String osName = "";
String os = System.getProperty("os.name");
@@ -232,10 +232,10 @@
} else if(os.toLowerCase().startsWith("linux")) {
osName = "linux";
}
-
+
return osName;
}
-
+
/**
* 璇诲彇鍥剧墖澶у皬
* @param filePath 鍥剧墖璺緞
@@ -251,13 +251,13 @@
return 0;
}
}
-
+
/**
* 璇诲彇鍥剧墖鏁版嵁
* @param file 鍥剧墖璺緞
- * @param memory 鍥剧墖鏁版嵁缂撳瓨
+ * @param memory 鍥剧墖鏁版嵁缂撳瓨
* @return
- * @throws IOException
+ * @throws IOException
*/
public static boolean ReadAllFileToMemory(String file, Memory memory) throws IOException {
if (memory != Memory.NULL)
@@ -273,7 +273,7 @@
if (infile.canRead())
{
in = new FileInputStream(infile);
- int buffLen = 1024;
+ int buffLen = 1024;
byte[] buffer = new byte[buffLen];
long currFileLen = 0;
int readLen = 0;
@@ -282,7 +282,7 @@
readLen = in.read(buffer);
memory.write(currFileLen, buffer, 0, readLen);
currFileLen += readLen;
- }
+ }
return true;
}
else
@@ -297,17 +297,17 @@
}finally{
if(in!=null){
in.close();
- }
+ }
}
}
-
+
return false;
}
-
+
static class JPGFilter extends FileFilter {
public boolean accept(File f) {
if(f.getName().toLowerCase().endsWith(".JPG")
- || f.getName().toLowerCase().endsWith(".jpg")
+ || f.getName().toLowerCase().endsWith(".jpg")
|| f.isDirectory()) {
return true;
}
@@ -319,19 +319,19 @@
return "*.jpg; *.JPG";
}
}
-
+
/*
* 鐢ㄩ�夋嫨鍣ㄩ�夋嫨鍥剧墖, 鑾峰彇鍥剧墖璺緞锛屽苟鍦ㄧ晫闈㈡樉绀�
*/
- public static String openPictureFile(PaintPanel paintPanel) {
+ public static String openPictureFile(PaintPanel paintPanel) {
try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
} catch (Exception e) {
e.printStackTrace();
- }
-
+ }
+
String picPath = "";
-
+
// 璇诲彇鍥剧墖
JFileChooser jfc = new JFileChooser("d:/");
jfc.setMultiSelectionEnabled(false); // 涓嶅彲浠ユ嫋閫夊涓枃浠�
@@ -341,10 +341,10 @@
JPGFilter filter = new JPGFilter();
jfc.addChoosableFileFilter(filter);
jfc.setFileFilter(filter);
-
+
if( jfc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
picPath = jfc.getSelectedFile().getAbsolutePath();
-
+
/*
* 璇诲彇鏈湴鍥剧墖, 骞跺湪闈㈡澘涓婃樉绀�
*/
@@ -352,22 +352,22 @@
if(picPath == null || picPath.equals("")) {
return "";
}
-
+
File file = new File(picPath);
if(!file.exists()) {
return "";
}
-
+
try {
bufferedImage = ImageIO.read(file);
} catch (IOException e) {
e.printStackTrace();
}
-
+
if(bufferedImage == null) {
paintPanel.setOpaque(true);
paintPanel.repaint();
-
+
System.err.println("鎵撳紑鍥剧墖澶辫触锛岃閲嶆柊閫夋嫨锛�");
return "";
} else {
@@ -376,19 +376,19 @@
paintPanel.repaint();
}
}
-
+
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
- }
+ }
return picPath;
}
-
+
/*
* 浼犲叆鍥剧墖璺緞, 鎵撳紑鍥剧墖, 骞跺湪闈㈡澘鏄剧ず
*/
- public static File openPictureFile(String picPath, PaintPanel paintPanel) {
+ public static File openPictureFile(String picPath, PaintPanel paintPanel) {
/*
* 璇诲彇鏈湴鍥剧墖, 骞跺湪闈㈡澘涓婃樉绀�
*/
@@ -396,22 +396,22 @@
if(picPath == null || picPath.equals("")) {
return null;
}
-
+
File file = new File(picPath);
if(!file.exists()) {
return null;
}
-
+
try {
bufferedImage = ImageIO.read(file);
} catch (IOException e) {
e.printStackTrace();
}
-
+
if(bufferedImage == null) {
paintPanel.setOpaque(true);
paintPanel.repaint();
-
+
System.err.println("鎵撳紑鍥剧墖澶辫触锛岃閲嶆柊閫夋嫨锛�");
return null;
} else {
@@ -419,24 +419,24 @@
paintPanel.setImage(bufferedImage);
paintPanel.repaint();
}
-
+
return file;
}
-
+
/**
* 璇诲彇鍥剧墖
* @return 鍥剧墖缂撳瓨
- * @throws IOException
+ * @throws IOException
*/
public static Memory readPictureFile(String picPath) throws IOException {
int nPicBufLen = 0;
Memory memory = null;
-
+
/*
* 璇诲彇鏈湴鍥剧墖澶у皬
*/
- nPicBufLen = (int)ToolKits.GetFileSize(picPath);
-
+ nPicBufLen = (int)ToolKits.GetFileSize(picPath);
+
// 璇诲彇鏂囦欢澶у皬澶辫触
if (nPicBufLen <= 0) {
System.err.println("璇诲彇鍥剧墖澶у皬澶辫触锛岃閲嶆柊閫夋嫨锛�");
@@ -448,46 +448,46 @@
*/
memory = new Memory(nPicBufLen); // 鐢宠缂撳瓨
memory.clear();
-
+
if (!ToolKits.ReadAllFileToMemory(picPath, memory)) {
System.err.println("璇诲彇鍥剧墖鏁版嵁锛岃閲嶆柊閫夋嫨锛�");
return null;
}
-
+
return memory;
}
-
+
/**
* 鐧诲綍璁惧璁惧閿欒鐘舵��, 鐢ㄤ簬鐣岄潰鏄剧ず
*/
public static String getErrorCodeShow() {
return ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError());
}
-
+
/**
* 鑾峰彇鎺ュ彛閿欒鐮佸拰閿欒淇℃伅锛岀敤浜庢墦鍗�
* @return
*/
public static String getErrorCodePrint() {
- return "\n{error code: (0x80000000|" + (LoginModule.netsdk.CLIENT_GetLastError() & 0x7fffffff) +").鍙傝�� NetSDKLib.java }"
- + " - {error info:" + ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError()) + "}\n";
+ return "Error Code: (0x80000000|" + (LoginModule.netsdk.CLIENT_GetLastError() & 0x7fffffff) +")"
+ + " Error Info:" + ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError()) + "";
}
-
+
/**
* 鑾峰彇鍗曚釜閰嶇疆
* @param hLoginHandle 鐧婚檰鍙ユ焺
* @param nChn 閫氶亾鍙凤紝-1 琛ㄧず鍏ㄩ�氶亾
* @param strCmd 閰嶇疆鍚嶇О
* @param cmdObject 閰嶇疆瀵瑰簲鐨勭粨鏋勪綋瀵硅薄
- * @return 鎴愬姛杩斿洖 true
+ * @return 鎴愬姛杩斿洖 true
*/
public static boolean GetDevConfig(LLong hLoginHandle, int nChn, String strCmd, Structure cmdObject) {
boolean result = false;
IntByReference error = new IntByReference(0);
int nBufferLen = 2*1024*1024;
byte[] strBuffer = new byte[nBufferLen];
-
- if(netsdkapi.CLIENT_GetNewDevConfig( hLoginHandle, strCmd , nChn, strBuffer, nBufferLen,error,3000)) {
+
+ if(netsdkapi.CLIENT_GetNewDevConfig( hLoginHandle, strCmd , nChn, strBuffer, nBufferLen,error,3000)) {
cmdObject.write();
if (configapi.CLIENT_ParseData(strCmd, strBuffer, cmdObject.getPointer(),
cmdObject.size(), null)) {
@@ -501,10 +501,10 @@
System.err.printf("Get %s Config Failed!Last Error = %s\n" , strCmd , getErrorCodePrint());
result = false;
}
-
+
return result;
}
-
+
/**
* 璁剧疆鍗曚釜閰嶇疆
* @param hLoginHandle 鐧婚檰鍙ユ焺
@@ -519,11 +519,11 @@
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);
+ IntByReference restart = new IntByReference(0);
cmdObject.write();
if (configapi.CLIENT_PacketData(strCmd, cmdObject.getPointer(), cmdObject.size(),
- szBuffer, nBufferLen)) {
+ szBuffer, nBufferLen)) {
cmdObject.read();
if( netsdkapi.CLIENT_SetNewDevConfig(hLoginHandle, strCmd , nChn , szBuffer, nBufferLen, error, restart, 3000)) {
result = true;
@@ -535,38 +535,38 @@
System.err.println("Packet " + strCmd + " Config Failed!" + getErrorCodePrint());
result = false;
}
-
+
return result;
}
-
+
// Win涓嬶紝灏咷BK String绫诲瀷鐨勮浆涓篜ointer
- public static Pointer GetGBKStringToPointer(String src) {
+ public static Pointer GetGBKStringToPointer(String src) {
Pointer pointer = null;
try {
byte[] b = src.getBytes("GBK");
pointer = new Memory(b.length+1);
pointer.clear(b.length+1);
-
+
pointer.write(0, b, 0, b.length);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return pointer;
}
-
+
/**
* 瀛楃涓叉嫹璐濓紝鐢ㄤ簬鍏堣幏鍙栵紝鍐嶈缃�(src 鈫� dst)
- * @param src
+ * @param src
* @param dst
*/
public static void StringToByteArray(String src, byte[] dst) {
for(int i = 0; i < dst.length; i++) {
dst[i] = 0;
}
-
+
System.arraycopy(src.getBytes(), 0, dst, 0, src.getBytes().length);
}
-
+
/**
* 鏁扮粍鎷疯礉锛� 鐢ㄤ簬鍏堣幏鍙栵紝鍐嶈缃�(src 鈫� dst)
* @param src
@@ -576,7 +576,7 @@
for(int i = 0; i < dst.length; i++) {
dst[i] = 0;
}
-
+
System.arraycopy(src, 0, dst, 0, src.length);
}
}
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java
index de23049..29ef39c 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/dhsdk/service/impl/DahuaSDK.java
@@ -4,6 +4,7 @@
import com.ruoyi.alarm.global.domain.GuideTask;
import com.ruoyi.alarm.global.service.impl.QueueHandler;
import com.ruoyi.common.annotation.SdkOperate;
+import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.file.MimeTypeUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
@@ -19,6 +20,7 @@
import com.ruoyi.utils.gis.GisUtil;
import com.ruoyi.utils.minio.MinioUtil;
import com.ruoyi.utils.sdk.common.GlobalVariable;
+import com.ruoyi.utils.sdk.dhsdk.common.ErrorCode;
import com.ruoyi.utils.sdk.dhsdk.lib.NetSDKLib;
import com.ruoyi.utils.sdk.dhsdk.lib.enumeration.EM_NEW_CONFIG;
import com.ruoyi.utils.sdk.dhsdk.lib.enumeration.NET_EM_CFG_OPERATE_TYPE;
@@ -317,14 +319,14 @@
*/
@Override
@SdkOperate
- public boolean pTZControl(CameraCmd cmd) {
+ public AjaxResult pTZControl(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
boolean enable = cmd.isEnable();
Integer chanNo = cmd.getChanNo();
Integer speed = cmd.getSpeed();
Integer code = cmd.getCode();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return false;
+ return AjaxResult.error("璁惧鏈櫥褰�");
}
NetSDKLib.LLong loginId = (NetSDKLib.LLong) GlobalVariable.loginMap.get(cameraId);
int dwStop;
@@ -391,8 +393,9 @@
boolean bool = PtzControlModule.ptzControl(loginId, chanNo - 1, dwPTZCommand, speed, speed, 0, dwStop);
if (!bool) {
log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + getErrorCodePrint());
+ return AjaxResult.error(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError()));
}
- return bool;
+ return AjaxResult.success();
}
/**
@@ -429,7 +432,7 @@
}
@Override
- public boolean setPtz1(CameraCmd cmd) {
+ public AjaxResult setPtz1(CameraCmd cmd) {
return setPtz(cmd) ;
}
@@ -443,12 +446,12 @@
*/
@Override
@SdkOperate
- public boolean setPtz(CameraCmd cmd) {
+ public AjaxResult setPtz(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
Integer chanNo = cmd.getChanNo();
Map<String, Double> ptz = cmd.getPtzMap();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return false;
+ return AjaxResult.error("璁惧鏈櫥褰�");
}
LLong loginId = (LLong) GlobalVariable.loginMap.get(cameraId);
try {
@@ -460,11 +463,12 @@
boolean bool = netsdk.CLIENT_DHPTZControlEx(loginId, chanNo - 1, NetSDKLib.NET_EXTPTZ_ControlType.NET_EXTPTZ_EXACTGOTO, p, t, z, 0);
if (!bool) {
log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + getErrorCodePrint());
+ return AjaxResult.error(ErrorCode.getErrorCode(LoginModule.netsdk.CLIENT_GetLastError()));
}
- return bool;
+ return AjaxResult.success();
} catch (Exception ex) {
log.error(ex.getMessage());
- return false;
+ return AjaxResult.error(ex.getMessage());
}
}
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/controller/HikSdkController.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/controller/HikSdkController.java
index b0a3fd4..3eea0a8 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/controller/HikSdkController.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/controller/HikSdkController.java
@@ -85,7 +85,7 @@
public @ResponseBody
AjaxResult PTZControlWithSpeed(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.pTZControl(cmd));
+ return sdk.pTZControl(cmd);
}
@ApiOperation("璋冪敤棰勭疆鐐�")
@@ -158,7 +158,7 @@
public @ResponseBody
AjaxResult setPTZ(@RequestBody CameraCmd cmd) {
cmd.setOperator(SecurityUtils.getUserId());
- return toAjax(sdk.setPtz(cmd));
+ return sdk.setPtz(cmd);
}
@ApiOperation("鎸囧悜鐩爣")
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
index 82a6c1d..61a578e 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
@@ -4,6 +4,7 @@
import com.ruoyi.alarm.global.domain.GuideTask;
import com.ruoyi.alarm.global.service.impl.QueueHandler;
import com.ruoyi.common.annotation.SdkOperate;
+import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.file.MimeTypeUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
@@ -19,6 +20,7 @@
import com.ruoyi.utils.gis.GisUtil;
import com.ruoyi.utils.minio.MinioUtil;
import com.ruoyi.utils.sdk.common.GlobalVariable;
+import com.ruoyi.utils.sdk.common.SdkErrorCodeEnum;
import com.ruoyi.utils.sdk.hiksdk.lib.ExceptionCallBack;
import com.ruoyi.utils.sdk.hiksdk.lib.HCNetSDK;
import com.sun.jna.NativeLong;
@@ -220,7 +222,10 @@
//鍚屾鐧诲綍
int lUserID = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
if (lUserID < 0) {
- log.debug("Login Failed 銆� " + camera.getIp() + ":" + camera.getPort() + " 銆�,Error Code锛�" + hCNetSDK.NET_DVR_GetLastError());
+ int errorCode = hCNetSDK.NET_DVR_GetLastError();
+ log.debug("Login Failed 銆� " + camera.getIp() + ":" + camera.getPort() + " 銆�," +
+ "Error Code:" + errorCode + " " +
+ "Error Info:" + SdkErrorCodeEnum.getDescByCode(errorCode));
camera.setChanNum(0);
camera.setLoginId(-1);
camera.setState("0");
@@ -376,14 +381,14 @@
*/
@Override
@SdkOperate
- public boolean pTZControl(CameraCmd cmd) {
+ public AjaxResult pTZControl(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
boolean enable = cmd.isEnable();
Integer channelNum = cmd.getChanNo();
Integer speed = cmd.getSpeed();
Integer code = cmd.getCode();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return false;
+ return AjaxResult.error("鐩告満鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
int dwStop;
@@ -452,8 +457,9 @@
if (!bool) {
int errorCode = hCNetSDK.NET_DVR_GetLastError();
log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + errorCode);
+ return AjaxResult.error("errorCode:" + errorCode + "errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
}
- return bool;
+ return AjaxResult.success();
}
/**
@@ -992,12 +998,12 @@
*/
@Override
@SdkOperate
- public boolean setPtz1(CameraCmd cmd) {
+ public AjaxResult setPtz1(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
Integer channelNum = cmd.getChanNo();
Map<String, Double> ptz = cmd.getPtzMap();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return false;
+ return AjaxResult.error("璁惧鏈櫥褰�");
}
Integer userId = (Integer) GlobalVariable.loginMap.get(cameraId);
NET_DVR_PTZPOS m_ptzPosCurrent = new NET_DVR_PTZPOS();
@@ -1013,13 +1019,14 @@
m_ptzPosCurrent.write();
boolean bool = hCNetSDK.NET_DVR_SetDVRConfig(userId, NET_DVR_SET_PTZPOS, channelNum, point, m_ptzPosCurrent.size());
if (!bool) {
- int code = hCNetSDK.NET_DVR_GetLastError();
- log.error("璁剧疆PTZ鍙傛暟澶辫触,璇风◢鍚庨噸璇�:" + code);
+ int errorCode = hCNetSDK.NET_DVR_GetLastError();
+ log.error("璁剧疆PTZ鍙傛暟澶辫触,璇风◢鍚庨噸璇�:" + errorCode);
+ return AjaxResult.error("errorCode:" + errorCode + "errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
}
- return bool;
+ return AjaxResult.success();
} catch (Exception ex) {
log.error(ex.getMessage());
- return false;
+ return AjaxResult.error("璁剧疆PTZ鍙傛暟寮傚父:" + ex.getMessage());
}
}
@@ -1033,13 +1040,13 @@
*/
@Override
@SdkOperate
- public boolean setPtz(CameraCmd cmd) {
+ public AjaxResult setPtz(CameraCmd cmd) {
try {
String cameraId = cmd.getCameraId();
Integer chanNo = cmd.getChanNo();
Map<String, Double> ptz = cmd.getPtzMap();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
- return false;
+ return AjaxResult.error("璁惧鏈櫥褰�");
}
Integer lUserID = (Integer) GlobalVariable.loginMap.get(cameraId);
IntByReference pchannel = new IntByReference(chanNo);
@@ -1071,14 +1078,15 @@
lpConfigParam6697.write();
boolean bool = hCNetSDK.NET_DVR_SetSTDConfig(lUserID, NET_DVR_SET_PTZABSOLUTEEX, lpConfigParam6697);
if (!bool) {
- int code = hCNetSDK.NET_DVR_GetLastError();
- log.error("璁剧疆楂樼簿搴TZ鍙傛暟澶辫触,璇风◢鍚庨噸璇�:" + code);
+ int errorCode = hCNetSDK.NET_DVR_GetLastError();
+ log.error("璁剧疆楂樼簿搴TZ鍙傛暟澶辫触,璇风◢鍚庨噸璇�:" + errorCode);
+ return AjaxResult.error("errorCode:" + errorCode + "errorInfo:" + SdkErrorCodeEnum.getDescByCode(errorCode));
}
- return bool;
+ return AjaxResult.success();
} catch (Exception ex) {
log.error("璁剧疆楂樼簿搴TZ鍙傛暟寮傚父", ex);
- return false;
+ return AjaxResult.error("璁剧疆楂樼簿搴TZ鍙傛暟寮傚父:" + ex);
}
}
--
Gitblit v1.9.3