| | |
| | | //根据获取的图斑集合获得kmz航线文件 |
| | | MultipartFile multipartFile = null; |
| | | try { |
| | | multipartFile = getFile(waylineName, list,28.62452712442823, 115.85666327144976); |
| | | multipartFile = getFile(waylineName, list, 28.62452712442823, 115.85666327144976); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | taskId = list.get(0).getTaskId(); |
| | | //上传航线文件 |
| | | WaylineFileEntity waylineFile = backWayline(multipartFile, waylineName, workspaceId, backclaim().getUsername()); |
| | | //将为规划的图斑状态更新为已规划 |
| | |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | /** |
| | | * 完成对未推送的图斑数据进行整合发送 |
| | | * |
| | |
| | | |
| | | } |
| | | } |
| | | @Scheduled(cron = "0 3 17 * * ?") |
| | | public void GtdbOperation() throws Exception { |
| | | String taskId = ""; |
| | | String dkbh = null; |
| | | List<List<LotInfo>> lists = convertToLists(getNoPush()); |
| | | for (List<LotInfo> lotInfo : lists) { |
| | | for (LotInfo lotInfo1 : lotInfo) { |
| | | List<MediaFileEntity> media = getPatchesService.listPohto(lotInfo1.getDkbh()); |
| | | //清空FJ表 |
| | | tbFJService.deleteData(); |
| | | for (MediaFileEntity mediaFile : media) { |
| | | //获取媒体文件名里的dkbh和taskId |
| | | dkbh = getDkbh(mediaFile.getFileName()); |
| | | //获取该媒体文件的图斑信息 |
| | | LotInfo lotInfo2 = getPatchesService.getLotinfo(dkbh); |
| | | taskId = lotInfo2.getTaskId(); |
| | | tbFJService.insertOneData(mediaFile, lotInfo2); |
| | | getPatchesService.patchesPushed(taskId, dkbh); |
| | | } |
| | | } |
| | | //存储db到服务器 |
| | | dbSaveGt(territoryConfigPojo.getResult(), territoryConfigPojo.getResultGtsave(), taskId); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建航线 |
| | |
| | | * @return |
| | | * @throws IOException |
| | | */ |
| | | public MultipartFile getFile(String waylineName, List<LotInfo> list,double lat, double lon) throws IOException { |
| | | public MultipartFile getFile(String waylineName, List<LotInfo> list, double lat, double lon) throws IOException { |
| | | //南昌28.62452712442823, 115.85666327144976 瑞金 25.8917266,116.020940643 |
| | | List<PointPO> coordinates = GeoToolsUtil.getRoutePointOrder(list, lat, lon); |
| | | XMLTemplateModel xmlModel = XMLTemplateModel.init(coordinates, list); |
| | |
| | | public List<List<LotInfo>> getNoPush(String workspaceId) { |
| | | List<LotInfo> list = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>() |
| | | .eq(LotInfo::getIsPush, 0) |
| | | .eq(LotInfo::getType, 1) |
| | | .eq(LotInfo::getInvestigate, 1) |
| | | .eq(LotInfo::getWorkspaceId, workspaceId)); |
| | | return groupTasks(list); |
| | | } |
| | | public List<List<LotInfo>> getNoPush() { |
| | | List<LotInfo> list = patchesMapper.selectList(new LambdaQueryWrapper<LotInfo>() |
| | | .eq(LotInfo::getIsPush, 0) |
| | | .eq(LotInfo::getType, 0) |
| | | .eq(LotInfo::getInvestigate, 1)); |
| | | return groupTasks(list); |
| | | } |
| | | |
| | |
| | | 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 { |
| | | try { |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | |
| | | // 构建请求体 |
| | | String jsonBody = buildRequestBody(name, fileId, time, taskDays, taskPeriods, jobId); |
| | | |
| | | // 设置请求头 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | headers.setAccept(List.of(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.ALL)); |
| | | headers.set("Accept-Language", "zh-CN,zh;q=0.9"); |
| | | headers.setConnection("keep-alive"); |
| | | headers.set("x-auth-token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE3MTg1ODUxNTQsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiI5Y2MwMGY3Zi0yODMwLTRmM2UtYjdmNC1lN2E1ZjIzYjNjNGYiLCJleHAiOjE4MDQ5ODUxNTQsImlhdCI6MTcxODU4NTE1NCwidXNlcm5hbWUiOiJhZG1pbkRQIn0.eTi9DTYGwcTvnIZasKTFq9OHQgMFS1-m840terb7ss0"); |
| | | |
| | | // 构建请求实体 |
| | | HttpEntity<String> requestEntity = new HttpEntity<>(jsonBody, headers); |
| | | |
| | | // 发送请求 |
| | | 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", |
| | | 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 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) { |
| | | // 将 List 和 String 类型的参数格式化为 JSON 字符串 |
| | | String taskDaysJson = taskDays != null ? taskDays.toString() : "[]"; |
| | | String taskPeriodsJson = taskPeriods != null ? taskPeriods.toString() : "[]"; |
| | | |
| | | // 使用 String.format 来生成 JSON 字符串 |
| | | return String.format("{" |
| | | + "\"name\":\"%s\"," |
| | | + "\"file_id\":\"%s\"," |
| | | + "\"dock_sn\":\"4TADKCM0010016\"," |
| | | + "\"task_type\":1," |
| | | + "\"select_execute_time\":\"%s\"," |
| | | + "\"rth_altitude\":100," |
| | | + "\"out_of_control_action\":0," |
| | | + "\"executeTimeContinuousArr\":[{\"index\":1,\"value\":[]}]," |
| | | + "\"executeTimeRepeatArr\":[{\"index\":1,\"value\":\"\"}]," |
| | | + "\"rep_fre_val\":1," |
| | | + "\"rep_fre_type\":3," |
| | | + "\"rep_rule_type\":1," |
| | | + "\"time_range\":[]," |
| | | + "\"rth_mode\":1," |
| | | + "\"1conValue\":[]," |
| | | + "\"1repValue\":\"\"," |
| | | + "\"task_days\":%s," |
| | | + "\"task_periods\":%s," |
| | | + "\"wayline_type\":0," |
| | | + "\"job_id\":\"%s\"" |
| | | + "}", name, fileId, select_execute_time, taskDaysJson, taskPeriodsJson, jobid); |
| | | } |
| | | |
| | | /** |
| | | * 将上传的db保存一份到本地 |
| | | * |
| | |
| | | public void dbSave(String path, String folder, String taskId) { |
| | | String sourceFilePath = path; // 源文件路径 |
| | | String targetFolderPath = fileFold(folder).getPath(); // 目标文件夹路径 |
| | | |
| | | try { |
| | | // 创建目标文件夹 |
| | | File targetFolder = new File(targetFolderPath); |
| | | if (!targetFolder.exists()) { |
| | | targetFolder.mkdirs(); |
| | | } |
| | | |
| | | // 获取当前时间 |
| | | LocalDateTime currentTime = LocalDateTime.now(); |
| | | |
| | | // 格式化时间,生成文件名 |
| | | String timeName = currentTime.format(DateTimeFormatter.ofPattern("HHmmss")); |
| | | String fileName = timeName + "_" + taskId + ".db"; |
| | | // 构建目标文件路径 |
| | | String targetFilePath = targetFolderPath + File.separator + fileName; |
| | | |
| | | // 复制文件到目标文件夹 |
| | | Path sourcePath = Paths.get(sourceFilePath); |
| | | Path targetPath = Paths.get(targetFilePath); |
| | | Files.copy(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException("Db文件复制失败", e); // 捕获并抛出原始异常 |
| | | } |
| | | } |
| | | public void dbSaveGt(String path, String folder, String taskId) { |
| | | String sourceFilePath = path; // 源文件路径 |
| | | String targetFolderPath = fileFold(folder,taskId).getPath(); // 目标文件夹路径 |
| | | |
| | | try { |
| | | // 创建目标文件夹 |
| | |
| | | } |
| | | return folder; |
| | | } |
| | | private static File fileFold(String fold,String taskId) { |
| | | // 获取当前时间 |
| | | LocalDateTime currentTime = LocalDateTime.now(); |
| | | |
| | | // 拼接文件夹路径 |
| | | String folderPath = fold + File.separator + taskId; |
| | | |
| | | // 创建文件夹 |
| | | File folder = new File(folderPath); |
| | | if (!folder.exists()) { |
| | | if (!folder.mkdirs()) { |
| | | throw new RuntimeException("文件创建失败" + folderPath); |
| | | } |
| | | } |
| | | return folder; |
| | | } |
| | | public static Long getCurrentTimestampPlus8Hours(long hours) { |
| | | // 获取当前时间 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | |
| | | return "云飞行计划" + currentTime.format(DateTimeFormatter.ofPattern("MMddHHmmssSS")); |
| | | } |
| | | |
| | | public static String getTimeName() { |
| | | LocalDateTime currentTime = LocalDateTime.now(); |
| | | // 格式化时间,生成当前时间 |
| | | return "国土调查云" + currentTime.format(DateTimeFormatter.ofPattern("MMddHHmmssSS")); |
| | | } |
| | | |
| | | public static String getNowDay() { |
| | | LocalDateTime currentTime = LocalDateTime.now(); |
| | | |