Xiajijian
2025-12-12 0083a82a5c090e2d75c6cafa5a686632b381c586
1. 测试航线修改发现bug。
4 files modified
97 ■■■■■ changed files
ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java 21 ●●●●● patch | view | raw | blame | history
ard-route/src/main/java/com/ard/route/util/InitializationUtils.java 65 ●●●●● patch | view | raw | blame | history
ard-route/src/main/java/com/ard/route/util/ToolUtils.java 8 ●●●●● patch | view | raw | blame | history
ard-route/src/main/resources/mapper/ArdRouteInfoMapper.xml 3 ●●●●● patch | view | raw | blame | history
ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java
@@ -81,6 +81,9 @@
        } catch (IOException | ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
        for (RoutePointReq routePointReq : ardRouteInfo.getUavRouteReq().getRoutePointList()) {
            routePointReq.setHeight(routePointReq.getHeight() + getDoublePoint(ardRouteInfo.getUavRouteReq().getTakeOffRefPoint(),"alt"));
        }
        return ardRouteInfo;
    }
@@ -97,6 +100,12 @@
        }else if ("0".equals(ardRouteInfo.getOrderByTime())) {
            ardRouteInfo.setOrderByTime("ASC");
        }
//        List<ArdRouteInfo> list = ardRouteInfoMapper.selectArdRouteInfoList(ardRouteInfo);
//        for (ArdRouteInfo routeInfo : list) {
//            for (RoutePointReq routePointReq : routeInfo.getUavRouteReq().getRoutePointList()) {
//                routePointReq.setHeight(routePointReq.getHeight() + getDoublePoint(ardRouteInfo.getUavRouteReq().getTakeOffRefPoint(),"alt"));
//            }
//        }
        return ardRouteInfoMapper.selectArdRouteInfoList(ardRouteInfo);
    }
@@ -230,12 +239,12 @@
                ardRouteInfo.setAircraft(droneTypeData(uavRouteReq));
            }
            // 判断禁飞区
            List<RoutePointReq> routePointList = ardRouteInfo.getUavRouteReq().getRoutePointList();
            for (RoutePointReq routePointReq : routePointList) {
                ArdNoflyDto ardNoflyDto = new ArdNoflyDto();
                ardNoflyDto.setCurrent(new Vertex(routePointReq.getLongitude(), routePointReq.getLatitude()));
                verifyNoFlyZone(ardNoflyDto);
            }
//            List<RoutePointReq> routePointList = ardRouteInfo.getUavRouteReq().getRoutePointList();
//            for (RoutePointReq routePointReq : routePointList) {
//                ArdNoflyDto ardNoflyDto = new ArdNoflyDto();
//                ardNoflyDto.setCurrent(new Vertex(routePointReq.getLongitude(), routePointReq.getLatitude()));
//                verifyNoFlyZone(ardNoflyDto);
//            }
            String url = ossService.upload("kmz",file);
            String urlDock = ossDockService.upload("kmz",file);
            ardRouteInfo.setName(file.getOriginalFilename());
ard-route/src/main/java/com/ard/route/util/InitializationUtils.java
@@ -8,13 +8,20 @@
import java.util.ArrayList;
import java.util.List;
import static com.ard.route.util.ToolUtils.getDoublePoint;
/**
 * 初始化数据
 * 测试数据
 */
