Initial commit: HZHub project setup with RuoYi-AI base

This commit is contained in:
2026-03-26 09:47:46 +00:00
commit 3584e491cc
5005 changed files with 318595 additions and 0 deletions

129
docs/architecture/README.md Normal file
View File

@@ -0,0 +1,129 @@
# HZHub 架构设计文档
## 1. 系统概述
### 1.1 项目背景
HZHub汇智中台是基于 RuoYi-AI 构建的企业级业务中台系统,旨在:
- 对内包装对接 ERP 系统
- 对外打通企业微信
- 提供 AI 能力赋能业务
### 1.2 核心目标
1. **业务中台系统建设**:三大门户(后台管理、公司门户、经销商门户)
2. **ERP 智能开发助手**:通过 AI 方式开发和维护 ERP 系统
3. **产品供应链管理优化**:智能库存、供应商绩效等
## 2. 系统架构
### 2.1 整体架构
```
前端层 → 网关层 → 服务层 → 数据层
```
### 2.2 服务划分
| 服务 | 职责 | 技术栈 |
|------|------|--------|
| hzhub-gateway | 统一入口、鉴权、路由 | Spring Cloud Gateway |
| hzhub-ai | AI 核心能力 | Spring Boot 4.0 + Spring AI 2.0 |
| hzhub-erp | ERP 数据适配 | Spring Boot 4.0 + JDBC |
| hzhub-admin | 管理后台前端 | Vue 3 |
| hzhub-portal-company | 公司门户前端 | Vue 3 |
| hzhub-portal-dealer | 经销商门户前端 | Vue 3 |
### 2.3 数据存储
| 存储 | 用途 | 说明 |
|------|------|------|
| MySQL | 业务数据 | 用户信息、权限、配置 |
| Milvus | 向量数据 | 知识库文档向量、语义检索 |
| SQL Server 2008 R2 | ERP 数据 | 直连 ERP 数据库 |
## 3. 关键设计决策
### 3.1 ERP 服务独立部署
**决策**ERP 服务独立为一个微服务
**理由**
- 数据源完全隔离,避免双数据源复杂性
- SQL Server 2008 R2 驱动兼容性风险隔离
- 未来 ERP 升级或替换不影响 AI 服务
### 3.2 AI 能力以组件形式集成
**决策**AI 用户端不独立部署,以组件形式嵌入两个门户
**理由**
- 减少独立系统维护成本
- 用户体验更统一
- 权限管理更简单
### 3.3 企业微信多实体分别对接
**决策**:四个企业微信实体(集团/汇亚/恒福/玛缇)分别对接
**实现**:门户层通过 `corpId` 区分实体,共用一套代码
## 4. 接口契约(预留)
### 4.1 ERP 服务接口
```java
@RestController
@RequestMapping("/erp/v1")
public interface ErpApi {
@PostMapping("/query")
Result<PageResult> query(@RequestBody ErpQueryRequest request);
@PostMapping("/execute")
Result<Void> execute(@RequestBody ErpExecuteRequest request);
@GetMapping("/schema/{tableName}")
Result<TableSchema> getSchema(@PathVariable String tableName);
}
```
### 4.2 AI 服务接口
复用 ruoyi-ai 提供的接口,通过网关暴露。
## 5. 部署架构
### 5.1 网络分区
| 服务 | 部署位置 | 访问方式 |
|------|---------|---------|
| 管理后台 | 内网 | 内网访问 |
| 公司门户 | 内网 | 内网 + 企业微信 H5 |
| 经销商门户 | 外网DMZ | 公网 + 企业微信 H5 |
| 网关/AI/ERP/n8n | 内网 | 网关统一入口 |
### 5.2 安全边界
- 外网入口Nginx SSL + WAF + IP 白名单
- 网关层JWT 鉴权 + 接口权限 + 限流
- 服务间内网隔离Feign 调用 + Token 传递
## 6. 技术风险
| 风险 | 影响 | 应对措施 |
|------|------|---------|
| SQL Server 2008 R2 驱动兼容性 | ERP 服务无法启动 | 预留双数据源,可切换 |
| Spring Boot 4.0 较新 | 第三方库适配问题 | 优先使用官方 starter |
| ruoyi-ai 早期阶段 | API 可能变化 | 复制代码而非 fork自主可控 |
## 7. 后续待办
1. ERP 数据架构专项调研
2. SQL Server JDBC 驱动兼容性验证
3. Milvus Docker 部署测试
4. 企业微信多实体对接方案细化
---
创建时间2026-03-26

View File

