修改费用计算代码
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from memory_profiler import profile
|
||||
from typing import Dict, List, Any, Optional, Set, Tuple
|
||||
|
||||
|
||||
@@ -117,6 +118,7 @@ class CalculationStrategy(ABC):
|
||||
cost_table: Dict[str, Any],
|
||||
json_file_path: Optional[str] = None,
|
||||
engineering_type: Optional[str] = None,
|
||||
json_data: Optional[Dict[str, Any]] = None,
|
||||
) -> Dict[str, float]:
|
||||
"""
|
||||
计算所有费用
|
||||
@@ -138,6 +140,7 @@ class CalculationStrategy(ABC):
|
||||
rcj_nodes: List[Tuple[Dict[str, Any], str]],
|
||||
project_children: List[Dict[str, Any]],
|
||||
json_file_path: Optional[str] = None,
|
||||
json_data: Optional[Dict[str, Any]] = None,
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
计算人材机节点的数量,考虑父级消耗量
|
||||
@@ -322,12 +325,20 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
cost_table: Dict[str, Any],
|
||||
json_file_path: Optional[str] = None,
|
||||
engineering_type: Optional[str] = None,
|
||||
json_data: Optional[Dict[str, Any]] = None,
|
||||
) -> Dict[str, float]:
|
||||
"""计算所有费用"""
|
||||
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)
|
||||
return original_calculate_all_fees(
|
||||
project_node,
|
||||
cost_table,
|
||||
json_file_path,
|
||||
engineering_type,
|
||||
self,
|
||||
json_data=json_data,
|
||||
)
|
||||
|
||||
def calculate_rcj_count(
|
||||
self,
|
||||
@@ -338,7 +349,7 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
"""计算人材机节点的数量"""
|
||||
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)
|
||||
return original_calc_rcj_count(rcj_nodes, project_children, json_file_path, json_data=json_data)
|
||||
|
||||
def cat_rcj_count(self, rcj_nodes: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
|
||||
"""汇总人材机节点的数量"""
|
||||
@@ -359,7 +370,14 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
return original_format_rcj_output(rcj_nodes, node_type)
|
||||
|
||||
# 修复 calculate_rcj_fees 未定义的错误
|
||||
def calculate_rcj_fees(self, json_file_path, project_name, project_guid=None):
|
||||
def calculate_rcj_fees(
|
||||
self,
|
||||
json_file_path,
|
||||
project_name,
|
||||
project_guid=None,
|
||||
json_data: Optional[Dict[str, Any]] = None,
|
||||
engineering_type: Optional[str] = None,
|
||||
):
|
||||
"""
|
||||
计算项目划分节点下所有人材机节点的合价
|
||||
|
||||
@@ -375,7 +393,7 @@ class DefaultCalculationStrategy(CalculationStrategy):
|
||||
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)
|
||||
return original_calculate_rcj_fees(json_file_path, project_name, project_guid, json_data=json_data)
|
||||
|
||||
def post_process_quantity_fees(self, output_file: str, project_name: str) -> None:
|
||||
"""对工程量取费表进行后处理"""
|
||||
|
||||
Reference in New Issue
Block a user