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

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 WbBoqResourceRespVO {

    @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long id;

    @Schema(description = "关联定额节点ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long divisionId;

    @Schema(description = "引用工料机ID", example = "1")
    private Long sourceResourceItemId;

    @Schema(description = "引用定额工料机组成ID", example = "1")
    private Long sourceQuotaResourceId;

    @Schema(description = "类型：labor-人工, material-材料, machine-机械", example = "material")
    private String resourceType;

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

    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "水泥")
    private String name;

    @Schema(description = "规格型号", example = "P.O 42.5")
    private String spec;

    @Schema(description = "单位", example = "t")
    private String unit;

    @Schema(description = "消耗量", example = "0.5")
    private BigDecimal consumeQty;

    @Schema(description = "调整消耗量（用户手动覆写，null表示使用原始逻辑值）", example = "0.6")
    private BigDecimal adjustConsumeQty;

    @Schema(description = "除税基价", example = "450.00")
    private BigDecimal taxExclBasePrice;

    @Schema(description = "含税基价", example = "490.50")
    private BigDecimal taxInclBasePrice;

    @Schema(description = "除税编制价", example = "460.00")
    private BigDecimal taxExclCompilePrice;

    @Schema(description = "含税编制价", example = "501.40")
    private BigDecimal taxInclCompilePrice;

    @Schema(description = "税率", example = "0.09")
    private BigDecimal taxRate;

    @Schema(description = "调整系数", example = "1.0")
    private BigDecimal adjustRate;

    @Schema(description = "实际单价（虚拟字段，内存计算：basePrice * adjustRate）", example = "450.00")
    private BigDecimal price;

    @Schema(description = "合价（虚拟字段，内存计算：consumeQty * price）", example = "225.00")
    private BigDecimal amount;

    @Schema(description = "除税基价合价（虚拟字段）", example = "50.00")
    private BigDecimal taxExclBaseTotalSum;

    @Schema(description = "含税基价合价（虚拟字段）", example = "54.50")
    private BigDecimal taxInclBaseTotalSum;

    @Schema(description = "除税编制价合价（虚拟字段）", example = "55.00")
    private BigDecimal taxExclCompileTotalSum;

    @Schema(description = "含税编制价合价（虚拟字段）", example = "59.95")
    private BigDecimal taxInclCompileTotalSum;

    @Schema(description = "除税合价（虚拟字段，用量×除税编制价）", example = "165.00")
    private BigDecimal taxExclTotalSum;

    @Schema(description = "含税合价（虚拟字段，用量×含税编制价）", example = "179.85")
    private BigDecimal taxInclTotalSum;

    @Schema(description = "计算基数（单位为%的工料机使用）")
    private Map<String, Object> calcBase;

    @Schema(description = "调整公式（虚拟字段）", example = "((x*1.2)+0.5)")
    private String adjustmentFormula;

    @Schema(description = "用量（工作台独有字段）", example = "10.00")
    private BigDecimal usageQty;

    @Schema(description = "机类ID", example = "1")
    private Long categoryId;

    @Schema(description = "机类代码", example = "人")
    private String categoryCode;

    @Schema(description = "来源类型：system-从定额复制, tenant-租户手动添加", example = "system")
    private String sourceType;

    @Schema(description = "价格来源显示文本（虚拟字段）", example = "信*01*广东*珠海*金湾")
    private String priceSourceText;

    @Schema(description = "是否有当前价格来源（虚拟字段，用于前端显示蓝色字体）", example = "true")
    private Boolean hasPriceSource;

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

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

    @Schema(description = "创建时间")
    private LocalDateTime createTime;

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

    @Schema(description = "子工料机列表（复合工料机展开）")
    private List<WbBoqResourceRespVO> children;
}
