| | |
| | | package com.javaweb.geo.controller; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | public class ProjectCameraController extends BaseController { |
| | | private String prefix = "geo/projectCamera"; |
| | | |
| | | private String appkey = "af786eacc71d43ef9393c028cf4face7"; |
| | | private String secret = "9ad87671f63d2258af6fd9b2e5fa6005"; |
| | | private String postUrl ="https://open.ys7.com/api/lapp/token/get"; |
| | | |
| | | @Autowired |
| | | private IProjectCameraService projectCameraService; |
| | | |
| | |
| | | public String projectCamera(String id, ModelMap mmap) { |
| | | mmap.put("projectId", id); |
| | | return prefix + "/projectCamera"; |
| | | } |
| | | |
| | | @RequiresPermissions("geo:projectCamera:view2") |
| | | @GetMapping("/view2") |
| | | public String projectCamera2() { |
| | | return prefix + "/projectCamera2"; |
| | | } |
| | | |
| | | /** |
| | |
| | | startPage(); |
| | | List<ProjectCamera> list = projectCameraService.selectProjectCameraList(projectCamera); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | @GetMapping("/cameralist") |
| | | @ResponseBody |
| | | public AjaxResult cameralist(ProjectCamera projectCamera) { |
| | | |
| | | List<ProjectCamera> list = projectCameraService.selectProjectCameraList(projectCamera); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @GetMapping("/cameraPlayerUrl") |
| | | @ResponseBody |
| | | public AjaxResult cameraPlayerUrl(String id ) { |
| | | |
| | | ProjectCamera projectCamera = projectCameraService.selectProjectCameraById(id); |
| | | String url = projectCamera.getIp(); |
| | | |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("appKey", appkey); |
| | | paramMap.put("appSecret", secret); |
| | | |
| | | HttpResponse response = HttpRequest.post(postUrl) |
| | | .form(paramMap) // 表单参数 |
| | | .execute(); |
| | | |
| | | String body = response.body(); |
| | | JSONObject jsonObject = JSONUtil.parseObj(body); |
| | | String code = jsonObject.getStr("code"); |
| | | StringBuffer buffer = new StringBuffer(); |
| | | if(code.equals("200")){ |
| | | JSONObject data = (JSONObject) jsonObject.get("data"); |
| | | String token = data.getStr("accessToken"); |
| | | buffer.append("https://open.ys7.com/console/jssdk/pc.html?accessToken="); |
| | | buffer.append(token); |
| | | buffer.append("&url="); |
| | | buffer.append(url); |
| | | } |
| | | |
| | | logger.debug(buffer.toString()); |
| | | AjaxResult ajaxResult = AjaxResult.success(); |
| | | ajaxResult.put("url",buffer.toString()); |
| | | return ajaxResult; |
| | | } |
| | | |
| | | /** |
| | |
| | | * 新增监控设备 |
| | | */ |
| | | @GetMapping("/add") |
| | | public String add() { |
| | | public String add(String projectId, ModelMap mmap) { |
| | | mmap.put("projectId", projectId); |
| | | return prefix + "/add"; |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("/player") |
| | | public String player( String id, ModelMap mmap) { |
| | | ProjectCamera projectCamera = projectCameraService.selectProjectCameraById(id); |
| | | String url = projectCamera.getIp(); |
| | | |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("appKey", appkey); |
| | | paramMap.put("appSecret", secret); |
| | | |
| | | HttpResponse response = HttpRequest.post(postUrl) |
| | | .form(paramMap) // 表单参数 |
| | | .execute(); |
| | | |
| | | String body = response.body(); |
| | | JSONObject jsonObject = JSONUtil.parseObj(body); |
| | | String code = jsonObject.getStr("code"); |
| | | StringBuffer buffer = new StringBuffer(); |
| | | if(code.equals("200")){ |
| | | JSONObject data = (JSONObject) jsonObject.get("data"); |
| | | String token = data.getStr("accessToken"); |
| | | buffer.append("https://open.ys7.com/console/jssdk/pc.html?accessToken="); |
| | | buffer.append(token); |
| | | buffer.append("&url="); |
| | | buffer.append(url); |
| | | } |
| | | |
| | | logger.debug(buffer.toString()); |
| | | mmap.put("id", id); |
| | | mmap.put("playerUrl", buffer.toString()); |
| | | return prefix + "/player"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改保存监控设备 |