| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.dji.sample.common.model.CustomClaim; |
| | | import com.dji.sample.manage.dao.IDeviceMapper; |
| | | import com.dji.sample.manage.model.entity.DeviceEntity; |
| | | import com.dji.sample.media.dao.IFileMapper; |
| | | import com.dji.sample.media.model.MediaFileEntity; |
| | | import com.dji.sample.patches.config.pojo.PatchesConfigPojo; |
| | |
| | | private TerritoryConfigPojo territoryConfigPojo; |
| | | @Autowired |
| | | private IWaylineJobBreakPointService jobBreakPointService; |
| | | |
| | | @Autowired |
| | | private IDeviceMapper deviceMapper; |
| | | /** |
| | | * 定时器,将没有规划的图斑生成航线,并将航线飞完后的成果数据进行保存推送 |
| | | * |
| | |
| | | return Files.readAllBytes(path); |
| | | } |
| | | |
| | | public static void sendPostWithParameters(String name, String fileId, String time, List<Long> taskDays, List<List<Long>> taskPeriods, String jobId) throws IOException { |
| | | public void sendPostWithParameters(String name, String fileId, String time, List<Long> taskDays, List<List<Long>> taskPeriods, String jobId,String docksn) throws IOException { |
| | | try { |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | |
| | | // 构建请求体 |
| | | String jsonBody = buildRequestBody(name, fileId, time, taskDays, taskPeriods, jobId); |
| | | |
| | | String jsonBody = buildRequestBody(name, fileId, time, taskDays, taskPeriods, jobId,docksn); |
| | | String workspaceId =getWorkspaceIdByDocksn(docksn); |
| | | // 设置请求头 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | |
| | | // 发送请求 |
| | | ResponseEntity<String> response = restTemplate.exchange( |
| | | // "https://wrj.shuixiongit.com/drone-api/wayline/api/v1/workspaces/4a574db8-4ad3-48f7-9f16-3edbcd8056e1/flight-tasks", |
| | | "http://localhost:6789/wayline/api/v1/workspaces/4a574db8-4ad3-48f7-9f16-3edbcd8056e1/flight-tasks", |
| | | "http://localhost:6789/wayline/api/v1/workspaces/"+workspaceId+"/flight-tasks", |
| | | HttpMethod.POST, |
| | | requestEntity, |
| | | String.class); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | System.out.println(response); |
| | | } catch (Exception e) { |
| | | throw new IllegalArgumentException("Request failed: " + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | public String getWorkspaceIdByDocksn(String docksn){ |
| | | DeviceEntity entity= deviceMapper.selectOne(new LambdaQueryWrapper<DeviceEntity>().eq(DeviceEntity::getDeviceSn,docksn)); |
| | | return entity.getWorkspaceId(); |
| | | } |
| | | public static void sendPostWithParameters(String name, String fileId, String time, List<Long> taskDays, List<List<Long>> taskPeriods) throws IOException { |
| | | try { |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | |
| | | + "}", name, fileId, select_execute_time, taskDays, taskPeriods); |
| | | } |
| | | |
| | | private static String buildRequestBody(String name, String fileId, String select_execute_time, List<Long> taskDays, List<List<Long>> taskPeriods, String jobid) { |
| | | private static String buildRequestBody(String name, String fileId, String select_execute_time, List<Long> taskDays, List<List<Long>> taskPeriods, String jobid, String dockSn) { |
| | | // 将 List 和 String 类型的参数格式化为 JSON 字符串 |
| | | String taskDaysJson = taskDays != null ? taskDays.toString() : "[]"; |
| | | String taskPeriodsJson = taskPeriods != null ? taskPeriods.toString() : "[]"; |
| | |
| | | return String.format("{" |
| | | + "\"name\":\"%s\"," |
| | | + "\"file_id\":\"%s\"," |
| | | + "\"dock_sn\":\"4TADKCM0010016\"," |
| | | + "\"dock_sn\":\"%s\"," |
| | | + "\"task_type\":1," |
| | | + "\"select_execute_time\":\"%s\"," |
| | | + "\"rth_altitude\":100," |
| | |
| | | + "\"task_periods\":%s," |
| | | + "\"wayline_type\":0," |
| | | + "\"job_id\":\"%s\"" |
| | | + "}", name, fileId, select_execute_time, taskDaysJson, taskPeriodsJson, jobid); |
| | | + "}", name, fileId, dockSn, select_execute_time, taskDaysJson, taskPeriodsJson, jobid); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 将上传的db保存一份到本地 |
| | | * |