package com.cf.imes.module.plan.controller.admin.orderimport.webcad.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;

import jakarta.validation.Valid;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Gqr
 * @since 2025/3/3 17:57
 */
@NoArgsConstructor
@Schema(description = "管理后台 - webcad板件信息 - RequestVO")
@Data
public class WebCadDataBlockReqVO {
    private Integer orginId;
    private Integer objectId;
    private String name;
    private Integer type;
    private Integer custBlockNo;
    @JsonProperty(value = "ID")
    private Integer ID;

    @Max(value = 99999, message = "板件宽度不能超过99999")
    @Min(value = 0, message = "板件宽度最小值为0")
    private Double width;

    @Max(value = 99999, message = "板件高度不能超过99999")
    @Min(value = 0, message = "板件高度最小值为0")
    private Double height;
    private String material;
    private String materialName;

    @Max(value = 99999, message = "板件厚度不能超过99999")
    @Min(value = 0, message = "板件厚度最小值为0")
    private Double thickness;
    private Integer boardType;
    private Double area;
    private Integer texture;
    private Integer holeFace;
    private Integer holeArrange;
    @JsonProperty(value = "unregular_point_count")
    private Integer unregularPointCount;
    private List<FrontBackHolesDTO> frontBackHoles;
    private List<SideHolesDTO> sideHoles;
    private Integer frontHoleCount;
    private Integer backHoleCount;
    private Integer sideHoleCount;
    private Integer frontModelCount;
    private Integer backModelCount;
    private Boolean isDoor;
    private Integer openDoorType;
    private Double offsetX;
    private Double offsetY;
    private Boolean isArcBase;
    private boolean isSpecialShape;
    private String remark;
    private Double kaiLiaoHeight;
    private Double kaiLiaoWidth;

    @Valid
//    private InfoDTO info;
    private String cabinetName;
    private String roomName;
    private Double cabinetDepth;
    private Double cabinetWidth;
    private Double cabinetHeight;
    private PointInfoDTO pointInfo;

    private Double sealLeft;
    private Double sealRight;
    private Double sealUp;
    private Double sealDown;
    private Double reservedEdgeUp;
    private Double reservedEdgeDown;
    private Double reservedEdgeLeft;
    private Double reservedEdgeRight;
    private Boolean isRect;
    private String spliteHeight;
    private String spliteThickness;
    private String spliteWidth;
    private boolean has2DModel;
    private boolean has3DModel;
    private String boardTypeName;
    private boolean isModel;
    private boolean isSideModel;
    private boolean hasSide2DModel;

    private List<List<String>> allRemarkList;

//    private Long plateGoodsId;
    private String goodsCode;

    private List<Integer> groupIds = new ArrayList<>();

    // 组件id
    private Integer componentId;

    public void setIsSpecialShape(boolean specialShape) {
        isSpecialShape = specialShape;
    }

    public void setIsSideModel(boolean sideModel) {
        isSideModel = sideModel;
    }

    public void setIsModel(boolean model) {
        isModel = model;
    }

    @NoArgsConstructor
    @Data
    public static class FrontBackHolesDTO {
        private Integer type;
        private PositionDTO position;
        private Double radius;
        private Double depth;
        private Integer face;
        private Double angle;
        private String name;
        private String goodsId;

        @NoArgsConstructor
        @Data
        public static class PositionDTO {
            private Double x;
            private Double y;
            private Double z;
        }
    }

    @NoArgsConstructor
    @Data
    public static class SideHolesDTO {
        private Integer type;
        private PositionDTO position;
        private EndPtDTO endPt;
        private Integer radius;
        private Double depth;
        private Integer face;
        private String name;
        private String goodsId;

        @NoArgsConstructor
        @Data
        public static class PositionDTO {
            private Double x;
            private Double y;
            private Double z;
        }

        @NoArgsConstructor
        @Data
        public static class EndPtDTO {
            private Double x;
            private Double y;
            private Integer z;
        }
    }


    @NoArgsConstructor
    @Data
    public static class PointInfoDTO {
        @JsonProperty("PointDetail")
        private List<PointDetailDTO> pointDetail;
        @JsonProperty("OrgPointDetail")
        private List<OrgPointDetailDTO> orgPointDetail;
        @JsonProperty("HoleDetail")
        private List<HoleDetailDTO> holeDetail;
        @JsonProperty("SideHoleDetail")
        private List<SideHoleDetailDTO> sideHoleDetail;
        @JsonProperty("ModelDetail")
        private List<ModelDetailDTO> modelDetail;
        @JsonProperty("SideModelDetail")
        private List<SideModelDetailDTO> sideModelDetail;
        @JsonProperty("Side2DModelDetail")
        private List<SideModelDetailDTO> side2DModelDetail;

        @NoArgsConstructor
        @Data
        public static class PointDetailDTO {
            @JsonProperty("PointID")
            private Integer pointID;
            @JsonProperty("PointX")
            private Double pointX;
            @JsonProperty("PointY")
            private Double pointY;
            @JsonProperty("Curve")
            private Double curve;
            @JsonProperty("SealSize")
            private Integer sealSize;
            @JsonProperty("SealColor")
            private String sealColor;
            @JsonProperty("ReservedEdge")
            private Integer reservedEdge;
        }

        @NoArgsConstructor
        @Data
        public static class OrgPointDetailDTO {
            @JsonProperty("PointID")
            private Integer pointID;
            @JsonProperty("PointX")
            private Double pointX;
            @JsonProperty("PointY")
            private Double pointY;
            @JsonProperty("Curve")
            private Double curve;
            @JsonProperty("SealSize")
            private Integer sealSize;
            @JsonProperty("SealColor")
            private String sealColor;
            @JsonProperty("ReservedEdge")
            private Integer reservedEdge;
        }

