# MES 生产管理系统部署状态

## ✅ 部署完成

### 📍 访问地址

| 环境 | 地址 | 状态 |
|------|------|------|
| 本地 (工厂服务器) | http://localhost:8091 | ✅ 运行中 |
| 本地API | http://localhost:3009 | ✅ 运行中 |
| 外网 (FRP穿透) | https://erp.we-smart.cn | ⏳ 需配置Nginx |

### 🔧 服务状态

```
┌─────────────────────────────────────────────────────────────┐
│                    工厂本地服务器 (wesmartai)                │
├─────────────────────────────────────────────────────────────┤
│  ✅ Web服务器: http://localhost:8091                         │
│  ✅ API服务器: http://localhost:3009                         │
│  ✅ FRP客户端: /opt/frp/frpc                                │
└─────────────────────────────────────────────────────────────┘
                              │
                              ▼ FRP穿透
┌─────────────────────────────────────────────────────────────┐
│                    阿里云服务器                              │
│                  8.138.219.128                               │
│              www.we-smart.cn                                 │
├─────────────────────────────────────────────────────────────┤
│  7012 ◄── 8091 (Web)                                        │
│  7013 ◄── 3009 (API)                                        │
│                                                             │
│  ⏳ Nginx配置: /etc/nginx/conf.d/erp.conf (待部署)          │
└─────────────────────────────────────────────────────────────┘
```

### 📋 FRP端口映射

| 服务 | 本地端口 | FRP远程端口 |
|------|----------|-------------|
| MES Web | 8091 | 7012 |
| MES API | 3009 | 7013 |

### 📝 管理命令

```bash
# 查看服务状态
curl http://localhost:3009/api/health
curl -I http://localhost:8091

# 查看日志
cd /home/maocai/.openclaw/workspace/internal/mes
tail -f logs/api.log
tail -f logs/web.log

# 停止服务
./stop-mes.sh

# 重启服务
./deploy-mes.sh

# 重启FRP
sudo systemctl restart frpc
```

### 🌐 外网访问配置 (阿里云)

需要在阿里云服务器执行以下操作：

```bash
# 1. SSH登录阿里云
ssh root@8.138.219.128

# 2. 复制Nginx配置
cp /path/to/nginx-erp.conf /etc/nginx/conf.d/erp.conf

# 3. 检查配置
nginx -t

# 4. 重载Nginx
systemctl reload nginx

# 5. 配置DNS (在域名解析商处)
# 添加A记录: erp.we-smart.cn → 8.138.219.128
```

### 📁 文件位置

```
/home/maocai/.openclaw/workspace/internal/mes/
├── index.html              # 订单管理
├── schedule.html           # 生产排期
├── board.html              # 生产看板
├── gantt.html              # 甘特图
├── api/
│   ├── server.js           # API服务器
│   └── data/
│       └── db.json         # 数据库
├── logs/
│   ├── api.log             # API日志
│   └── web.log             # Web日志
├── deploy-mes.sh           # 部署脚本
├── stop-mes.sh             # 停止脚本
├── nginx-erp.conf          # Nginx配置
└── DEPLOY.md               # 部署文档
```

### 🔗 相关配置

- **FRP配置**: `/opt/frp/frpc.ini`
- **FRP服务**: `sudo systemctl status frpc`
- **本地服务PID**: `logs/api.pid`, `logs/web.pid`
