实现完整功能
This commit is contained in:
+22
-22
@@ -5,6 +5,7 @@
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
import json
|
||||
from typing import Any, Type
|
||||
|
||||
|
||||
class ProjectToolkit(ABC):
|
||||
@@ -13,13 +14,13 @@ class ProjectToolkit(ABC):
|
||||
描述: 代表整个项目结构的顶层容器
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.project_division_set = ProjectDivisionItem() # 项目划分集对象
|
||||
def __init__(self, config: Any):
|
||||
pass
|
||||
|
||||
# 项目划分查询方法
|
||||
|
||||
@abstractmethod
|
||||
def get_division_by_name(self, name):
|
||||
def get_division_by_name(self, name_part):
|
||||
"""
|
||||
通过名称获取项目划分对象
|
||||
|
||||
@@ -89,7 +90,7 @@ class ProjectToolkit(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_quantities_node_by_parent_and_code(self, parent_path, quantity_type=None, code=None):
|
||||
def get_quantities_node_by_parent_and_code(self, parent_path, quantity_type, code):
|
||||
"""
|
||||
通过父节点路径和编码获取工程量对象(定额、主材或设备),包括子节点
|
||||
|
||||
@@ -108,14 +109,15 @@ class ProjectToolkit(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_quantities_node_by_parent_and_name(self, parent_path, partial_name, quantity_type=None):
|
||||
def get_quantities_node_by_parent_and_name(self, parent_path, quantity_type, partial_name):
|
||||
"""
|
||||
通过父节点路径、模糊节点名称和类型获取工程量对象(主材或者设备),包括子节点
|
||||
通过父节点路径、类型和模糊节点名称获取工程量对象(主材或者设备),包括子节点
|
||||
|
||||
Args:
|
||||
parent_path (str): 父节点的路径,以'/'分隔的多级节点路径
|
||||
partial_name (str): 目标节点的模糊或不完整名称
|
||||
quantity_type (str): 工程量类型('定额'、'主材'、'设备')
|
||||
partial_name (str): 目标节点的模糊或不完整名称
|
||||
|
||||
|
||||
Returns:
|
||||
dict: 返回字典,字段包括:
|
||||
@@ -202,7 +204,7 @@ class ProjectToolkit(ABC):
|
||||
|
||||
# 费用表查询方法
|
||||
@abstractmethod
|
||||
def get_fee_schedule_on_auxiliary_expense_table(self, table_name, fee_name, fee: str):
|
||||
def get_fee_schedule_on_auxiliary_expense_table(self, table_name, fee_name, fee_attribute: str):
|
||||
"""
|
||||
在辅助费用表中查找费用
|
||||
|
||||
@@ -221,7 +223,7 @@ class ProjectToolkit(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_fee_schedule_on_other_expense_table(self, table_name, fee_name, fee):
|
||||
def get_fee_schedule_on_other_expense_table(self, table_name, fee_name, fee_attribute):
|
||||
"""
|
||||
在其它费用表中查找费用
|
||||
|
||||
@@ -240,7 +242,7 @@ class ProjectToolkit(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_fee_schedule_on_land_acquisition_fee_table_table(self, table_name, fee_name, fee):
|
||||
def get_fee_schedule_on_land_acquisition_fee_table_table(self, table_name, fee_name, fee_attribute):
|
||||
"""
|
||||
在其中:场地征用费用表中查找费用
|
||||
|
||||
@@ -259,7 +261,7 @@ class ProjectToolkit(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_fee_schedule_on_installation_price_difference_table(self, table_name, fee_name, fee):
|
||||
def get_fee_schedule_on_installation_price_difference_table(self, table_name, fee_name, fee_attribute):
|
||||
"""
|
||||
在安装价差费用表中查找费用
|
||||
|
||||
@@ -278,7 +280,7 @@ class ProjectToolkit(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_fee_schedule_on_Engineering_Cost_table(self, table_name, fee_name, fee):
|
||||
def get_fee_schedule_on_Engineering_Cost_table(self, table_name, fee_name, fee_attribute):
|
||||
"""
|
||||
在工程费用表中查找费用
|
||||
|
||||
@@ -687,18 +689,19 @@ class Fee:
|
||||
self.施工费 = None # xsd:string (可选)
|
||||
self.单位投资 = None # xsd:string (可选)
|
||||
|
||||
class ProjectBuilder:
|
||||
# 存储注册的工具类
|
||||
_registry = None
|
||||
_config = {}
|
||||
|
||||
class ProjectBuilder:
|
||||
"""项目工具工厂类"""
|
||||
|
||||
# 存储注册的工具类
|
||||
_registry: Type[ProjectToolkit] | None = None
|
||||
_config: Any = None
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def register(cls, toolkit_class: type, config: dict):
|
||||
def register(cls, toolkit_class: Type[ProjectToolkit], config: Any):
|
||||
"""
|
||||
注册工具类到工厂
|
||||
|
||||
@@ -716,13 +719,10 @@ class ProjectBuilder:
|
||||
"""
|
||||
创建工具实例
|
||||
|
||||
参数:
|
||||
|
||||
返回:
|
||||
实例化的工具对象
|
||||
"""
|
||||
if cls._registry is None:
|
||||
raise KeyError(f"未注册的类,请先注册类")
|
||||
raise KeyError("未注册的类,请先注册类")
|
||||
|
||||
|
||||
return cls._registry(cls._config)
|
||||
return cls._registry(cls._config)
|
||||
Reference in New Issue
Block a user