|
|
|
@ -8,7 +8,7 @@ from fastapi import HTTPException
|
|
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from docx import Document
|
|
|
|
from docx import Document
|
|
|
|
from pathlib import Path
|
|
|
|
from pathlib import Path
|
|
|
|
from datetime import datetime
|
|
|
|
from datetime import datetime, date
|
|
|
|
from docx.shared import Inches, Pt
|
|
|
|
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.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.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 = {}
|
|
|
|
replacements = {}
|
|
|
|
if time_type == 0:
|
|
|
|
if time_type == 0:
|
|
|
|
# 组装替换的文本
|
|
|
|
# 组装替换的文本
|
|
|
|
|
|
|
|
day_cycle = getDayCycle(year,month,day)
|
|
|
|
replacements = {
|
|
|
|
replacements = {
|
|
|
|
"{{year}}": year,
|
|
|
|
"{{year}}": year,
|
|
|
|
"{{month}}": month,
|
|
|
|
"{{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}}": doc_dict["sentiment_para"],
|
|
|
|
"{{sentiment_trend}}": doc_dict["sentiment_trend"],
|
|
|
|
"{{sentiment_trend}}": doc_dict["sentiment_trend"],
|
|
|
|
"{{exception}}": electricity_exception,
|
|
|
|
"{{exception}}": electricity_exception,
|
|
|
|
|
|
|
|
"{{period}}": str(day_cycle),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
elif time_type == 1:
|
|
|
|
elif time_type == 1:
|
|
|
|
# 组装替换的文本
|
|
|
|
# 组装替换的文本
|
|
|
|
|
|
|
|
day_cycle = getDayCycle(year_now,month_now,day_now)
|
|
|
|
replacements = {
|
|
|
|
replacements = {
|
|
|
|
"{{year}}": str(year_now),
|
|
|
|
"{{year}}": str(year_now),
|
|
|
|
"{{month}}": str(month_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}}": doc_dict["sentiment_para"],
|
|
|
|
"{{sentiment_trend}}": doc_dict["sentiment_trend"],
|
|
|
|
"{{sentiment_trend}}": doc_dict["sentiment_trend"],
|
|
|
|
"{{exception}}": electricity_exception,
|
|
|
|
"{{exception}}": electricity_exception,
|
|
|
|
|
|
|
|
"{{period}}": str(day_cycle),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# 组装日报
|
|
|
|
# 组装日报
|
|
|
|
@ -875,6 +879,17 @@ def delete_old_file(file):
|
|
|
|
logger.info(f"删除旧文件失败:{e}")
|
|
|
|
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__':
|
|
|
|
# if __name__ == '__main__':
|
|
|
|
# folder_path = 'E:/work_data/work/三工单日报/20250310/20250310'
|
|
|
|
# folder_path = 'E:/work_data/work/三工单日报/20250310/20250310'
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|