Files
BIPMaterialManager/README.md
Misaka_Company 98567d69f0 docs: clarify project rename is planned only, not yet applied to code
- Update rename notice in all 6 doc files to state that the rename from
  ERPAuto to BIPMaterialManager is currently a plan only, with no actual
  code changes implemented
- Documentation names updated for forward compatibility; all code-level
  configs, paths, and artifact names remain unchanged

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-03 16:38:57 +08:00

218 lines
5.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# BIPMaterialManager - BIP 物料管理工具
> **项目重命名说明**:本项目计划从 `ERPAuto` 重命名为 `BIPMaterialManager`。本次重命名仅停留在计划阶段,尚未落实到任何具体代码。目前仅对文档中的项目名称进行了更新,代码层面的配置、路径、产物名称等均保持原样,将在后续阶段统一处理。
一个基于 Electron 的桌面应用程序,用于自动化处理 BIP 系统中的物料数据提取和清理任务。
## 功能特性
- **数据提取**:从 ERP 系统批量下载物料计划数据
- **物料清理**:自动删除指定的物料代码,支持干运行模式
- **数据库支持**:支持 MySQL 和 SQL Server 数据存储
- **Excel 解析**:自动解析下载的 Excel 文件
## 快速开始
### 环境要求
- Node.js >= 18
- npm >= 9
- 可访问的 ERP 系统
### 安装
```bash
# 克隆项目
git clone <repository-url>
cd BIPMaterialManager
# 安装依赖
npm install
```
### 配置
在项目根目录创建 `config.yaml` 文件(可参考 `config.template.yaml`
```yaml
# ERP 配置(固定基础设施)
erp:
url: https://your-erp-server.com
# 数据库配置
database:
activeType: mysql # 或 sqlserver
mysql:
host: localhost
port: 3306
database: erpauto
username: root
password: your_password
charset: utf8mb4
sqlserver:
server: localhost
port: 1433
database: erpauto
username: sa
password: your_password
driver: 'ODBC Driver 18 for SQL Server'
trustServerCertificate: true
# 路径配置
paths:
dataDir: './data/'
defaultOutput: 'output.xlsx'
validationOutput: 'validation-result.xlsx'
```
**注意**ERP 用户名和密码在应用的设置界面中配置,存储在数据库中(按用户管理)。
### 运行开发环境
```bash
npm run dev
```
### 构建应用
```bash
# Windows 安装版 + 便携版
npm run build:win
```
当前项目的正式构建与发布链路仅维护 Windows 目标。
## 使用指南
### 数据提取
1. 启动应用后,点击主页的「数据提取」进入提取页面
2. 在订单号输入框中输入订单号,每行一个
3. 设置批量大小(默认 100
4. 点击「开始提取」按钮
5. 等待提取完成,查看结果
### 物料清理
1. 点击主页的「物料清理」进入清理页面
2. 输入订单号(每行一个)
3. 输入要删除的物料代码(每行一个)
4. 勾选「干运行模式」可预览删除结果(不实际删除)
5. 点击「开始清理」按钮
6. 查看清理结果和详细统计
## 测试
```bash
# 运行单元测试
npm run test
# 运行 E2E 测试
npm run test:e2e
# 查看测试报告
npm run test:e2e:report
# 查看覆盖率报告
npm run test:coverage
```
### 测试基础设施
P0 测试优化已完成2026-04性能提升 **41.5%**7.65s → 4.49s)。
**文档**:
- [测试工厂使用指南](docs/TEST_FACTORY_USAGE.md) — 测试数据工厂 API 和最佳实践
- [Mock 库使用指南](docs/MOCK_LIBRARY_USAGE.md) — Mock 工厂函数和迁移指南
**快速示例**:
```typescript
// 使用测试工厂
import { UserFactory, OrderFactory } from '@/tests/fixtures/factory'
const admin = UserFactory.createAdmin()
const order = OrderFactory.createOrder()
// 使用 Mock 库
import { createMockLogger, createMockConfigManager } from '@/tests/mocks'
const logger = createMockLogger()
const config = createMockConfigManager({ logging: { level: 'debug' } })
```
## 项目结构
```
BIPMaterialManager/
├── src/
│ ├── main/ # 主进程代码
│ │ ├── services/ # 业务服务
│ │ ├── ipc/ # IPC 处理器
│ │ └── types/ # TypeScript 类型
│ ├── preload/ # 预加载脚本
│ └── renderer/ # 渲染进程React UI
├── tests/
│ ├── unit/ # 单元测试
│ ├── integration/ # 集成测试
│ └── e2e/ # E2E 测试
└── docs/ # 文档
```
> **注意**:由于项目正在进行重命名,代码层面的配置文件、路径和产物名称暂时仍使用 `erpauto`,将在后续阶段统一更新。
## 技术栈
- **框架**Electron 39
- **前端**React 19 + TypeScript
- **构建工具**electron-vite
- **浏览器自动化**Playwright
- **数据库**mysql2, mssql
- **Excel 处理**ExcelJS
- **测试**Vitest, Playwright Test
## 常见问题
### 无法连接 ERP 系统
1. 检查 `config.yaml` 中的 ERP URL 是否正确
2. 确认网络连接正常
3. 检查 ERP 系统是否可访问
4. 在设置界面中确认 ERP 用户名和密码已配置
### 提取失败
1. 确认订单号格式正确
2. 检查 ERP 系统账号权限
3. 查看应用日志获取详细错误信息
### 数据库连接失败
1. 确认数据库服务已启动
2. 检查 `config.yaml` 中的数据库配置
3. 确认防火墙允许数据库端口访问
## 开发
```bash
# 安装依赖
npm install
# 启动开发服务器
npm run dev
# 类型检查
npm run typecheck
# 代码格式化
npm run format
# Lint 检查
npm run lint
```
## 许可证
MIT License