feat: Add AI report generation with DIFY integration

- Add Users table for display name resolution from AD authentication
- Integrate DIFY AI service for report content generation
- Create docx assembly service with image embedding from MinIO
- Add REST API endpoints for report generation and download
- Add WebSocket notifications for generation progress
- Add frontend UI with progress modal and download functionality
- Add integration tests for report generation flow

Report sections (Traditional Chinese):
- 事件摘要 (Summary)
- 時間軸 (Timeline)
- 參與人員 (Participants)
- 處理過程 (Resolution Process)
- 目前狀態 (Current Status)
- 最終處置結果 (Final Resolution)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
egg
2025-12-04 18:32:40 +08:00
parent 77091eefb5
commit 3927441103
32 changed files with 4374 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
資料表結構:
- user_sessions: 儲存使用者 session 資料,包含加密密碼用於自動刷新
- users: 永久儲存使用者資訊 (用於報告生成時的姓名解析)
"""
from sqlalchemy import Column, Integer, String, DateTime, Index
from datetime import datetime
@@ -29,3 +30,39 @@ class UserSession(Base):
DateTime, default=datetime.utcnow, nullable=False, comment="Last API request time"
)
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
class User(Base):
"""Permanent user information for display name resolution in reports
This table stores user information from AD API and persists even after
session expiration. Used for:
- Displaying user names (instead of emails) in generated reports
- Tracking user metadata (office location, job title)
"""
__tablename__ = "users"
user_id = Column(
String(255), primary_key=True, comment="User email address (e.g., ymirliu@panjit.com.tw)"
)
display_name = Column(
String(255), nullable=False, comment="Display name from AD (e.g., 'ymirliu 劉念蓉')"
)
office_location = Column(
String(100), nullable=True, comment="Office location from AD (e.g., '高雄')"
)
job_title = Column(
String(100), nullable=True, comment="Job title from AD"
)
last_login_at = Column(
DateTime, nullable=True, comment="Last login timestamp"
)
created_at = Column(
DateTime, default=datetime.utcnow, nullable=False, comment="First login timestamp"
)
# Indexes
__table_args__ = (
Index("ix_users_display_name", "display_name"),
)