# CPTE WMS 微服务架构文档 ## 1. 架构概述 ### 1.1 系统定位 CPTE WMS 是基于 Spring Boot 3.5.5 + Spring Cloud 2025.0.0 构建的仓库管理系统微服务架构,采用 Kubernetes 进行容器编排部署。 ### 1.2 架构风格 - **微服务架构**: 业务按领域拆分为独立服务 - **服务网格**: 基于 Kubernetes Service 的服务发现 - **事件驱动**: Redis 发布订阅实现异步通信 - **容器化部署**: Docker + Kubernetes --- ## 2. 系统架构图 ### 2.1 整体架构 ``` ┌────────────────────────────────────────────────────────────────────────────────┐ │ 外部访问层 │ │ ┌─────────────────────────────────────────────────────────────────────────┐ │ │ │ Nginx Ingress │ │ │ │ (负载均衡 / SSL 终止 / 路由) │ │ │ └─────────────────────────────────────────────────────────────────────────┘ │ └────────────────────────────────────────────────────────────────────────────────┘ │ ▼ ┌────────────────────────────────────────────────────────────────────────────────┐ │ 应用服务层 │ │ ┌──────────────────────────────────────────────────────────────────────────┐ │ │ │ Namespace: cpte-wms │ │ │ │ │ │ │ │ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │ │ │ │ │ Basic Service │ │Inbound Service │ │Outbound Service│ │ │ │ │ │ 基础服务 │ │ 入库服务 │ │ 出库服务 │ │ │ │ │ │ Port: 8001 │ │ Port: 8002 │ │ Port: 8003 │ │ │ │ │ │ /cpte-wms-basic│ │/cpte-wms-inbound│ │/cpte-wms-outbound│ │ │ │ │ └───────┬────────┘ └───────┬────────┘ └───────┬────────┘ │ │ │ │ │ │ │ │ │ │ │ │ ┌──────────────┼───────────────┐ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ▼ ▼ ▼ ▼ ▼ │ │ │ │ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │ │ │ │ │Inventory Service│ │Schedule Service│ │ System Service │ │ │ │ │ │ 库存服务 │ │ 调度服务 │ │ 系统服务 │ │ │ │ │ │ Port: 8004 │ │ Port: 8005 │ │ Port: 8000 │ │ │ │ │ │/cpte-wms-inventory│ │/cpte-wms-schedule│ │/cpte-wms │ │ │ │ │ └────────────────┘ └────────────────┘ └────────────────┘ │ │ │ │ │ │ │ │ ┌────────────────────────────────────────────────────────────────────┐ │ │ │ │ │ cpte-wms-api (共享层) │ │ │ │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ │ │ │ │ Feign Client│ │ DTO │ │ 分布式锁 │ │ 工具类 │ │ │ │ │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ │ │ └────────────────────────────────────────────────────────────────────┘ │ │ │ └──────────────────────────────────────────────────────────────────────────┘ │ └────────────────────────────────────────────────────────────────────────────────┘ │ ▼ ┌────────────────────────────────────────────────────────────────────────────────┐ │ 基础设施层 │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ MySQL │ │ Redis │ │ MinIO │ │ Nacos │ │ │ │ 数据持久化 │ │ 缓存/锁/消息 │ │ 文件存储 │ │ 配置中心 │ │ │ │ Port: 53306 │ │ Port: 6379 │ │ │ │ │ │ │ └──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘ │ └────────────────────────────────────────────────────────────────────────────────┘ ``` ### 2.2 服务拓扑图 ``` ┌─────────────────┐ │ System Service │ │ 系统服务 │ │ Port: 8000 │ └────────┬────────┘ │ ┌───────────────────────────┼───────────────────────────┐ │ │ │ ▼ ▼ ▼ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ Basic Service │◄───────▶│Inbound Service │◄───────▶│Outbound Service │ │ 基础服务 │ Feign │ 入库服务 │ Feign │ 出库服务 │ │ Port: 8001 │ │ Port: 8002 │ │ Port: 8003 │ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │ │ │ │ Feign │ Feign │ Feign │ │ │ └──────────────┬────────────┴────────────┬──────────────┘ │ │ ▼ ▼ ┌─────────────────┐ ┌─────────────────┐ │Inventory Service│ │Schedule Service │ │ 库存服务 │ │ 调度服务 │ │ Port: 8004 │ │ Port: 8005 │ └─────────────────┘ └─────────────────┘ ``` --- ## 3. 服务清单 ### 3.1 核心服务 | 服务名称 | 服务标识 | 端口 | Context Path | 职责 | |---------|---------|------|-------------|------| | 基础服务 | cpte-wms-basic | 8001 | /cpte-wms-basic | 物料、库区、点位、容器等基础数据管理 | | 入库服务 | cpte-wms-inbound | 8002 | /cpte-wms-inbound | ASN 管理、收货、上架等入库业务 | | 出库服务 | cpte-wms-outbound | 8003 | /cpte-wms-outbound | 拣货、发货、波次等出库业务 | | 库存服务 | cpte-wms-inventory | 8004 | /cpte-wms-inventory | 库存查询、盘点、移库等库存业务 | | 调度服务 | cpte-wms-schedule | 8005 | /cpte-wms-schedule | AGV 调度、输送线控制、定时任务 | | 系统服务 | cpte-wms | 8000 | /cpte-wms | 用户、权限、系统管理等 | ### 3.2 共享模块 | 模块名称 | Artifact ID | 职责 | |---------|-------------|------| | 公共 API | cpte-wms-api | Feign Client、DTO、分布式锁、工具类 | | 基础核心 | cpte-boot-base-core | 公共组件、配置、异常处理 | | 系统业务 | cpte-system-biz | 用户权限、字典、日志等 | --- ## 4. 服务通信架构 ### 4.1 通信方式 ``` ┌─────────────────────────────────────────────────────────────────┐ │ 服务通信方式 │ ├─────────────────────────────────────────────────────────────────┤ │ │ │ 1. 同步通信 (OpenFeign) │ │ ┌─────────┐ HTTP/REST ┌─────────┐ │ │ │ Service │ ──────────────▶ │ Service │ │ │ │ A │ │ B │ │ │ └─────────┘ └─────────┘ │ │ │ │ 2. 异步通信 (Redis Pub/Sub) │ │ ┌─────────┐ Publish ┌───────┐ Subscribe ┌─────────┐ │ │ Service │ ─────────────▶ │ Redis │ ──────────────▶ │ Service │ │ │ A │ │ │ │ B │ │ └─────────┘ └───────┘ └─────────┘ │ │ │ 3. 分布式锁 (Redisson) │ │ ┌─────────┐ Lock/Unlock ┌───────┐ │ │ │ Service │ ◄────────────────▶ │ Redis │ │ │ │ A │ │ │ │ │ └─────────┘ └───────┘ │ │ │ └─────────────────────────────────────────────────────────────────┘ ``` ### 4.2 OpenFeign 配置 ```yaml feign: client: wms-basic: url: http://cpte-wms-basic:8001/cpte-wms-basic config: default: connectTimeout: 5000 # 连接超时 5 秒 readTimeout: 10000 # 读取超时 10 秒 loggerLevel: INFO # 日志级别 ``` **Feign 核心配置**: - HTTP 客户端: OkHttp - 连接超时: 5 秒 - 读取超时: 10 秒 - 重试策略: 初始间隔 100ms,最大间隔 1 秒,最多重试 3 次 ### 4.3 服务调用关系 ``` ┌─────────────────────────────────────────────────────────────────────────┐ │ 服务调用依赖关系 │ ├─────────────────────────────────────────────────────────────────────────┤ │ │ │ Inbound Service (入库服务) │ │ ├── Feign → Basic Service (获取物料、库区信息) │ │ ├── Feign → Inventory Service (更新库存) │ │ └── Feign → Schedule Service (触发 AGV 任务) │ │ │ │ Outbound Service (出库服务) │ │ ├── Feign → Basic Service (获取物料、点位信息) │ │ ├── Feign → Inventory Service (扣减库存、锁定库存) │ │ └── Feign → Schedule Service (触发拣货任务) │ │ │ │ Inventory Service (库存服务) │ │ ├── Feign → Basic Service (获取物料、容器信息) │ │ └── Redisson → 分布式锁 (库存操作锁) │ │ │ │ Schedule Service (调度服务) │ │ ├── Feign → Basic Service (获取点位信息) │ │ ├── Feign → Inventory Service (库存校验) │ │ └── Quartz → 定时任务调度 │ │ │ └─────────────────────────────────────────────────────────────────────────┘ ``` --- ## 5. 数据架构 ### 5.1 数据存储架构 ``` ┌─────────────────────────────────────────────────────────────────────────┐ │ 数据存储架构 │ ├─────────────────────────────────────────────────────────────────────────┤ │ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ MySQL (主数据库) │ │ │ │ cpte-wms 数据库 │ │ │ │ │ │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ │ │ base_item │ │ base_area │ │ base_point │ 基础数据 │ │ │ │ │ 物料表 │ │ 库区表 │ │ 点位表 │ │ │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ │ │ │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ │ │ data_asn │ │asn_detail │ │receive_record│ 入库数据 │ │ │ │ │ 入库单 │ │ 入库明细 │ │ 收货记录 │ │ │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ │ │ │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ │ │ sys_user │ │ sys_role │ │ sys_permission│ 系统数据 │ │ │ │ │ 用户表 │ │ 角色表 │ │ 权限表 │ │ │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ Redis (缓存/消息) │ │ │ │ │ │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ │ │ Session │ │ 数据缓存 │ │ 分布式锁 │ │ │ │ │ │ 会话存储 │ │ 热点数据 │ │ Redisson │ │ │ │ │ └─────────────┘ └─────────────┘ └─────────────┘ │ │ │ │ │ │ │ │ ┌─────────────┐ ┌─────────────┐ │ │ │ │ │ Pub/Sub │ │ 消息队列 │ │ │ │ │ │ 事件发布 │ │ 异步任务 │ │ │ │ │ └─────────────┘ └─────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────────────┘ ``` ### 5.2 数据库连接池 ```yaml Druid 连接池配置: initial-size: 5 # 初始连接数 min-idle: 5 # 最小空闲连接 maxActive: 1000 # 最大活跃连接 maxWait: 60000 # 最大等待时间 60s validationQuery: SELECT 1 # 验证 SQL ``` ### 5.3 Redis 部署模式 支持多种部署模式: - **STANDALONE**: 单机模式 - **MASTER_SLAVE**: 主从模式 - **SENTINEL**: 哨兵模式 - **CLUSTER**: 集群模式 --- ## 6. 部署架构 ### 6.1 Kubernetes 部署架构 ``` ┌─────────────────────────────────────────────────────────────────────────┐ │ Kubernetes Cluster │ ├─────────────────────────────────────────────────────────────────────────┤ │ │ │ ┌───────────────────────────────────────────────────────────────────┐ │ │ │ Namespace: cpte-wms │ │ │ │ │ │ │ │ ┌─────────────────────────────────────────────────────────────┐ │ │ │ │ │ Workload (Deployment) │ │ │ │ │ │ │ │ │ │ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐│ │ │ │ │ │ │ Pod │ │ Pod │ │ Pod │ │ Pod │ │ Pod ││ │ │ │ │ │ │ Basic │ │ Inbound │ │Outbound │ │Inventory│ │Schedule ││ │ │ │ │ │ │ :8001 │ │ :8002 │ │ :8003 │ │ :8004 │ │ :8005 ││ │ │ │ │ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘│ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └───────┼───────────┼───────────┼───────────┼───────────┼──────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ ┌───────┴───────────┴───────────┴───────────┴───────────┴──────┐ │ │ │ │ │ Service (ClusterIP) │ │ │ │ │ │ │ │ │ │ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ │ │ │ │cpte-wms │ │cpte-wms │ │cpte-wms │ │inventory│ │schedule │ │ │ │ │ │ │ │ -basic │ │ -inbound│ │ -outbound│ │ -service│ │ -service│ │ │ │ │ │ │ │ :8001 │ │ :8002 │ │ :8003 │ │ :8004 │ │ :8005 │ │ │ │ │ │ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ │ │ │ │ └───────────────────────────────────────────────────────────────┘ │ │ │ │ │ │ │ │ ┌───────────────────────────────────────────────────────────────┐ │ │ │ │ │ ConfigMap & Secret │ │ │ │ │ │ │ │ │ │ │ │ ConfigMap: application.yml, 环境变量 │ │ │ │ │ │ Secret: DB_PASSWORD, REDIS_PASSWORD, SIGNATURE_SECRET │ │ │ │ │ └───────────────────────────────────────────────────────────────┘ │ │ │ │ │ │ │ │ ┌───────────────────────────────────────────────────────────────┐ │ │ │ │ │ PersistentVolumeClaim │ │ │ │ │ │ │ │ │ │ │ │ cpte-wms-basic-data (10Gi) - 文件上传存储 │ │ │ │ │ │ cpte-wms-inbound-data (10Gi) - 文件上传存储 │ │ │ │ │ └───────────────────────────────────────────────────────────────┘ │ │ │ └────────────────────────────────────────────────────────────────────┘ │ │ │ │ ┌───────────────────────────────────────────────────────────────────┐ │ │ │ 基础设施服务 │ │ │ │ │ │ │ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │ │ │ │ MySQL │ │ Redis │ │ Nginx │ │ MinIO │ │ │ │ │ │ Service │ │ Service │ │ Ingress │ │ OSS │ │ │ │ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │ │ └───────────────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────────────┘ ``` ### 6.2 服务资源配置 | 服务 | CPU Request | CPU Limit | Memory Request | Memory Limit | 副本数 | |-----|-------------|-----------|----------------|--------------|--------| | Basic | 500m | 2000m | 1Gi | 2Gi | 1 | | Inbound | 500m | 2000m | 1Gi | 2Gi | 1 | | Outbound | 100m | 500m | 256Mi | 1Gi | 1 | | Inventory | 100m | 500m | 256Mi | 1Gi | 1 | | Schedule | 100m | 500m | 256Mi | 1Gi | 1 | ### 6.3 健康检查配置 ```yaml 探针配置: livenessProbe: path: /{context}/actuator/health/liveness initialDelaySeconds: 90-180 periodSeconds: 20 timeoutSeconds: 10 failureThreshold: 3 readinessProbe: path: /{context}/actuator/health/readiness initialDelaySeconds: 45-120 periodSeconds: 10-15 timeoutSeconds: 5-10 failureThreshold: 3 startupProbe: path: /{context}/actuator/health/liveness initialDelaySeconds: 0-30 periodSeconds: 10 failureThreshold: 30-90 ``` --- ## 7. 安全架构 ### 7.1 认证授权架构 ``` ┌─────────────────────────────────────────────────────────────────────────┐ │ 认证授权架构 │ ├─────────────────────────────────────────────────────────────────────────┤ │ │ │ ┌─────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ Client │─────▶│ Nginx │─────▶│ Service │ │ │ │ │ │ Ingress │ │ Instance │ │ │ └─────────┘ └─────────────┘ └──────┬──────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────┐ │ │ │ JwtFilter │ │ │ │ - Token 解析 │ │ │ │ - Token 验证 │ │ │ │ - Token 刷新 │ │ │ └──────────┬──────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────┐ │ │ │ ShiroRealm │ │ │ │ - 用户认证 │ │ │ │ - 角色校验 │ │ │ │ - 权限校验 │ │ │ └──────────┬──────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────┐ │ │ │ Business Logic │ │ │ └─────────────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────────────┘ ``` ### 7.2 敏感信息管理 ``` ┌─────────────────────────────────────────────────────────────────────────┐ │ Kubernetes Secret 管理 │ ├─────────────────────────────────────────────────────────────────────────┤ │ │ │ Secret 类型: Opaque │ │ │ │ 存储的敏感信息: │ │ ├── MYSQL_HOST # MySQL 主机地址 │ │ ├── MYSQL_PORT # MySQL 端口 │ │ ├── MYSQL_DATABASE # 数据库名称 │ │ ├── MYSQL_USERNAME # 数据库用户名 │ │ ├── MYSQL_PASSWORD # 数据库密码 │ │ ├── REDIS_HOST # Redis 主机地址 │ │ ├── REDIS_PORT # Redis 端口 │ │ ├── REDIS_PASSWORD # Redis 密码 │ │ ├── MAIL_HOST # 邮件服务器地址 │ │ ├── MAIL_USERNAME # 邮件用户名 │ │ ├── MAIL_PASSWORD # 邮件密码 │ │ └── SIGNATURE_SECRET # 接口签名密钥 │ │ │ └─────────────────────────────────────────────────────────────────────────┘ ``` ### 7.3 服务间认证 ```java // Feign Token 拦截器 public class FeignTokenInterceptor implements RequestInterceptor { @Override public void apply(RequestTemplate template) { // 从当前上下文获取 Token 并传递给下游服务 String token = getCurrentToken(); template.header("Authorization", "Bearer " + token); } } ``` --- ## 8. 可观测性架构 ### 8.1 监控架构 ``` ┌─────────────────────────────────────────────────────────────────────────┐ │ 监控架构 │ ├─────────────────────────────────────────────────────────────────────────┤ │ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ Prometheus 采集层 │ │ │ │ │ │ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ │ │ Basic │ │ Inbound │ │Outbound │ │Inventory│ │Schedule │ │ │ │ │ │ :8001 │ │ :8002 │ │ :8003 │ │ :8004 │ │ :8005 │ │ │ │ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │ │ │ │ │ │ │ │ │ │ │ │ │ └───────────┴───────────┴───────────┴───────────┘ │ │ │ │ │ │ │ │ │ ▼ │ │ │ │ /actuator/prometheus │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ Prometheus Server │ │ │ │ - 指标采集 │ │ │ │ - 数据存储 │ │ │ │ - 告警规则 │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ Grafana 可视化 │ │ │ │ - 仪表盘展示 │ │ │ │ - 告警通知 │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────────────┘ ``` ### 8.2 Actuator 端点 | 端点 | 路径 | 说明 | |-----|------|------| | health | /actuator/health | 健康状态 | | info | /actuator/info | 应用信息 | | prometheus | /actuator/prometheus | Prometheus 指标 | | metrics | /actuator/metrics | JVM 指标 | ### 8.3 日志架构 ``` ┌─────────────────────────────────────────────────────────────────────────┐ │ 日志架构 │ ├─────────────────────────────────────────────────────────────────────────┤ │ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ Pod │ │ Pod │ │ Pod │ │ Pod │ │ Pod │ │ │ │ stdout │ │ stdout │ │ stdout │ │ stdout │ │ stdout │ │ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │ │ │ │ │ │ │ │ │ └───────────┴───────────┴───────────┴───────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ 日志收集器 (Filebeat/Fluentd) │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ Elasticsearch │ │ │ │ - 日志存储 │ │ │ │ - 全文检索 │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ Kibana │ │ │ │ - 日志查询 │ │ │ │ - 可视化分析 │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────────────┘ ``` --- ## 9. 高可用架构 ### 9.1 服务高可用 ``` ┌─────────────────────────────────────────────────────────────────────────┐ │ 服务高可用设计 │ ├─────────────────────────────────────────────────────────────────────────┤ │ │ │ 1. 多副本部署 │ │ ┌─────────────────────────────────────────────────────────────┐ │ │ │ Deployment (replicas: N) │ │ │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ │ │ Pod 1 │ │ Pod 2 │ │ Pod N │ │ │ │ │ └─────────┘ └─────────┘ └─────────┘ │ │ │ └─────────────────────────────────────────────────────────────┘ │ │ │ │ 2. 滚动更新 │ │ ┌─────────────────────────────────────────────────────────────┐ │ │ │ strategy: │ │ │ │ type: RollingUpdate │ │ │ │ rollingUpdate: │ │ │ │ maxSurge: 1 # 最多多 1 个 Pod │ │ │ │ maxUnavailable: 0 # 最少可用 Pod 数 │ │ │ └─────────────────────────────────────────────────────────────┘ │ │ │ │ 3. 健康检查 │ │ ┌─────────────────────────────────────────────────────────────┐ │ │ │ livenessProbe → 存活检查 (失败则重启) │ │ │ │ readinessProbe → 就绪检查 (失败则从 Service 移除) │ │ │ │ startupProbe → 启动检查 (慢启动保护) │ │ │ └─────────────────────────────────────────────────────────────┘ │ │ │ │ 4. 服务降级 │ │ ┌─────────────────────────────────────────────────────────────┐ │ │ │ @FeignClient(fallbackFactory = BasicServiceFallbackFactory)│ │ │ │ → 服务不可用时返回默认响应 │ │ │ └─────────────────────────────────────────────────────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────────────┘ ``` ### 9.2 数据高可用 ``` ┌─────────────────────────────────────────────────────────────────────────┐ │ 数据高可用设计 │ ├─────────────────────────────────────────────────────────────────────────┤ │ │ │ MySQL 高可用: │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ ┌─────────────┐ ┌─────────────┐ │ │ │ │ │ Master │ ───▶ │ Slave │ │ │ │ │ │ (读写) │ │ (只读) │ │ │ │ │ └─────────────┘ └─────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ │ Redis 高可用: │ │ ┌─────────────────────────────────────────────────────────────────┐ │ │ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ │ │ │ │ Master │ ───▶ │ Slave │ ◀─── │ Sentinel │ │ │ │ │ └─────────────┘ └─────────────┘ │ (监控) │ │ │ │ │ └─────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────┘ │ │ │ └─────────────────────────────────────────────────────────────────────────┘ ``` --- ## 10. 技术栈清单 ### 10.1 核心框架 | 组件 | 版本 | 用途 | |-----|------|------| | Spring Boot | 3.5.5 | 应用框架 | | Spring Cloud | 2025.0.0 | 微服务治理 | | JDK | 17 | 运行环境 | ### 10.2 数据层 | 组件 | 版本 | 用途 | |-----|------|------| | MyBatis Plus | 3.5.12 | ORM 框架 | | Druid | 1.2.24 | 连接池 | | MySQL | 8.0.27 | 关系数据库 | | Redis | - | 缓存/分布式锁 | ### 10.3 服务通信 | 组件 | 版本 | 用途 | |-----|------|------| | OpenFeign | 4.2.0 | 服务调用 | | OkHttp | - | HTTP 客户端 | | Redisson | 3.27.0 | 分布式锁 | ### 10.4 容器化 | 组件 | 用途 | |-----|------| | Docker | 容器运行时 | | Kubernetes | 容器编排 | | KubeSphere | 容器平台 | ### 10.5 其他组件 | 组件 | 版本 | 用途 | |-----|------|------| | Knife4j | 4.5.0 | API 文档 | | Quartz | - | 定时任务 | | Shiro | 2.0.4 | 安全框架 | | JWT | 4.5.0 | Token 认证 | --- ## 11. 服务依赖关系图 ``` ┌─────────────────┐ │ System Service │ │ (用户/权限) │ └────────┬────────┘ │ │ 认证 │ ┌──────────────────────────────┼──────────────────────────────┐ │ │ │ ▼ ▼ ▼ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │ Basic Service │◄───────────│Inbound Service │───────────▶│Outbound Service │ │ (基础数据) │ Feign │ (入库业务) │ Feign │ (出库业务) │ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │ │ │ │ Feign │ Feign │ Feign │ │ │ │ ┌────────────────────┼────────────────────┐ │ │ │ │ │ │ ▼ ▼ ▼ ▼ ▼ ┌─────────────────────────┐ ┌─────────────────┐ ┌─────────────────────────┐ │ Inventory Service │◄───│Schedule Service │───▶│ 基础设施 │ │ (库存业务) │ │ (调度任务) │ │ ┌─────┐ ┌─────┐ │ └─────────────────────────┘ └─────────────────┘ │ │MySQL│ │Redis│ │ │ └─────┘ └─────┘ │ └─────────────────────────┘ ``` --- ## 附录 ### A. 服务端口汇总 | 服务 | 容器端口 | Service 端口 | ClusterIP | |-----|---------|-------------|-----------| | cpte-wms-basic | 8001 | 8001 | 10.233.42.190 | | cpte-wms-inbound | 8002 | 8002 | 10.233.51.195 | | cpte-wms-outbound | 8003 | 8003 | - | | inventory-service | 8004 | 8004 | - | | outbound-service | 8003 | 8003 | - | ### B. Context Path 汇总 | 服务 | Context Path | |-----|-------------| | Basic | /cpte-wms-basic | | Inbound | /cpte-wms-inbound | | Outbound | /cpte-wms-outbound | | Inventory | /cpte-wms-inventory | | Schedule | /cpte-wms-schedule | ### C. 关键配置项 | 配置项 | 说明 | |-------|------| | spring.application.name | 服务名称 | | server.port | 服务端口 | | server.servlet.context-path | 上下文路径 | | feign.client.wms-basic.url | 基础服务地址 | | jeecg.redisson.address | Redis 地址 |