|
@@ -5,20 +5,22 @@ import com.sw.patroleditor.common.ResultData;
|
|
import com.sw.patroleditor.domain.model.*;
|
|
import com.sw.patroleditor.domain.model.*;
|
|
import com.sw.patroleditor.exception.BusinessException;
|
|
import com.sw.patroleditor.exception.BusinessException;
|
|
import com.sw.patroleditor.exception.ErrorCode;
|
|
import com.sw.patroleditor.exception.ErrorCode;
|
|
-import com.sw.patroleditor.service.PTZCtrlService;
|
|
|
|
|
|
+import com.sw.patroleditor.service.HKService;
|
|
import com.sw.patroleditor.util.HkHttpUtils;
|
|
import com.sw.patroleditor.util.HkHttpUtils;
|
|
import com.sw.patroleditor.util.XmlUtils;
|
|
import com.sw.patroleditor.util.XmlUtils;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.Base64;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 云台控制接口
|
|
|
|
|
|
+ * 海康接口
|
|
*
|
|
*
|
|
* @author machao
|
|
* @author machao
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
-public class PTZCtrlServiceImpl implements PTZCtrlService {
|
|
|
|
|
|
+public class HKServiceImpl implements HKService {
|
|
|
|
|
|
HkHttpUtils httpUtils = new HkHttpUtils();
|
|
HkHttpUtils httpUtils = new HkHttpUtils();
|
|
|
|
|
|
@@ -34,7 +36,7 @@ public class PTZCtrlServiceImpl implements PTZCtrlService {
|
|
String uri = "/ISAPI/PTZCtrl/channels/" + bodyRequestModel.getChannel() + "/continuous";
|
|
String uri = "/ISAPI/PTZCtrl/channels/" + bodyRequestModel.getChannel() + "/continuous";
|
|
bodyRequestModel.setUri(uri);
|
|
bodyRequestModel.setUri(uri);
|
|
//发送指令
|
|
//发送指令
|
|
- return sendCMD2Hik(ptzData, bodyRequestModel, PTZData.class);
|
|
|
|
|
|
+ return sendCtrlCMD2Hik(ptzData, bodyRequestModel, PTZData.class);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -48,7 +50,7 @@ public class PTZCtrlServiceImpl implements PTZCtrlService {
|
|
BodyRequestModel bodyRequestModel = new BodyRequestModel();
|
|
BodyRequestModel bodyRequestModel = new BodyRequestModel();
|
|
String uri = "/ISAPI/System/Video/inputs/channels/" + bodyRequestModel.getChannel() + "/focus";
|
|
String uri = "/ISAPI/System/Video/inputs/channels/" + bodyRequestModel.getChannel() + "/focus";
|
|
bodyRequestModel.setUri(uri);
|
|
bodyRequestModel.setUri(uri);
|
|
- return sendCMD2Hik(focusData, bodyRequestModel, FocusData.class);
|
|
|
|
|
|
+ return sendCtrlCMD2Hik(focusData, bodyRequestModel, FocusData.class);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -63,18 +65,41 @@ public class PTZCtrlServiceImpl implements PTZCtrlService {
|
|
BodyRequestModel bodyRequestModel = new BodyRequestModel();
|
|
BodyRequestModel bodyRequestModel = new BodyRequestModel();
|
|
String uri = "/ISAPI/PTZCtrl/channels/" + bodyRequestModel.getChannel() + "/position3D";
|
|
String uri = "/ISAPI/PTZCtrl/channels/" + bodyRequestModel.getChannel() + "/position3D";
|
|
bodyRequestModel.setUri(uri);
|
|
bodyRequestModel.setUri(uri);
|
|
- return sendCMD2Hik(position3D, bodyRequestModel, Position3D.class);
|
|
|
|
|
|
+ return sendCtrlCMD2Hik(position3D, bodyRequestModel, Position3D.class);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 可见光抓图
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResultData picture() {
|
|
|
|
+ String resp = null;
|
|
|
|
+ BodyRequestModel bodyRequestModel = new BodyRequestModel();
|
|
|
|
+ String uri = "/ISAPI/Streaming/channels/" + bodyRequestModel.getChannel() + "/picture";
|
|
|
|
+ bodyRequestModel.setUri(uri);
|
|
|
|
+ //发送指令
|
|
|
|
+ try {
|
|
|
|
+ byte[] bytes = httpUtils.doPictureGet(bodyRequestModel);
|
|
|
|
+ //Base64编码
|
|
|
|
+ resp = Base64.getEncoder().encodeToString(bytes);
|
|
|
|
+ //System.out.println(resp);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new BusinessException(ErrorCode.FAIL.getCode(), e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return ResultData.success(resp);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 利用摘要认证并按照ISAPI协议向HIK发送指令
|
|
|
|
|
|
+ * 利用摘要认证并按照ISAPI协议向HIK发送控制指令
|
|
*
|
|
*
|
|
* @param cmdData
|
|
* @param cmdData
|
|
* @param bodyRequestModel
|
|
* @param bodyRequestModel
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private ResultData sendCMD2Hik(Object cmdData, BodyRequestModel bodyRequestModel, Class<?>... classT) {
|
|
|
|
|
|
+ private ResultData sendCtrlCMD2Hik(Object cmdData, BodyRequestModel bodyRequestModel, Class<?>... classT) {
|
|
try {
|
|
try {
|
|
String xml = XmlUtils.objectToXml(cmdData, classT);
|
|
String xml = XmlUtils.objectToXml(cmdData, classT);
|
|
bodyRequestModel.setEntity(xml);
|
|
bodyRequestModel.setEntity(xml);
|