rain
2024-06-19 cbbb9003b44d7c9d7adc80188343f0065732b0ce
src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
@@ -149,7 +149,7 @@
                .rthAltitude(param.getRthAltitude())
                .mediaCount(0)
                .build();
        if (StringUtils.hasText(param.getJobId())){
        if (StringUtils.hasText(param.getJobId())) {
            jobEntity.setJobId(param.getJobId());
        }
        return insertWaylineJob(jobEntity);
@@ -338,7 +338,7 @@
        if (WaylineTaskTypeEnum.IMMEDIATE == waylineJob.getTaskType()) {
            boolean isExecuted = executeFlightTask(waylineJob.getWorkspaceId(), waylineJob.getJobId());
            if (!isExecuted) {
                return ResponseResult.error("执行任务失败");
                return ResponseResult.error("当前状态不支持飞行,请检查是否已有正在执行的飞行任务!");
            }
        }
@@ -517,7 +517,7 @@
    }
    @Override
    public Optional<WaylineJobDTO> getJobByJobId(String workspaceId, String jobId,Boolean isBreakPoint) {
    public Optional<WaylineJobDTO> getJobByJobId(String workspaceId, String jobId, Boolean isBreakPoint) {
        WaylineJobEntity jobEntity = mapper.selectOne(
                new LambdaQueryWrapper<WaylineJobEntity>()
                        .eq(WaylineJobEntity::getWorkspaceId, workspaceId)
@@ -566,7 +566,7 @@
    @Override
    public PaginationData<WaylineJobDTO> getJobsByWorkspaceIdNew(String workspaceId, long page, long pageSize, WaylineJobQueryParam waylineJobQueryParam, String order) {
        Page<WaylineJobEntity> pageData = mapper.getPageNew(new Page<WaylineJobEntity>(page, pageSize), waylineJobQueryParam, workspaceId,order);
        Page<WaylineJobEntity> pageData = mapper.getPageNew(new Page<WaylineJobEntity>(page, pageSize), waylineJobQueryParam, workspaceId, order);
        List<WaylineJobDTO> records = pageData.getRecords()
                .stream()
@@ -575,7 +575,7 @@
        // 是否需要断点续飞
        records.forEach(wjd -> wjd.setBreakPoint(waylineJobBreakPointService.count(
                new LambdaQueryWrapper<WaylineJobBreakPointEntity>().eq(WaylineJobBreakPointEntity::getJobId,wjd.getJobId())) > 0));
                new LambdaQueryWrapper<WaylineJobBreakPointEntity>().eq(WaylineJobBreakPointEntity::getJobId, wjd.getJobId())) > 0));
        return new PaginationData<WaylineJobDTO>(records, new Pagination(pageData));
@@ -652,6 +652,18 @@
        messageSender.publish(topic, builder.build());
    }
    @Override
    public List<String> selectJobIdByName(String name) {
        List<WaylineJobEntity> waylineJobs = mapper.selectList(new LambdaQueryWrapper<WaylineJobEntity>()
                .select(WaylineJobEntity::getJobId)
                .like(WaylineJobEntity::getName, name));
        return waylineJobs.stream()
                .map(WaylineJobEntity::getJobId)
                .collect(Collectors.toList());
    }
    @Override
    public void uploadMediaHighestPriority(String workspaceId, String jobId) {
@@ -800,10 +812,10 @@
                if (flyToRes.getCode() == ResponseResult.CODE_SUCCESS) {
                    //第一个点指令飞行成功后,把数组存到redis中
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("targetList",targetList);
                    jsonObject.put("payloadIndex",flyAreaParam.getPayloadIndex());
                    jsonObject.put("curIndex",0);
                    RedisOpsUtils.set("tuban:"+sn,jsonObject);
                    jsonObject.put("targetList", targetList);
                    jsonObject.put("payloadIndex", flyAreaParam.getPayloadIndex());
                    jsonObject.put("curIndex", 0);
                    RedisOpsUtils.set("tuban:" + sn, jsonObject);
                }
                break;
            }
@@ -953,22 +965,22 @@
    @Override
    public WaylineJobCountDTO patrolStatistics(String workspaceId, String queryTime,String deviceSn) {
    public WaylineJobCountDTO patrolStatistics(String workspaceId, String queryTime, String deviceSn) {
        WaylineJobCountDTO waylineJobCountDTO = new WaylineJobCountDTO();
        List<DroneFlightLogEntity>  list =  flightLogMapper.patrolStatistics(workspaceId,queryTime,deviceSn);
        List<DroneFlightLogEntity> list = flightLogMapper.patrolStatistics(workspaceId, queryTime, deviceSn);
        if (!CollectionUtils.isEmpty(list)) {
            waylineJobCountDTO.setTotalNumber(list.size());
            long totalTime = list.stream().filter(task -> task.getEndTime()!= null && task.getStartTime()!= null).mapToLong(s -> s.getEndTime() - s.getStartTime()).sum() / 1000;
            long totalTime = list.stream().filter(task -> task.getEndTime() != null && task.getStartTime() != null).mapToLong(s -> s.getEndTime() - s.getStartTime()).sum() / 1000;
            long h = totalTime / 3600;
            long m = (totalTime % 3600) / 60;
            waylineJobCountDTO.setTotalDuration( String.format("%02d h %02d min", h, m));
            waylineJobCountDTO.setTotalDuration(String.format("%02d h %02d min", h, m));
            List<String> deviceSns = list.stream().map(DroneFlightLogEntity::getDeviceSn).distinct().collect(Collectors.toList());
            double sum = 0.0;
            for (String sn : deviceSns) {
                Double totalFlightDistance = new LambdaQueryChainWrapper<>(flightLogMapper)
                        .eq(DroneFlightLogEntity::getDeviceSn, sn).orderByDesc(DroneFlightLogEntity::getEndTime).last("limit 1").one().getTotalFlightDistance();
                if (totalFlightDistance!= null){
                    sum+=totalFlightDistance;
                if (totalFlightDistance != null) {
                    sum += totalFlightDistance;
                }
            }
            waylineJobCountDTO.setTotalDistance((int) sum);