| | |
| | | import com.dji.sample.wayline.service.IWaylineFileService; |
| | | import com.dji.sample.wayline.service.IWaylineJobService; |
| | | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.fasterxml.jackson.databind.node.ObjectNode; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.io.ByteArrayResource; |
| | | import org.springframework.http.*; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.util.UriComponentsBuilder; |
| | | |
| | | import javax.xml.transform.Result; |
| | | import java.nio.file.StandardCopyOption; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.concurrent.Future; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.dji.sample.patches.utils.MultipartFileTOFileUtil.convert; |
| | |
| | | long timestamp = System.currentTimeMillis(); |
| | | String waylineName = "云飞行调查" + timestamp; |
| | | //根据获取的图斑集合获得kmz航线文件 |
| | | MultipartFile multipartFile = getFile(waylineName, list); |
| | | MultipartFile multipartFile = null; |
| | | try { |
| | | multipartFile = getFile(waylineName, list); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | //上传航线文件 |
| | | backWayline(multipartFile, waylineName, workspaceId, backclaim().getUsername()); |
| | | //将为规划的图斑状态更新为已规划 |
| | | updatePatchesStatu(list); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void myTask2() { |
| | | ExecutorService executor = Executors.newSingleThreadExecutor(); |
| | | executor.execute(() -> { |
| | | try { |
| | | dbOperation(); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }); |
| | | executor.shutdown(); |
| | | } |
| | | |
| | | @Transactional |
| | | public void dbOperation() throws Exception { |
| | | String workspaceId = "4a574db8-4ad3-48f7-9f16-3edbcd8056e1"; |
| | | String taskId = ""; |
| | | List<List<MediaFileEntity>> list = getNoadd(); |
| | | List<List<MediaFileEntity>> medias = convertToLists(list); |
| | | for (List<MediaFileEntity> media : medias) { |
| | |
| | | tbFJService.insertOneData(mediaFile, lotInfo); |
| | | //更新媒体文件的是否添加状态 |
| | | updateMediaStatu(mediaFile); |
| | | |
| | | } |
| | | //存储db到服务器 |
| | | dbSave(territoryConfigPojo.getResult(), territoryConfigPojo.getResultsave(), taskId); |
| | | //发送请求给第三方接口 |
| | | sendPostWithFileAndParameter(territoryConfigPojo.getResult(), taskId); |
| | | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建航线 |
| | | * |
| | | * @param waylineName |
| | | * @param list |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 将航线上传Oss |
| | | * |
| | | * @param multipartFile |
| | | * @param waylineName |
| | | * @param workspaceId |
| | |
| | | return claim; |
| | | } |
| | | |
| | | public static CreateJobParam JobParam(String waylineId) { |
| | | long timestamp = System.currentTimeMillis(); |
| | | List<List<Long>> listOfLists = new ArrayList<>(); |
| | | List<Long> sublist = new ArrayList<>(); |
| | | sublist.add(1715852375L); // 添加整数值 |
| | | listOfLists.add(sublist); |
| | | List<Long> list = new ArrayList<>(); |
| | | list.add(1715852375L); |
| | | CreateJobParam param = new CreateJobParam(); |
| | | param.setName("云飞行调查"+timestamp); |
| | | param.setTaskType(TIMED); |
| | | param.setOutOfControlAction(0); |
| | | param.setRepFreType(3); |
| | | param.setRepFreVal(1); |
| | | param.setRepRuleType(1); |
| | | param.setRthAltitude(80); |
| | | param.setWaylineType(WAYPOINT); |
| | | param.setTaskPeriods(listOfLists); |
| | | param.setTaskDays(list); |
| | | param.setFileId(waylineId); |
| | | param.setDockSn("4TADKCMB0010016"); |
| | | return param; |
| | | } |
| | | |
| | | public static <T> List<List<T>> convertToLists(List<List<T>> listOfLists) { |
| | | List<List<T>> convertedLists = new ArrayList<>(); |
| | | for (List<T> list : listOfLists) { |
| | |
| | | |
| | | /** |
| | | * 将成果发送post请求到第三方接口 |
| | | * |
| | | * @param filePath |
| | | * @param taskId |
| | | * @throws IOException |
| | |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers); |
| | | |
| | | // 发送请求 |
| | | ResponseEntity<String> result=restTemplate.exchange( |
| | | "http://39.98.48.180:8087/landCloudWork/artifact/media/upload.action", |
| | | restTemplate.exchange( |
| | | "https://jxlandcloud.org.cn/landCloudWork/artifact/media/upload.action", |
| | | // "http://localhost:6789/territory/tbdkjbxx/upload", |
| | | HttpMethod.POST, |
| | | requestEntity, |
| | |
| | | |
| | | /** |
| | | * 将上传的db保存一份到本地 |
| | | * |
| | | * @param path |
| | | * @param folder |
| | | * @param taskId |
| | |
| | | } |
| | | return folder; |
| | | } |
| | | |
| | | } |