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 void loginAll() {
|
|
}
|
|
@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")) {
|
|
}
|
}
|
} 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")) {
|
|
}
|
}
|
} 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")) {
|
|
}
|
}
|
} 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;
|
}
|
|
@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;
|
}
|
|
@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;
|
}
|
|
@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;
|
}
|
}
|