xuyonghao
2024-12-30 c273539ea3b191ee680921ef5d09477a770cd644
app/utils/excelmerge/conformity.py
@@ -2,8 +2,6 @@
import random
import shutil
import string
import threading
import time
from datetime import datetime
from openpyxl import load_workbook
@@ -27,17 +25,16 @@
def delete_file_after_delay(file_path, delay_minutes):
    delay_seconds = delay_minutes * 60
    from main import scheduler
    def delete_file():
        time.sleep(delay_seconds)
        try:
            if os.path.exists(file_path):
                os.remove(file_path)
        except Exception as e:
            logger.error(f"定时删除Excel文件时发生错误: {e}")
    threading.Thread(target=delete_file).start()
    scheduler.add_job(delete_file, 'interval', minutes=delay_minutes, id=f"delete_{file_path}")
def run_conformity(file_path, print_path):
@@ -82,7 +79,7 @@
        template_excel.save(output_path)
        template_excel.close()
        delete_file_after_delay(output_path, 5)
        delete_file_after_delay(output_path, 3)
        try:
            for filename in os.listdir(file_path):