2024-11-04 10:52:23 +08:00
|
|
|
|
# -*- encoding:utf-8 -*-
|
2024-10-22 10:06:22 +08:00
|
|
|
|
import ast
|
2024-11-04 10:52:23 +08:00
|
|
|
|
import json
|
2024-10-22 10:06:22 +08:00
|
|
|
|
import re
|
2024-11-04 10:52:23 +08:00
|
|
|
|
from collections import OrderedDict
|
2024-10-22 10:06:22 +08:00
|
|
|
|
|
2024-10-30 20:41:19 +08:00
|
|
|
|
from flask_app.general.json_utils import clean_json_string
|
|
|
|
|
from flask_app.general.多线程提问 import multi_threading
|
|
|
|
|
from flask_app.general.通义千问long import upload_file
|
|
|
|
|
from flask_app.main.判断是否分包等 import read_questions_from_judge
|
|
|
|
|
|
2024-11-04 17:13:06 +08:00
|
|
|
|
def process_judge_questions(judge_file_path, chosen_numbers, merged_baseinfo_path, baseinfo_list1):
|
2024-10-30 20:41:19 +08:00
|
|
|
|
judge_questions = read_questions_from_judge(judge_file_path, chosen_numbers)
|
|
|
|
|
judge_consortium = judge_consortium_bidding(baseinfo_list1)
|
|
|
|
|
if judge_consortium:
|
|
|
|
|
judge_consortium_question = (
|
|
|
|
|
"该招标文件对于联合体投标的要求是怎样的,请按json格式给我提供信息,"
|
|
|
|
|
"外层键名为'联合体投标要求',其中有一个嵌套键值对为:\"是否接受联合体投标\":\"是\""
|
|
|
|
|
)
|
|
|
|
|
judge_questions.append(judge_consortium_question)
|
2024-11-04 17:13:06 +08:00
|
|
|
|
file_id3 = upload_file(merged_baseinfo_path)
|
2024-10-30 20:41:19 +08:00
|
|
|
|
res2 = multi_threading(judge_questions, "", file_id3, 2)
|
|
|
|
|
|
|
|
|
|
if not res2:
|
|
|
|
|
print("基础信息整合: multi_threading error!")
|
|
|
|
|
else:
|
|
|
|
|
for question, response in res2:
|
|
|
|
|
baseinfo_list1.append(clean_json_string(response))
|
2024-10-22 10:06:22 +08:00
|
|
|
|
|
|
|
|
|
def judge_consortium_bidding(baseinfo_list):
|
|
|
|
|
updated_list = []
|
|
|
|
|
accept_bidding = False
|
|
|
|
|
for baseinfo in baseinfo_list:
|
|
|
|
|
# 检查 "是否接受联合体投标" 键是否存在且其值为 "是"
|
|
|
|
|
if "是否接受联合体投标" in baseinfo and baseinfo["是否接受联合体投标"] == "是":
|
|
|
|
|
accept_bidding = True
|
|
|
|
|
# 从字典中移除特定键值对
|
|
|
|
|
baseinfo.pop("是否接受联合体投标", None)
|
|
|
|
|
# # 将修改后的 json 数据转换回 JSON 字符串(如果需要)
|
|
|
|
|
# updated_info = json.dumps(json_data)
|
|
|
|
|
updated_list.append(baseinfo)
|
|
|
|
|
# 更新原始列表,如果你想保留修改
|
|
|
|
|
baseinfo_list[:] = updated_list
|
|
|
|
|
return accept_bidding
|
|
|
|
|
|
|
|
|
|
def process_string_list(string_list):
|
|
|
|
|
# 使用正则表达式匹配方括号内的内容
|
|
|
|
|
match = re.search(r'\[(.*?)\]', string_list)
|
|
|
|
|
if match:
|
|
|
|
|
# 获取匹配的内容,即方括号内的部分
|
|
|
|
|
content_inside_brackets = match.group(1)
|
|
|
|
|
if content_inside_brackets: # 检查内容是否为空
|
|
|
|
|
# 检查内容是否是数字列表
|
|
|
|
|
if all(item.strip().isdigit() for item in content_inside_brackets.split(',')):
|
|
|
|
|
# 如果是数字,不用加引号,直接保留数字
|
|
|
|
|
formatted_list = '[' + ', '.join(item.strip() for item in content_inside_brackets.split(',') if item.strip()) + ']'
|
|
|
|
|
else:
|
|
|
|
|
# 如果不全是数字,按字符串处理
|
|
|
|
|
formatted_list = '[' + ', '.join(f"'{item.strip()}'" for item in content_inside_brackets.split(',') if item.strip()) + ']'
|
|
|
|
|
else:
|
|
|
|
|
return [] # 直接返回空列表如果内容为空
|
|
|
|
|
|
|
|
|
|
# 使用 ast.literal_eval 来解析格式化后的字符串
|
|
|
|
|
try:
|
|
|
|
|
actual_list = ast.literal_eval(formatted_list)
|
|
|
|
|
return actual_list
|
|
|
|
|
except SyntaxError as e:
|
|
|
|
|
print(f"禁止投标情形: Error parsing list: {e}")
|
|
|
|
|
return []
|
|
|
|
|
else:
|
|
|
|
|
# 如果没有匹配到内容,返回空列表
|
2024-11-04 10:52:23 +08:00
|
|
|
|
return []
|
|
|
|
|
|