feat: 添加生命周期报告和AI规则管理功能 - 在Dockerfile中添加pillow依赖包用于图像处理 - 实现生命周期报告调度任务,支持日报和周报两种类型 - 新增TASK_RUN_LIFECYCLE任务常量和相关配置选项 - 扩展AI Agent服务以支持用户规则,并在分析时应用规则 - 添加AI用户规则创建、更新和查询接口 - 增加项目生命周期和财务需求分析技能 - 扩展现有模型以支持更完整的业务数据字段 - 实现飞书图片上传功能用于报告展示 ```
58 lines
3.3 KiB
Python
58 lines
3.3 KiB
Python
from datetime import date, datetime
|
|
|
|
from sqlalchemy import Boolean, JSON, Date, DateTime, Integer, String, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.constants import ActorValue
|
|
from app.core.database import Base
|
|
from app.core.utils.time import utc_now
|
|
from app.modules.business.constants import (
|
|
SourceSystem,
|
|
StatusValue,
|
|
)
|
|
from app.modules.business.models.common import TimestampMixin
|
|
|
|
|
|
class WorkReport(Base, TimestampMixin):
|
|
__tablename__ = "work_reports"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
code: Mapped[str] = mapped_column(String(64), unique=True, index=True)
|
|
report_type: Mapped[str] = mapped_column(String(32), index=True)
|
|
title: Mapped[str] = mapped_column(String(255), index=True)
|
|
reporter: Mapped[str] = mapped_column(String(128), default=ActorValue.SYSTEM, index=True)
|
|
department: Mapped[str | None] = mapped_column(String(128), nullable=True, index=True)
|
|
project_code: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
|
|
period_start: Mapped[date] = mapped_column(Date, index=True)
|
|
period_end: Mapped[date] = mapped_column(Date, index=True)
|
|
content: Mapped[str] = mapped_column(Text)
|
|
metrics: Mapped[dict | None] = mapped_column(JSON, nullable=True)
|
|
risk_summary: Mapped[dict | None] = mapped_column(JSON, nullable=True)
|
|
status: Mapped[str] = mapped_column(String(64), default=StatusValue.GENERATED, index=True)
|
|
source_system: Mapped[str] = mapped_column(String(64), default=SourceSystem.INTERNAL)
|
|
employee_code: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
|
|
external_id: Mapped[str | None] = mapped_column(String(128), nullable=True, index=True)
|
|
is_late: Mapped[bool] = mapped_column(Boolean, default=False, index=True)
|
|
is_draft: Mapped[bool] = mapped_column(Boolean, default=False, index=True)
|
|
source_updated_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, index=True)
|
|
last_seen_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, index=True)
|
|
is_active: Mapped[bool] = mapped_column(Boolean, default=True, index=True)
|
|
|
|
class ReportPushRun(Base, TimestampMixin):
|
|
__tablename__ = "report_push_runs"
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
code: Mapped[str] = mapped_column(String(64), unique=True, index=True)
|
|
report_type: Mapped[str] = mapped_column(String(64), index=True)
|
|
title: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
receive_id: Mapped[str | None] = mapped_column(String(128), nullable=True, index=True)
|
|
receive_id_type: Mapped[str] = mapped_column(String(64), index=True)
|
|
status: Mapped[str] = mapped_column(String(32), index=True)
|
|
task_id: Mapped[str | None] = mapped_column(String(128), nullable=True, index=True)
|
|
actor: Mapped[str] = mapped_column(String(128), default=ActorValue.SYSTEM, index=True)
|
|
provider_response: Mapped[dict | None] = mapped_column(JSON, nullable=True)
|
|
error_message: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
queued_at: Mapped[datetime] = mapped_column(DateTime, default=utc_now, index=True)
|
|
sent_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
|
idempotency_key: Mapped[str | None] = mapped_column(String(128), nullable=True, unique=True, index=True)
|