guoshilong
2023-11-15 923a5e9fdfcfcc765606bce6fa7f99cb3717dcbe
图斑飞行
7 files modified
7 files added
1 files deleted
751 ■■■■ changed files
pom.xml 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/control/service/impl/ControlServiceImpl.java 81 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/geo/entity/Crs.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/geo/entity/Feature.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/geo/entity/GeoJson.java 16 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/geo/entity/Geometry.java 38 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/geo/entity/Property.java 12 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/geo/utils/GeoUtils.java 182 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/manage/service/IDeviceService.java 1 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/utils/GeoUtils.java 86 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/wayline/controller/WaylineJobController.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/wayline/model/param/FlyAreaParam.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/wayline/service/IWaylineJobService.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java 142 ●●●● patch | view | raw | blame | history
src/main/resources/jkj(1).json 151 ●●●●● patch | view | raw | blame | history
pom.xml
@@ -153,6 +153,12 @@
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.11.3</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>
src/main/java/com/dji/sample/control/service/impl/ControlServiceImpl.java
@@ -1,5 +1,6 @@
package com.dji.sample.control.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.dji.sample.common.error.CommonErrorEnum;
import com.dji.sample.common.model.ResponseResult;
import com.dji.sample.component.mqtt.model.*;
@@ -9,10 +10,12 @@
import com.dji.sample.component.websocket.model.BizCodeEnum;
import com.dji.sample.component.websocket.service.ISendMessageService;
import com.dji.sample.control.model.dto.FlyToProgressReceiver;
import com.dji.sample.control.model.dto.PointDTO;
import com.dji.sample.control.model.dto.ResultNotifyDTO;
import com.dji.sample.control.model.dto.TakeoffProgressReceiver;
import com.dji.sample.control.model.enums.DroneAuthorityEnum;
import com.dji.sample.control.model.enums.DroneControlMethodEnum;
import com.dji.sample.control.model.enums.FlyToStatusEnum;
import com.dji.sample.control.model.enums.RemoteDebugMethodEnum;
import com.dji.sample.control.model.param.*;
import com.dji.sample.control.service.IControlService;
@@ -24,6 +27,7 @@
import com.dji.sample.manage.service.IDeviceRedisService;
import com.dji.sample.manage.service.IDeviceService;
import com.dji.sample.wayline.model.enums.WaylineErrorCodeEnum;
import com.dji.sample.wayline.model.param.PointPOJO;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
@@ -32,9 +36,7 @@
import org.springframework.messaging.MessageHeaders;
import org.springframework.stereotype.Service;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
/**
 * @author sean
@@ -97,7 +99,7 @@
                    "error: " + serviceIdentifier + serviceReply.getResult());
        }
        if (controlMethodEnum.getProgress()) {
            RedisOpsUtils.setWithExpire(serviceIdentifier + RedisConst.DELIMITER +  bid, sn,
            RedisOpsUtils.setWithExpire(serviceIdentifier + RedisConst.DELIMITER + bid, sn,
                    RedisConst.DEVICE_ALIVE_SECOND * RedisConst.DEVICE_ALIVE_SECOND);
        }
        return ResponseResult.success();
@@ -105,6 +107,7 @@
    /**
     * Handles multi-state command progress information.
     *
     * @param receiver
     * @param headers
     * @return
@@ -118,7 +121,8 @@
        String sn = RedisOpsUtils.get(key).toString();
        EventsReceiver<EventsOutputProgressReceiver> eventsReceiver = mapper.convertValue(receiver.getData(),
                new TypeReference<EventsReceiver<EventsOutputProgressReceiver>>(){});
                new TypeReference<EventsReceiver<EventsOutputProgressReceiver>>() {
                });
        eventsReceiver.setBid(receiver.getBid());
        eventsReceiver.setSn(sn);
@@ -186,7 +190,7 @@
    @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_FLY_TO_POINT_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS)
    public CommonTopicReceiver handleFlyToPointProgress(CommonTopicReceiver receiver, MessageHeaders headers) {
        String dockSn  = receiver.getGateway();
        String dockSn = receiver.getGateway();
        Optional<DeviceDTO> deviceOpt = deviceRedisService.getDeviceOnline(dockSn);
        if (deviceOpt.isEmpty()) {
@@ -194,7 +198,8 @@
            return null;
        }
        FlyToProgressReceiver eventsReceiver = mapper.convertValue(receiver.getData(), new TypeReference<FlyToProgressReceiver>(){});
        FlyToProgressReceiver eventsReceiver = mapper.convertValue(receiver.getData(), new TypeReference<FlyToProgressReceiver>() {
        });
        webSocketMessageService.sendBatch(deviceOpt.get().getWorkspaceId(), UserTypeEnum.WEB.getVal(),
                BizCodeEnum.FLY_TO_POINT_PROGRESS.getCode(),
                ResultNotifyDTO.builder().sn(dockSn)
@@ -202,8 +207,63 @@
                                eventsReceiver.getStatus().getMessage() : eventsReceiver.getResult().getErrorMsg())
                        .result(eventsReceiver.getResult().getErrorCode())
                        .build());
        if (eventsReceiver.getStatus().equals(FlyToStatusEnum.WAYLINE_OK)) {
            JSONObject jsonObject = (JSONObject) RedisOpsUtils.get("tuban:" + dockSn);
            if (jsonObject != null) {
                List<PointPOJO> targetList = (List<PointPOJO>) jsonObject.get("targetList");
                int curIndex = (Integer) jsonObject.get("curIndex");
                flyToNextPoint(targetList, curIndex, dockSn);
            }
        }
        return receiver;
    }
    private ResponseResult flyToNextPoint(List<PointPOJO> targetList, int curIndex, String sn) {
        curIndex = curIndex + 1;
        //当无人机状态为人工时再发布下一个命令
        while (true) {
            Optional<DeviceDTO> dockOpt = deviceRedisService.getDeviceOnline(sn);
            DeviceModeCodeEnum deviceMode = deviceService.getDeviceMode(dockOpt.get().getChildDeviceSn());
            if (DeviceModeCodeEnum.MANUAL == deviceMode) {
                if (curIndex == targetList.size()) {
                    //当前是最后一个点,返航
                    ResponseResult returnHome = controlDockDebug(sn, "return_home", null);
                    RedisOpsUtils.del("tuban:" + sn);
                    return returnHome;
                }
                else {
                    //当前不是最后一个点,飞行到下一个点
                    FlyToPointParam flyToPointParam = new FlyToPointParam();
                    flyToPointParam.setMaxSpeed(14);
                    List<PointDTO> pointDTOS = new ArrayList<>();
                    PointDTO pointDTO = new PointDTO();
                    pointDTO.setHeight(150.0);
                    pointDTO.setLongitude(targetList.get(curIndex).getLon());
                    pointDTO.setLatitude(targetList.get(curIndex).getLat());
                    pointDTOS.add(pointDTO);
                    flyToPointParam.setPoints(pointDTOS);
                    ResponseResult flyToRes = flyToPoint(sn, flyToPointParam);
                    if (flyToRes.getCode() == ResponseResult.CODE_SUCCESS) {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("targetList", targetList);
                        jsonObject.put("curIndex", curIndex);
                        RedisOpsUtils.set("tuban:" + sn, jsonObject);
                    }
                    return flyToRes;
                }
            }
        }
    }
    private void checkTakeoffCondition(String dockSn) {
        Optional<DeviceDTO> dockOpt = deviceRedisService.getDeviceOnline(dockSn);
@@ -231,14 +291,15 @@
    @ServiceActivator(inputChannel = ChannelName.INBOUND_EVENTS_TAKE_OFF_TO_POINT_PROGRESS, outputChannel = ChannelName.OUTBOUND_EVENTS)
    public CommonTopicReceiver handleTakeoffToPointProgress(CommonTopicReceiver receiver, MessageHeaders headers) {
        String dockSn  = receiver.getGateway();
        String dockSn = receiver.getGateway();
        Optional<DeviceDTO> deviceOpt = deviceRedisService.getDeviceOnline(dockSn);
        if (deviceOpt.isEmpty()) {
            log.error("机场离线");
            return null;
        }
        TakeoffProgressReceiver eventsReceiver = mapper.convertValue(receiver.getData(), new TypeReference<TakeoffProgressReceiver>(){});
        TakeoffProgressReceiver eventsReceiver = mapper.convertValue(receiver.getData(), new TypeReference<TakeoffProgressReceiver>() {
        });
        webSocketMessageService.sendBatch(deviceOpt.get().getWorkspaceId(), UserTypeEnum.WEB.getVal(),
                BizCodeEnum.TAKE_OFF_TO_POINT_PROGRESS.getCode(),
@@ -299,7 +360,7 @@
    }
    @Override
    public ResponseResult requestsConfig(String sn,String method, RequestsParam param) {
    public ResponseResult requestsConfig(String sn, String method, RequestsParam param) {
        ServiceReply serviceReply = messageSenderService.publishRequestsTopic(sn, method, param);
        return ResponseResult.CODE_SUCCESS != serviceReply.getResult() ?
                ResponseResult.error(serviceReply.getResult(), "错误码:" + serviceReply.getResult())
src/main/java/com/dji/sample/geo/entity/Crs.java
New file
@@ -0,0 +1,10 @@
package com.dji.sample.geo.entity;
import lombok.Data;
@Data
public class Crs {
    private String type;
    private Property properties;
}
src/main/java/com/dji/sample/geo/entity/Feature.java
New file
@@ -0,0 +1,16 @@
package com.dji.sample.geo.entity;
import lombok.Data;
@Data
public class Feature {
    private String type;
    private Integer id;
    private Geometry geometry;
    private Property properties;
}
src/main/java/com/dji/sample/geo/entity/GeoJson.java
New file
@@ -0,0 +1,16 @@
package com.dji.sample.geo.entity;
import lombok.Data;
import java.util.List;
@Data
public class GeoJson {
    private String type;
    private Crs crs;
    private List<Feature> features;
}
src/main/java/com/dji/sample/geo/entity/Geometry.java
New file
@@ -0,0 +1,38 @@
package com.dji.sample.geo.entity;
import lombok.Data;
import java.util.List;
@Data
public class Geometry {
    private String type;
    /**
     * [
     *           [
     *             [
     *               115.81799999999998,
     *               28.652296152000076
     *             ],
     *             [
     *               115.81961010540385,
     *               28.650053326558464
     *             ],
     *             [
     *               115.82417867053516,
     *               28.650434040319453
     *             ],
     *             [
     *               115.82265581549132,
     *               28.652908679765517
     *             ],
     *             [
     *               115.81799999999998,
     *               28.652296152000076
     *             ]
     *           ]
     * ]
     */
    private List<List<List<Double>>> coordinates;
}
src/main/java/com/dji/sample/geo/entity/Property.java
New file
@@ -0,0 +1,12 @@
package com.dji.sample.geo.entity;
import lombok.Data;
@Data
public class Property {
    private String name;
    private String FID;
    private String Id;
}
src/main/java/com/dji/sample/geo/utils/GeoUtils.java
New file
@@ -0,0 +1,182 @@
package com.dji.sample.geo.utils;
import com.dji.sample.geo.entity.Feature;
import com.dji.sample.geo.entity.GeoJson;
import com.dji.sample.wayline.model.param.FlyAreaParam;
import com.dji.sample.wayline.model.param.PointPOJO;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
 * 空间计算工具类
 */
