feat: 2026-07-11 全量更新 - 代办集成+会议室预定+知识迭代修复+UI统一+Bug修复
== 已部署上线 (9项) == - 代办事项真实数据源集成 (企微审批API 8bug修复链) - H5/坐席端 Logo样式统一+绿色背景 - 视频引导页修复 (localStorage key v2) - 坐席端 v9 Vue版本修复 (ElMessage._context) - 截图按钮 v10 修复 (getDisplayMedia user gesture) - 扫码样式恢复+H5扫码登录跳转修复 - H5截图快捷键提示 == 代码完成待部署 (3项) == - 知识迭代3Bug修复 (#8 POST端点/#7 MERGE幂等/#6 过期检查) - 会议室预定-小鱼易联终端 (40文件, 40/40测试通过) - IT资产升级审批推送 (asset_service.py) == 需求文档 (2项) == - 坐席端AI辅助消息框-PRD (4项新功能确认) - 坐席端布局优化建议 v2.0 (7天计划) == 新增文档 == - 日报-2026-07-11.md - 知识迭代Bug修复报告-20260711.md - 会议室预定-部署指南.md - CHANGELOG.md 更新 == 测试 == - test_todo_integration.py: 40/40 - test_meetingroom.py: 40/40 - test_bugfix_ki_suggestions.py: 21/21
This commit is contained in:
+55
-7
@@ -89,7 +89,7 @@ async def lifespan(app: FastAPI):
|
||||
log_dir=settings.RUNTIME_LOG_DIR,
|
||||
)
|
||||
|
||||
logger.info("🚀 企微IT智能服务台启动中...")
|
||||
logger.info("🚀 智能IT服务平台启动中...")
|
||||
|
||||
# 校验关键配置项(防止生产环境忘记配置导致静默失败)
|
||||
_validate_config()
|
||||
@@ -107,12 +107,12 @@ async def lifespan(app: FastAPI):
|
||||
# 启动超时提醒定时任务
|
||||
_start_scheduler()
|
||||
|
||||
logger.info("✅ 企微IT智能服务台启动完成")
|
||||
logger.info("✅ 智能IT服务平台启动完成")
|
||||
|
||||
yield # 应用运行中
|
||||
|
||||
# ===== 关闭事件 =====
|
||||
logger.info("👋 企微IT智能服务台关闭中...")
|
||||
logger.info("👋 智能IT服务平台关闭中...")
|
||||
|
||||
# 停止超时提醒定时任务
|
||||
_stop_scheduler()
|
||||
@@ -120,7 +120,7 @@ async def lifespan(app: FastAPI):
|
||||
# 清理共享服务实例(关闭 Redis 连接、httpx 连接池等)
|
||||
await cleanup_shared_services()
|
||||
|
||||
logger.info("✅ 企微IT智能服务台已关闭")
|
||||
logger.info("✅ 智能IT服务平台已关闭")
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
@@ -130,6 +130,43 @@ async def lifespan(app: FastAPI):
|
||||
_scheduler = None
|
||||
|
||||
|
||||
async def expire_pending_suggestions():
|
||||
"""将超时未处理的 pending 建议标记为 expired。
|
||||
|
||||
扫描所有 status='pending' 且创建时间超过 72 小时的建议,
|
||||
将其状态更新为 expired(终态,不可逆)。
|
||||
|
||||
执行频率:每小时 1 次
|
||||
超时阈值:72 小时
|
||||
扫描范围:仅 status='pending'(不含 queued)
|
||||
"""
|
||||
from app.database import _get_session_factory
|
||||
|
||||
try:
|
||||
async_session_factory = _get_session_factory()
|
||||
async with async_session_factory() as db:
|
||||
# 将创建超过 72 小时的 pending 建议标记为 expired
|
||||
result = await db.execute(
|
||||
text(
|
||||
"UPDATE knowledge_suggestions "
|
||||
"SET status = 'expired', updated_at = NOW() "
|
||||
"WHERE status = 'pending' "
|
||||
"AND created_at < NOW() - INTERVAL '72 hours'"
|
||||
)
|
||||
)
|
||||
await db.commit()
|
||||
expired_count = result.rowcount
|
||||
if expired_count > 0:
|
||||
logger.info(
|
||||
f"⏰ 过期处理完成:{expired_count} 条 pending 建议已标记为 expired"
|
||||
f"(超时 72 小时)"
|
||||
)
|
||||
else:
|
||||
logger.debug("过期处理完成:无待过期的 pending 建议")
|
||||
except Exception as e:
|
||||
logger.error(f"过期处理定时任务执行失败: {e}")
|
||||
|
||||
|
||||
def _start_scheduler():
|
||||
"""启动定时任务调度器。
|
||||
|
||||
@@ -157,8 +194,19 @@ def _start_scheduler():
|
||||
replace_existing=True,
|
||||
)
|
||||
|
||||
# 注册过期处理任务(每 1 小时执行一次,将超时 72 小时的 pending 建议标记为 expired)
|
||||
_scheduler.add_job(
|
||||
expire_pending_suggestions,
|
||||
'interval',
|
||||
hours=1,
|
||||
id='expire_pending_suggestions',
|
||||
name='过期处理:超时72小时的pending建议标记为expired',
|
||||
replace_existing=True,
|
||||
)
|
||||
|
||||
_scheduler.start()
|
||||
logger.info("✅ 超时提醒定时任务已启动(每 30 秒执行一次)")
|
||||
logger.info("✅ 过期处理定时任务已启动(每 1 小时执行一次,超时阈值 72 小时)")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"启动定时任务调度器失败: {e}")
|
||||
@@ -518,7 +566,7 @@ async def _init_funny_phrases(db, FunnyPhrase):
|
||||
return
|
||||
|
||||
phrases = [
|
||||
FunnyPhrase(scene="shake", content="大哥,俺这就去摇人,稍等...", tone="亲切", sort_order=1),
|
||||
FunnyPhrase(scene="shake", content="少主,这就为您去摇人,稍等...", tone="亲切", sort_order=1),
|
||||
FunnyPhrase(scene="keyword", content="收到!这就帮您摇位大神来", tone="稍正式", sort_order=1),
|
||||
FunnyPhrase(scene="waiting", content="人还在路上,别急别急~", tone="安抚", sort_order=1),
|
||||
FunnyPhrase(scene="connected", content="人摇来了!IT坐席为您服务", tone="明确交接", sort_order=1),
|
||||
@@ -545,7 +593,7 @@ async def _init_quick_reply_templates(db, QuickReplyTemplate):
|
||||
|
||||
templates = [
|
||||
QuickReplyTemplate(category="账号", title="密码重置", content="您好{employee_name},您的密码重置链接已发送至您的企业邮箱,请在30分钟内完成操作。", variables=["employee_name"], sort_order=1),
|
||||
QuickReplyTemplate(category="账号", title="账号解锁", content="您好,您的账号已解锁,请5分钟后重新尝试登录。如仍有问题请联系IT服务台。", variables=[], sort_order=2),
|
||||
QuickReplyTemplate(category="账号", title="账号解锁", content="您好,您的账号已解锁,请5分钟后重新尝试登录。如仍有问题请联系智能IT服务台。", variables=[], sort_order=2),
|
||||
QuickReplyTemplate(category="网络", title="VPN连接指引", content="请按以下步骤操作:1.打开VPN客户端 2.选择\u201c公司内网\u201d 3.输入域账号密码 4.点击连接。详细图文教程请查看右侧\u201c操作步骤\u201d。", variables=[], sort_order=3),
|
||||
QuickReplyTemplate(category="网络", title="WiFi连接", content="公司WiFi名称:Office-5G,密码请咨询前台或查看工位标签。", variables=[], sort_order=4),
|
||||
QuickReplyTemplate(category="软件", title="软件安装申请", content="您好,软件安装需要提交审批申请。请在右侧\u201c审批流程\u201d中点击\u201c软件安装申请\u201d链接提交。", variables=[], sort_order=5),
|
||||
@@ -672,7 +720,7 @@ def create_app() -> FastAPI:
|
||||
# 创建 FastAPI 实例
|
||||
# lifespan: 应用生命周期管理(启动/关闭事件)
|
||||
app = FastAPI(
|
||||
title="企微IT智能服务台",
|
||||
title="智能IT服务平台",
|
||||
description="基于企微自建应用消息API的IT服务坐席系统",
|
||||
version="1.0.0",
|
||||
lifespan=lifespan,
|
||||
|
||||
Reference in New Issue
Block a user