feat 🐛:1

v2025-07-15-table
许标 6 months ago
parent 0535bda51a
commit 1daa07176e

Binary file not shown.

@ -215,7 +215,7 @@ def deal_excel_over_load(file_path):
else:
overload_top5_list.append(need_final_output[i])
if count >0 :
overload_top5_list.append([f"其他{count + other_count}供电局",overload_value])
overload_top5_list.append([f"其他{count + other_count}家单位",overload_value])
return overload_top5_list
except Exception as e:
logger.exception(f"对数据按照’省‘进行分类汇总{e}")

@ -8,7 +8,7 @@ from fastapi import HTTPException
from fastapi.responses import JSONResponse
from docx import Document
from pathlib import Path
from datetime import datetime
from datetime import datetime, date
from docx.shared import Inches, Pt
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
@ -628,6 +628,7 @@ def deal_docx(folder_path, save_path=None, time_type=0,over_load_value=0):
replacements = {}
if time_type == 0:
# 组装替换的文本
day_cycle = getDayCycle(year,month,day)
replacements = {
"{{year}}": year,
"{{month}}": month,
@ -641,10 +642,12 @@ def deal_docx(folder_path, save_path=None, time_type=0,over_load_value=0):
"{{sentiment}}": doc_dict["sentiment_para"],
"{{sentiment_trend}}": doc_dict["sentiment_trend"],
"{{exception}}": electricity_exception,
"{{period}}": str(day_cycle),
}
elif time_type == 1:
# 组装替换的文本
day_cycle = getDayCycle(year_now,month_now,day_now)
replacements = {
"{{year}}": str(year_now),
"{{month}}": str(month_now),
@ -658,6 +661,7 @@ def deal_docx(folder_path, save_path=None, time_type=0,over_load_value=0):
"{{sentiment}}": doc_dict["sentiment_para"],
"{{sentiment_trend}}": doc_dict["sentiment_trend"],
"{{exception}}": electricity_exception,
"{{period}}": str(day_cycle),
}
# 组装日报
@ -875,6 +879,17 @@ def delete_old_file(file):
logger.info(f"删除旧文件失败:{e}")
def getDayCycle(year_str,month_str,day_str):
year = int(year_str)
month = int(month_str)
day = int(day_str)
# 创建日期对象
d = date(year, month, day)
# 获取是今年的第几天
day_of_year = d.timetuple().tm_yday-1
print(f"{year}{month}{day}日是今年的第 {day_of_year} 天。")
return day_of_year
# if __name__ == '__main__':
# folder_path = 'E:/work_data/work/三工单日报/20250310/20250310'
#

@ -19,3 +19,12 @@
5) tools/replace_text.py
6) tools/style.py
# 2025-07-29
1) tools/final_doc.py
2) tools/deal_excels.py
3) tools/count_data.py
# 2025-08-04
1) tools/deal_excels.py
2) tools/final_doc.py
3) 日报模块

Loading…
Cancel
Save