GetCameraPreviewURL.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package com.ruoyi.common.utils.hkws;
  2. import com.hikvision.artemis.sdk.ArtemisHttpUtil;
  3. import com.hikvision.artemis.sdk.config.ArtemisConfig;
  4. import com.alibaba.fastjson2.JSONObject;
  5. import java.util.HashMap;
  6. import java.util.Map;
  7. public class GetCameraPreviewURL {
  8. public static String GetCameraPreviewURL(String url,String body) {
  9. /**
  10. * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
  11. */
  12. ArtemisConfig.host = "60.171.161.56:1443"; // 平台的ip端口
  13. ArtemisConfig.appKey = "25679504"; // 密钥appkey
  14. ArtemisConfig.appSecret = "9F3cOy6JnpHeOeDOYcgP";// 密钥appSecret
  15. /**
  16. * STEP2:设置OpenAPI接口的上下文
  17. */
  18. final String ARTEMIS_PATH = "/artemis";
  19. /**
  20. * STEP3:设置接口的URI地址
  21. */
  22. //final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/cameras";
  23. final String previewURLsApi = ARTEMIS_PATH + url;
  24. Map<String, String> path = new HashMap<String, String>(2) {
  25. {
  26. put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
  27. }
  28. };
  29. /**
  30. * STEP4:设置参数提交方式
  31. */
  32. String contentType = "application/json";
  33. /**
  34. * STEP6:调用接口
  35. */
  36. String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);// post请求application/json类型参数
  37. return result;
  38. }
  39. /* public static void main(String[] args) {
  40. *//**
  41. * STEP3:设置接口的URI地址
  42. *//*
  43. String url = "/api/resource/v2/door/search";
  44. *//**
  45. * STEP5:组装请求参数
  46. *//*
  47. JSONObject jsonBody = new JSONObject();
  48. jsonBody.put("pageNo", 1);
  49. jsonBody.put("pageSize", 60);
  50. *//*jsonBody.put("receptionistId", "123v453673dsferf12312");
  51. JSONObject jsonBody2 = new JSONObject();
  52. jsonBody2.put("defaultPrivilegeGroupFlag","1");
  53. String[] privilegeGroupIds = {"793d155-3cc3-4b2a-bb23-8507552863"};
  54. jsonBody2.put("privilegeGroupIds",privilegeGroupIds);
  55. jsonBody.put("visitorPermissionSet",jsonBody2);
  56. jsonBody.put("visitStartTime", "2024-06-28T15:00:00+08:00");
  57. jsonBody.put("visitEndTime", "2024-06-28T19:00:00+08:00");
  58. jsonBody.put("visitPurpose", "参观");
  59. List<JSONObject> jSONObjectList = new ArrayList<>();
  60. JSONObject jsonBody3 = new JSONObject();
  61. jsonBody3.put("visitorName","张三");
  62. jsonBody3.put("gender",1);
  63. jsonBody3.put("phoneNo","18297543143");
  64. jsonBody3.put("plateNo","浙A12345");
  65. jsonBody3.put("certificateType",111);
  66. jsonBody3.put("certificateNo","312488198704015698");
  67. jsonBody3.put("certAddr","江苏南京");
  68. jsonBody3.put("certIssuer","南京市政府");
  69. jsonBody3.put("nation",1);
  70. jsonBody3.put("birthplace","江苏南京");
  71. jsonBody3.put("visitorPhoto","cMc8yMjIfE87ujdq0nvyPcKodJ3XPpvt//2Q==");
  72. jsonBody3.put("visitorWorkUnit","海康威视");
  73. jsonBody3.put("visitorAddress","人民路一号");
  74. jSONObjectList.add(jsonBody3);
  75. jsonBody.put("visitorInfoList", jSONObjectList);*//*
  76. String result = GetCameraPreviewURL(url,jsonBody.toString());
  77. System.out.println("result结果示例: " + result);
  78. }*/
  79. }