修改增加完整工程json

This commit is contained in:
chentianrui
2025-08-01 17:37:40 +08:00
parent 9609bb67b4
commit b67cc5e2c0
36 changed files with 4792633 additions and 809028 deletions
+29 -12
View File
@@ -155,25 +155,42 @@ def match_and_compare_costs(calc_costs, ext_costs, similarity_threshold=0.6):
def save_comparison_to_txt(comparison, output_txt_path):
"""保存对比结果到 TXT 文件"""
"""保存对比结果到 TXT 文件,差异保留两位小数,交换计算值和参考值位置"""
with open(output_txt_path, "w", encoding="utf-8") as f:
f.write(f"{'项目':<20} {'计算值':<15} {'参考值':<15} {'差异':<15} {'匹配项':<20} {'相似度':<8}\n")
f.write("-" * 100 + "\n")
# 表头:项目、参考值、计算值、差异、原数据项
f.write(f"{'项目':<20} {'参考值':<25} {'计算值':<25} {'差异':<25} {'原数据项':<30}\n")
f.write("-" * 120 + "\n")
for item in comparison:
project = item["项目"] or ""
calc = f"{item['计算值']:.2f}" if item["计算值"] is not None else ""
ref = f"{item['参考值']:.2f}" if item["参考值"] is not None else ""
diff = f"{item['差异']:.2f}" if item["差异"] is not None else ""
match = item["匹配项"] or ""
sim = f"{item['相似度']:.3f}" if item["相似度"] is not None else ""
f.write(f"{project:<20} {calc:<15} {ref:<15} {diff:<15} {match:<20} {sim:<8}\n")
# 原始字段
project = (item["项目"] or "").ljust(20)[:20] # 最多20字符,左对齐
# 交换计算值和参考值的位置
ref = str(item["参考值"]) if item["参考值"] is not None else ""
ref = ref.ljust(25)[:25]
calc = str(item["计算值"]) if item["计算值"] is not None else ""
calc = calc.ljust(25)[:25] # 最多25字符宽度
# 差异保留两位小数
if item["差异"] is not None:
diff = f"{item['差异']:.2f}"
else:
diff = ""
diff = diff.ljust(25)[:25]
original = (item["匹配项"] or "").ljust(30)[:30] # 原数据项字段更宽
f.write(f"{project}{ref}{calc}{diff}{original}\n")
print(f"对比结果已保存至: {output_txt_path}")
def main():
# 配置路径
calculation_json_path = "project2json/outputs/bclresult/基础工程材料工地运输_496A54BB-8A38-4BE1-B116-AD4780E6874A_预算工程_calculation_results.json"
project_data_json_path = "project2json/outputs/json/220kV变电站工程_readable.json" # 你要提供这个文件
calculation_json_path = (
"project2json/outputs/bclresult/一般土建_496A54BB-8A38-4BE1-B116-AD4780E6874A_预算工程_calculation_results.json"
)
project_data_json_path = "project2json/outputs/json/220kV变电站工程_readable.json"
# 1. 提取 GUID
guid = extract_guid_from_filename(calculation_json_path)