|  |  |  | 
|---|
|  |  |  | package com.ruoyi.device.uav.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.ruoyi.common.core.controller.BaseController; | 
|---|
|  |  |  | import com.ruoyi.common.core.domain.AjaxResult; | 
|---|
|  |  |  | import com.ruoyi.device.uav.service.UavService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Value; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.annotation.PostConstruct; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private UavService uavService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${uav.enabled}") | 
|---|
|  |  |  | private Boolean uavEnabled; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostConstruct | 
|---|
|  |  |  | public void created() { | 
|---|
|  |  |  | if(!uavEnabled){//无人机加入开关 | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.uavService.login(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/") | 
|---|
|  |  |  | @ApiOperation("无人机get接口") | 
|---|
|  |  |  | public Object get(@RequestParam String url, @RequestParam String data) { | 
|---|
|  |  |  | return this.uavService.doUavRequest(GET, url, data); | 
|---|
|  |  |  | public Object get(@RequestParam String url) { | 
|---|
|  |  |  | return this.uavService.doUavRequest(GET, url, "{}"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/") | 
|---|
|  |  |  | @ApiOperation("无人机post接口") | 
|---|
|  |  |  | public Object post(@RequestBody Map<String,String> param) { | 
|---|
|  |  |  | public Object post(@RequestBody Map<String, String> param) { | 
|---|
|  |  |  | String url = param.get("url"); | 
|---|
|  |  |  | String data = param.get("data"); | 
|---|
|  |  |  | return this.uavService.doUavRequest(POST, url, data); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @DeleteMapping("/") | 
|---|
|  |  |  | @ApiOperation("无人机delete接口") | 
|---|
|  |  |  | public Object delete(@RequestParam String url, @RequestParam String data) { | 
|---|
|  |  |  | public Object delete(@RequestBody Map<String, String> param) { | 
|---|
|  |  |  | String url = param.get("url"); | 
|---|
|  |  |  | String data = param.get("data"); | 
|---|
|  |  |  | return this.uavService.doUavRequest(DELETE, url, data); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/getToken") | 
|---|
|  |  |  | @ApiOperation("无人机delete接口") | 
|---|
|  |  |  | public Object getToken() { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return this.uavService.getToken(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/checkPointValid") | 
|---|
|  |  |  | @ApiOperation("无人机检测航点有效性接口") | 
|---|
|  |  |  | public Object checkPointValid(@RequestBody Map<String,Map<String,Object>> param) { | 
|---|
|  |  |  | String url = "wayline/api/v1/waylines/planning/check_point_valid"; | 
|---|
|  |  |  | return this.uavService.checkPointValid(url, param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/checkLineValid") | 
|---|
|  |  |  | @ApiOperation("无人机检测线路有效性接口") | 
|---|
|  |  |  | public Object checkLineValid(@RequestBody Map<String,List<Map<String,String>>> param) { | 
|---|
|  |  |  | String url = "wayline/api/v1/waylines/planning/check_line_valid"; | 
|---|
|  |  |  | return this.uavService.checkLineValid(url, param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("/getWorkspaceId") | 
|---|
|  |  |  | @ApiOperation("获取工作空间主键") | 
|---|
|  |  |  | public AjaxResult getWorkspaceId() { | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | String workspaceId = this.uavService.getWorkspaceId(); | 
|---|
|  |  |  | if(workspaceId != null){ | 
|---|
|  |  |  | return AjaxResult.success(workspaceId); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | return AjaxResult.success(""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch(Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return AjaxResult.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/addWaylinesPlanning") | 
|---|
|  |  |  | @ApiOperation("新增航线") | 
|---|
|  |  |  | public Object addWaylinesPlanning(@RequestBody Map<String,Object> param) { | 
|---|
|  |  |  | String url = "wayline/api/v1/waylines/planning"; | 
|---|
|  |  |  | return this.uavService.addWaylinesPlanning(url, param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @DeleteMapping("/deleteWaylinesPlanning") | 
|---|
|  |  |  | @ApiOperation("删除航线") | 
|---|
|  |  |  | public Object deleteWaylinesPlanning(@RequestBody Map<String,String> param) { | 
|---|
|  |  |  | String url = "wayline/api/v1/waylines/delete/"; | 
|---|
|  |  |  | return this.uavService.deleteWaylinesPlanning(url, param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PutMapping("/updateWaylinesPlanning") | 
|---|
|  |  |  | @ApiOperation("修改航线") | 
|---|
|  |  |  | public Object updateWaylinesPlanning(@RequestBody Map<String,Object> param) { | 
|---|
|  |  |  | String url = "wayline/api/v1/waylines/update"; | 
|---|
|  |  |  | return this.uavService.updateWaylinesPlanning(url, param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/addAlarm") | 
|---|
|  |  |  | @ApiOperation("单点任务") | 
|---|
|  |  |  | public Object addAlarm(@RequestBody Map<String,Object> param) { | 
|---|
|  |  |  | String url = "manage/api/v1/alarms/add"; | 
|---|
|  |  |  | return this.uavService.addAlarm(url, param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/saveCurrentGroup") | 
|---|
|  |  |  | @ApiOperation("同步") | 
|---|
|  |  |  | public Object saveCurrentGroup(@RequestBody Map<String,Object> param) { | 
|---|
|  |  |  | String url = "wayline/api/v1/waylines/planning/save_current_group"; | 
|---|
|  |  |  | return this.uavService.saveCurrentGroup(url, param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|