diff --git a/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/IntegrationURL.java b/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/IntegrationURL.java new file mode 100644 index 000000000..790bb0291 --- /dev/null +++ b/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/IntegrationURL.java @@ -0,0 +1,511 @@ +package cn.iocoder.yudao.module.hiking; + +import com.alibaba.fastjson.JSONObject; +import com.hikvision.artemis.sdk.ArtemisHttpUtil; +import com.hikvision.artemis.sdk.config.ArtemisConfig; + +import java.util.HashMap; +import java.util.Map; + +public class IntegrationURL { + + + //设置平台参数,根据实际情况,设置host appKey appSecret 三个参数. + static { + ArtemisConfig.host = "127.0.0.1:443"; // 平台的ip端口 + ArtemisConfig.appKey = "29180881"; // 密钥appkey + ArtemisConfig.appSecret = "XO0wCAYGi4KV70ybjznx";// 密钥appSecret + } + + //设置OpenAPI接口的上下文 + public static final String ARTEMIS_PATH = "/artemis"; + + + // 获取根区域信息 + public static String getRegionsRootURL(String accessToken) { + + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/regions/root"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, null, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + //查询区域列表v2 + public static String getRegionListURL(String resourceType,int pageNo,int pageSize,String accessToken) { + + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/irds/v2/region/nodesByParams"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("resourceType",resourceType); + jsonBody.put("pageNo", pageNo); + jsonBody.put("pageSize", pageSize); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 根据区域编号获取下一级区域列表v2 + public static String getRegionListByParentIndexCodeURL(String parentIndexCode, String resourceType,int pageNo,int pageSize,String accessToken) { + + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v2/regions/subRegions"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("parentIndexCode", parentIndexCode); + jsonBody.put("resourceType",resourceType); + jsonBody.put("pageNo", pageNo); + jsonBody.put("pageSize", pageSize); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 分页获取区域列表 + public static String getRegionListPageURL(int pageNo,int pageSize,String accessToken) { + + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/regions"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("pageNo", pageNo); + jsonBody.put("pageSize", pageSize); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 根据编号获取区域详细信息 + public static String getRegionByIndexCodesURL(String[] indexCodes,String accessToken) { + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/region/regionCatalog/regionInfo"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("indexCodes", indexCodes); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 增量获取区域数据 + public static String getRegionTimeRangeURL(String startTime, String pageNo, String pageSize,String accessToken) { + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/region/timeRange"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("startTime", startTime); + jsonBody.put("pageNo", pageNo); + jsonBody.put("pageSize", pageSize); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + //查询监控点列表v2 + public static String getCameraListURL(int pageNo,int pageSize,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v2/camera/search"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("pageNo", pageNo); //当前页码 + jsonBody.put("pageSize", pageSize); //分页大小 + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //分页获取监控点资源 + public static String getCameraResourceURL(int pageNo,int pageSize,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/cameras"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("pageNo", pageNo); //当前页码 + jsonBody.put("pageSize", pageSize); //分页大小 + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 根据区域编号获取下级监控点列表 + public static String getCameraListByRegionIndexCodeURL(String regionIndexCode, int pageNo,int pageSize,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/regions/regionIndexCode/cameras"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("regionIndexCode", regionIndexCode); //区域编号 + jsonBody.put("pageNo", pageNo); //当前页码 + jsonBody.put("pageSize", pageSize); //分页大小 + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 根据编号获取监控点详细信息 + public static String getCameraByCameraIndexCodeURL(String cameraIndexCode,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/cameras/indexCode"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode", cameraIndexCode); //监控点唯一标识 + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 增量获取监控点数据 + public static String getCameraTimeRangeURL(String startTime, int pageNo, int pageSize, String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/camera/timeRange"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("startTime", startTime); + jsonBody.put("pageNo", pageNo); //当前页码 + jsonBody.put("pageSize", pageSize); //分页大小 + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //获取监控点预览取流URLv2 + public static String getPreviewURL(String cameraIndexCode, Integer streamType, String protocol, Integer transmode, String expand, String streamform, String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/video/v2/cameras/previewURLs"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode", cameraIndexCode); //监控点唯一标识,分页获取监控点资源接口获取返回参数cameraIndexCode + jsonBody.put("streamType", streamType); + jsonBody.put("protocol", protocol); + jsonBody.put("transmode", transmode); + jsonBody.put("expand", expand); + jsonBody.put("streamform", streamform); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //获取监控点回放取流URLv2 + public static String getPlaybackURL(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/video/v2/cameras/playbackURLs"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode", cameraIndexCode);//监控点唯一标识,分页获取监控点资源接口获取返回参数cameraIndexCode + jsonBody.put("recordLocation", recordLocation); + jsonBody.put("protocol", protocol); + jsonBody.put("transmode", transmode); + jsonBody.put("beginTime",beginTime );//开始查询时间(IOS8601格式:yyyy-MM-dd’T’HH:mm:ss.SSSXXX)例如北京时间:2017-06-14T00:00:00.000+08:00, + jsonBody.put("endTime",endTime);//结束时间 + jsonBody.put("uuid",uuid ); + jsonBody.put("expand",expand ); + jsonBody.put("streamform",streamform ); + jsonBody.put("lockType",lockType ); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //监控点3D放大 + public static String getControlURL(String cameraIndexCode,int startX,int startY,int endX,int endY,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/video/v1/ptzs/selZoom"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode",cameraIndexCode ); + jsonBody.put("startX",startX ); + jsonBody.put("startY",startY ); + jsonBody.put("endX",endX ); + jsonBody.put("endY",endY ); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //根据监控点编号进行云台操作 + public static String getYunTaiOperationURL(String cameraIndexCode, Integer action, String command, Integer speed, Integer presetIndex,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/video/v1/ptzs/controlling"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode", cameraIndexCode); + jsonBody.put("action",action ); + jsonBody.put("command",command ); + jsonBody.put("speed",speed ); + jsonBody.put("presetIndex",presetIndex ); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //access_token认证 + public static String getAccessTokenURL() { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/v1/oauth/token"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + String body = jsonBody.toJSONString(); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, null, null, null, contentType , null);// post请求application/json类型参数 + + return result; + } + + + + + +} diff --git a/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/api/HikingCameraApiImpl.java b/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/api/HikingCameraApiImpl.java index 8acac3681..ffd18ea79 100644 --- a/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/api/HikingCameraApiImpl.java +++ b/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/api/HikingCameraApiImpl.java @@ -43,12 +43,12 @@ public class HikingCameraApiImpl implements CameraApi { } @Override - public CommonResult selectPreviewUrlByCameraIndexCode(String cameraIndexCode) { - return success(cameraService.getPreviewUrl(cameraIndexCode)); + public CommonResult selectPreviewUrlByCameraIndexCode(String cameraIndexCode, Integer streamType, String protocol, Integer transmode, String expand, String streamform) { + return success(cameraService.getPreviewUrl(cameraIndexCode, streamType, protocol, transmode, expand, streamform)); } @Override - public CommonResult selectPlayBackUrlByCameraIndexCode(String cameraIndexCode, String beginTime, String endTime) { - return success(cameraService.getPlayBackUrl(cameraIndexCode, beginTime, endTime)); + public CommonResult selectPlayBackUrlByCameraIndexCode(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType) { + return success(cameraService.getPlayBackUrl(cameraIndexCode, recordLocation,protocol,transmode,beginTime,endTime, uuid, expand, streamform, lockType)); } } diff --git a/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/service/camera/CameraServiceImpl.java b/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/service/camera/CameraServiceImpl.java index 84f800a58..3f61e488c 100644 --- a/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/service/camera/CameraServiceImpl.java +++ b/ludu-module-hiking/ludu-module-hiking-biz/src/main/java/cn/iocoder/yudao/module/hiking/service/camera/CameraServiceImpl.java @@ -147,13 +147,13 @@ public class CameraServiceImpl implements CameraService { } @Override - public String getPreviewUrl(String cameraIndexCode) { - return IntegrationURL.getPreviewURL(cameraIndexCode, getAccessToken()); + public String getPreviewUrl(String cameraIndexCode, Integer streamType, String protocol, Integer transmode, String expand, String streamform) { + return IntegrationURL.getPreviewURL(cameraIndexCode, streamType, protocol, transmode, expand, streamform, getAccessToken()); } @Override - public String getPlayBackUrl(String cameraIndexCode, String startTime, String endTime) { - return IntegrationURL.getPlaybackURL(cameraIndexCode, startTime, endTime, getAccessToken()); + public String getPlayBackUrl(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType) { + return IntegrationURL.getPlaybackURL(cameraIndexCode, recordLocation,protocol,transmode,beginTime,endTime, uuid, expand, streamform, lockType, getAccessToken()); } @Override