| | |
| | | |
| | | import cn.gistack.sm.hk.constant.HkConstant; |
| | | import cn.gistack.sm.hk.constant.ProtocolConstant; |
| | | import cn.gistack.sm.hk.vo.EventVO; |
| | | import cn.gistack.sm.hk.vo.HkVO; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.hikvision.artemis.sdk.ArtemisHttpUtil; |
| | | import com.hikvision.artemis.sdk.config.ArtemisConfig; |
| | | import org.springblade.core.tool.api.R; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | import static cn.gistack.sm.hk.constant.HkConstant.ARTEMIS_PATH; |
| | | import static cn.gistack.sm.hk.util.GetCameraUtils.GetCameraPreviewURL; |
| | | |
| | | public class GetCameraUtils { |
| | | |
| | | /** |
| | |
| | | ArtemisConfig.appKey = HkConstant.AppKey; |
| | | // 秘钥appSecret |
| | | ArtemisConfig.appSecret = HkConstant.AppSecret; |
| | | |
| | | if (type==3) { |
| | | // 秘钥appKey |
| | | ArtemisConfig.appKey = HkConstant.EventAppKey; |
| | | // 秘钥appSecret |
| | | ArtemisConfig.appSecret = HkConstant.EventAppSecret; |
| | | // host |
| | | ArtemisConfig.host = HkConstant.Event_NEW_HOST; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | * @param url 视频预览url |
| | | * @param cameraIndexCode 监控点唯一标识 |
| | | * @param protocol |
| | | * @param transmode |
| | | * @param expand |
| | | * @return |
| | | */ |
| | | public static String GetCameraPreviewURL(Integer type,String url, String cameraIndexCode, String protocol,String expand) { |
| | | public static String GetCameraPreviewURL(Integer type, |
| | | String url, |
| | | String cameraIndexCode, |
| | | String protocol, |
| | | Integer transmode, |
| | | String expand, |
| | | Integer streamType) { |
| | | /** |
| | | * 组装请求参数 |
| | | */ |
| | | JSONObject jsonBody = new JSONObject(); |
| | | jsonBody.put("cameraIndexCode", cameraIndexCode); |
| | | jsonBody.put("streamType", 0); |
| | | jsonBody.put("streamType",streamType); |
| | | jsonBody.put("protocol", protocol); |
| | | jsonBody.put("transmode", 1); |
| | | jsonBody.put("transmode", transmode); |
| | | if (null!= expand && !expand.equals("")) { |
| | | jsonBody.put("expand", expand); |
| | | } |
| | |
| | | return common(type,url,body); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取监控点资源分页数据 |
| | | * |
| | | * @param url 监控资源url |
| | | * @return |
| | | */ |
| | | public static String GetCameraResourcePage(Integer type,Integer pageNo, Integer pageSize, String url) { |
| | | /** |
| | | * 组装请求参数 |
| | | */ |
| | | JSONObject jsonBody = new JSONObject(); |
| | | jsonBody.put("pageNo", pageNo); |
| | | jsonBody.put("pageSize", pageSize); |
| | | String body = jsonBody.toJSONString(); |
| | | |
| | | /** |
| | | * 调用接口并返回数据 |
| | | * post请求application/json类型参数; |
| | | */ |
| | | return common(type,url, body); |
| | | } |
| | | |
| | | /** |
| | | * 抓图 |
| | | * |
| | |
| | | return common(type,url, body); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | /** |
| | | * 获取监控点资源分页数据 |
| | | * @param url 监控资源url |
| | | * @return |
| | | */ |
| | | public static String GetCameraResourcePage(Integer type,Integer pageNo, Integer pageSize, String url) { |
| | | /** |
| | | * 组装请求参数 |
| | | */ |
| | | JSONObject jsonBody = new JSONObject(); |
| | | jsonBody.put("pageNo", pageNo); |
| | | jsonBody.put("pageSize", pageSize); |
| | | String body = jsonBody.toJSONString(); |
| | | |
| | | /** |
| | | * 调用接口并返回数据 |
| | | * post请求application/json类型参数; |
| | | */ |
| | | return common(type,url, body); |
| | | } |
| | | |
| | | /** |
| | | * 海康视频事件订阅 |
| | | * @param eventVO |
| | | * @param url |
| | | * @return |
| | | */ |
| | | public static String addEventSubscriptionByEventTypes(EventVO eventVO, String url) { |
| | | /** |
| | | * 组装请求参数 |
| | | */ |
| | | JSONObject jsonBody = new JSONObject(); |
| | | jsonBody.put("eventTypes", Arrays.stream(eventVO.getEventTypes().split(",")).mapToLong(Long::parseLong).toArray()); |
| | | jsonBody.put("eventDest", eventVO.getEventDest()); |
| | | if (null!=eventVO.getSubType()){ |
| | | jsonBody.put("subType", eventVO.getSubType()); |
| | | } |
| | | if (null!=eventVO.getEventLvl()){ |
| | | jsonBody.put("eventLvl", Arrays.stream(eventVO.getEventLvl().split(",")).mapToInt(Integer::parseInt).toArray()); |
| | | } |
| | | String body = jsonBody.toJSONString(); |
| | | |
| | | /** |
| | | * 调用接口并返回数据 |
| | | * post请求application/json类型参数; |
| | | */ |
| | | return common(null==eventVO.getType()?1:eventVO.getType(),url, body); |
| | | } |
| | | |
| | | /** |
| | | * 海康视频事件取消订阅 |
| | | * @param eventVO |
| | | * @param url |
| | | * @return |
| | | */ |
| | | public static String removeEventSubscriptionByEventTypes(EventVO eventVO, String url) { |
| | | long[] eventTypes = Arrays.stream(eventVO.getEventTypes().split(",")).mapToLong(Long::parseLong).toArray(); |
| | | /** |
| | | * 组装请求参数 |
| | | */ |
| | | JSONObject jsonBody = new JSONObject(); |
| | | jsonBody.put("eventTypes", eventTypes); |
| | | String body = jsonBody.toJSONString(); |
| | | |
| | | /** |
| | | * 调用接口并返回数据 |
| | | * post请求application/json类型参数; |
| | | */ |
| | | return common(null==eventVO.getType()?1:eventVO.getType(),url, body); |
| | | } |
| | | |
| | | /** |
| | | * 查询事件订阅信息 |
| | | * @param eventVO |
| | | * @param url |
| | | * @return |
| | | */ |
| | | public static String getEventSubscriptionView(EventVO eventVO, String url) { |
| | | /** |
| | | * 组装请求参数 |
| | | */ |
| | | JSONObject jsonBody = new JSONObject(); |
| | | String body = jsonBody.toJSONString(); |
| | | |
| | | /** |
| | | * 调用接口并返回数据 |
| | | * post请求application/json类型参数; |
| | | */ |
| | | return common(null==eventVO.getType()?1:eventVO.getType(),url, body); |
| | | } |
| | | |
| | | // public static void main(String[] args) { |
| | | // |
| | | // String previewURL = GetCameraPreviewURL(1, HkConstant.previewURLs, |
| | | // "0c4f30948dde4998a676ec6983119cb5", |
| | |
| | | // String common = common(HkConstant.playbackURLs, body); |
| | | // |
| | | // System.out.println("common = " + common); |
| | | } |
| | | // } |
| | | } |