package com.multictrl.modules.business.dto.command;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import lombok.Data;

/**
 * 一键起飞参数
 *
 * @author Sdy
 * @since 1.0.0 2026/4/27
 */
@Data
@Schema(name = "一键起飞请求参数")
public class TakeoffToPoint {

    @NotNull(message = "目标点纬度不能为空")
    @DecimalMin(value = "-90.0", message = "纬度最小值为-90")
    @DecimalMax(value = "90.0", message = "纬度最大值为90")
    @Schema(description = "目标点纬度，角度值，南纬是负，北纬是正，精度到小数点后6位",
            requiredMode = Schema.RequiredMode.REQUIRED, example = "31.029651")
    private Double targetLatitude;

    @NotNull(message = "目标点经度不能为空")
    @DecimalMin(value = "-180.0", message = "经度最小值为-180")
    @DecimalMax(value = "180.0", message = "经度最大值为180")
    @Schema(description = "目标点经度，角度值，东经是正，西经是负，精度到小数点后6位",
            requiredMode = Schema.RequiredMode.REQUIRED, example = "120.766442")
    private Double targetLongitude;

    @NotNull(message = "目标点高度不能为空(相对机场高度)")
    @DecimalMin(value = "2.0", message = "目标点高度最小值为2米")
    @DecimalMax(value = "1500.0", message = "目标点高度最大值为1500米")
    @Schema(description = "目标点高度（相对机场高度），飞行器到点后默认行为：悬停",
            requiredMode = Schema.RequiredMode.REQUIRED, example = "100.5")
    private Double height;

    //@Schema(description = "目标点高度（椭球高），使用 WGS84 模型，飞行器到点后默认行为：悬停",
    //        requiredMode = Schema.RequiredMode.REQUIRED, example = "100.5")
    @Schema(hidden = true)
    private Float targetHeight;

    //@NotNull(message = "安全起飞高度不能为空")
    @DecimalMin(value = "20.0", message = "安全起飞高度最小值为20米")
    @DecimalMax(value = "1500.0", message = "安全起飞高度最大值为1500米")
    @Schema(description = "相对(机场)起飞点的高度（ALT），飞行器先升到特定的高度，然后再飞向目标点", example = "150.0", defaultValue = "目标点高度")
    private Float securityTakeoffHeight;

    //@NotNull(message = "返航模式不能为空")
    @Schema(description = "【必填】返航模式设置值：0-智能高度,1-设定高度。大疆机场当前不支持设置返航高度模式，只能选择'设定高度'模式",
            allowableValues = {"0", "1"}, example = "1", hidden = true)
    private Integer rthMode;

    //@NotNull(message = "返航高度不能为空")
    @Min(value = 2, message = "返航高度最小值为2米")
    @Max(value = 1500, message = "返航高度最大值为1500米")
    @Schema(description = "相对(机场)起飞点的高度，相对高 ALT", example = "100", defaultValue = "目标点高度+100d")
    private Integer rthAltitude;

    //@NotNull(message = "遥控器失控动作不能为空")
    @Schema(description = "遥控器失控动作：0-悬停,1-着陆(降落),2-返航",
            allowableValues = {"0", "1", "2"}, example = "2", defaultValue = "2")
    private Integer rcLostAction;

    //@NotNull(message = "指点飞行失控动作不能为空")
    @Schema(description = "【必填】指点飞行失控动作：0-继续执行指点飞行任务,1-退出指点飞行任务，执行普通失控行为",
            allowableValues = {"0", "1"}, example = "1", defaultValue = "1")
    private Integer commanderModeLostAction;

    //@NotNull(message = "指点飞行模式不能为空")
//    @Schema(description = "【必填】指点飞行模式设置值：0-智能高度飞行,1-设定高度飞行",
//            requiredMode = Schema.RequiredMode.REQUIRED, allowableValues = {"0", "1"}, example = "1", defaultValue = "1")
    @Schema(hidden = true)
    private Integer commanderFlightMode;

    //    @NotNull(message = "指点飞行高度不能为空")
//    @DecimalMin(value = "2.0", message = "指点飞行高度最小值为2米")
//    @DecimalMax(value = "3000.0", message = "指点飞行高度最大值为3000米")
//    @Schema(description = "【必填】指点飞行高度，相对(机场)起飞点的高度，相对高 ALT",
//            requiredMode = Schema.RequiredMode.REQUIRED, example = "120.5")
    @Schema(hidden = true)
    private Float commanderFlightHeight;

    //@NotBlank(message = "任务UUID不能为空")
//    @Schema(description = "无需填写，由后端生成。" +
//            " 一键起飞任务 UUID，全局唯一，用于染色，云端区分该值是普通计划任务还是一键起飞任务",
//            example = "a1b2c3d4-e5f6-7890-abcd-ef1234567890")
    @Schema(hidden = true)
    private String flightId;

    //@NotNull(message = "最大速度不能为空")
    @Min(value = 1, message = "最大速度最小值为1米/秒")
    @Max(value = 15, message = "最大速度最大值为15米/秒")
    @Schema(description = "一键起飞的飞行过程中能达到的最大速度", example = "10", defaultValue = "10")
    private Integer maxSpeed;

    @Valid
    @Schema(description = "可选字段，用于在室内进行模拟任务调试。注意：进行模拟飞行前，请务必取下桨叶，以防舱盖关闭时夹断桨叶")
    private SimulateMission simulateMission;

    @Schema(description = "飞行安全预检查：0-关闭,1-开启。设置一键起飞和航线任务中的飞行安全是否预先检查。此字段为可选，默认为0",
            example = "1", allowableValues = {"0", "1"})
    private Integer flightSafetyAdvanceCheck = 0;

    @Data
    @Schema(description = "模拟任务配置")
    public static class SimulateMission {

        @NotNull(message = "是否开启模拟器不能为空")
        @Schema(description = "是否开启模拟器任务：0-不开启,1-开启",
                requiredMode = Schema.RequiredMode.REQUIRED, allowableValues = {"0", "1"}, example = "0")
        private Integer isEnable;

        @DecimalMin(value = "-90.0", message = "纬度最小值为-90")
        @DecimalMax(value = "90.0", message = "纬度最大值为90")
        @Schema(description = "纬度", example = "39.908724")
        private Double latitude;

        @DecimalMin(value = "-180.0", message = "经度最小值为-180")
        @DecimalMax(value = "180.0", message = "经度最大值为180")
        @Schema(description = "经度", example = "116.397460")
        private Double longitude;
    }
}
