Files
wecom_it_smart_desk/docs/IT服务台部署修复记录-2026-06-13.md
T

185 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# IT智能服务台 - 部署修复记录
**日期**2026-06-13
**负责人**:宋献
**状态**:待部署验证
---
## 一、问题概述
### 1.1 部署后 H5 用户端报错
```
POST /api/h5/conversations/current/messages 返回 500 错误:
- 错误1column conversations.impact_scope does not exist
- 错误2AIHandler.__init__() missing 1 required positional argument: 'ai_service'
```
### 1.2 影响范围
| 系统 | 影响 | 说明 |
|------|------|------|
| H5 用户端 | 阻塞 | 无法发送消息触发 AI 回复 |
| Dify AI | 无法测试 | 依赖 H5 消息发送 |
| 管理后台 | 已修复 | admin001 已设为管理员 |
---
## 二、根因分析
### 2.1 数据库缺列
服务器上数据库 `conversations` 表缺少4个新增列:
- `impact_scope` — 影响范围
- `is_blocking` — 是否阻塞
- `emotion_state` — 情绪状态
- `dify_conversation_id` — Dify 会话ID
### 2.2 AIHandler 初始化错误
代码重构后 `AIHandler.__init__` 需要传入 `AIService` 实例,但 `dependencies.py` 中两处调用仍使用无参构造函数:
```python
# 错误代码
return AIHandler()
# 正确代码
return AIHandler(ai_service=AIService())
```
---
## 三、修复内容
### 3.1 数据库修复(已完成)
```sql
ALTER TABLE conversations ADD COLUMN IF NOT EXISTS impact_scope VARCHAR(50);
ALTER TABLE conversations ADD COLUMN IF NOT EXISTS is_blocking BOOLEAN DEFAULT false;
ALTER TABLE conversations ADD COLUMN IF NOT EXISTS emotion_state VARCHAR(50);
ALTER TABLE conversations ADD COLUMN IF NOT EXISTS dify_conversation_id VARCHAR(255);
```
### 3.2 代码修复
**文件**`backend/app/dependencies.py`
**修复内容**2处 AIHandler 调用补上 ai_service 参数
| 位置 | 修复前 | 修复后 |
|------|--------|--------|
| get_shared_ai_handler() | `return AIHandler()` | `return AIHandler(ai_service=AIService())` |
| dep_ai_handler() | `return AIHandler()` | `return AIHandler(ai_service=AIService())` |
---
## 四、部署步骤
### 4.1 本地打包
```powershell
cd D:\资料\03-项目开发\wecom_it_smart_desk\deploy-server
.\打包部署.bat
```
生成文件:
- `it-smart-desk-server-deploy.zip` — 前端+nginx+docker-compose
- `deploy-backend.tar` — 后端 Docker 镜像(含修复)
### 4.2 上传服务器
通过堡垒机将文件上传到服务器 `/tmp/`
- `it-smart-desk-server-deploy.zip`
- `deploy-backend.tar`
### 4.3 服务器部署
```bash
# 1. 加载后端镜像
docker load -i /tmp/deploy-backend.tar
# 2. 重启后端容器
docker stop wecom_it_backend && docker rm wecom_it_backend
docker run -d --name wecom_it_backend ... (原启动命令)
# 3. 验证后端健康
curl https://itsupport.servyou.com.cn/health
```
---
## 五、验证检查项
### 5.1 后端健康检查
```bash
curl https://itsupport.servyou.com.cn/health
# 预期返回:{"status":"ok"}
```
### 5.2 H5 消息发送测试
1. H5 Mock 登录:`POST /api/h5/mock-login`
2. 发送消息:`POST /api/h5/conversations/current/messages`
3. 预期:返回 AI 回复(调用 Dify 成功)
### 5.3 Dify AI 集成状态
管理后台 → 集成配置 → Dify AI 状态应为 `connected`
---
## 六、相关配置
### 6.1 服务器信息
| 项目 | 值 |
|------|------|
| 服务器 IP | 10.90.5.110 |
| 域名 | itsupport.servyou.com.cn |
| WAF | 115.236.188.3 |
### 6.2 企微配置
| 项目 | 值 |
|------|------|
| CorpID | wwa8c87970b2011f41 |
| AgentID | 1000133 |
| Token | wAqMCP |
| EncodingAESKey | KQY3cEsBc3rdi3xua9rPd5WxH8kYOhyASzWZQf75aJS |
### 6.3 Dify 配置
| 项目 | 值 |
|------|------|
| API URL | http://yw-dify.dc.servyou-it.com/dify2openai/v1/chat/completions |
| API Key | http://yw-dify.dc.servyou-it.com/v1\|app-UaTWYdBSwN6VktKQlbh5YN5H\|Chat |
### 6.4 数据库配置
| 项目 | 值 |
|------|------|
| 数据库 | PostgreSQL |
| 库名 | wecom_it_desk |
| 用户 | wecom |
| 密码 | wecom_secret_2026 |
---
## 七、相关文件
| 文件路径 | 说明 |
|---------|------|
| `backend/app/dependencies.py` | 修复后的代码 |
| `deploy-server/build-and-deploy.ps1` | 打包部署脚本 |
| `deploy-server/打包部署.bat` | 一键执行入口 |
| `docs/IT服务台PRDv1.0.md` | 产品需求文档 |
---
**更新历史**
| 日期 | 更新内容 |
|------|---------|
| 2026-06-13 | 初始记录,数据库修复 + 代码修复 + 打包脚本 |