import json


class ProjectQuantity:
    """
    工程量
    描述: 代表项目划分项(ProjectDivisionItem)下的具体工作单元或物料项，是定额、主材、设备的父类型
    """

    def __init__(self):
        self.id = None  # xsd:string
        self.类型 = None  # xsd:string ("0"为定额,"1"为主材,"5"为设备)
        self.name = None  # xsd:string
        self.编码 = None  # xsd:string
        self.单位 = None  # xsd:string
        self.数量 = None  # xsd:string
        self.资源库名称 = None  # xsd:string
        self.投标数量 = None  # xsd:string (可选)
        self.投标单价 = None  # xsd:string (可选)
        self.特征段 = None  # xsd:string (可选)
        self.关联父级量 = None  # xsd:string (可选)
        self.颜色标记 = None  # xsd:string (可选)
        self.单价不含税 = None
        self.cost_set = None  # xsd:CostSet
        self.设备类型 = None  # xsd:string
        self.供货方 = None  # xsd:string

        # （定额）
        self.综合地形类型 = None  # xsd:string
        self.乙供材料费不含税 = None  # xsd:string
        self.调差类型 = None  # xsd:string
        self.机械费不含税 = None  # xsd:string
        self.地形费计算方式 = None  # xsd:string
        self.专业属性 = None  # xsd:string

        # （主材）
        self.拆分 = None  # xsd:string
        self.设备性材料 = None  # xsd:string
        self.预算价不含税 = None  # xsd:string
        self.损耗 = None  # xsd:string
        self.预算价含税 = None  # xsd:string

        # 技改预算_定额
        self.脚手架计取 = None  # xsd:string
        self.甲供材料费_含税 = None  # xsd:string
        self.配件类型 = None  # xsd:string
        self.专业类型 = None  # xsd:string
        self.调试费计取 = None  # xsd:string
        self.甲供材料费 = None  # xsd:string
        self.费用类型 = None  # xsd:string


class Ration(ProjectQuantity):
    """
    定额
    描述: 代表一种标准的工程量条目，通常包含详细的工、料、机消耗标准
    """

    def __init__(self):
        super().__init__()
        self.计算式 = None  # xsd:string
        self.中标计算式 = None  # xsd:string
        self.人工费 = None  # xsd:string
        self.机械费 = None  # xsd:string
        self.甲供材料费不含税 = None  # xsd:string
        self.材料费 = None  # xsd:string
        self.定额系数 = None  # xsd:string
        self.人工系数 = None  # xsd:string
        self.材料系数 = None  # xsd:string
        self.机械系数 = None  # xsd:string
        self.定额范围 = None  # xsd:string
        self.定额章节名称 = None  # xsd:string
        self.费用类型 = None  # xsd:string
        self.甲供材料费含税 = None  # xsd:string
        self.投标合价 = None  # xsd:string
        self.其中甲供材料费 = None  # xsd:string
        self.合价不含税 = None  # xsd:string
        self.基价 = None  # xsd:string
        self.所属定额库 = None  # xsd:string

    def __str__(self):
        """返回定额的字符串表示"""
        attrs = {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
        return json.dumps(attrs, ensure_ascii=False, indent=2)


class Material(ProjectQuantity):
    """
    主材
    描述: 代表工程中使用的主要材料
    """

    def __init__(self):
        super().__init__()
        self.规格型号 = None  # xsd:string
        self.损耗率 = None  # xsd:string
        self.供货方 = None  # xsd:string
        self.集中配送 = None  # xsd:string (可选)
        self.单重 = None  # xsd:string (可选)
        self.市场价不含税 = None  # xsd:string
        self.市场价含税 = None  # xsd:string
        self.单价含税 = None  # xsd:string
        self.结算市场价不含税 = None  # xsd:string (可选)
        self.结算市场价含税 = None  # xsd:string (可选)
        self.基准价不含税 = None  # xsd:string (可选)
        self.基准价含税 = None  # xsd:string (可选)
        self.费用类型 = None  # xsd:string
        self.增值税率 = None  # xsd:string (可选)
        self.合价含税 = None  # xsd:string
        self.合价不含税 = None  # xsd:string
        self.线重 = None  # xsd:string (可选)
        self.制造长度 = None  # xsd:string (可选)
        self.截面积 = None  # xsd:string (可选)
        self.拆分 = None  # xsd:string (可选)

    def __str__(self):
        """返回材料的字符串表示"""
        attrs = {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
        return json.dumps(attrs, ensure_ascii=False, indent=2)


class Equipment(ProjectQuantity):
    """
    设备
    描述: 代表工程中安装或使用的设备
    """

    def __init__(self):
        super().__init__()
        self.规格型号 = None  # xsd:string
        self.供货方 = None  # xsd:string
        self.运杂费率 = None  # xsd:string (可选)
        self.单价含税 = None  # xsd:string
        self.设备类型 = None  # xsd:string (可选)
        self.增值税率 = None  # xsd:string (可选)
        self.合价含税 = None  # xsd:string
        self.合价不含税 = None  # xsd:string


class MaterialOrEquipment:
    """
    材机
    描述: 代表DetailedWorkItem中所列出的具体材料、人工或机械设备及其详细信息
    """

    def __init__(self):
        self.id = None  # xsd:string
        self.编码 = None  # xsd:string
        self.名称 = None  # xsd:string
        self.单位 = None  # xsd:string
        self.type = None  # xsd:string
        self.供货方 = None  # xsd:string
        self.预算价不含税 = None  # xsd:string
        self.市场价不含税 = None  # xsd:string
        self.预算价含税 = None  # xsd:string
        self.市场价含税 = None  # xsd:string
        self.结算预算价不含税 = None  # xsd:string
        self.结算市场价不含税 = None  # xsd:string
        self.结算预算价含税 = None  # xsd:string
        self.结算市场价含税 = None  # xsd:string
        self.暂估价 = None  # xsd:string
        self.拆分 = None  # xsd:string
        self.全口径市场价不含税 = None  # xsd:string
        self.全口径市场价含税 = None  # xsd:string
        self.商品砼 = None  # xsd:string
        self.数量 = None  # xsd:string
        self.是否未计价 = None  # xsd:string


class bill_node:
    """
    清单
    描述: 代表清单项，通常包含多个定额
    """

    def __init__(self):
        self.清单名称 = None  # xsd:string
        self.清单全码 = None  # xsd:string
        self.编码 = None  # xsd:string
        self.单位 = None  # xsd:string
        self.计算式 = None  # xsd:string
        self.数量 = None  # xsd:string
        self.取费表 = None  # xsd:string
        self.合价 = None  # xsd:string
        self.工作内容 = None  # xsd:string
        self.类型 = None  # xsd:string
        self.type = None  # xsd:string
        self.项目特征 = None  # xsd:string
        self.资源库名称 = None  # xsd:string
        self.计算规则 = None  # xsd:string
        self.单价 = None  # xsd:string
        self.一次性费用 = None  # xsd:string
        self.取费表名称 = None  # xsd:string
        self.取费表类型 = None  # xsd:string
        self.单价不含税 = None  # xsd:string
        self.合价不含税 = None  # xsd:string
        self.专业类型 = None  # xsd:string
        self.关联父级量 = None  # xsd:string
        self.含量 = None  # xsd:string

    def __str__(self):
        """返回清单的字符串表示"""
        attrs = {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
        return json.dumps(attrs, ensure_ascii=False, indent=2)
