Răsfoiți Sursa

docs: add installation guide and remove hardcoded credentials

徐福静0235668 4 luni în urmă
părinte
comite
84b956b028

+ 3 - 3
backend/src/main/resources/application.yml

@@ -9,7 +9,7 @@ spring:
     driver-class-name: com.mysql.cj.jdbc.Driver
     driver-class-name: com.mysql.cj.jdbc.Driver
     url: jdbc:mysql://localhost:3306/huanbao?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
     url: jdbc:mysql://localhost:3306/huanbao?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
     username: root
     username: root
-    password: xfj7758758@
+    password: your_password  # 请替换为你的MySQL密码
   
   
   jackson:
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss
     date-format: yyyy-MM-dd HH:mm:ss
@@ -47,12 +47,12 @@ knife4j:
 
 
 # JWT配置
 # JWT配置
 jwt:
 jwt:
-  secret: recycle-app-jwt-secret-key-2024-very-long-secret
+  secret: your-jwt-secret-key  # 请替换为你的JWT密钥(建议32位以上随机字符串)
   expiration: 86400000  # 24小时
   expiration: 86400000  # 24小时
 
 
 # DeepSeek AI配置
 # DeepSeek AI配置
 ai:
 ai:
   api:
   api:
-    key: sk-3ae5d07978a54d369b8e9fb9bc944e78 # 请替换为你的DeepSeek API Key
+    key: your-deepseek-api-key  # 请替换为你的DeepSeek API Key,申请地址: https://platform.deepseek.com
     url: https://api.deepseek.com/v1/chat/completions
     url: https://api.deepseek.com/v1/chat/completions
     model: deepseek-chat
     model: deepseek-chat

+ 3 - 3
backend/target/classes/application.yml

@@ -9,7 +9,7 @@ spring:
     driver-class-name: com.mysql.cj.jdbc.Driver
     driver-class-name: com.mysql.cj.jdbc.Driver
     url: jdbc:mysql://localhost:3306/huanbao?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
     url: jdbc:mysql://localhost:3306/huanbao?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
     username: root
     username: root
-    password: xfj7758758@
+    password: your_password  # 请替换为你的MySQL密码
   
   
   jackson:
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss
     date-format: yyyy-MM-dd HH:mm:ss
@@ -47,12 +47,12 @@ knife4j:
 
 
 # JWT配置
 # JWT配置
 jwt:
 jwt:
-  secret: recycle-app-jwt-secret-key-2024-very-long-secret
+  secret: your-jwt-secret-key  # 请替换为你的JWT密钥(建议32位以上随机字符串)
   expiration: 86400000  # 24小时
   expiration: 86400000  # 24小时
 
 
 # DeepSeek AI配置
 # DeepSeek AI配置
 ai:
 ai:
   api:
   api:
-    key: sk-3ae5d07978a54d369b8e9fb9bc944e78 # 请替换为你的DeepSeek API Key
+    key: your-deepseek-api-key  # 请替换为你的DeepSeek API Key,申请地址: https://platform.deepseek.com
     url: https://api.deepseek.com/v1/chat/completions
     url: https://api.deepseek.com/v1/chat/completions
     model: deepseek-chat
     model: deepseek-chat

+ 350 - 0
作品安装说明.md

