This commit is contained in:
hsafaei
2026-02-17 18:07:16 +03:30
parent 9c99d816db
commit 3a57a2cfc2
8 changed files with 3850 additions and 3174 deletions
+77 -7
View File
@@ -7,7 +7,6 @@ import uuid
import pandas as pd
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")))
@@ -199,7 +198,7 @@ def import_project_to_elastic(
print(t2 - t1)
def import_tlist_projects():
def import_tlist_projects_to_gn_tree():
config_env = load_dotenv(dotenv_path="./config.env")
MYSQL_username = os.getenv("MYSQL_username")
@@ -255,6 +254,8 @@ def import_option_to_elastic(
index_name_o="gn_option",
):
res = get_options(main_key)
if not res :
res = get_options_2(main_key)
titles = []
for item in res :
title = item["value"]
@@ -273,6 +274,7 @@ def import_option_to_elastic(
"titles": titles,
}
elastic.es.index(index=index_name_o, id=eid, document=data)
return data
def import_option_base_list(elastic):
@@ -363,6 +365,69 @@ def import_option_base_list(elastic):
elastic, op["main_key"], op["main_label"], group_key, eid
)
def import_option_base_list_2(elastic):
op_list = [
{
"main_key": "receive_handle_type",
"main_label": "پرونده - اعلام وصول - نوع فوریت",
},
{
"main_key": "refer_commission_type",
"main_label": "پرونده - ارجاع - نوع کمیسیون",
},
{
"main_key": "commission_report_type",
"main_label": "پرونده - گزارش کمیسیون - نوع گزارش ",
},
{
"main_key": "parl_handle_info_type",
"main_label": "پرونده - اعلام وصول - نوع رسیدگی ",
},
{
"main_key": "parl_handle_demand_type",
"main_label": "پرونده - صحن - نوع تقاضاها ",
},
{
"main_key": "letter_result_type",
"main_label": "پرونده - ارسال و دریافت - نتیجه نامه ",
},
{
"main_key": "eblagh_qanon_time_type",
"main_label": "پرونده - نوع زمانی قانون (آزمایشی/موقت) ",
},
{
"main_key": "eblagh_qanon_template_type",
"main_label": "پرونده - نوع قالبی قانون ",
},
{
"main_key": "qasection_conformity",
"main_label": "پرونده - بررسی و تایید محتوا ",
},
{
"main_key": "qasection_eblagh_letters_type",
"main_label": "پرونده - ارسال و دریافت امضاء و انتشار ",
}
]
list_data = []
number = 0
for op in op_list:
number = number + 1
print(op["main_key"])
eid = "mb_op2_" + str(number)
group_key = "عناوین انتخابی فرمها"
if "group_key" in op:
group_key = op["group_key"]
_source = import_option_to_elastic(
elastic, op["main_key"], op["main_label"], group_key, eid
)
list_data.append({
'id': eid,
'_source' : _source
})
return list_data
def import_option_codes(elastic, index_name_o="gn_option"):
@@ -615,17 +680,22 @@ if __name__ == "__main__":
# ---مرحله اول
# import_tlist_projects()
# import_tlist_projects_to_gn_tree()
# import_option_base_list(elastic)
import_option_base_list(elastic)
# import_option_parleman_members(elastic)
import_option_parleman_members(elastic)
# import_option_codes(elastic)
import_option_codes(elastic)
# import_option_others(elastic)
import_option_others(elastic)
# elastic.backupIndexToZipfile("G:/Project2/111", "gn_tree", "gn_tree")
# elastic.backupIndexToZipfile("G:/Project2/111", "gn_option", "gn_option")
file_json = "app/../data/option_import_1.json"
list_data_import = import_option_base_list_2(elastic)
with open(file_json, "w", encoding="utf8") as f:
json.dump(list_data_import, f, ensure_ascii=False, indent=4)