Files
AIclinicalresearch/backend/DEPLOY_TO_SAE_FOR_WECHAT_MP.md
HaHafeng dfc0fe0b9a feat(pkb): Integrate pgvector and create Dify replacement plan
Summary:
- Migrate PostgreSQL to pgvector/pgvector:pg15 Docker image
- Successfully install and verify pgvector 0.8.1 extension
- Create comprehensive Dify-to-pgvector migration plan
- Update PKB module documentation with pgvector status
- Update system documentation with pgvector integration

Key changes:
- docker-compose.yml: Switch to pgvector/pgvector:pg15 image
- Add EkbDocument and EkbChunk data model design
- Design R-C-R-G hybrid retrieval architecture
- Add clinical data JSONB fields (pico, studyDesign, regimen, safety, criteria, endpoints)
- Create detailed 10-day implementation roadmap

Documentation updates:
- PKB module status: pgvector RAG infrastructure ready
- System status: pgvector 0.8.1 integrated
- New: Dify replacement development plan (01-Dify替换为pgvector开发计划.md)
- New: Enterprise medical knowledge base solution V2

Tested: PostgreSQL with pgvector verified, frontend and backend functionality confirmed
2026-01-20 00:00:58 +08:00

162 lines
2.9 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.
# 部署微信服务号到SAE快速指南
## 🎯 目标
将微信服务号回调服务部署到SAE生产环境使用域名`iit.xunzhengyixue.com`
---
## 📋 Step 1: 确认环境变量配置
编辑 `backend/.env`,确认以下配置存在:
```env
# 微信服务号配置
WECHAT_MP_APP_ID=wx062568ff49e4570c
WECHAT_MP_APP_SECRET=c0d19435d1a1e948939c16d767ec0faf
WECHAT_MP_TOKEN=IitPatientWechat2026JanToken
WECHAT_MP_ENCODING_AES_KEY=VIzwMGRG4Ll8Sd7fPxPXLlBaWdsh2rK2qIGpyaEoc1v
```
---
## 📋 Step 2: 在SAE控制台配置环境变量
1. **登录阿里云SAE控制台**
2. **进入应用管理 → 选择应用**
3. **配置管理 → 环境变量**
4. **添加以下环境变量**
```
WECHAT_MP_APP_ID=wx062568ff49e4570c
WECHAT_MP_APP_SECRET=c0d19435d1a1e948939c16d767ec0faf
WECHAT_MP_TOKEN=IitPatientWechat2026JanToken
WECHAT_MP_ENCODING_AES_KEY=VIzwMGRG4Ll8Sd7fPxPXLlBaWdsh2rK2qIGpyaEoc1v
```
5. **保存配置**
---
## 📋 Step 3: 部署代码到SAE
```bash
cd D:\MyCursor\AIclinicalresearch\backend
.\deploy-to-sae.ps1
```
**等待部署完成**约5-10分钟
---
## 📋 Step 4: 验证部署
访问以下URL确认服务正常
```
https://iit.xunzhengyixue.com/api/v1/iit/health
```
**期望返回**
```json
{
"status": "ok",
"module": "iit-manager",
"version": "1.1.0"
}
```
---
## 📋 Step 5: 配置微信公众平台
1. **登录微信公众平台**https://mp.weixin.qq.com/
2. **进入:设置与开发 → 基本配置 → 服务器配置**
3. **点击"修改配置"**
4. **填写以下信息**
| 配置项 | 值 |
|--------|-----|
| **URL** | `https://iit.xunzhengyixue.com/wechat/patient/callback` |
| **Token** | `IitPatientWechat2026JanToken` |
| **EncodingAESKey** | `VIzwMGRG4Ll8Sd7fPxPXLlBaWdsh2rK2qIGpyaEoc1v` |
| **消息加解密方式** | **安全模式(推荐)** |
| **数据格式** | **XML** |
5. **点击"提交"**
6. **验证成功后点击"启用"**
---
## ✅ 验证成功标志
### 配置阶段:
- ✅ 页面显示"配置成功"
- ✅ 服务器配置状态为"已启用"
### 测试阶段:
1. **关注公众号**AI for 临床研究
2. **查看SAE日志**,应该看到:
```
📥 收到微信服务号回调消息
🔐 检测到加密消息,开始解密...
✅ 消息解密成功
👤 用户关注公众号
```
---
## 🔧 如何查看SAE日志
1. **登录阿里云SAE控制台**
2. **应用管理 → 选择应用 → 实例管理**
3. **点击"日志" → "实时日志"**
4. **查看最近的日志输出**
---
## 📝 优势
使用生产环境的优势:
- ✅ 域名 `iit.xunzhengyixue.com` 已备案
- ✅ HTTPS证书已配置
- ✅ 已在企业微信中验证过
- ✅ 无需natapp内网穿透
- ✅ 稳定性更好
- ✅ 无需配置域名验证
---
## ⏱️ 预计用时
- 配置环境变量2分钟
- 部署到SAE5-10分钟
- 配置微信公众平台3分钟
- **总计10-15分钟**
---
**立即开始部署!** 🚀