修改增加完整工程json
This commit is contained in:
@@ -4,7 +4,7 @@ import xml.etree.ElementTree as ET
|
||||
from typing import Dict, Callable, Any, Optional
|
||||
import os
|
||||
from enum import Enum, auto
|
||||
from expressioncalculator import ExpressionCalculator
|
||||
from equipment_calculation.expressioncalculator import ExpressionCalculator
|
||||
import copy
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
from typing import Dict, List, Any, Optional, Tuple
|
||||
from bcl_calculator import (
|
||||
from equipment_calculation.bcl_calculator import (
|
||||
BCLCalculator,
|
||||
BCLContext,
|
||||
BCLVariant,
|
||||
@@ -10,7 +10,7 @@ from bcl_calculator import (
|
||||
BCLDataSourceItem,
|
||||
BCLDataSourceContext,
|
||||
)
|
||||
from project import Ration, MaterialOrEquipment, Material, Equipment, bill_node
|
||||
from equipment_calculation.project import Ration, MaterialOrEquipment, Material, Equipment, bill_node
|
||||
from copy import deepcopy
|
||||
import logging
|
||||
|
||||
|
||||
@@ -236,9 +236,9 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
|
||||
def __init__(self):
|
||||
# 导入必要的模块
|
||||
from expressioncalculator import ExpressionCalculator
|
||||
from bcl_utils import calculator
|
||||
from item_acquisition import get_quantity_nodes, get_classified_resource_nodes
|
||||
from equipment_calculation.expressioncalculator import ExpressionCalculator
|
||||
from equipment_calculation.bcl_utils import calculator
|
||||
from equipment_calculation.item_acquisition import get_quantity_nodes, get_classified_resource_nodes
|
||||
|
||||
# 缓存已计算过的费用
|
||||
self.calculated_fees = {}
|
||||
@@ -252,7 +252,7 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
in_calculation: Optional[Set[str]] = None,
|
||||
) -> float:
|
||||
"""计算取费基数"""
|
||||
from quantity_fee_calculator import calculate_fee_base as original_calculate_fee_base
|
||||
from equipment_calculation.quantity_fee_calculator import calculate_fee_base as original_calculate_fee_base
|
||||
|
||||
# 传递自身作为计算策略
|
||||
return original_calculate_fee_base(fee_base, cost_table, project_node, context, in_calculation, self)
|
||||
@@ -266,7 +266,9 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
in_calculation: Optional[Set[str]] = None,
|
||||
) -> float:
|
||||
"""计算表内费用"""
|
||||
from quantity_fee_calculator import calculate_internal_fee as original_calculate_internal_fee
|
||||
from equipment_calculation.quantity_fee_calculator import (
|
||||
calculate_internal_fee as original_calculate_internal_fee,
|
||||
)
|
||||
|
||||
# 传递自身作为计算策略
|
||||
return original_calculate_internal_fee(fee_code, cost_table, project_node, context, in_calculation, self)
|
||||
@@ -274,20 +276,22 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
def calculate_external_variable(self, var_name: str, context: Any) -> float:
|
||||
"""计算表外变量"""
|
||||
# 直接使用 calculator.calculate,而不是调用 quantity_fee_calculator.py 中的函数
|
||||
from bcl_utils import calculator
|
||||
from equipment_calculation.bcl_utils import calculator
|
||||
|
||||
result = calculator.calculate(var_name, context)
|
||||
return float(result) if result is not None else 0.0
|
||||
|
||||
def find_fee_item_by_code(self, cost_table: Dict[str, Any], code: str) -> Optional[Dict[str, Any]]:
|
||||
"""在取费表中查找指定代码的费用项"""
|
||||
from quantity_fee_calculator import find_fee_item_by_code as original_find_fee_item_by_code
|
||||
from equipment_calculation.quantity_fee_calculator import (
|
||||
find_fee_item_by_code as original_find_fee_item_by_code,
|
||||
)
|
||||
|
||||
return original_find_fee_item_by_code(cost_table, code)
|
||||
|
||||
def find_fee_base_nodes(self, node: Dict[str, Any], result: Optional[List] = None) -> List[Dict[str, Any]]:
|
||||
"""递归查找取费表中包含"取费基数"的节点或有子节点的费用项"""
|
||||
from quantity_fee_calculator import find_fee_base_nodes as original_find_fee_base_nodes
|
||||
from equipment_calculation.quantity_fee_calculator import find_fee_base_nodes as original_find_fee_base_nodes
|
||||
|
||||
return original_find_fee_base_nodes(node, result)
|
||||
|
||||
@@ -299,7 +303,7 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
engineering_type: Optional[str] = None,
|
||||
) -> Dict[str, float]:
|
||||
"""计算所有费用"""
|
||||
from quantity_fee_calculator import calculate_all_fees as original_calculate_all_fees
|
||||
from equipment_calculation.quantity_fee_calculator import calculate_all_fees as original_calculate_all_fees
|
||||
|
||||
# 传递自身作为计算策略
|
||||
return original_calculate_all_fees(project_node, cost_table, json_file_path, engineering_type, self)
|
||||
@@ -311,25 +315,25 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
json_file_path: Optional[str] = None,
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""计算人材机节点的数量"""
|
||||
from resource_fee_calculator import calc_rcj_count as original_calc_rcj_count
|
||||
from equipment_calculation.resource_fee_calculator import calc_rcj_count as original_calc_rcj_count
|
||||
|
||||
return original_calc_rcj_count(rcj_nodes, project_children, json_file_path)
|
||||
|
||||
def cat_rcj_count(self, rcj_nodes: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
||||
"""汇总人材机节点的数量"""
|
||||
from resource_fee_calculator import cat_rcj_count as original_cat_rcj_count
|
||||
from equipment_calculation.resource_fee_calculator import cat_rcj_count as original_cat_rcj_count
|
||||
|
||||
return original_cat_rcj_count(rcj_nodes)
|
||||
|
||||
def calc_rcj_fee(self, rcj_nodes: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
||||
"""计算人材机节点的费用"""
|
||||
from resource_fee_calculator import calc_rcj_fee as original_calc_rcj_fee
|
||||
from equipment_calculation.resource_fee_calculator import calc_rcj_fee as original_calc_rcj_fee
|
||||
|
||||
return original_calc_rcj_fee(rcj_nodes)
|
||||
|
||||
def format_rcj_output(self, rcj_nodes: List[Dict[str, Any]], node_type: str) -> List[Dict[str, Any]]:
|
||||
"""格式化人材机节点输出"""
|
||||
from resource_fee_calculator import format_rcj_output as original_format_rcj_output
|
||||
from equipment_calculation.resource_fee_calculator import format_rcj_output as original_format_rcj_output
|
||||
|
||||
return original_format_rcj_output(rcj_nodes, node_type)
|
||||
|
||||
@@ -347,7 +351,7 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
Dict[str, Any]: 计算结果
|
||||
"""
|
||||
# 导入原始函数
|
||||
from resource_fee_calculator import calculate_rcj_fees as original_calculate_rcj_fees
|
||||
from equipment_calculation.resource_fee_calculator import calculate_rcj_fees as original_calculate_rcj_fees
|
||||
|
||||
# 调用原始函数
|
||||
return original_calculate_rcj_fees(json_file_path, project_name, project_guid)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import os
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Dict, List, Any, Optional, Tuple
|
||||
from software_types import SoftwareType
|
||||
from find_project_nodes import get_project_divisions_list
|
||||
from quantity_fee_calculator import calculate_quantity_fees as base_calculate_quantity_fees
|
||||
from resource_fee_calculator import calculate_resource_fees as base_calculate_resource_fees
|
||||
from calculation_strategy import CalculationStrategy, DefaultCalculationStrategy
|
||||
from equipment_calculation.software_types import SoftwareType
|
||||
from equipment_calculation.find_project_nodes import get_project_divisions_list
|
||||
from equipment_calculation.quantity_fee_calculator import calculate_quantity_fees as base_calculate_quantity_fees
|
||||
from equipment_calculation.resource_fee_calculator import calculate_resource_fees as base_calculate_resource_fees
|
||||
from equipment_calculation.calculation_strategy import CalculationStrategy, DefaultCalculationStrategy
|
||||
import json
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class CalculatorBase(ABC):
|
||||
def calculate_quantity_fee_tables(
|
||||
self,
|
||||
json_file_path: str,
|
||||
project_name: str = None,
|
||||
project_name: str,
|
||||
) -> None:
|
||||
"""
|
||||
计算工程量取费表
|
||||
@@ -141,7 +141,7 @@ class CalculatorBase(ABC):
|
||||
os.makedirs(self.get_output_dir(), exist_ok=True)
|
||||
|
||||
# 初始化BCL计算器,传递软件类型和计算类型
|
||||
from bcl_utils import init_bcl_calculator
|
||||
from equipment_calculation.bcl_utils import init_bcl_calculator
|
||||
|
||||
init_bcl_calculator(
|
||||
software_category=self.software_type.category.value,
|
||||
@@ -189,7 +189,7 @@ class CalculatorBase(ABC):
|
||||
os.makedirs(self.get_output_dir(), exist_ok=True)
|
||||
|
||||
# 初始化BCL计算器,传递软件类型和计算类型
|
||||
from bcl_utils import init_bcl_calculator
|
||||
from equipment_calculation.bcl_utils import init_bcl_calculator
|
||||
|
||||
init_bcl_calculator(
|
||||
software_category=self.software_type.category.value,
|
||||
|
||||
@@ -103,7 +103,7 @@ def parse_json_content(json_file_path: str) -> Tuple[Optional[str], Optional[str
|
||||
|
||||
# 定义阶段类型映射表
|
||||
budget_types = ["概预算", "定额", "估算", "概算"]
|
||||
list_types = ["清单", "结算", "竣工", "决算"]
|
||||
list_types = ["清单", "结算", "招标控制价", "招投标工程"]
|
||||
|
||||
# 从division字段获取软件名称和阶段类型
|
||||
if "division" in data:
|
||||
@@ -240,14 +240,10 @@ def process_json_file(
|
||||
|
||||
# 执行计算
|
||||
print(" 开始计算工程量取费表...")
|
||||
calculator.calculate_quantity_fee_tables(
|
||||
json_file_path=input_file, project_name=project, adjustment_type=adjustment_type
|
||||
)
|
||||
calculator.calculate_quantity_fee_tables(json_file_path=input_file, project_name=project)
|
||||
|
||||
print(" 开始计算人材机合价...")
|
||||
calculator.calculate_resource_fee_tables(
|
||||
json_file_path=input_file, project_name=project, adjustment_type=adjustment_type
|
||||
)
|
||||
calculator.calculate_resource_fee_tables(json_file_path=input_file, project_name=project)
|
||||
|
||||
print(f" 处理完成: {input_file}")
|
||||
print(f" 结果保存在: {output_dir}")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,8 @@ import json
|
||||
import os
|
||||
import sys
|
||||
from typing import Dict, List, Any, Optional, Tuple, Set
|
||||
from expressioncalculator import ExpressionCalculator
|
||||
from bcl_utils import (
|
||||
from equipment_calculation.expressioncalculator import ExpressionCalculator
|
||||
from equipment_calculation.bcl_utils import (
|
||||
ZjQuantityBCLContext,
|
||||
ZjProjectBCLContext,
|
||||
ZjBillBCLContext,
|
||||
@@ -16,7 +16,7 @@ from bcl_utils import (
|
||||
create_list_from_node,
|
||||
create_node_from_type,
|
||||
)
|
||||
from item_acquisition import (
|
||||
from equipment_calculation.item_acquisition import (
|
||||
get_cost_table_children,
|
||||
get_quantity_nodes,
|
||||
get_bill_cost_table,
|
||||
@@ -104,7 +104,7 @@ def process_DXdata(json_data):
|
||||
# 在create_list_from_node函数后添加一个包装函数
|
||||
def create_list_from_node_with_quantity(node, quantity=None):
|
||||
"""创建清单对象并设置数量"""
|
||||
from bcl_utils import create_list_from_node
|
||||
from equipment_calculation.bcl_utils import create_list_from_node
|
||||
|
||||
bill_obj = create_list_from_node(node)
|
||||
|
||||
@@ -499,7 +499,7 @@ def calculate_all_fees(
|
||||
print(f"设置清单对象数量: {bill_obj.quantity}")
|
||||
|
||||
# 创建工程量对象
|
||||
from bcl_utils import create_node_from_type
|
||||
from equipment_calculation.bcl_utils import create_node_from_type
|
||||
|
||||
project_obj = create_node_from_type(project_node)
|
||||
|
||||
@@ -517,7 +517,7 @@ def calculate_all_fees(
|
||||
context = BCLDataSourceContext([QuantityItem], bill_context)
|
||||
else:
|
||||
# 非清单工程 - 工程信息 -> 工程量节点
|
||||
from bcl_utils import create_node_from_type
|
||||
from equipment_calculation.bcl_utils import create_node_from_type
|
||||
|
||||
project_obj = create_node_from_type(project_node)
|
||||
|
||||
@@ -729,7 +729,7 @@ def calculate_quantity_fees(
|
||||
"""
|
||||
# 如果没有提供计算策略,使用默认策略
|
||||
if calculation_strategy is None:
|
||||
from calculation_strategy import DefaultCalculationStrategy
|
||||
from equipment_calculation.calculation_strategy import DefaultCalculationStrategy
|
||||
|
||||
calculation_strategy = DefaultCalculationStrategy()
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ import math
|
||||
from typing import Dict, List, Any, Tuple
|
||||
from copy import deepcopy
|
||||
|
||||
from item_acquisition import get_quantity_nodes, get_classified_resource_nodes, load_project_data
|
||||
from equipment_calculation.item_acquisition import get_quantity_nodes, get_classified_resource_nodes, load_project_data
|
||||
|
||||
# 修改后的代码:先将字典转换为对象
|
||||
from bcl_utils import create_node_from_type, create_material_or_equipment_from_node
|
||||
from equipment_calculation.bcl_utils import create_node_from_type, create_material_or_equipment_from_node
|
||||
|
||||
from bcl_utils import (
|
||||
from equipment_calculation.bcl_utils import (
|
||||
ZjMaterialOrEquipmentBCLContext,
|
||||
ZjProjectBCLContext,
|
||||
BCLVariant,
|
||||
@@ -19,8 +19,8 @@ from bcl_utils import (
|
||||
calculator,
|
||||
)
|
||||
|
||||
from bcl_utils import BCLDataSourceItem, BCLDataSourceContext
|
||||
from item_acquisition import get_quantity_nodes, get_classified_resource_nodes
|
||||
from equipment_calculation.bcl_utils import BCLDataSourceItem, BCLDataSourceContext
|
||||
from equipment_calculation.item_acquisition import get_quantity_nodes, get_classified_resource_nodes
|
||||
|
||||
# 人材机节点定义合并条件常量
|
||||
LABOR_MERGE_CONDITIONS = [
|
||||
@@ -999,7 +999,7 @@ def calculate_resource_fees(
|
||||
"""
|
||||
# 如果没有提供计算策略,使用默认策略
|
||||
if calculation_strategy is None:
|
||||
from calculation_strategy import DefaultCalculationStrategy
|
||||
from equipment_calculation.calculation_strategy import DefaultCalculationStrategy
|
||||
|
||||
calculation_strategy = DefaultCalculationStrategy()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from calculator_base import CalculatorBase
|
||||
from software_types import (
|
||||
from equipment_calculation.calculator_base import CalculatorBase
|
||||
from equipment_calculation.software_types import (
|
||||
SoftwareType,
|
||||
MAIN_GRID_BUDGET,
|
||||
MAIN_GRID_BILL,
|
||||
@@ -8,7 +8,7 @@ from software_types import (
|
||||
TECHNICAL_RENOVATION_BUDGET,
|
||||
TECHNICAL_RENOVATION_BILL,
|
||||
)
|
||||
from calculation_strategy import CalculationStrategy, DefaultCalculationStrategy
|
||||
from equipment_calculation.calculation_strategy import CalculationStrategy, DefaultCalculationStrategy
|
||||
import json
|
||||
import os
|
||||
from typing import Any, Dict, Optional, Set
|
||||
@@ -86,7 +86,7 @@ class MainGridBillCalculationStrategy(DefaultCalculationStrategy):
|
||||
def calculate_external_variable(self, var_name: str, context: Any) -> float:
|
||||
"""计算表外变量,并乘以父级清单的数量"""
|
||||
# 使用默认实现计算表外变量
|
||||
from bcl_utils import calculator
|
||||
from equipment_calculation.bcl_utils import calculator
|
||||
|
||||
result = calculator.calculate(var_name, context)
|
||||
|
||||
@@ -277,7 +277,7 @@ class TechnicalRenovationBillCalculationStrategy(DefaultCalculationStrategy):
|
||||
def calculate_external_variable(self, var_name: str, context: Any) -> float:
|
||||
"""计算表外变量,并乘以父级清单的数量"""
|
||||
# 使用默认实现计算表外变量
|
||||
from bcl_utils import calculator
|
||||
from equipment_calculation.bcl_utils import calculator
|
||||
|
||||
result = calculator.calculate(var_name, context)
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user