public class GeoUtils {
    /**
     * 默认地球半径
     */
    private static double EARTH_RADIUS = 6371000;//赤道半径(单位m)
    /**
     * 转化为弧度(rad)
     */
    private static double rad(double d) {
        return d * Math.PI / 180.0;
    }
    /**
     * 计算中心经纬度与目标经纬度的距离(米)
     *
     * @param centerLon 中心精度
     * @param centerLat 中心纬度
     * @param targetLon 需要计算的精度
     * @param targetLat 需要计算的纬度
     * @return 米
     */
    public static double distance(double centerLon, double centerLat, double targetLon, double targetLat) {
        double jl_jd = 102834.74258026089786013677476285;// 每经度单位米;
        double jl_wd = 111712.69150641055729984301412873;// 每纬度单位米;
        double b = Math.abs((centerLat - targetLat) * jl_jd);
        double a = Math.abs((centerLon - targetLon) * jl_wd);
        return Math.sqrt((a * a + b * b));
    }
    /**
     * 根据多个点计算中心点
     * @param list
     * @return
     */
    public static PointPOJO getCenterPoint(List<PointPOJO> list) {
        int total = list.size();
        double X = 0, Y = 0, Z = 0;
        for (int i = 0; i < list.size(); i++) {
            PointPOJO point = list.get(i);
            double lat, lon, x, y, z;
            lon = point.getLon() * Math.PI / 180;
            lat = point.getLat() * Math.PI / 180;
            x = Math.cos(lat) * Math.cos(lon);
            y = Math.cos(lat) * Math.sin(lon);
            z = Math.sin(lat);
            X += x;
            Y += y;
            Z += z;
        }
        X = X / total;
        Y = Y / total;
        Z = Z / total;
        double Lon = Math.atan2(Y, X);
        double Hyp = Math.sqrt(X * X + Y * Y);
        double Lat = Math.atan2(Z, Hyp);
        PointPOJO centerPoint = new PointPOJO();
        centerPoint.setLon( Lon * 180 / Math.PI);
        centerPoint.setLat(Lat * 180 / Math.PI);
        return centerPoint;
    }
    /**
     * 获取点区域并按从近到远排序
     * @param flyAreaParam
     * @return
     */
    public static List<PointPOJO> caculatePointList(FlyAreaParam flyAreaParam){
        List<List<PointPOJO>> areaList = flyAreaParam.getAreaList();
        PointPOJO dockPoint = flyAreaParam.getDockPoint();
        Double radius = flyAreaParam.getRadius();
        List<PointPOJO> centerPointList = new ArrayList<>();
        //根据区域获取中心点
        areaList.forEach(area -> {
            PointPOJO centerPoint = GeoUtils.getCenterPoint(area);
            centerPointList.add(centerPoint);
        });
        //巡逻目标集合
        List<PointPOJO> targetList = new ArrayList<>();
        //获取所有中心点之后,
        centerPointList.forEach(centerPoint -> {
            //判断各个中心点和机场点的距离
            double distance = GeoUtils.distance(dockPoint.getLon(), dockPoint.getLat(), centerPoint.getLon(), centerPoint.getLat());
            //当距离小于半径时,添加到目标集合中
            if (distance <= radius) {
                centerPoint.setDistance(distance);
                targetList.add(centerPoint);
            }
        });
        //按距离从近到远排序
        targetList.sort(Comparator.comparing(PointPOJO::getDistance));
        return targetList;
    }
    /**
     * 根据geojson获取点区域并按从近到远排序
     * @param geoJson
     * @return
     */
    public static List<PointPOJO> caculatePointList(GeoJson geoJson,PointPOJO dockPoint,Double radius){
        List<Feature> features = geoJson.getFeatures();
        List<List<PointPOJO>> areaList = new ArrayList<>();
        features.forEach(feature -> {
            List<PointPOJO> list = new ArrayList<>();
            List<List<Double>> coordinates = feature.getGeometry().getCoordinates().get(0);
            coordinates.forEach(coordinate ->{
                PointPOJO pointPOJO = new PointPOJO();
                pointPOJO.setLon(coordinate.get(0));
                pointPOJO.setLat(coordinate.get(1));
                list.add(pointPOJO);
            });
            areaList.add(list);
        });
        FlyAreaParam flyAreaParam = new FlyAreaParam();
        flyAreaParam.setDockPoint(dockPoint);
        flyAreaParam.setRadius(radius);
        flyAreaParam.setAreaList(areaList);
        List<PointPOJO> pointPOJOS = caculatePointList(flyAreaParam);
        return pointPOJOS;
    }
    /**
     * 读取json文件
     * @param path
     * @return
     */
    public static GeoJson readJsonFile(String path){
        try {
            File file = new File(path);
            ObjectMapper objectMapper = new ObjectMapper();
            objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            return objectMapper.readValue(file, GeoJson.class);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}
src/main/java/com/dji/sample/manage/service/IDeviceService.java
@@ -212,6 +212,7 @@
    /**
     * Query the working status of the aircraft.
     * 查询飞行器的工作状态
     * @param deviceSn
     * @return
     */
src/main/java/com/dji/sample/utils/GeoUtils.java
File was deleted
src/main/java/com/dji/sample/wayline/controller/WaylineJobController.java
@@ -189,9 +189,9 @@
     *
     * @return
     */
    @PostMapping("/{sn}/jobs/flyByArea")
    @PostMapping("/{sn}/jobs/{device_sn}/flyByArea")
    @SysLogAnnotation(operModul = "根据区域飞行", operType = "根据区域飞行", operDesc = "根据区域飞行")
    public ResponseResult flyByArea(@PathVariable(name = "sn") String sn, @RequestBody FlyAreaParam flyAreaParam) {
        return waylineJobService.flyByArea(sn, flyAreaParam);
    public ResponseResult flyByArea(@PathVariable(name = "sn") String sn, @RequestBody FlyAreaParam flyAreaParam,@PathVariable(name = "device_sn")String deviceSn) {
        return waylineJobService.flyByArea(sn, flyAreaParam,deviceSn);
    }
}
src/main/java/com/dji/sample/wayline/model/param/FlyAreaParam.java
@@ -16,4 +16,6 @@
    private List<List<PointPOJO>> areaList;
    //无人机巡逻半径 (m)
    private  Double radius;
    @JsonProperty(value = "jsonPath")
    private String jsonPath;
}
src/main/java/com/dji/sample/wayline/service/IWaylineJobService.java
@@ -168,7 +168,7 @@
    void updateJobCollect(WaylineJobEntity waylineJob);
    ResponseResult flyByArea(String sn, FlyAreaParam flyAreaParam);
    ResponseResult flyByArea(String sn, FlyAreaParam flyAreaParam,String deviceSn);
    /**
     * 判断是否有下一次任务
src/main/java/com/dji/sample/wayline/service/impl/WaylineJobServiceImpl.java
@@ -1,11 +1,10 @@
package com.dji.sample.wayline.service.impl;
import com.alibaba.druid.stat.TableStat;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dji.sample.common.error.CommonErrorEnum;
@@ -23,6 +22,7 @@
import com.dji.sample.control.model.param.TakeoffToPointParam;
import com.dji.sample.control.service.IControlService;
import com.dji.sample.control.service.IDrcService;
import com.dji.sample.geo.entity.GeoJson;
import com.dji.sample.manage.model.dto.DeviceDTO;
import com.dji.sample.manage.model.enums.DeviceModeCodeEnum;
import com.dji.sample.manage.model.enums.DockModeCodeEnum;
@@ -35,7 +35,7 @@
import com.dji.sample.media.model.MediaFileCountDTO;
import com.dji.sample.media.model.MediaMethodEnum;
import com.dji.sample.media.service.IFileService;
import com.dji.sample.utils.GeoUtils;
import com.dji.sample.geo.utils.GeoUtils;
import com.dji.sample.wayline.dao.IWaylineJobMapper;
import com.dji.sample.wayline.model.dto.*;
import com.dji.sample.wayline.model.entity.WaylineJobEntity;
@@ -57,6 +57,7 @@
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.io.File;
import java.net.URL;
import java.sql.SQLException;
import java.time.*;
@@ -491,13 +492,13 @@
    }
    @Override
    public Boolean updateJob(WaylineJobDTO dto){
    public Boolean updateJob(WaylineJobDTO dto) {
        try {
            if (dto.getStatus() == 3){
            if (dto.getStatus() == 3) {
                this.checkNextJob(dto);
            }
        }catch (SQLException e) {
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
@@ -522,8 +523,8 @@
    @Override
    public List<WaylineJobDTO> getChildrenJobs(String workspaceId, WaylineJobQueryParam waylineJobQueryParam) {
        List<WaylineJobEntity> list= mapper.getJobs(workspaceId, waylineJobQueryParam);
        List<WaylineJobDTO> records =list
        List<WaylineJobEntity> list = mapper.getJobs(workspaceId, waylineJobQueryParam);
        List<WaylineJobDTO> records = list
                .stream()
                .map(this::entity2Dto)
                .collect(Collectors.toList());
@@ -700,39 +701,65 @@
    }
    @Override
    public ResponseResult flyByArea(String sn, FlyAreaParam flyAreaParam) {
    public ResponseResult flyByArea(String sn, FlyAreaParam flyAreaParam, String deviceSn) {
        List<List<PointPOJO>> areaList = flyAreaParam.getAreaList();
        //获取所有中心点
//        List<PointPOJO> targetList = GeoUtils.caculatePointList(flyAreaParam);
        PointPOJO dockPoint = flyAreaParam.getDockPoint();
        Double radius = flyAreaParam.getRadius();
        GeoJson geoJson = GeoUtils.readJsonFile(flyAreaParam.getJsonPath());
        List<PointPOJO> targetList = GeoUtils.caculatePointList(geoJson, dockPoint, flyAreaParam.getRadius());
        List<PointPOJO> centerPointList = new ArrayList<>();
        //一键起飞
        TakeoffToPointParam takeoffToPointParam = buildTakeoffToPointParam(dockPoint);
        //根据区域获取中心点
        areaList.forEach(area -> {
            PointPOJO centerPoint = GeoUtils.getCenterPoint(area);
            centerPointList.add(centerPoint);
        });
        ResponseResult takeoffToPointRes = controlService.takeoffToPoint(sn, takeoffToPointParam);
        //巡逻目标集合
        List<PointPOJO> targetList = new ArrayList<>();
        //获取所有中心点之后,
        centerPointList.forEach(centerPoint -> {
            //判断各个中心点和机场点的距离
            double distance = GeoUtils.distance(dockPoint.getLon(), dockPoint.getLat(), centerPoint.getLon(), centerPoint.getLat());
        //设置飞向第一个点
        while (takeoffToPointRes.getCode() == ResponseResult.CODE_SUCCESS) {
            //获取无人机状态
            DeviceModeCodeEnum deviceMode = deviceService.getDeviceMode(deviceSn);
            //当距离小于半径时,添加到目标集合中
            if (distance <= radius) {
                centerPoint.setDistance(distance);
                targetList.add(centerPoint);
            //当无人机状态为手动飞行
            if (deviceMode == DeviceModeCodeEnum.MANUAL) {
                //飞向目标点
                FlyToPointParam flyToPointParam = new FlyToPointParam();
                flyToPointParam.setMaxSpeed(14);
                List<PointDTO> pointDTOS = new ArrayList<>();
                PointDTO pointDTO = new PointDTO();
                pointDTO.setHeight(150.0);
                pointDTO.setLongitude(targetList.get(0).getLon());
                pointDTO.setLatitude(targetList.get(0).getLat());
                pointDTOS.add(pointDTO);
                flyToPointParam.setPoints(pointDTOS);
                ResponseResult flyToRes = controlService.flyToPoint(sn, flyToPointParam);
                if (flyToRes.getCode() == ResponseResult.CODE_SUCCESS) {
                    //第一个点指令飞行成功后,把数组存到redis中
                    /**
                     * {
                     *      targetList:[],
                     *      curIndex:
                     * }
                     */
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("targetList",targetList);
                    jsonObject.put("curIndex",0);
                    RedisOpsUtils.set("tuban:"+sn,jsonObject);
                }
                break;
            }
        });
        }
        //按距离从近到远排序
        targetList.sort(Comparator.comparing(PointPOJO::getDistance));
        return ResponseResult.success();
    }
        //后续为无人机操作逻辑
        //先飞到空中
    public TakeoffToPointParam buildTakeoffToPointParam(PointPOJO dockPoint) {
        TakeoffToPointParam takeoffToPointParam = new TakeoffToPointParam();
        takeoffToPointParam.setTargetLatitude(dockPoint.getLat());
@@ -749,43 +776,12 @@
        takeoffToPointParam.setMaxSpeed(10.0);
        takeoffToPointParam.setExitWaylineWhenRcLost(WaylineRcLostActionEnum.EXECUTE_RC_LOST_ACTION);
        return ResponseResult.success();
//        //起飞
//        ResponseResult responseResult = controlService.takeoffToPoint(sn, takeoffToPointParam);
//
//        if (responseResult.getCode() != ResponseResult.CODE_SUCCESS) {
//            return responseResult;
//        }
//        //向目标点飞行
//
//        FlyToPointParam flyToPointParam = new FlyToPointParam();
//        flyToPointParam.setMaxSpeed(14);
//        List<PointDTO> pointDTOS = new ArrayList<>();
//        targetList.forEach(pointPOJO -> {
//            PointDTO pointDTO = new PointDTO();
//            pointDTO.setHeight(150.0);
//            pointDTO.setLongitude(pointPOJO.getLon());
//            pointDTO.setLatitude(pointPOJO.getLat());
//
//            pointDTOS.add(pointDTO);
//        });
//        flyToPointParam.setPoints(pointDTOS);
//        ResponseResult responseResult1 = controlService.flyToPoint(sn, flyToPointParam);
//
//        if (responseResult1.getCode() != ResponseResult.CODE_SUCCESS) {
//            return responseResult1;
//        }
//
//        //返航
//        //return_home
//
//
//        return ResponseResult.success();
        return takeoffToPointParam;
    }
    @Override
    public ResponseResult checkNextJob(WaylineJobDTO job)  throws SQLException  {
    public ResponseResult checkNextJob(WaylineJobDTO job) throws SQLException {
        WaylineJobEntity params = new WaylineJobEntity();
        params.setJobId(job.getJobId());
@@ -809,7 +805,7 @@
        long currentTime = System.currentTimeMillis();
        for (int i = 0; i < executeStartTimeArr.size(); i++) {
            Long startTime = executeStartTimeArr.get(i).get(0)*1000;
            Long startTime = executeStartTimeArr.get(i).get(0) * 1000;
            //如果当前时间小于开始时间
            if (currentTime < startTime) {
                //当前索引就是下一次要执行的时间
@@ -903,13 +899,11 @@
    }
    @Override
    public WaylineJobCountDTO patrolStatistics(String workspaceId,String queryTime) {
    public WaylineJobCountDTO patrolStatistics(String workspaceId, String queryTime) {
        WaylineJobCountDTO waylineJobCountDTO = new WaylineJobCountDTO();
        List<WaylineJobEntity> list = mapper.patrolStatistics(workspaceId,queryTime);
        if (!CollectionUtils.isEmpty(list)){
        List<WaylineJobEntity> list = mapper.patrolStatistics(workspaceId, queryTime);
        if (!CollectionUtils.isEmpty(list)) {
            waylineJobCountDTO.setTotalNumber(list.size());
            long totalTime = list.stream().mapToLong(s -> s.getEndTime() - s.getBeginTime()).sum() / 1000;
            StringBuffer buffer = new StringBuffer();
@@ -925,9 +919,9 @@
    @Override
    public void updateJobCollect(WaylineJobEntity waylineJob) {
        new LambdaUpdateChainWrapper<>(mapper)
                .eq(WaylineJobEntity::getJobId,waylineJob.getJobId())
                .set(WaylineJobEntity::getCollectStatus,waylineJob.getCollectStatus())
                .set(WaylineJobEntity::getUserId,waylineJob.getUserId())
                .eq(WaylineJobEntity::getJobId, waylineJob.getJobId())
                .set(WaylineJobEntity::getCollectStatus, waylineJob.getCollectStatus())
                .set(WaylineJobEntity::getUserId, waylineJob.getUserId())
                .update();
    }
src/main/resources/jkj(1).json
New file
@@ -0,0 +1,151 @@
{
  "type": "FeatureCollection",
  "crs": {
    "type": "name",
    "properties": {
      "name": "EPSG:4326"
    }
  },
  "features": [
    {
      "type": "Feature",
      "id": 0,
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              115.86646556494736,
              28.634450296554235
            ],
            [
              115.86425430209033,
              28.635738328540754
            ],
            [
              115.86455173471609,
              28.633120921432976
            ],
            [
              115.86697714906381,
              28.633843533997606
            ],
            [
              115.86646556494736,
              28.634450296554235
            ]
          ]
        ]
      },
      "properties": {
        "FID": 0,
        "Id": 0
      }
    },
    {
      "type": "Feature",
      "id": 1,
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              115.86400669060504,
              28.620271391369386
            ],
            [
              115.86002109341996,
              28.616202513049245
            ],
            [
              115.86637425430604,
              28.614203765804177
            ],
            [
              115.86591204400565,
              28.617200102075913
            ],
            [
              115.86400669060504,
              28.620271391369386
            ]
          ]
        ]
      },
      "properties": {
        "FID": 1,
        "Id": 0
      }
    },
    {
      "type": "Feature",
      "id": 2,
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              115.83936693345481,
              28.616199931733206
            ],
            [
              115.84128848946852,
              28.616084360149614
            ],
            [
              115.84093157031771,
              28.618154491224743
            ],
            [
              115.83814760094094,
              28.618654178035968
            ],
            [
              115.83936693345481,
              28.616199931733206
            ]
          ]
        ]
      },
      "properties": {
        "FID": 2,
        "Id": 0
      }
    },
    {
      "type": "Feature",
      "id": 3,
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              115.76493801956997,
              28.690367528093361
            ],
            [
              115.76654812497384,
              28.688124702651749
            ],
            [
              115.77111669010515,
              28.688505416412738
            ],
            [
              115.7695938350613,
              28.690980055858802
            ],
            [
              115.76493801956997,
              28.690367528093361
            ]
          ]
        ]
      },
      "properties": {
        "FID": 3,
        "Id": 0
      }
    }
  ]
}