2024-08-29 16:37:09 +08:00
|
|
|
|
import json
|
|
|
|
|
|
2024-09-09 15:21:07 +08:00
|
|
|
|
from flask_app.main.json_utils import clean_json_string
|
2024-08-29 17:30:49 +08:00
|
|
|
|
from flask_app.main.通义千问long import upload_file, qianwen_long
|
2024-08-29 16:37:09 +08:00
|
|
|
|
|
2024-09-09 15:21:07 +08:00
|
|
|
|
def combine_technical_and_business(data, target_values1, target_values2):
|
|
|
|
|
extracted_data = {} # 根级别存储所有数据
|
|
|
|
|
technical_found = False
|
|
|
|
|
business_found = False
|
2024-08-29 16:37:09 +08:00
|
|
|
|
|
2024-09-09 15:21:07 +08:00
|
|
|
|
def extract_nested(data, parent_key='', is_technical=False, is_business=False):
|
|
|
|
|
nonlocal technical_found, business_found
|
|
|
|
|
if isinstance(data, dict):
|
|
|
|
|
for key, value in data.items():
|
|
|
|
|
current_key = f"{parent_key}.{key}" if parent_key else key
|
2024-08-29 16:37:09 +08:00
|
|
|
|
|
2024-09-09 15:21:07 +08:00
|
|
|
|
# 检查是否为技术标的内容
|
|
|
|
|
if any(target in key for target in target_values1):
|
|
|
|
|
if not is_technical:
|
|
|
|
|
# 直接存储在根级别
|
|
|
|
|
extracted_data[key] = value
|
|
|
|
|
technical_found = True
|
|
|
|
|
# 标记为技术标内容并停止进一步处理这个分支
|
|
|
|
|
continue
|
2024-08-29 16:37:09 +08:00
|
|
|
|
|
2024-09-09 15:21:07 +08:00
|
|
|
|
# 检查是否为商务标的内容
|
|
|
|
|
elif any(target in key for target in target_values2):
|
|
|
|
|
if not is_business:
|
|
|
|
|
# 存储在'商务标'分类下
|
|
|
|
|
if '商务标' not in extracted_data:
|
|
|
|
|
extracted_data['商务标'] = {}
|
|
|
|
|
extracted_data['商务标'][key] = value
|
|
|
|
|
business_found = True
|
|
|
|
|
# 标记为商务标内容并停止进一步处理这个分支
|
|
|
|
|
continue
|
2024-08-29 16:37:09 +08:00
|
|
|
|
|
2024-09-09 15:21:07 +08:00
|
|
|
|
# 如果当前值是字典或列表,且不在技术或商务分类下,继续递归搜索
|
|
|
|
|
if isinstance(value, dict) or isinstance(value, list):
|
|
|
|
|
extract_nested(value, current_key, is_technical, is_business)
|
|
|
|
|
|
|
|
|
|
elif isinstance(data, list):
|
|
|
|
|
for index, item in enumerate(data):
|
|
|
|
|
extract_nested(item, f"{parent_key}[{index}]", is_technical, is_business)
|
|
|
|
|
|
|
|
|
|
# 开始从顶级递归搜索
|
|
|
|
|
extract_nested(data)
|
|
|
|
|
|
|
|
|
|
# 处理未找到匹配的情况
|
|
|
|
|
if not technical_found:
|
|
|
|
|
extracted_data['技术标'] = ''
|
|
|
|
|
if not business_found:
|
|
|
|
|
extracted_data['商务标'] = ''
|
|
|
|
|
|
|
|
|
|
return extracted_data
|
2024-08-29 16:37:09 +08:00
|
|
|
|
|
|
|
|
|
def combine_evaluation_standards(truncate2):
|
|
|
|
|
# 商务标、技术标评分项:千问
|
|
|
|
|
print("starting商务标技术标...")
|
|
|
|
|
file_id = upload_file(truncate2)
|
|
|
|
|
user_query_2 = (
|
|
|
|
|
"根据该文档中的评标办法前附表,请你列出该文件的技术标,商务标,投标报价评审标准以及它们对应的具体评分要求,若对应内容中存在其他信息,在键名如'技术标'中新增子键名'备注'存放该信息。如果评分内容不是这3个,则返回文档中给定的评分内容以及它的评分要求,都以json的格式返回结果。请不要回答有关形式、资格、响应性评审标准的内容")
|
|
|
|
|
evaluation_res = qianwen_long(file_id, user_query_2)
|
2024-09-09 15:21:07 +08:00
|
|
|
|
target_values1 = ['技术标', '设计', '实施', '方案']
|
|
|
|
|
target_values2=['投标报价','商务标','业绩','信誉','分值','计算公式','信用','人员','资格','奖项','认证','荣誉']
|
|
|
|
|
update_json=combine_technical_and_business(clean_json_string(evaluation_res),target_values1,target_values2)
|
|
|
|
|
evaluation_combined_res = json.dumps(update_json,ensure_ascii=False,indent=4)
|
2024-08-29 16:37:09 +08:00
|
|
|
|
print("商务标技术标done")
|
|
|
|
|
return evaluation_combined_res
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2024-09-09 15:21:07 +08:00
|
|
|
|
truncate2="C:\\Users\\Administrator\\Desktop\\招标文件\\招标04_evaluation_method.pdf"
|
2024-08-29 16:37:09 +08:00
|
|
|
|
res=combine_evaluation_standards(truncate2)
|
|
|
|
|
print(res)
|