CameraServiceImpl.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package com.ruoyi.system.service.impl;
  2. import com.alibaba.fastjson2.JSON;
  3. import com.alibaba.fastjson2.JSONArray;
  4. import com.alibaba.fastjson2.JSONObject;
  5. import com.ruoyi.common.core.domain.AjaxResult;
  6. import com.ruoyi.common.exception.ServiceException;
  7. import com.ruoyi.common.utils.SecurityUtils;
  8. import com.ruoyi.common.utils.StringUtils;
  9. import com.ruoyi.common.utils.hkws.GetCameraPreviewURL;
  10. import com.ruoyi.system.domain.vo.CameraInfoVo;
  11. import com.ruoyi.system.service.CameraService;
  12. import org.apache.poi.ss.usermodel.DateUtil;
  13. import org.springframework.stereotype.Service;
  14. import java.util.Date;
  15. /**
  16. * 监控Service业务层处理
  17. *
  18. * @author ruoyi
  19. * @date 2024-06-25
  20. */
  21. @Service
  22. public class CameraServiceImpl implements CameraService {
  23. @Override
  24. public AjaxResult selectCameraList(CameraInfoVo cameraInfoVo) {
  25. /**
  26. * STEP3:设置接口的URI地址
  27. */
  28. String url = "/api/resource/v2/camera/search";
  29. /**
  30. * STEP5:组装请求参数
  31. */
  32. String body = JSONArray.toJSONString(cameraInfoVo);
  33. /*JSONObject jsonBody = new JSONObject();
  34. jsonBody.put("cameraIndexCode", "8e59cc5559904589938be47888e5214a");
  35. jsonBody.put("streamType", 0);
  36. jsonBody.put("protocol", "httpflv");
  37. jsonBody.put("transmode", 1);
  38. jsonBody.put("expand", "streamform=ps");*/
  39. /* jsonBody.put("pageNo", 1);
  40. jsonBody.put("pageSize", 30);*/
  41. String result = GetCameraPreviewURL.GetCameraPreviewURL(url,body);
  42. JSONObject jsonObject = JSON.parseObject(result);
  43. return AjaxResult.success(jsonObject);
  44. }
  45. @Override
  46. public AjaxResult video(String cameraIndexCode) {
  47. if(StringUtils.isEmpty(cameraIndexCode)){
  48. throw new ServiceException("参数错误");
  49. }
  50. /**
  51. * STEP3:设置接口的URI地址
  52. */
  53. String url = "/api/video/v2/cameras/previewURLs";
  54. /**
  55. * STEP5:组装请求参数
  56. */
  57. JSONObject jsonBody = new JSONObject();
  58. jsonBody.put("cameraIndexCode", cameraIndexCode);
  59. jsonBody.put("streamType", 0);
  60. jsonBody.put("protocol", "httpflv");
  61. jsonBody.put("transmode", 1);
  62. jsonBody.put("expand", "streamform=ps");
  63. String result = GetCameraPreviewURL.GetCameraPreviewURL(url,jsonBody.toString());
  64. JSONObject jsonObject = JSON.parseObject(result);
  65. return AjaxResult.success(jsonObject);
  66. }
  67. }