```
feat: 添加生命周期报告和AI规则管理功能 - 在Dockerfile中添加pillow依赖包用于图像处理 - 实现生命周期报告调度任务,支持日报和周报两种类型 - 新增TASK_RUN_LIFECYCLE任务常量和相关配置选项 - 扩展AI Agent服务以支持用户规则,并在分析时应用规则 - 添加AI用户规则创建、更新和查询接口 - 增加项目生命周期和财务需求分析技能 - 扩展现有模型以支持更完整的业务数据字段 - 实现飞书图片上传功能用于报告展示 ```
This commit is contained in:
@@ -5,10 +5,12 @@ from app.core.background.task_queue.constants import (
|
||||
TASK_PUSH_PROJECT_WEEKLY,
|
||||
TASK_SYNC_LEGACY_PROJECTS,
|
||||
TASK_SYNC_LEGACY_TASKS,
|
||||
TASK_RUN_LIFECYCLE,
|
||||
)
|
||||
from app.core.background.task_queue.dispatcher import dispatch_task
|
||||
from app.core.background.task_queue.events import enqueue_event_dispatch
|
||||
from app.core.background.task_queue.legacy import enqueue_legacy_project_sync, enqueue_legacy_task_sync
|
||||
from app.core.background.task_queue.lifecycle import enqueue_lifecycle_report
|
||||
from app.core.background.task_queue.reports import enqueue_daily_brief_push, enqueue_project_weekly_push
|
||||
from app.core.background.task_queue.risk import enqueue_risk_event_generation
|
||||
|
||||
@@ -20,11 +22,13 @@ __all__ = [
|
||||
"TASK_PUSH_PROJECT_WEEKLY",
|
||||
"TASK_SYNC_LEGACY_PROJECTS",
|
||||
"TASK_SYNC_LEGACY_TASKS",
|
||||
"TASK_RUN_LIFECYCLE",
|
||||
"dispatch_task",
|
||||
"enqueue_daily_brief_push",
|
||||
"enqueue_event_dispatch",
|
||||
"enqueue_legacy_project_sync",
|
||||
"enqueue_legacy_task_sync",
|
||||
"enqueue_lifecycle_report",
|
||||
"enqueue_project_weekly_push",
|
||||
"enqueue_risk_event_generation",
|
||||
]
|
||||
|
||||
@@ -4,3 +4,4 @@ TASK_GENERATE_RISK_EVENTS = "risks.generate_events"
|
||||
TASK_SYNC_LEGACY_PROJECTS = "legacy.sync_projects"
|
||||
TASK_SYNC_LEGACY_TASKS = "legacy.sync_tasks"
|
||||
TASK_DISPATCH_PENDING_EVENTS = "events.dispatch_pending"
|
||||
TASK_RUN_LIFECYCLE = "reports.run_lifecycle"
|
||||
|
||||
50
app/core/background/task_queue/lifecycle.py
Normal file
50
app/core/background/task_queue/lifecycle.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from typing import Any
|
||||
|
||||
from app.core.background.task_queue.constants import TASK_RUN_LIFECYCLE
|
||||
from app.core.config import get_settings
|
||||
from app.core.constants import ActorValue
|
||||
from app.core.database import SessionLocal
|
||||
from app.modules.reports.lifecycle_pipeline import LifecyclePipelineService
|
||||
|
||||
|
||||
def enqueue_lifecycle_report(
|
||||
report_type: str,
|
||||
receive_id: str | None = None,
|
||||
receive_id_type: str = "chat_id",
|
||||
force: bool = False,
|
||||
actor: str = ActorValue.SCHEDULER,
|
||||
) -> dict[str, Any]:
|
||||
db = SessionLocal()
|
||||
try:
|
||||
service = LifecyclePipelineService(db)
|
||||
workflow, period_key, deduplicated = service.prepare(report_type, actor, force)
|
||||
if deduplicated:
|
||||
return {
|
||||
"workflow_code": workflow.code,
|
||||
"period_key": period_key,
|
||||
"deduplicated": True,
|
||||
"status": workflow.status,
|
||||
}
|
||||
if get_settings().task_queue_enabled:
|
||||
from app.tasks import celery_app
|
||||
|
||||
result = celery_app.signature(
|
||||
TASK_RUN_LIFECYCLE,
|
||||
kwargs={
|
||||
"report_type": report_type,
|
||||
"receive_id": receive_id,
|
||||
"receive_id_type": receive_id_type,
|
||||
"force": force,
|
||||
"actor": actor,
|
||||
},
|
||||
).apply_async()
|
||||
return {
|
||||
"workflow_code": workflow.code,
|
||||
"period_key": period_key,
|
||||
"task_id": result.id,
|
||||
"deduplicated": False,
|
||||
"status": "queued",
|
||||
}
|
||||
return service.run(report_type, receive_id, receive_id_type, force, actor)
|
||||
finally:
|
||||
db.close()
|
||||
Reference in New Issue
Block a user