rain
2024-06-20 3904fbdccb96a9b1b4f919d18505d5ebb8ef976a
定时九洲巡查
9 files modified
131 ■■■■ changed files
src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java 48 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/controller/PatchesController.java 40 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/patches/utils/TimerUtil.java 28 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/pojo/TerritoryConfigPojo.java 3 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/territory/utils/WaterMarkUtil.java 5 ●●●●● patch | view | raw | blame | history
src/main/resources/application-dev.yml 1 ●●●● patch | view | raw | blame | history
src/main/resources/application-prod.yml 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/manage/service/impl/LiveStreamServiceImpl.java
@@ -117,17 +117,15 @@
        //相机已经在直播中,请勿重复开启直播
        if(receiveReply.getResult() == 513003) {
            LiveDTO live = new LiveDTO();
//            live.setUrl(liveParam.getUrl().replace("rtmp", "https").replace("735","700") + ".flv");
            LiveUrlGB28181DTO gb28181 = urlToGB28181(liveParam.getUrl());
            live.setUrl(new StringBuilder()
                    .append("http://")
                    .append(gb28181.getServerIP())
                    .append(":8880/rtp/")
                    .append(gb28181.getAgentID())
                    .append("_")
                    .append(gb28181.getChannel())
                    .append(".live.flv")
                    .toString());
            live.setUrl(liveParam.getUrl().replace("rtmp", "https").replace("735","700") + ".flv");
//            LiveUrlGB28181DTO gb28181 = urlToGB28181(liveParam.getUrl());
//            live.setUrl(new StringBuilder()
//                    .append("https://wrj.shuixiongit.com/zb/rtp/")
//                    .append(gb28181.getAgentID())
//                    .append("_")
//                    .append(gb28181.getChannel())
//                    .append(".live.flv")
//                    .toString());
            return ResponseResult.success(live);
        }
@@ -144,29 +142,27 @@
//                live.setUrl(liveParam.getUrl().replace("rtmp", "webrtc"));
                live.setUrl(liveParam.getUrl().replace("rtmp", "https").replace("735","700") + ".flv");
                break;
//            case GB28181:
//                LiveUrlGB28181DTO gb28181 = urlToGB28181(liveParam.getUrl());
//                live.setUrl(new StringBuilder()
//                        .append("webrtc://")
//                        .append(gb28181.getServerIP())
//                        .append("/live/")
//                        .append(gb28181.getAgentID())
//                        .append("@")
//                        .append(gb28181.getChannel())
//                        .toString());
//                break;
            case GB28181:
                LiveUrlGB28181DTO gb28181 = urlToGB28181(liveParam.getUrl());
                live.setUrl(new StringBuilder()
                        .append("http://")
                        .append("webrtc://")
                        .append(gb28181.getServerIP())
                        .append(":8880/rtp/")
                        .append("/live/")
                        .append(gb28181.getAgentID())
                        .append("_")
                        .append("@")
                        .append(gb28181.getChannel())
                        .append(".live.flv")
                        .toString());
                break;
//            case GB28181:
//                LiveUrlGB28181DTO gb28181 = urlToGB28181(liveParam.getUrl());
//                live.setUrl(new StringBuilder()
//                        .append("https://wrj.shuixiongit.com/zb/rtp/")
//                        .append(gb28181.getAgentID())
//                        .append("_")
//                        .append(gb28181.getChannel())
//                        .append(".live.flv")
//                        .toString());
//                break;
            case RTSP:
                String url = receiveReply.getOutput().toString();
                this.resolveUrlUser(url, live);
src/main/java/com/dji/sample/media/service/impl/FileServiceImpl.java
@@ -117,7 +117,7 @@
            File file1 = TbFjServiceImpl.downloadFile(url);
            long timestamp = convertToTimestamp(file.getMetadata().getCreatedTime());
            File file2 = new File(WaterMarkUtil.addWatermark(file1, timestamp, file.getMetadata().getShootPosition().getLat(),
                    file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree(),territoryConfigPojo.getWatermark()).toURI());
                    file.getMetadata().getShootPosition().getLng(), file.getMetadata().getGimbalYawDegree()).toURI());
            Object data = ImgUtil.getInfo(file1);
            mediaFileMarkEntity.setDronedata(data);
            mediaFileMarkEntity.setWorkspaceId(workspaceId);
