| src/main/java/com/dji/sample/patches/controller/PatchesController.java | ●●●●● patch | view | raw | blame | history | |
| src/main/java/com/dji/sample/patches/utils/TimerUtil.java | ●●●●● patch | view | raw | blame | history | |
| src/main/java/com/dji/sample/territory/utils/HashUtil.java | ●●●●● patch | view | raw | blame | history |
src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -11,6 +11,7 @@ import com.dji.sample.patches.service.GetPatchesService; import com.dji.sample.patches.service.ShpToDataSourceService; import com.dji.sample.patches.service.impl.ShpToDataSourceServiceImpl; import com.dji.sample.patches.utils.TimerUtil; import com.dji.sample.territory.service.impl.TbDkjbxxServiceImpl; import com.dji.sample.wayline.model.entity.WaylineFileEntity; import com.dji.sample.wayline.service.IWaylineFileService; @@ -38,7 +39,8 @@ private IWaylineFileService waylineFileService; @Autowired private TbDkjbxxServiceImpl tbDkjbxxService; @Autowired private TimerUtil timerUtil; /** * 根据workspaceId获取图斑列表信息 * @@ -72,6 +74,11 @@ getPatchesService.delPatches(); return ResponseResult.success(); } @GetMapping("/useMyTask") public ResponseResult useMyTask() throws Exception { timerUtil.myTask(); return ResponseResult.success(); } /** * 根据图斑的地块编号获取相对应音视频 src/main/java/com/dji/sample/patches/utils/TimerUtil.java
@@ -247,6 +247,7 @@ */ public static void sendPostWithFileAndParameter(String filePath, String taskId) throws IOException { // 创建 RestTemplate 实例 try{ RestTemplate restTemplate = new RestTemplate(); // 读取文件内容为字节数组 @@ -271,6 +272,9 @@ HttpMethod.POST, requestEntity, String.class); }catch (Exception e){ throw new IllegalArgumentException("db推送失败"+e.getMessage()); } } private static MultiValueMap<String, Object> buildRequestBody(String taskId, byte[] fileContent, String filePath) { src/main/java/com/dji/sample/territory/utils/HashUtil.java
New file @@ -0,0 +1,43 @@ package com.dji.sample.territory.utils; import org.bouncycastle.crypto.digests.SM3Digest; import org.bouncycastle.util.encoders.Hex; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class HashUtil { public static String SM3Hash(File file) { String filePath = String.valueOf(file); String hashHex = ""; try { byte[] fileBytes = readFile(filePath); byte[] hash = calculateHash(fileBytes); hashHex = Hex.toHexString(hash); } catch (IOException e) { e.printStackTrace(); } return hashHex; } private static byte[] readFile(String filePath) throws IOException { FileInputStream fis = new FileInputStream(filePath); byte[] buffer = new byte[1024]; int bytesRead; StringBuilder sb = new StringBuilder(); while ((bytesRead = fis.read(buffer)) != -1) { sb.append(new String(buffer, 0, bytesRead)); } fis.close(); return sb.toString().getBytes(); } private static byte[] calculateHash(byte[] input) { SM3Digest digest = new SM3Digest(); digest.update(input, 0, input.length); byte[] hash = new byte[digest.getDigestSize()]; digest.doFinal(hash, 0); return hash; } }