        @NoArgsConstructor
        @Data
        public static class HoleDetailDTO {
            @JsonProperty("HoleID")
            private Integer holeID;
            @JsonProperty("HoleType")
            private Integer holeType;
            @JsonProperty("Face")
            private Integer face;
            @JsonProperty("PointX")
            private Double pointX;
            @JsonProperty("PointY")
            private Double pointY;
            @JsonProperty("PointZ")
            private Integer pointZ;
            @JsonProperty("Radius")
            private Double radius;
            @JsonProperty("Depth")
            private Double depth;
            @JsonProperty("EndPoint")
            private String endPoint;
            @JsonProperty("Angle")
            private Integer angle;
        }

        @NoArgsConstructor
        @Data
        public static class SideHoleDetailDTO {
            @JsonProperty("HoleID")
            private Integer holeID;
            @JsonProperty("HoleType")
            private Integer holeType;
            @JsonProperty("Face")
            private Integer face;
            @JsonProperty("PointX")
            private Double pointX;
            @JsonProperty("PointY")
            private Double pointY;
            @JsonProperty("PointZ")
            private Double pointZ;
            @JsonProperty("Radius")
            private Double radius;
            @JsonProperty("Depth")
            private Double depth;
            @JsonProperty("EndPoint")
            private String endPoint;
            @JsonProperty("PointX2")
            private Double pointX2;
            @JsonProperty("PointY2")
            private Double pointY2;
        }

        @NoArgsConstructor
        @Data
        public static class ModelDetailDTO {
            @JsonProperty("ModelID")
            private Integer modelID;
            @JsonProperty("LineID")
            private Integer lineID;
            @JsonProperty("Face")
            private Integer face;
            @JsonProperty("KnifeName")
            private String knifeName;
            @JsonProperty("KnifeRadius")
            private Double knifeRadius;
            @JsonProperty("Depth")
            private Double depth;
            @JsonProperty("PointList")
            private List<PointListDTO> pointList;
            @JsonProperty("OriginModeling")
            private OriginModelingDTO originModeling;
            @JsonProperty("ModelType")
            private Integer modelType;
            @JsonProperty("OffSetList")
            private List<OffSetListDTO> offSetList;


            @NoArgsConstructor
            @Data
            public static class OriginModelingDTO {
                @JsonProperty("outline")
                private OutlineDTO outline;
                @JsonProperty("addLen")
                private Double addLen;
                @JsonProperty("addWidth")
                private Double addWidth;
                @JsonProperty("addDepth")
                private Double addDepth;
                @JsonProperty("thickness")
                private Double thickness;
                @JsonProperty("dir")
                private Integer dir;
                @JsonProperty("knifeRadius")
                private Double knifeRadius;
                @JsonProperty("holes")
                private List<HolesDTO> holes;

                @NoArgsConstructor
                @Data
                public static class OutlineDTO {
                    @JsonProperty("pts")
                    private List<PtsDTO> pts;
                    @JsonProperty("buls")
                    private List<Double> buls;

                    @NoArgsConstructor
                    @Data
                    public static class PtsDTO {
                        @JsonProperty("x")
                        private Double x;
                        @JsonProperty("y")
                        private Double y;
                    }
                }

                @NoArgsConstructor
                @Data
                public static class HolesDTO {
                    @JsonProperty("pts")
                    private List<PtsDTO> pts;
                    @JsonProperty("buls")
                    private List<Double> buls;

                    @NoArgsConstructor
                    @Data
                    public static class PtsDTO {
                        @JsonProperty("x")
                        private Double x;
                        @JsonProperty("y")
                        private Double y;
                    }
                }
            }

            @NoArgsConstructor
            @Data
            public static class PointListDTO {
                @JsonProperty("LineID")
                private Integer lineID;
                @JsonProperty("PointID")
                private Integer pointID;
                @JsonProperty("PointX")
                private Double pointX;
                @JsonProperty("PointY")
                private Double pointY;
                @JsonProperty("Depth")
                private Double depth;
                @JsonProperty("Curve")
                private Double curve;
                @JsonProperty("Radius")
                private Double radius;
            }

            @NoArgsConstructor
            @Data
            public static class OffSetListDTO {
                @JsonProperty("Value")
                private Double value;
                @JsonProperty("Deep")
                private Double deep;
                @JsonProperty("Angle")
                private Double angle;
                @JsonProperty("Name")
                private String name;
                @JsonProperty("Radius")
                private Double radius;
            }
        }

        @NoArgsConstructor
        @Data
        public static class SideModelDetailDTO {
            @JsonProperty("ModelID")
            private Integer modelID;
            @JsonProperty("LineID")
            private Integer lineID;
            @JsonProperty("Face")
            private Integer face;
            @JsonProperty("KnifeName")
            private String knifeName;
            @JsonProperty("ChaiDanName")
            private String chaiDanName;
            @JsonProperty("KnifeRadius")
            private Double knifeRadius;
            @JsonProperty("Depth")
            private Double depth;
            @JsonProperty("ModelType")
            private Integer modelType;
            @JsonProperty("OriginModeling")
            private ModelDetailDTO.OriginModelingDTO originModeling;
            @JsonProperty("PointList")
            private List<ModelDetailDTO.PointListDTO> pointList;
            @JsonProperty("OffSetList")
            private List<ModelDetailDTO.OffSetListDTO> offSetList;
        }
    }
}