src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -88,14 +88,15 @@
     */
    @DeleteMapping("/deletePatches")
    public ResponseResult del(String workspaceId) {
        int count=getPatchesService.delPatches(workspaceId);
        return ResponseResult.success("删除的图斑数量是"+count);
        int count = getPatchesService.delPatches(workspaceId);
        return ResponseResult.success("删除的图斑数量是" + count);
    }
    @DeleteMapping("/deleteOne")
    public ResponseResult deleteOne(int id){
        int count= getPatchesService.deleteOne(id);
        if (count!=0){
            return ResponseResult.success("图斑删除成功id为"+id);
    public ResponseResult deleteOne(int id) {
        int count = getPatchesService.deleteOne(id);
        if (count != 0) {
            return ResponseResult.success("图斑删除成功id为" + id);
        }
        return ResponseResult.error("图斑删除失败");
    }
@@ -105,14 +106,16 @@
        String xzq = DistrictCodeUtils.nameToCode(code);
        return ResponseResult.success(xzq);
    }
    @GetMapping("/getInfoById")
    public ResponseResult<LotInfo> wayAndPatchesId(@RequestParam String patchesId) {
        return ResponseResult.success(getPatchesService.getPatchesFromId(patchesId));
    }
    @GetMapping("/getWayline")
    public ResponseResult getWayline(@RequestParam String waylineName, @RequestBody List<LotInfo> list){
    public ResponseResult getWayline(@RequestParam String waylineName, @RequestBody List<LotInfo> list) {
        try {
            MultipartFile file=timerUtil.getFile(waylineName,list);
            MultipartFile file = timerUtil.getFile(waylineName, list);
            return ResponseResult.success(file);
        } catch (IOException e) {
            throw new RuntimeException(e);
@@ -120,13 +123,13 @@
    }
    @PostMapping("/patchesToWayline")
    public ResponseResult patchesToWayline(@RequestBody  List<LotInfo> list,
    public ResponseResult patchesToWayline(@RequestBody List<LotInfo> list,
                                           @RequestParam String waylineName,
                                           @RequestParam String workspaceId,
                                           HttpServletRequest request) throws IOException {
        CustomClaim customClaim = (CustomClaim)request.getAttribute(TOKEN_CLAIM);
        CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM);
        String creator = customClaim.getUsername();
        MultipartFile file=timerUtil.getFile(waylineName,list);
        MultipartFile file = timerUtil.getFile(waylineName, list);
        waylineFileService.importKmzFileBack(file, workspaceId, creator);
        WaylineFileEntity entity = waylineFileService.selectByName(waylineName);
        Map<String, String> infoMap = new HashMap<>();
@@ -144,16 +147,18 @@
    @GetMapping("/useMyTask")
    public ResponseResult useMyTask() throws Exception {
        try {
            timerUtil.myTask();
//            timerUtil.myTask();
//            timerUtil.myTask2();
//            timerUtil.myTask3();
            timerUtil.mytask4();
        } catch (Exception e) {
            throw new RuntimeException("db存储发送出现异常"+e);
            throw new RuntimeException("db存储发送出现异常" + e);
        }
        return ResponseResult.success();
    }
//    @GetMapping ("/tests")
    //    @GetMapping ("/tests")
//    public ResponseResult use()  {
//        try {
//            TimerUtil.sendPostWithFileAndParameter("src/main/resources/tmp/20240613/205621_635148ea-0ddb-4b23-945c-8a67abd813c9.db",
@@ -163,6 +168,13 @@
//        }
//        return ResponseResult.success();
//    }
    @PostMapping("/way")
    public void getway(@RequestParam("file") MultipartFile file,
                       @RequestParam String workspaceId,
                       @RequestParam String waylineName,
                       @RequestParam String username) {
        waylineFileService.importKmzFileBack(file, workspaceId, username);
    }
    /**
     * 根据图斑的地块编号获取相对应音视频
src/main/java/com/dji/sample/patches/utils/TimerUtil.java
@@ -24,6 +24,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.*;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -86,7 +87,7 @@
     */
    @Scheduled(cron = "0 0 0 * * ?")
    public void myTask() throws Exception {
        Long time = getCurrentTimestampPlus8Hours();
        Long time = getCurrentTimestampPlus8Hours(14);
        String taskId = "";
        String workspaceId = "4a574db8-4ad3-48f7-9f16-3edbcd8056e1";
//        获取未规划的图斑集合
@@ -140,6 +141,18 @@
            Optional<WaylineJobDTO> waylineJobDTO = waylineJobService.getJobByJobId(workspaceId, jobid, true);
            waylineJobService.publishOneFlightTask(waylineJobDTO.get());
        }
    }
    @Scheduled(cron = "0 0 0 * * ?")
    public void mytask4() throws IOException {
        Long time = getCurrentTimestampPlus8Hours(9);
        List<List<Long>> listOfLists = new ArrayList<>();
        List<Long> sublist = new ArrayList<>();
        sublist.add(time); // 添加整数值
        listOfLists.add(sublist);
        List<Long> lists1 = new ArrayList<>();
        lists1.add(time);
        String times = convertTimestampToFormattedString(time);
        sendPostWithParameters("九洲巡查","73e14492-f1b2-4fc4-81c0-7ca65cd3bc56", times, lists1, listOfLists);
    }
    /**
@@ -520,12 +533,12 @@
        return folder;
    }
    public static Long getCurrentTimestampPlus8Hours() {
    public static Long getCurrentTimestampPlus8Hours(long hours) {
        // 获取当前时间
        LocalDateTime now = LocalDateTime.now();
        // 加上8小时
        LocalDateTime nowPlus8Hours = now.plusHours(8);
        LocalDateTime nowPlus8Hours = now.plusHours(hours);
        // 转换为UTC时间戳
        ZonedDateTime zonedDateTime = nowPlus8Hours.atZone(ZoneId.systemDefault());
@@ -574,14 +587,5 @@
        // 格式化时间,生成当前时间
        return "云飞行计划" + currentTime.format(DateTimeFormatter.ofPattern("MMdd"));
    }
    public static void main(String[] args) {
        // 获取当前时间
        LocalDateTime currentTime = LocalDateTime.now();
        // 格式化时间,生成文件夹名字
        String folderName = currentTime.format(DateTimeFormatter.ofPattern("MMddHHmmssSS"));
        System.out.println(folderName);
    }
}
src/main/java/com/dji/sample/territory/pojo/TerritoryConfigPojo.java
@@ -26,7 +26,4 @@
    @Value("${db.sqlite.resourceSave}")
    private String resourcesave;
    @Value("${db.sqlite.waterMark}")
    private String watermark;
}
src/main/java/com/dji/sample/territory/service/impl/TbFjServiceImpl.java
@@ -145,7 +145,7 @@
        //对应图片和视频文件进行不同处理
        boolean endsWith = key.endsWith(".mp4");
        if (!endsWith) {
            file1 = WaterMarkUtil.addWatermark(file, sj, lat, lng, gimbalYawDegree,territoryConfigPojo.getWatermark());
            file1 = WaterMarkUtil.addWatermark(file, sj, lat, lng, gimbalYawDegree);
            byte[] bytesArray = Files.readAllBytes(file1.toPath());
            fjhxz= sm3(bytesArray);
            FJ = fileToByteArray(file1);
src/main/java/com/dji/sample/territory/utils/WaterMarkUtil.java
@@ -26,7 +26,7 @@
     * @return 添加水印并压缩后的图片文件。
     * @throws IOException 如果读取或保存图片失败。
     */
    public static File addWatermark(File file, Long pssj, Double lat, Double lng, Double angles,String path) throws IOException, FontFormatException {
    public static File addWatermark(File file, Long pssj, Double lat, Double lng, Double angles) throws IOException, FontFormatException {
        double anglses = convertAngle(angles);
        String angel = angle(anglses);
        Long timestamp = pssj; // 例如:Unix 时间戳(以秒为单位)
@@ -64,8 +64,7 @@
        alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f);
        g2d.setComposite(alphaComposite);
        String extraInfo = String.format("Lon:%.7f Lat:%.7f\n%s %s", lng, lat, angel, sd);
        File fontFile = new File("src/main/resources/MiSans-Normal.ttf"); // 替换为你的字体文件路径
//        File fontFile = new File("/usr/share/fonts/MiSans-Normal.ttf"); // 替换为你的字体文件路径
        File fontFile = new File("/usr/share/fonts/MiSans-Normal.ttf"); // 替换为你的字体文件路径
        Font customFont = Font.createFont(Font.TRUETYPE_FONT, fontFile).deriveFont(36.00F);
        // 注册字体
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
src/main/resources/application-dev.yml
@@ -118,4 +118,3 @@
    result: DB/result_db.db
    resultSave: src/main/resources/tmp
    resourceSave: src/main/resources/tmp
    waterMark: src/main/resources/MiSans-Normal.ttf
src/main/resources/application-prod.yml
@@ -117,4 +117,4 @@
    result: /home/drone/server/sqlite/result_db.db
    resultSave: /home/drone/server/sqlite/retUpload/
    resourceSave: /home/drone/server/sqlite/upload/
    waterMark: /usr/share/fonts/MiSans-Normal.ttf