fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解
This commit is contained in:
@@ -33,6 +33,7 @@ from apscheduler.triggers.interval import IntervalTrigger
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class WorkflowStatus(Enum):
|
||||
"""工作流状态"""
|
||||
|
||||
@@ -41,6 +42,7 @@ class WorkflowStatus(Enum):
|
||||
ERROR = "error"
|
||||
COMPLETED = "completed"
|
||||
|
||||
|
||||
class WorkflowType(Enum):
|
||||
"""工作流类型"""
|
||||
|
||||
@@ -50,6 +52,7 @@ class WorkflowType(Enum):
|
||||
SCHEDULED_REPORT = "scheduled_report" # 定时报告
|
||||
CUSTOM = "custom" # 自定义工作流
|
||||
|
||||
|
||||
class WebhookType(Enum):
|
||||
"""Webhook 类型"""
|
||||
|
||||
@@ -58,6 +61,7 @@ class WebhookType(Enum):
|
||||
SLACK = "slack"
|
||||
CUSTOM = "custom"
|
||||
|
||||
|
||||
class TaskStatus(Enum):
|
||||
"""任务执行状态"""
|
||||
|
||||
@@ -67,6 +71,7 @@ class TaskStatus(Enum):
|
||||
FAILED = "failed"
|
||||
CANCELLED = "cancelled"
|
||||
|
||||
|
||||
@dataclass
|
||||
class WorkflowTask:
|
||||
"""工作流任务定义"""
|
||||
@@ -90,6 +95,7 @@ class WorkflowTask:
|
||||
if not self.updated_at:
|
||||
self.updated_at = self.created_at
|
||||
|
||||
|
||||
@dataclass
|
||||
class WebhookConfig:
|
||||
"""Webhook 配置"""
|
||||
@@ -114,6 +120,7 @@ class WebhookConfig:
|
||||
if not self.updated_at:
|
||||
self.updated_at = self.created_at
|
||||
|
||||
|
||||
@dataclass
|
||||
class Workflow:
|
||||
"""工作流定义"""
|
||||
@@ -143,6 +150,7 @@ class Workflow:
|
||||
if not self.updated_at:
|
||||
self.updated_at = self.created_at
|
||||
|
||||
|
||||
@dataclass
|
||||
class WorkflowLog:
|
||||
"""工作流执行日志"""
|
||||
@@ -163,6 +171,7 @@ class WorkflowLog:
|
||||
if not self.created_at:
|
||||
self.created_at = datetime.now().isoformat()
|
||||
|
||||
|
||||
class WebhookNotifier:
|
||||
"""Webhook 通知器 - 支持飞书、钉钉、Slack"""
|
||||
|
||||
@@ -318,6 +327,7 @@ class WebhookNotifier:
|
||||
"""关闭 HTTP 客户端"""
|
||||
await self.http_client.aclose()
|
||||
|
||||
|
||||
class WorkflowManager:
|
||||
"""工作流管理器 - 核心管理类"""
|
||||
|
||||
@@ -1488,9 +1498,11 @@ class WorkflowManager:
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
# Singleton instance
|
||||
_workflow_manager = None
|
||||
|
||||
|
||||
def get_workflow_manager(db_manager=None) -> WorkflowManager:
|
||||
"""获取 WorkflowManager 单例"""
|
||||
global _workflow_manager
|
||||
|
||||
Reference in New Issue
Block a user