2024-09-23 15:49:30 +08:00
|
|
|
|
import concurrent.futures
|
2024-09-13 15:03:55 +08:00
|
|
|
|
import json
|
2024-09-23 15:49:30 +08:00
|
|
|
|
import time
|
2024-09-13 15:03:55 +08:00
|
|
|
|
|
2024-09-18 11:57:17 +08:00
|
|
|
|
from flask_app.货物标.技术要求提取 import get_technical_requirements
|
|
|
|
|
from flask_app.main.通义千问long import upload_file
|
2024-09-23 15:49:30 +08:00
|
|
|
|
from 商务服务其他要求提取 import get_business_requirements
|
|
|
|
|
from flask_app.main.json_utils import nest_json_under_key
|
2024-09-13 15:03:55 +08:00
|
|
|
|
#获取采购清单
|
2024-09-23 15:49:30 +08:00
|
|
|
|
def fetch_procurement_reqs(truncate_file):
|
|
|
|
|
# 上传文件并获取 file_id
|
2024-09-18 11:57:17 +08:00
|
|
|
|
file_id = upload_file(truncate_file)
|
2024-09-23 15:49:30 +08:00
|
|
|
|
|
|
|
|
|
# 使用 ThreadPoolExecutor 并行处理 get_technical_requirements 和 get_business_requirements
|
|
|
|
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
|
|
|
# 提交任务给线程池
|
|
|
|
|
future_technical = executor.submit(get_technical_requirements, file_id)
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
future_business = executor.submit(get_business_requirements, truncate_file, file_id)
|
|
|
|
|
|
|
|
|
|
# 获取并行任务的结果
|
|
|
|
|
technical_requirements = future_technical.result()
|
|
|
|
|
business_requirements = future_business.result()
|
|
|
|
|
# 构建最终的嵌套结构,确保四个键平级
|
|
|
|
|
procurement_reqs = {
|
|
|
|
|
"技术要求": technical_requirements.get("技术要求", {}),
|
|
|
|
|
"商务要求": business_requirements.get("商务要求", {}),
|
|
|
|
|
"服务要求": business_requirements.get("服务要求", {}),
|
|
|
|
|
"其他要求": business_requirements.get("其他要求", {})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return procurement_reqs
|
2024-09-13 15:03:55 +08:00
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
output_folder = "C:\\Users\\Administrator\\Desktop\\货物标\\货物标output"
|
2024-10-15 20:57:58 +08:00
|
|
|
|
# file_path="C:\\Users\\Administrator\\Desktop\\货物标\\output1\\2-招标文件(2020年广水市中小学教师办公电脑系统及多媒体“班班通”设备采购安装项目)_procurement.pdf"
|
|
|
|
|
file_path="C:\\Users\\Administrator\\Desktop\\货物标\\output1\\磋商文件_procurement.pdf"
|
2024-09-23 15:49:30 +08:00
|
|
|
|
res=fetch_procurement_reqs(file_path)
|
|
|
|
|
print(json.dumps(res, ensure_ascii=False, indent=4))
|