@@ -0,0 +1,88 @@
digraph HZHubArchitectureCN {
graph [fontname="Noto Sans CJK SC", fontsize=24, bgcolor=white, margin=0, rankdir=TB, splines=ortho, nodesep=0.6, ranksep=1.2];
node [fontname="Noto Sans CJK SC", shape=box, style="rounded,filled", fontsize=11, margin="0.3,0.2"];
edge [fontname="Noto Sans CJK SC", fontsize=10, color="#666666"];
// Title
labelloc="t";
label="HZHub 汇智中台 - 系统架构图\n企业级业务中台";
// Frontend Layer
subgraph cluster_frontend {
label="前端接入层";
style=filled;
color="#E3F2FD";
fontcolor="#1565C0";
fontsize=14;
labelloc=b;
labeljust=left;
admin [label="hzhub-admin\n管理后台\n• 模型管理\n• 知识库配置\n• 智能体编排", fillcolor="#BBDEFB", color="#1976D2"];
company [label="hzhub-portal-company\n公司门户\n• 企业微信H5\n• 审批流程\n• 销售CRM\n• BI报表", fillcolor="#BBDEFB", color="#1976D2"];
dealer [label="hzhub-portal-dealer\n经销商门户\n• 企业微信H5\n• 自助开单\n• 进销存\n• AI素材生成", fillcolor="#BBDEFB", color="#1976D2"];
}
// Gateway Layer
subgraph cluster_gateway {
label="API网关层";
style=filled;
color="#FFF3E0";
fontcolor="#E65100";
fontsize=14;
labelloc=b;
labeljust=left;
gateway [label="HZHub-Gateway\nAPI网关\n• 统一鉴权\n• 路由转发\n• 限流熔断", fillcolor="#FFE0B2", color="#F57C00", width=4.5];
}
// Service Layer
subgraph cluster_service {
label="核心服务层";
style=filled;
color="#E8F5E9";
fontcolor="#2E7D32";
fontsize=14;
labelloc=b;
labeljust=left;
ai [label="hzhub-ai\nAI服务\n• Spring Boot 4.0\n• Spring AI 2.0\n• LangChain4j\n• RAG/知识库\n• 多智能体", fillcolor="#C8E6C9", color="#388E3C"];
erp [label="hzhub-erp\nERP服务\n• Spring Boot 4.0\n• JDBC/SQL Server\n• 数据适配层\n• 双数据源预留", fillcolor="#C8E6C9", color="#388E3C"];
n8n [label="n8n\n工作流引擎\n• 流程编排\n• 审批自动化\n• 定时任务\n• Webhook集成", fillcolor="#F8BBD9", color="#C2185B"];
}
// Data Layer
subgraph cluster_data {
label="数据存储层";
style=filled;
color="#F3E5F5";
fontcolor="#7B1FA2";
fontsize=14;
labelloc=b;
labeljust=left;
mysql [label="MySQL\n业务数据\n• 用户权限\n• 系统配置", fillcolor="#E1BEE7", color="#7B1FA2"];
milvus [label="Milvus\n向量数据库\n• 文档向量\n• 语义检索", fillcolor="#E1BEE7", color="#7B1FA2"];
sqlserver [label="SQL Server 2008 R2\nERP数据库\n• 存储过程\n• 直连访问", fillcolor="#E1BEE7", color="#7B1FA2"];
}
// Connections
admin -> gateway;
company -> gateway;
dealer -> gateway;
gateway -> ai;
gateway -> erp;
gateway -> n8n;
ai -> mysql;
ai -> milvus;
erp -> sqlserver;
// Workflow trigger (dashed)
ai -> n8n [style=dashed, color="#9E9E9E", label="工作流触发"];
// Rankings for layout
{rank=same; admin; company; dealer}
{rank=same; ai; erp; n8n}
{rank=same; mysql; milvus; sqlserver}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 KiB

View File

@@ -0,0 +1,88 @@
digraph HZHubArchitecture {
graph [fontname="Arial", fontsize=24, bgcolor=white, margin=0, rankdir=TB, splines=ortho, nodesep=0.6, ranksep=1.2];
node [fontname="Arial", shape=box, style="rounded,filled", fontsize=11, margin="0.3,0.2"];
edge [fontname="Arial", fontsize=10, color="#666666"];
// Title
labelloc="t";
label="HZHub Architecture Diagram\nEnterprise Business Middle-Platform";
// Frontend Layer
subgraph cluster_frontend {
label="Frontend Layer";
style=filled;
color="#E3F2FD";
fontcolor="#1565C0";
fontsize=14;
labelloc=b;
labeljust=left;
admin [label="hzhub-admin\nManagement Portal\n• Model Management\n• Knowledge Base Config\n• Agent Orchestration", fillcolor="#BBDEFB", color="#1976D2"];
company [label="hzhub-portal-company\nCompany Portal\n• WeChat Work H5\n• Approval Workflow\n• Sales CRM\n• BI Reports", fillcolor="#BBDEFB", color="#1976D2"];
dealer [label="hzhub-portal-dealer\nDealer Portal\n• WeChat Work H5\n• Self-service Order\n• Inventory Mgmt\n• AI Material Gen", fillcolor="#BBDEFB", color="#1976D2"];
}
// Gateway Layer
subgraph cluster_gateway {
label="Gateway Layer";
style=filled;
color="#FFF3E0";
fontcolor="#E65100";
fontsize=14;
labelloc=b;
labeljust=left;
gateway [label="HZHub-Gateway\nAPI Gateway\n• Unified Authentication\n• Routing & Load Balancing\n• Rate Limiting & Circuit Breaker", fillcolor="#FFE0B2", color="#F57C00", width=4.5];
}
// Service Layer
subgraph cluster_service {
label="Service Layer";
style=filled;
color="#E8F5E9";
fontcolor="#2E7D32";
fontsize=14;
labelloc=b;
labeljust=left;
ai [label="hzhub-ai\nAI Service\n• Spring Boot 4.0\n• Spring AI 2.0\n• LangChain4j\n• RAG / Knowledge Base\n• Multi-Agent System", fillcolor="#C8E6C9", color="#388E3C"];
erp [label="hzhub-erp\nERP Service\n• Spring Boot 4.0\n• JDBC / SQL Server\n• Data Adapter Layer\n• Dual DataSource (Reserved)", fillcolor="#C8E6C9", color="#388E3C"];
n8n [label="n8n\nWorkflow Engine\n• Workflow Orchestration\n• Approval Automation\n• Scheduled Tasks\n• Webhook Integration", fillcolor="#F8BBD9", color="#C2185B"];
}
// Data Layer
subgraph cluster_data {
label="Data Layer";
style=filled;
color="#F3E5F5";
fontcolor="#7B1FA2";
fontsize=14;
labelloc=b;
labeljust=left;
mysql [label="MySQL\nBusiness Data\n• User & Permission\n• System Config", fillcolor="#E1BEE7", color="#7B1FA2"];
milvus [label="Milvus\nVector Database\n• Document Embeddings\n• Semantic Search", fillcolor="#E1BEE7", color="#7B1FA2"];
sqlserver [label="SQL Server 2008 R2\nERP Database\n• Stored Procedures\n• Direct Connection", fillcolor="#E1BEE7", color="#7B1FA2"];
}
// Connections
admin -> gateway;
company -> gateway;
dealer -> gateway;
gateway -> ai;
gateway -> erp;
gateway -> n8n;
ai -> mysql;
ai -> milvus;
erp -> sqlserver;
// Workflow trigger (dashed)
ai -> n8n [style=dashed, color="#9E9E9E", label="Workflow Trigger"];
// Rankings for layout
{rank=same; admin; company; dealer}
{rank=same; ai; erp; n8n}
{rank=same; mysql; milvus; sqlserver}
}

View File

@@ -0,0 +1,47 @@
graph TB
subgraph 前端层["🖥️ 前端接入层"]
A1["hzhub-admin<br/>管理后台"]
A2["hzhub-portal-company<br/>公司门户"]
A3["hzhub-portal-dealer<br/>经销商门户"]
end
subgraph 网关层["🌐 API网关层"]
B["HZHub-Gateway<br/>统一鉴权/路由/限流"]
end
subgraph 服务层["⚙️ 核心服务层"]
C1["hzhub-ai<br/>AI服务"]
C2["hzhub-erp<br/>ERP服务"]
C3["n8n<br/>工作流引擎"]
end
subgraph 数据层["💾 数据存储层"]
D1["MySQL<br/>业务数据"]
D2["Milvus<br/>向量数据"]
D3["SQL Server 2008 R2<br/>ERP数据"]
end
A1 --> B
A2 --> B
A3 --> B
B --> C1
B --> C2
B --> C3
C1 --> D1
C1 --> D2
C2 --> D3
C1 -.->|工作流调用| C3
style A1 fill:#e1f5fe
style A2 fill:#e1f5fe
style A3 fill:#e1f5fe
style B fill:#fff3e0
style C1 fill:#e8f5e9
style C2 fill:#e8f5e9
style C3 fill:#fce4ec
style D1 fill:#f3e5f5
style D2 fill:#f3e5f5
style D3 fill:#f3e5f5

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 KiB