package com.yhy.module.core.controller.admin.workbench.vo.audit;

import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import lombok.Data;

/**
 * 审核模式分部分项树 Response VO（包含送审、审定、差异三组数据）
 */
@Schema(description = "工作台 - 审核模式分部分项树 Response VO")
@Data
public class AuditDivisionTreeRespVO {

    @Schema(description = "审定分部分项ID（快照表ID，用于编辑）", example = "1")
    private Long id;

    @Schema(description = "来源分部分项ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long sourceDivisionId;

    @Schema(description = "父节点ID", example = "1")
    private Long parentId;

    @Schema(description = "节点类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "quota")
    private String nodeType;

    @Schema(description = "来源类型", example = "manual")
    private String sourceType;

    @Schema(description = "编码", example = "010101")
    private String code;

    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "土石方工程")
    private String name;

    @Schema(description = "单位（审定值，可编辑覆盖）", example = "m3")
    private String unit;

    @Schema(description = "项目特征（审定值，可编辑覆盖）", example = "1.土壤类别：一类土")
    private String feature;

    @Schema(description = "编码是否被编辑过", example = "false")
    private Boolean codeEdited;

    @Schema(description = "名称是否被编辑过", example = "false")
    private Boolean nameEdited;

    @Schema(description = "单位是否被编辑过", example = "false")
    private Boolean unitEdited;

    @Schema(description = "项目特征是否被编辑过", example = "false")
    private Boolean featureEdited;

    @Schema(description = "排序号", example = "1")
    private Integer sortOrder;

    @Schema(description = "层级路径")
    private String[] path;

    // ========== 送审数据（编制模式实时） ==========
    @Schema(description = "送审编码（原编制模式数据）", example = "010101")
    private String submitCode;

    @Schema(description = "送审名称（原编制模式数据）", example = "土石方工程")
    private String submitName;

    @Schema(description = "送审单位（原编制模式数据）", example = "m3")
    private String submitUnit;

    @Schema(description = "送审项目特征（原编制模式数据）", example = "1.土壤类别：一类土")
    private String submitFeature;

    @Schema(description = "送审工程量", example = "100.00")
    private BigDecimal submitQty;

    @Schema(description = "送审单价", example = "25.50")
    private BigDecimal submitUnitPrice;

    @Schema(description = "送审费率", example = "3.5")
    private BigDecimal submitRate;

    @Schema(description = "送审合价", example = "2550.00")
    private BigDecimal submitTotalPrice;

    // ========== 审定数据（快照，可编辑） ==========
    @Schema(description = "审定工程量", example = "90.00")
    private BigDecimal approveQty;

    @Schema(description = "审定单价", example = "25.50")
    private BigDecimal approveUnitPrice;

    @Schema(description = "审定费率", example = "3.5")
    private BigDecimal approveRate;

    @Schema(description = "审定合价", example = "2295.00")
    private BigDecimal approveTotalPrice;

    // ========== 差异数据（送审 - 审定） ==========
    @Schema(description = "量差（送审-审定）", example = "10.00")
    private BigDecimal diffQty;

    @Schema(description = "价差（送审-审定）", example = "0.00")
    private BigDecimal diffUnitPrice;

    @Schema(description = "费率差（送审-审定）", example = "0.0")
    private BigDecimal diffRate;

    @Schema(description = "合价差（送审-审定）", example = "255.00")
    private BigDecimal diffTotalPrice;

    @Schema(description = "变化类型：none/modify/add/delete", example = "modify")
    private String changeType;

    @Schema(description = "数据来源：submit=送审行, approve=审核行（仅定额节点有值）", example = "submit")
    private String dataSource;

    @Schema(description = "是否可编辑（送审定额行false，审核定额行true）", example = "true")
    private Boolean editable;

    @Schema(description = "扩展属性")
    private Map<String, Object> attributes;

    @Schema(description = "更新时间")
    private LocalDateTime updateTime;

    @Schema(description = "子节点列表")
    private List<AuditDivisionTreeRespVO> children;

    // 变化类型常量
    public static final String CHANGE_TYPE_NONE = "none";
    public static final String CHANGE_TYPE_MODIFY = "modify";
    public static final String CHANGE_TYPE_ADD = "add";
    public static final String CHANGE_TYPE_DELETE = "delete";

    // 数据来源常量（仅定额节点使用）
    public static final String DATA_SOURCE_SUBMIT = "submit";
    public static final String DATA_SOURCE_APPROVE = "approve";
}