@@ -0,0 +1,350 @@
+# 再生视界 · 智慧回收平台 — 作品安装说明
+
+---
+
+## 一、项目简介
+
+"再生视界"是一款**端—边—云协同**的智能回收物联网系统,致力于打通废弃物从投递到处理的全链路感知与决策闭环。本项目采用前后端分离架构,覆盖 **C 端(用户端)**、**B 端(企业端)**、**G 端(政府监管端)** 三大终端,共计 **61 张数据表**,实现端侧感知、边侧推理、云侧决策的完整闭环。
+
+---
+
+## 二、系统架构与功能-数据表对接总览
+
+### 2.1 端侧 — 感知采集层
+
+> 多光谱传感器与红外模组集成于智能回收箱与 AR 分拣终端,同步采集废弃物材质、污染度与含水率。
+
+| 功能模块 | 前端组件路径 | 对应数据表 | 说明 |
+|---|---|---|---|
+| **AR 智能识别** | `src/app/consumer/home/ar-recognition/` | `scan_history` | 基于 TensorFlow.js + COCO-SSD 的浏览器端物体检测,记录识别类别、置信度、边界框坐标 |
+| **废品分类感知** | `src/app/consumer/booking-recycle/` | `waste_categories` | 多光谱传感器数据映射为 8 大废品分类(纸类/塑料/玻璃/电子/纺织/金属/家具/其他),含材质单价、碳减排系数 |
+| **投递点状态** | `src/app/consumer/home/drop-points/` | `drop_points` | 智能回收箱实时容量(capacity 字段 0-100%)、支持类型、运行状态监控 |
+| **回收员终端** | `src/app/consumer/home/collectors/` | `collectors` | 回收员实时位置(经纬度)、在线状态、擅长类目、服务评分 |
+
+### 2.2 边侧 — 推理预警层
+
+> Jetson 边缘计算设备完成本地推理与满溢预警。
+
+| 功能模块 | 前端组件路径 | 对应数据表 | 说明 |
+|---|---|---|---|
+| **设备管理与监控** | `src/app/business/device-management/` | `devices` | 设备类型(分拣/压缩/粉碎/分选/打包)、运行时长、处理量、温度/压力传感数据 |
+| **设备告警** | `src/app/business/dashboard/` | `device_alerts` | 多级告警(低/中/高/严重),覆盖温度、压力、效率、故障类型 |
+| **满溢预警** | `src/app/business/dashboard/` | `business_alerts` | 订单/设备/库存/财务多维度预警,支持处理/忽略工作流 |
+| **设备维护调度** | `src/app/business/device-management/` | `device_maintenance` | 常规/维修/紧急三类维护,含技工、成本、时间追踪 |
+| **监控点位** | `src/app/business/dashboard/` | `monitoring_locations` | 社区/商场/学校/办公楼 4 类点位,实时容量与满溢状态 |
+
+### 2.3 云侧 — 决策调度层
+
+> STGNN 时空图神经网络融合多源数据,提前 3 小时预判峰值并生成最优调度方案。
+
+| 功能模块 | 前端组件路径 | 对应数据表 | 说明 |
+|---|---|---|---|
+| **AI 运营助手(B 端)** | `src/app/business/ai-operations-assistant/` | `ai_chat_history`, `ai_insights` | DeepSeek 大模型驱动的智能对话,生成运营洞察与调度建议 |
+| **AI 决策助手(G 端)** | `src/app/government/ai-decision-assistant/` | `ai_generated_reports` | AI 自动生成月度/行业/政策分析报告 |
+| **AI 个人助手(C 端)** | `src/app/consumer/ai-assistant/` | — | 面向用户的垃圾分类咨询与环保知识问答(OpenAI SDK + DeepSeek API) |
+| **数据报表** | `src/app/business/data-reports/` | `statistics_reports` | 日/周/月/年报表,含回收量、营收、碳减排、节水、节电等环保数据 |
+| **区域统计** | `src/app/government/supervision-overview/` | `region_statistics`, `category_statistics` | 多区域回收率、再生利用率、分类准确率对比 |
+| **产业链分析** | `src/app/government/industry-analysis/` | `industry_chain_data` | 回收→分拣→加工→再生全链路数据,含企业数量、从业人数、产值、增长率 |
+| **风险评估** | `src/app/government/industry-analysis/` | `risk_assessments` | 市场/政策/技术/环保四维风险,含概率评估与应对策略 |
+| **政策模拟** | `src/app/government/subsidy-management/` | `policy_simulations` | 补贴政策效果模拟,预估回收量增长、预算成本、碳减排量 |
+| **政策效果评估** | `src/app/government/subsidy-management/` | `policy_evaluations` | 补贴总额、回收量增长、参与率、满意度、成本效益比 |
+
+---
+
+## 三、三端功能与数据表完整对接
+
+### 3.1 C 端(用户端) — 26 张表
+
+| 功能页面 | 路由路径 | 核心数据表 |
+|---|---|---|
+| 注册/登录 | `/auth/login`, `/auth/register` | `users` |
+| 首页 | `/consumer/home` | `activities`, `drop_points`, `collectors` |
+| AR 智能识别 | `/consumer/ar-recognition` | `scan_history`, `waste_categories` |
+| 预约回收 | `/consumer/booking-recycle` | `recycle_orders`, `user_addresses`, `waste_categories` |
+| 收益明细 | `/consumer/earnings` | `earnings`, `points_records`, `withdraw_records` |
+| 积分商城 | `/consumer/points-mall` | `products`, `exchange_records`, `checkin_records`, `tasks`, `user_tasks` |
+| 环保知识 | `/consumer/eco-knowledge` | — |
+| AI 助手 | `/consumer/ai-assistant` | — (调用 DeepSeek API) |
+| 消息通知 | `/consumer/notifications` | `notifications` |
+| 我的订单 | `/consumer/profile/orders` | `recycle_orders`, `order_reviews` |
+| 地址管理 | `/consumer/profile/addresses` | `user_addresses` |
+| 我的收藏 | `/consumer/profile/favorites` | `favorites` |
+| 邀请好友 | `/consumer/profile/invite-friends` | `invite_records` |
+| 在线客服 | `/consumer/profile/customer-service` | `customer_service_sessions`, `customer_service_messages` |
+| 成就徽章 | 个人中心内嵌 | `badges`, `user_badges` |
+| 捐赠 | 收益页面内嵌 | `donation_projects`, `donation_records` |
+
+### 3.2 B 端(企业端) — 18 张表
+
+| 功能页面 | 路由路径 | 核心数据表 |
+|---|---|---|
+| 工作台仪表盘 | `/business/dashboard` | `business_alerts`, `business_todos`, `monitoring_locations` |
+| 订单管理 | `/business/order-management` | `business_orders`, `recycle_orders`(关联 C 端) |
+| 设备管理 | `/business/device-management` | `devices`, `device_maintenance`, `device_alerts` |
+| 数据报表 | `/business/data-reports` | `statistics_reports` |
+| AI 运营助手 | `/business/ai-operations-assistant` | `ai_chat_history`, `ai_insights` |
+| 企业中心 | `/business/enterprise-center` | `enterprises`, `enterprise_employees`, `contracts`, `subscription_plans`, `enterprise_subscriptions` |
+| 政策补贴申请 | 企业中心内嵌 | `policies`, `policy_applications` |
+| 登录审计 | 企业中心内嵌 | `login_logs` |
+
+### 3.3 G 端(政府端) — 17 张表
+
+| 功能页面 | 路由路径 | 核心数据表 |
+|---|---|---|
+| 监管总览 | `/government/supervision-overview` | `administrative_regions`, `recycle_stations`, `government_warnings`, `region_statistics` |
+| 补贴管理 | `/government/subsidy-management` | `subsidy_applications`, `subsidy_payments`, `policy_evaluations`, `policy_simulations` |
+| 产业分析 | `/government/industry-analysis` | `industry_chain_data`, `category_statistics`, `risk_assessments` |
+| AI 决策助手 | `/government/ai-decision-assistant` | `ai_generated_reports` |
+| 政府中心 | `/government/government-center` | `government_users`, `government_notices`, `government_operation_logs` |
+| 合规检查 | 监管总览内嵌 | `compliance_checks` |
+| 密码设置 | `/government/government-center/password-settings` | `government_users` |
+| 通知设置 | `/government/government-center/notification-settings` | `notification_settings` |
+| 帮助中心 | `/government/government-center/help-center` | — |
+
+---
+
+## 四、安装说明
+
+### 4.1 环境要求
+
+| 环境 | 最低版本 | 推荐版本 | 说明 |
+|---|---|---|---|
+| **Node.js** | 18.x | 20.x LTS | 前端构建运行环境 |
+| **npm** | 9.x | 10.x | Node 包管理器 |
+| **JDK** | 11 | 17 | 后端 Spring Boot 运行环境 |
+| **Maven** | 3.8+ | 3.9.x | Java 依赖管理与构建 |
+| **MySQL** | 5.7 | 8.x | 关系型数据库 |
+| **Redis** | 6.x | 7.x | 缓存服务(可选) |
+| **Git** | 2.x | 最新版 | 版本管理 |
+
+### 4.2 获取源码
+
+```bash
+git clone https://github.com/mobile-1234/recycle-app.git
+cd recycle-app
+```
+
+### 4.3 数据库初始化
+
+#### 步骤 1:创建数据库
+
+```sql
+CREATE DATABASE IF NOT EXISTS huanbao DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+USE huanbao;
+```
+
+#### 步骤 2:导入数据表(共 61 张)
+
+在 MySQL 命令行或可视化工具(如 Navicat / MySQL Workbench)中,依次执行以下 SQL 文件:
+
+```bash
+# 顺序执行,不可颠倒
+mysql -u root -p huanbao < database/recycle_app_database.sql          # C端 26张表
+mysql -u root -p huanbao < database/recycle_app_business_database.sql  # B端 18张表
+mysql -u root -p huanbao < database/recycle_app_government_database.sql # G端 17张表
+```
+
+> **注意**:SQL 文件中包含 `USE recycle_app;` 语句,如果你使用的数据库名为 `huanbao`,需将 SQL 文件中的 `recycle_app` 替换为 `huanbao`,或直接使用 `database/补充缺失表.sql` 一次性建表。
+
+#### 步骤 3:验证表数量
+
+```sql
+USE huanbao;
+SELECT COUNT(*) AS total_tables FROM information_schema.tables WHERE table_schema = 'huanbao';
+-- 预期结果:61
+```
+
+### 4.4 后端安装与启动
+
+#### 步骤 1:修改数据库配置
+
+编辑 `backend/src/main/resources/application.yml`:
+
+```yaml
+spring:
+  datasource:
+    url: jdbc:mysql://localhost:3306/huanbao?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
+    username: root
+    password: 你的数据库密码    # ← 修改为你的MySQL密码
+
+# DeepSeek AI 配置(AI助手功能需要)
+ai:
+  api:
+    key: 你的DeepSeek-API-Key  # ← 修改为你的API Key,申请地址: https://platform.deepseek.com
+    url: https://api.deepseek.com/v1/chat/completions
+    model: deepseek-chat
+```
+
+#### 步骤 2:编译并启动
+
+```bash
+cd backend
+
+# 方式一:Maven 命令启动(开发模式)
+mvn spring-boot:run
+
+# 方式二:打包后运行(生产模式)
+mvn clean package -DskipTests
+java -jar target/recycle-app-backend-1.0.0.jar
+```
+
+#### 步骤 3:验证后端
+
+- 浏览器访问 **http://localhost:8080/doc.html** 查看 Knife4j API 文档
+- 出现 Swagger 接口文档页面即表示后端启动成功
+
+### 4.5 前端安装与启动
+
+#### 步骤 1:安装依赖
+
+```bash
+# 在项目根目录执行
+npm install
+```
+
+> 首次安装可能需要 3-5 分钟,取决于网络状况。
+
+#### 步骤 2:启动开发服务器
+
+```bash
+npm start
+# 或
+ng serve
+```
+
+#### 步骤 3:访问应用
+
+- 浏览器打开 **http://localhost:4200**
+- 默认进入登录页面 `/auth/login`
+- 登录后根据用户角色跳转至对应端:
+  - **C 端用户** → `/consumer/home`
+  - **B 端企业** → `/business/dashboard`
+  - **G 端政府** → `/government/supervision-overview`
+
+---
+
+## 五、项目目录结构
+
+```
+recycle-app/
+├── backend/                          # 后端 Spring Boot 项目
+│   ├── pom.xml                       # Maven 依赖配置
+│   └── src/main/
+│       ├── java/com/recycle/
+│       │   ├── controller/
+│       │   │   ├── client/           # C端 API 接口
+│       │   │   ├── business/         # B端 API 接口
+│       │   │   └── government/       # G端 API 接口
+│       │   ├── entity/               # 61个实体类(对应61张表)
+│       │   ├── mapper/               # MyBatis 数据访问层
+│       │   ├── service/              # 业务逻辑层
+│       │   ├── config/               # 跨域、Swagger等配置
+│       │   └── util/                 # JWT等工具类
+│       └── resources/
+│           └── application.yml       # 应用配置
+│
+├── src/                              # 前端 Angular 项目
+│   └── app/
+│       ├── auth/                     # 认证模块(登录/注册/忘记密码)
+│       ├── consumer/                 # C端用户模块
+│       │   ├── home/                 # 首页(AR识别/投递点/回收员/活动)
+│       │   ├── booking-recycle/      # 预约回收
+│       │   ├── earnings/             # 收益管理
+│       │   ├── points-mall/          # 积分商城
+│       │   ├── eco-knowledge/        # 环保知识
+│       │   ├── ai-assistant/         # AI 智能助手
+│       │   └── profile/              # 个人中心(订单/地址/收藏/客服等)
+│       ├── business/                 # B端企业模块
+│       │   ├── dashboard/            # 工作台仪表盘
+│       │   ├── order-management/     # 订单管理
+│       │   ├── device-management/    # 设备管理
+│       │   ├── data-reports/         # 数据报表
+│       │   ├── ai-operations-assistant/ # AI运营助手
+│       │   └── enterprise-center/    # 企业中心
+│       ├── government/               # G端政府模块
+│       │   ├── supervision-overview/ # 监管总览
+│       │   ├── subsidy-management/   # 补贴管理
+│       │   ├── industry-analysis/    # 产业分析
+│       │   ├── ai-decision-assistant/# AI决策助手
+│       │   └── government-center/    # 政府中心
+│       ├── core/                     # 核心模块(守卫/拦截器/服务)
+│       └── shared/                   # 共享模块
+│
+├── database/                         # 数据库脚本
+│   ├── init_huanbao_database.sql     # 初始化说明
+│   ├── recycle_app_database.sql      # C端 26张表
+│   ├── recycle_app_business_database.sql  # B端 18张表
+│   └── recycle_app_government_database.sql # G端 17张表
+│
+├── package.json                      # 前端依赖配置
+├── angular.json                      # Angular 项目配置
+└── tsconfig.json                     # TypeScript 配置
+```
+
+---
+
+## 六、核心技术栈
+
+| 层级 | 技术 | 版本 | 用途 |
+|---|---|---|---|
+| **前端框架** | Angular | 20.x | SPA 应用框架 |
+| **移动端 UI** | Ionic | 8.x | 跨平台移动端组件库 |
+| **桌面端 UI** | NG-ZORRO (Ant Design) | 20.x | B 端 / G 端企业级 UI |
+| **AI 推理(端侧)** | TensorFlow.js + COCO-SSD | 4.x | 浏览器端实时物体检测 |
+| **3D 渲染** | Babylon.js | 8.x | AR 场景 3D 渲染 |
+| **数据可视化** | ECharts + Chart.js | 6.x / 4.x | 图表展示 |
+| **AI 对话(云侧)** | OpenAI SDK + LangChain | 6.x / 0.3.x | DeepSeek 大模型对话与决策 |
+| **地图服务** | 高德地图 | 1.x | 投递点/回收员定位与导航 |
+| **后端框架** | Spring Boot | 2.7 | REST API 服务 |
+| **ORM** | MyBatis-Plus | 3.5.x | 数据库操作 |
+| **数据库** | MySQL | 8.x | 数据持久化 |
+| **认证** | JWT (JJWT) | 0.12.x | 用户身份认证 |
+| **API 文档** | Knife4j (Swagger) | 3.0.x | 接口调试与文档 |
+| **缓存** | Redis | 可选 | 高频数据缓存 |
+
+---
+
+## 七、API 接口说明
+
+| 端 | 前缀 | 主要接口 |
+|---|---|---|
+| **C 端** | `/api/c/` | `auth/*`(认证)、`user/*`(用户)、`orders/*`(订单)、`categories/*`(分类)、`collectors/*`(回收员)、`products/*`(积分商城) |
+| **B 端** | `/api/b/` | `auth/*`(企业登录)、`orders/*`(订单管理) |
+| **G 端** | `/api/g/` | `auth/*`(政府登录)、`statistics/*`(数据统计) |
+
+---
+
+## 八、常见问题
+
+### Q1: `npm install` 报错?
+- 确保 Node.js ≥ 18,执行 `node -v` 检查
+- 尝试清除缓存:`npm cache clean --force`,然后重新安装
+
+### Q2: 后端启动失败提示数据库连接错误?
+- 确认 MySQL 服务已启动
+- 确认 `application.yml` 中的数据库名、用户名、密码正确
+- 确认已执行数据库初始化 SQL 脚本
+
+### Q3: 前端页面打开后一片空白?
+- 确认后端已启动(`http://localhost:8080/doc.html` 可访问)
+- 检查浏览器控制台是否有跨域错误,后端 `config/` 目录下已配置 CORS
+
+### Q4: AI 助手功能不可用?
+- 需要配置 DeepSeek API Key
+- 在 `backend/src/main/resources/application.yml` 中填写有效的 `ai.api.key`
+- API Key 申请地址:https://platform.deepseek.com
+
+### Q5: AR 识别功能加载缓慢?
+- TensorFlow.js COCO-SSD 模型首次加载需下载约 5MB 模型文件
+- 建议使用 Chrome / Edge 浏览器,需允许摄像头权限
+
+---
+
+## 九、开源地址
+
+- **GitHub**:https://github.com/mobile-1234/recycle-app
+- **许可证**:建议添加 MIT 或 Apache-2.0 开源许可
+
+---
+
+*文档生成时间:2026-04-29*