|
@@ -24,12 +24,15 @@ import requests
|
|
|
import json
|
|
|
import os
|
|
|
import paramiko
|
|
|
-import zipfile
|
|
|
+import zipfile, traceback
|
|
|
+from flask import Flask, request, jsonify
|
|
|
from datetime import datetime, timedelta
|
|
|
from typing import Optional
|
|
|
from pytz import timezone
|
|
|
-import shutil
|
|
|
+import shutil, time
|
|
|
import tempfile
|
|
|
+app = Flask('pre_prod_ftp——service')
|
|
|
+
|
|
|
api_url = 'http://itil.jiayuepowertech.com:9958/itil/api/stationModelConfig'
|
|
|
nick_name = {
|
|
|
'0': 'seer',
|
|
@@ -329,7 +332,7 @@ def configure_scheduler():
|
|
|
|
|
|
# 配置第一个触发器:处理每个主小时段的前 60 分钟(0-50 分钟)
|
|
|
trigger1 = CronTrigger(
|
|
|
- hour='0,6,12,18', # 主触发小时
|
|
|
+ hour='23,5,11,17', # 主触发小时
|
|
|
minute='0-50/10', # 每 10 分钟一次,覆盖 00:00-00:50
|
|
|
timezone='Asia/Shanghai' # 按需设置时区
|
|
|
)
|
|
@@ -344,6 +347,31 @@ def configure_scheduler():
|
|
|
except (KeyboardInterrupt, SystemExit):
|
|
|
logger.info("⏹️ 定时任务已停止")
|
|
|
|
|
|
+
|
|
|
+@app.route('/pre_prod_ftp', methods=['POST'])
|
|
|
+def pre_prod_ftp():
|
|
|
+ # 获取程序开始时间
|
|
|
+ start_time = time.time()
|
|
|
+ result = {}
|
|
|
+ success = 0
|
|
|
+ args = {}
|
|
|
+ try:
|
|
|
+ target_job()
|
|
|
+ success = 1
|
|
|
+ except Exception as e:
|
|
|
+ my_exception = traceback.format_exc()
|
|
|
+ my_exception.replace("\n", "\t")
|
|
|
+ result['msg'] = my_exception
|
|
|
+ logger.info("生产文件下发ftp出错:{}".format(my_exception))
|
|
|
+ end_time = time.time()
|
|
|
+ result['success'] = success
|
|
|
+ result['args'] = args
|
|
|
+ result['start_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
|
|
|
+ result['end_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))
|
|
|
+ return result
|
|
|
+
|
|
|
+
|
|
|
if __name__ == "__main__":
|
|
|
configure_scheduler()
|
|
|
- # target_job()
|
|
|
+ from waitress import serve
|
|
|
+ serve(app, host="0.0.0.0", port=10118)
|