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
 *
 * @author yhy
 */
@Schema(description = "工作台 - 市场主材设备 Response VO")
@Data
public class WbBoqMarketMaterialRespVO {

    @Schema(description = "主键ID", example = "1")
    private Long id;

    @Schema(description = "分部分项ID", example = "1")
    private Long divisionId;

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

    @Schema(description = "引用定额市场主材设备ID", example = "1")
    private Long sourceMarketMaterialId;

    @Schema(description = "资源类型", example = "material")
    private String resourceType;

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

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

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

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

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

    @Schema(description = "调整消耗量", example = "1.6")
    private BigDecimal adjustConsumeQty;

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

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

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

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

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

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

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

    @Schema(description = "父工料机ID", example = "1")
    private Long parentId;

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

    @Schema(description = "用量", example = "100")
    private BigDecimal usageQty;

    @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 = "除税基价合价", example = "675.00")
    private BigDecimal taxExclBaseTotalSum;

    @Schema(description = "含税基价合价", example = "762.75")
    private BigDecimal taxInclBaseTotalSum;

    @Schema(description = "除税编制价合价", example = "690.00")
    private BigDecimal taxExclCompileTotalSum;

    @Schema(description = "含税编制价合价", example = "779.70")
    private BigDecimal taxInclCompileTotalSum;

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

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

    @Schema(description = "是否复合工料机", example = "false")
    private Boolean isMerged;

    @Schema(description = "复合工料机子数据列表")
    private List<MergedItemVO> mergedItems;

    /**
     * 复合工料机子数据 VO
     */
    @Schema(description = "复合工料机子数据")
    @Data
    public static class MergedItemVO {
        @Schema(description = "子数据ID", example = "1")
        private Long id;

        @Schema(description = "源工料机ID", example = "100")
        private Long resourceItemId;

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

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

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

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

        @Schema(description = "资源类型", example = "material")
        private String resourceType;

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

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

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

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

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

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

        @Schema(description = "除税基价合价", example = "150.00")
        private BigDecimal taxExclBaseTotalSum;

        @Schema(description = "含税基价合价", example = "169.50")
        private BigDecimal taxInclBaseTotalSum;

        @Schema(description = "除税编制价合价", example = "180.00")
        private BigDecimal taxExclCompileTotalSum;

        @Schema(description = "含税编制价合价", example = "203.40")
        private BigDecimal taxInclCompileTotalSum;
    }
}
