|
|
|
@ -10,10 +10,10 @@ from docx import Document
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
from docx.shared import Inches, Pt
|
|
|
|
|
from app.tools.deal_excels import deal_excel, top5_dod_analysis, transform_data
|
|
|
|
|
from app.tools.deal_excels import deal_excel, top5_dod_analysis, transform_data, deal_excel_over_load
|
|
|
|
|
from app.tools.get_time import get_time
|
|
|
|
|
from app.tools.replace_text import replace_text_in_docx
|
|
|
|
|
from app.tools.replace_table import copy_table, copy_sta_table, copy_table_no_align
|
|
|
|
|
from app.tools.replace_table import copy_table, copy_sta_table
|
|
|
|
|
from app.tools.style import table_style
|
|
|
|
|
from app.tools.effective_date import get_next_day
|
|
|
|
|
from app.tools.find_before_word import extract_overload_info_from_previous_day
|
|
|
|
@ -61,8 +61,12 @@ def deal_docx(folder_path, save_path=None, time_type=0):
|
|
|
|
|
file_path_dict["power_off_excel"] = folder_path + "/" + file
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if file.endswith(".xlsx") and "停电报表配变明细" in file:
|
|
|
|
|
file_path_dict["over_load_excel"] = folder_path + "/" + file
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
# 如果传入的文件不对,抛出异常
|
|
|
|
|
if len(file_path_dict) != 3:
|
|
|
|
|
if len(file_path_dict) != 4:
|
|
|
|
|
logger.exception("文件格式错误")
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=400,
|
|
|
|
@ -113,9 +117,9 @@ def deal_docx(folder_path, save_path=None, time_type=0):
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
# 第二点过载台数
|
|
|
|
|
if re.search(r"过载(\d+)[条台]", para.text):
|
|
|
|
|
if re.search(r"过载(\d+)(?:[条台]|\s*)?", para.text):
|
|
|
|
|
doc_dict["over_load"] = (
|
|
|
|
|
re.search(r"过载(\d+)[条台]", para.text).group().replace("过载", "")
|
|
|
|
|
re.search(r"过载(\d+)(?:[条台]|\s*)?", para.text).group().replace("过载", "")
|
|
|
|
|
).replace("条", "").replace("台", "")
|
|
|
|
|
# print(doc_dict['over_load'])
|
|
|
|
|
continue
|
|
|
|
@ -365,10 +369,10 @@ def deal_docx(folder_path, save_path=None, time_type=0):
|
|
|
|
|
standardize_date = (
|
|
|
|
|
f"{month_before}月{day_before}日17时至{month}月{day}日17时期间,"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
elif time_type == 1:
|
|
|
|
|
# -------------------------20250429更新,修改开始和结束时间---------------------------------
|
|
|
|
|
standardize_date = f"{year}年{month}月{day}日0时至24时期间,"
|
|
|
|
|
#standardize_date = f"{year}年{month}月{day}日0时至24时期间,"
|
|
|
|
|
standardize_date = f"{month}月{day}日0时至24时期间,"
|
|
|
|
|
# standardize_date = ''
|
|
|
|
|
# -------------------------20250429更新,修改开始和结束时间---------------------------------
|
|
|
|
|
|
|
|
|
@ -596,7 +600,8 @@ def deal_docx(folder_path, save_path=None, time_type=0):
|
|
|
|
|
|
|
|
|
|
# 将数据组装相关的时间内容
|
|
|
|
|
doc_dict["first_point_para1"] = standardize_date + doc_dict["first_point_para1"]
|
|
|
|
|
doc_dict["sentiment_para"] = standardize_date + doc_dict["sentiment_para"]
|
|
|
|
|
#doc_dict["sentiment_para"] = standardize_date + doc_dict["sentiment_para"]
|
|
|
|
|
doc_dict["sentiment_para"] = doc_dict["sentiment_para"]
|
|
|
|
|
|
|
|
|
|
# {{standardize_date}}全网收到{{complain_num}}条供电类投诉,环比{{complain_dod}}条;
|
|
|
|
|
complain_text = (
|
|
|
|
@ -766,6 +771,21 @@ def deal_docx(folder_path, save_path=None, time_type=0):
|
|
|
|
|
is_dynamics=False
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
logger.info("将配变重过载的数据插入表格5")
|
|
|
|
|
# 统计配变过载前五的数据
|
|
|
|
|
top_5_results = deal_excel_over_load(file_path_dict["over_load_excel"])
|
|
|
|
|
# 表4中的插入位置
|
|
|
|
|
start_tb4_row = 2
|
|
|
|
|
start_tb4_col = 8
|
|
|
|
|
if not top_5_results.empty:
|
|
|
|
|
data = top_5_results.values
|
|
|
|
|
copy_sta_table(
|
|
|
|
|
electricity_daily.tables[1],
|
|
|
|
|
data,
|
|
|
|
|
start_tb4_row,
|
|
|
|
|
start_tb4_col,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# copy_sta_table(electricity_daily.tables[3], top5_list, start_tb4_row, start_tb4_col)
|
|
|
|
|
|
|
|
|
|
# 将表格中的字体中文设置成仿宋,英文数字设置成新罗马,均为11号大小
|
|
|
|
|