public class InitializationUtils {
    // 禅思H20T 公倍数
    private static final Double CHANSI_H20 = 23.76237623;
    // 禅思H20T 焦距值
    private static final Double CHANSI_H20_FOCUS = 6.83;
    private static final String WAYPOINT_TURN_MODE_DEFAULT = "toPointAndStopWithDiscontinuityCurvature";
    /**
@@ -44,28 +51,62 @@
        if (uavRouteReq.getGlobalWaypointTurnMode() != null){
            waypointTurnReq.setWaypointTurnMode(uavRouteReq.getGlobalWaypointTurnMode());
        }else {
            waypointTurnReq.setWaypointTurnMode("toPointAndStopWithDiscontinuityCurvature");
            waypointTurnReq.setWaypointTurnMode(WAYPOINT_TURN_MODE_DEFAULT);
        }
        uavRouteReq.setWaypointTurnReq(waypointTurnReq);
        uavRouteReq.setGimbalPitchMode("usePointSetting");
        //buildZoom(uavRouteReq);
        // 变焦数值加工
        buildZoom(uavRouteReq);
        // 修改每个航点的高度
        buildHeight(uavRouteReq);
        // 动作组编号数据加工
        buildActionGroupReq(uavRouteReq);
        return uavRouteReq;
    }
    /**
     * 构建动作组编号
     */
    public void buildActionGroupReq(UavRouteReq uavRouteReq){
        int pointActionCounter = 0;
        for (RoutePointReq routePointReq : uavRouteReq.getRoutePointList()) {
            if (routePointReq.getActionGroupList() != null){
                for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) {
                    actionGroupReq.setActionGroupId(pointActionCounter++);
                    actionGroupReq.setActionGroupStartIndex(routePointReq.getRoutePointIndex());
                    actionGroupReq.setActionGroupEndIndex(routePointReq.getRoutePointIndex());
                    actionGroupReq.setActionTriggerType("reachPoint");
                }
            }
        }
    }
    /**
     * 修改每个航点的高度
     * 根据起飞点高度减去当前航点高度
     */
    public void buildHeight(UavRouteReq uavRouteReq){
        double takeOffHeight = getDoublePoint(uavRouteReq.getTakeOffRefPoint(),"alt");
        for (RoutePointReq routePointReq : uavRouteReq.getRoutePointList()) {
            routePointReq.setHeight(routePointReq.getHeight() - takeOffHeight);
        }
    }
    /**
     * 变焦动作加工
     */
    private UavRouteReq buildZoom(UavRouteReq uavRouteReq){
    private void buildZoom(UavRouteReq uavRouteReq){
        for (RoutePointReq routePointReq : uavRouteReq.getRoutePointList()) {
            for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) {
                for (PointActionReq action : actionGroupReq.getActions()) {
                    if (action.getZoom() != null){
                        action.setZoom(action.getZoom() * CHANSI_H20);
                        //action.setZoom(action.getZoom() * CHANSI_H20);
                        action.setZoom(action.getZoom() * CHANSI_H20_FOCUS);
                    }
                }
            }
        }
        return uavRouteReq;
    }
    /**
@@ -250,18 +291,4 @@
//        ardRouteActions2.setWaitTime(2);
//    }
    public byte[] testParameters() {
        String data = "74 79 01 3C 44 42 4D 32 35 30 39 37 34 30 36 35 30 30 38 D1 00 10 08 01 15 00 00 70 41 1D 00 00 00 41 22 4A 09 06 9C E7 80 8B F0 59 40 11 08 98 33 BA 07 1D 3F 40 1D 00 00 F0 41 25 00 00 00 41 2A 09 08 01 15 00 00 20 41 18 02 2A 09 08 03 15 00 00 80 3F 18 02 2A 09 08 04 15 00 00 80 3F 18 02 30 01 58 FF FF FF FF FF FF FF FF FF 01 22 55 09 F1 BC 12 50 7A F0 59 40 11 08 98 33 BA 07 1D 3F 40 1D 00 00 20 42 25 00 00 00 41 2A 09 08 09 15 00 00 A0 41 18 02 2A 09 08 06 15 00 00 20 42 18 02 2A 09 08 07 15 00 00 20 42 18 02 2A 09 08 08 15 00 00 20 42 18 02 30 01 58 FF FF FF FF FF FF FF FF FF 01 22 3F 09 F1 BC 12 50 7A F0 59 40 11 91 92 E4 DA CC 1C 3F 40 1D 00 00 48 42 25 00 00 00 41 2A 09 08 09 15 00 00 70 41 18 02 2A 09 08 0A 15 00 00 40 40 18 02 30 01 58 FF FF FF FF FF FF FF FF FF 01 22 34 09 06 9C E7 80 8B F0 59 40 11 91 92 E4 DA CC 1C 3F 40 1D 00 00 70 42 25 00 00 00 41 2A 09 08 02 15 00 00 80 3F 18 02 30 01 58 FF FF FF FF FF FF FF FF FF 01 30 32 70 32";
        String[] hexStrings = data.split(" ");
        StringBuilder sb = new StringBuilder();
        sb.append("byte[] encodedBytes = {");
        for (int i = 0; i < hexStrings.length; i++) {
            sb.append("(byte) 0x").append(hexStrings[i]);
            if (i < hexStrings.length - 1) {
                sb.append(", ");
            }
        }
        sb.append("};");
        return sb.toString().getBytes();
    }
}
ard-route/src/main/java/com/ard/route/util/ToolUtils.java
@@ -129,9 +129,12 @@
    /**
     * 截取字符串
     * 获取经纬度
     * 获取经纬度高度
     */
    public static Double getDoublePoint(String str,String type) {
        if (str == null || str.isEmpty()) {
            return null;
        }
        String[] parts = str.split(",");
        if ("lon".equals(type)) {
            return Double.parseDouble(parts[0].trim());
@@ -139,6 +142,9 @@
        if ("lat".equals(type)){
            return Double.parseDouble(parts[1].trim());
        }
        if ("alt".equals(type)){
            return Double.parseDouble(parts[2].trim());
        }
        return null;
    }
ard-route/src/main/resources/mapper/ArdRouteInfoMapper.xml
@@ -51,6 +51,9 @@
            <if test="path != null  and path != ''"> and path = #{path}</if>
            <if test="groupId != null"> and group_id = #{groupId}</if>
        </where>
        <if test="orderByTime == null and orderByTime == ''">
            ORDER BY update_time DESC
        </if>
        <!-- 动态排序 -->
        <if test="orderByTime != null and orderByTime != ''">
            ORDER BY update_time ${orderByTime}