Files
SBrainCO/README.md
T
2026-07-26 22:48:08 +08:00

127 lines
3.8 KiB
Markdown

# 马兰拉面数字化运营管理平台
连锁餐饮数字化运营管理系统 — 任务闭环驱动门店改善
## 闭环目标
数据发现问题 → 自动分级 → 生成门店任务 → 现场执行 → 周度检查 → 月度验收 → 有效经验标准化
## 技术栈
- **后端**: Node.js + Express + TypeScript + PostgreSQL (pg)
- **前端**: React 18 + TypeScript + Vite + TailwindCSS + Recharts + React Query
- **认证**: JWT (角色: hq / regional / store / dept)
- **数据库**: PostgreSQL 15, `bill_query` @ localhost:5432
## 项目结构
```
SBrainCO/
├── package.json # monorepo 根配置
├── server/ # 后端
│ ├── src/
│ │ ├── config/database.ts
│ │ ├── middleware/auth.ts, error.ts
│ │ ├── routes/data.ts, tasks.ts, auth.ts
│ │ ├── types/index.ts
│ │ └── index.ts
│ ├── sql/
│ │ ├── 01_create_tables.sql
│ │ ├── 02_create_functions.sql
│ │ ├── 03_create_views.sql
│ │ └── 04_init_data.sql
│ └── .env
├── client/ # 前端
│ ├── src/
│ │ ├── components/ # Layout, MetricCard, Badge, DataTable
│ │ ├── pages/ # Dashboard, Tasks, StoreDetail, MonthlyReview, Indicators, Regional, Store, Login
│ │ ├── lib/ # api.ts, utils.ts
│ │ ├── App.tsx
│ │ └── main.tsx
│ └── vite.config.ts
└── shared/types.ts
```
## 快速启动
### 1. 安装依赖
```bash
# 根目录安装
npm run install:all
```
### 2. 初始化数据库
```bash
# 按顺序执行SQL脚本
psql -d bill_query -f server/sql/01_create_tables.sql
psql -d bill_query -f server/sql/02_create_functions.sql
psql -d bill_query -f server/sql/03_create_views.sql
psql -d bill_query -f server/sql/04_init_data.sql
```
### 3. 启动开发服务器
```bash
# 根目录一键启动
npm run dev
# 或分别启动
cd server && npm run dev # 后端 http://localhost:3001
cd client && npm run dev # 前端 http://localhost:5173
```
### 4. 访问系统
- 前端: http://localhost:5173
- 后端API: http://localhost:3001/api
- 默认账号:
- 总部管理员 / 123 (hq)
- 区域经理 / 123 (regional)
- 潘家园店长 / 123 (store)
- 商品部 / 123 (dept)
## API 接口
### 数据查询 (25个)
- `GET /api/overview` — 公司概览
- `GET /api/overview/daily` — 日度趋势
- `GET /api/stores` — 门店列表
- `GET /api/stores/:code` — 门店详情
- `GET /api/stores/risk` — 风险分级
- `GET /api/stores/priority` — 整改优先级
- `GET /api/stores/quadrant` — 经营象限
- `GET /api/cost/*` — 成本分析
- `GET /api/platform/economics` — 平台经济性
- `GET /api/member/*` — 会员分析
- `GET /api/sku/*` — SKU分析
- `GET /api/risk/*` — 风险分析
- `GET /api/time/*` — 时间规律
- `GET /api/channel` — 渠道结构
### 任务闭环 (23个)
- `GET /api/tasks` — 任务列表
- `GET /api/tasks/:id` — 任务详情
- `POST /api/tasks` — 创建任务
- `PUT /api/tasks/:id` — 更新任务
- `PUT /api/tasks/:id/execute` — 执行反馈
- `PUT /api/tasks/:id/weekly-check` — 周度检查
- `PUT /api/tasks/:id/verify` — 月度验收
- `POST /api/tasks/:id/rollback` — 任务回滚
- `POST /api/tasks/auto-generate` — 自动生成任务
- `GET /api/tasks/loop-health` — 闭环健康度
- `GET|POST /api/tasks/practices` — 经验标准化
- `GET|POST /api/tasks/indicators` — 指标字典
- `GET /api/tasks/stores/:code/daily-card` — 店长日卡
## 闭环健康度
| 指标 | 当前值 | 目标 |
|---|---|---|
| 任务生成率 | 100% | ≥95% |
| 店长执行率 | 0% | ≥80% |
| 区域周检率 | 0% | ≥80% |
| 月度验收率 | 0% | ≥80% |
| 经验推广率 | 0% | ≥80% |