init smt erp project

This commit is contained in:
2026-10-13 16:35:04 +08:00
parent d8643761f5
commit ed03b70f79

194
README.md
View File

@@ -1,118 +1,82 @@
# SMT-ERP
SMT-ERP 是面向瑞银电子马来西亚(SMT)分公司的私有化 ERP 系统,服务于吉隆坡分公司的进销存、生产、财务和内部管理场景。
SMT-ERP is a privately deployed ERP system for Reallin's SMT operation in Malaysia. It brings sales, purchasing, inventory, production, finance, assets, reporting, and system administration into one application. The project is intended for deployment on SMT-managed infrastructure.
项目以 SMT 为首个落地试点,面向人员规模不超过 100 人的海外分公司建设,后续可复制到其他海外分公司。系统部署在 SMT 本地机房,核心业务数据由企业自主掌控。
## 项目目标
围绕“总部生产完成 → 调拨至 SMT → SMT 包装/组装 → 交付客户 → 收款”的业务链路,建立从订单、调拨、库存、生产到财务的闭环管理,解决库存依赖 Excel、审批依赖线下纸质流程以及业务账与财务账不一致等问题。
系统重点支持:
- TNB(马来西亚国家电力公司)订单及二级市场订单管理
- 总部调拨、SMT 本地包材采购和到货管理
- 包装 BOM、生产工单、领料、报工和完工入库
- 批次(LOT NO)与电表序列号(S/N From - S/N To)全流程追溯
- 销售出库、客户签收、应收应付、成本核算和财务报表
- 钉钉国际版审批集成,以及 SMT 与 Reallin 的数据互通
## 当前项目结构
## Repository layout
```text
SMT_ERP/
├── smtERP-boot/ # Java 后端服务
│ ├── src/main/java/ # 控制器、业务逻辑、数据访问和系统配置
│ ├── src/main/resources/
│ │ ├── application.yml
│ │ └── mapper_xml/ # MyBatis XML 映射
│ └── docs/ # 初始化及数据库升级脚本
├── smtERP-web/ # Web 前端
│ ├── src/api/ # 后端接口封装
│ ├── src/views/ # 业务页面
│ └── src/components/ # 通用组件
SMT-ERP/
├── smtERP-boot/ Java backend (controllers, services, persistence, configuration)
│ ├── docs/ Database initialization and other SQL scripts
│ └── src/main/resources/ application.yml and MyBatis XML mappers
├── smtERP-web/ Vue frontend (pages, API clients, components)
├── LICENSE
└── README.md
```
## 技术架构
## Architecture
| 层级 | 当前实现 |
|---|---|
| 前端 | Vue 2.7.16、Vue Router 3、Vuex 3、Ant Design Vue 1.5.2、Axios |
| 后端 | Java 11、Spring Boot 2.0.0.RELEASE、Maven |
| 持久层 | MyBatis-Plus 3.0.7.1、MyBatis XML Mapper |
| 数据库 | MySQL 8.0.33 驱动,默认数据库名 `jsh_erp` |
| 缓存 | Redis |
| 接口文档 | Springfox Swagger 2.7.0、Swagger Bootstrap UI |
| 部署 | SMT 本地机房私有化部署,可运行于 Windows 或 Linux |
| Component | Implementation in this repository |
| --- | --- |
| Frontend | Vue 2.7, Vue Router 3, Vuex 3, Ant Design Vue 1.5.2, Axios, Vue CLI |
| Backend | Java 11, Spring Boot 2.0.0.RELEASE, Maven |
| Persistence | MyBatis-Plus 3.0.7.1 and MyBatis XML mappers |
| Database | MySQL; the configured JDBC driver is MySQL Connector/J 8.0.33 |
| Cache | Redis |
| API documentation | Springfox Swagger 2.7.0 and Swagger Bootstrap UI |
> 需求文档规划的 Vue 3 属于后续技术演进方向;当前仓库前端仍以 Vue 2.7.16 为准。后端编译版本以 `smtERP-boot/pom.xml` 中的 `<java.version>11</java.version>` 为准。
The backend source code is under the `com.reallin.smt` package. The configured backend context path is `/apis`.
## 业务规划
## Local setup
### 第一阶段:核心业务闭环
### Prerequisites
1. 销售管理:客户、报价、TNB/二级市场订单、交货计划、发货、签收、销售对账。
2. 采购管理:总部调拨申请与接收、本地包材采购、供应商、采购入库和对账。
3. 生产管理:包装 BOM、包装工单、领料、生产报工、质检、完工入库和生产进度。
4. 仓储管理:多仓库、入库、出库、批次、序列号、库存账、库存预警、盘点和库存规划。
5. 审批与数据互通:接入钉钉国际版审批,并规划 SMT 与 Reallin 的业务数据同步。
- JDK 11 and Maven
- Node.js and npm
- MySQL and Redis instances reachable from the backend
### 第二阶段:内部信息化管理
### 1. Initialize MySQL
将当前线下 Excel 管理内容逐步搬到线上,覆盖考勤、请假、培训、资产、费用及其他内部管理事项。
### 财务与合规重点
- 以人民币作为主要结算币种,同时支持本地采购使用 MYR(马来西亚林吉特)记录。
- 财务年度为每年 3 月 1 日至次年 3 月 31 日。
- 支持应收、应付、总账、费用、成本、发票和资产负债表/利润表等报表。
- 财务核算遵循马来西亚当地业务要求,预留 MFRS、SST 及电子发票相关能力。
- 发票录入需满足清关及货运文件齐全等前置条件,并支持跨期入账和电子发票提交时间窗口控制。
## 开发环境
- JDK 11
- Maven 3.6+(以本机 Maven 版本为准)
- Node.js 及 npm/yarn
- MySQL 8.0+
- Redis 6.x+
- IntelliJ IDEA 或其他 Java IDE
## 本地运行
### 1. 初始化数据库
创建 MySQL 数据库后,执行:
Create a database named `app072` (or update the JDBC URL in `smtERP-boot/src/main/resources/application.yml` to match your database). Import the repository's initialization dump:
```text
smtERP-boot/docs/jsh_erp.sql
smtERP-boot/docs/smt-erp-init-data.sql
```
后续升级脚本按版本和实际需求执行,数据库升级记录见 `smtERP-boot/docs/`。
For example, from the repository root in a shell that supports input redirection:
### 2. 配置后端
```bash
mysql -u YOUR_MYSQL_USER -p -e "CREATE DATABASE app072 CHARACTER SET utf8mb4;"
mysql -u YOUR_MYSQL_USER -p app072 < smtERP-boot/docs/smt-erp-init-data.sql
```
编辑 `smtERP-boot/src/main/resources/application.yml`,至少确认以下配置:
On Windows, run the import command in Command Prompt (`cmd`) or use a MySQL client with an SQL import feature. The dump contains `DROP TABLE IF EXISTS` statements and existing data; import it only into the database you intend to initialize.
- MySQL 地址、数据库名、用户名和密码
- Redis 地址、端口和密码
- 文件上传目录及目录权限
- 服务端口和上下文路径
### 2. Configure the backend
请勿在生产环境直接使用仓库中的示例密码,并避免将真实密码提交到 Git。
`smtERP-boot/src/main/resources/application.yml` currently uses `127.0.0.1:3306/app072` for MySQL, `10.20.120.47:6379` for Redis, port `27210`, and context path `/apis`. Set these environment variables before starting the backend:
### 3. 启动后端
| Variable | Purpose |
| --- | --- |
| `DB_USERNAME` | MySQL username |
| `DB_PASSWORD` | MySQL password |
| `REDIS_PASSWORD` | Redis password |
| `SYNC_API_KEY` | Optional key for external synchronization; without it, a logged-in ERP session is required |
Adjust the MySQL and Redis hosts to match your environment. The configured Tomcat temporary directory (`/data/app/P072/tmp/tomcat`) and file upload/export directories (`/data/app/P072/upload`, `/data/app/P072/export`) must exist and be writable by the backend, or be changed to suitable paths before startup. Do not commit real credentials to the repository.
### 3. Start the backend
```bash
cd smtERP-boot
mvn spring-boot:run
```
后端默认地址:`http://localhost:27210/jshERP-boot`
With the current configuration, the backend base URL is `http://localhost:27210/apis` when started on your machine. The external inbound synchronization endpoint is `POST http://localhost:27210/apis/smtInbound/sync`.
### 4. 启动前端
### 4. Start the frontend
In a second terminal, from the repository root:
```bash
cd smtERP-web
@@ -120,35 +84,9 @@ npm install
npm run serve
```
前端开发地址:`http://localhost:27200`。开发服务器会将 `/jshERP-boot` 请求代理到 `http://localhost:27210`。
Open `http://localhost:27200`. The frontend sends API requests under `/apis`. Its development proxy in `smtERP-web/vue.config.js` currently forwards those requests to `http://10.20.120.47:27210`. That host must be reachable; for a backend running on the same machine, change the proxy target to `http://localhost:27210` before starting the frontend.
### SMT 其他入库同步
外部平台可调用 `POST /jshERP-boot/smtInbound/sync`,请求头为
`Content-Type: application/json`,请求体示例:
```json
[
{
"docNo": "SM2503070001",
"businessDate": "2025-03-07 00:00:00.000",
"materialCode": "C.4.T.0.00562",
"materialName": "MD-4GVIII(VB)",
"specification": "MD-4GVIII(VB)",
"qtyPriceAmount": 50,
"finallyPrice": "324",
"totalNetMoney": "14336.280000000",
"totalMoney": "16200.000000000",
"sourceDocNo": "SH2503070002"
}
]
```
接口按 `docNo` 去重:未审核单据会被整单覆盖,已审核单据会跳过,并在
`auditedDocNos` 中返回冲突单号。Excel 导入使用同一规则。其他入库审核通过时,
系统以 `materialCode` 作为 ERP 条码创建或更新商品,并将库存写入“成品仓库”。
### 5. 构建
## Build
```bash
cd smtERP-web
@@ -158,36 +96,12 @@ cd ../smtERP-boot
mvn clean package
```
构建生成的 `target/`、`dist/`、压缩包、`node_modules/` 和运行日志不会纳入版本库。
Frontend build output is written to `smtERP-web/dist/`; Maven writes backend build output to `smtERP-boot/target/`. Both are excluded from Git by the repository ignore rules.
## 部署说明
## Deployment notes
系统采用 SMT 本地机房部署模式,建议由 SMT 开发与 IT 人员共同负责部署和日常维护,总部系统信息部提供架构、集成和技术支持。
Provide production MySQL and Redis connections, environment variables, writable storage paths, and a web server for the built frontend. Route `/apis` to the backend service on port `27210`; serve the frontend separately. Verify authentication, permissions, inventory operations, and integrations against the deployed environment before use.
生产部署至少应完成:
## License
1. 准备 Java 11 运行环境、MySQL、Redis 和 Web 服务器/反向代理。
2. 初始化数据库并按发布版本执行升级脚本。
3. 使用生产数据库、Redis、文件目录和外部接口配置替换示例配置。
4. 配置前端静态文件、后端服务、反向代理、备份和日志轮转。
5. 上线前验证登录、权限、库存、单据、审批回调和数据同步链路。
## 组织与协作
SMT 当前组织包括财务部、市场部、技术部、生产部和行政部门,系统权限设计需结合部门、岗位、仓库和数据范围进行隔离。
- SMT 项目管理:Hafiz
- SMT 开发、需求收集和日常运维:Aziman
- SMT 机房、网络和部署支持:Haslim
- 总部架构、核心模块、钉钉国际版集成和技术支持:总部系统信息部
- 需求提交渠道:Reallin 售后服务平台
## 版本与状态
当前仓库是 SMT-ERP 的开发基线,已包含现有进销存、财务、生产、报表、系统管理等基础代码。需求文档中的钉钉国际版审批、SMT 与 Reallin 数据互通、完整序列号追溯及第二阶段内部信息化能力,按项目迭代计划逐步建设。
需求依据:SMT(马来西亚)ERP 系统需求文档 v1.7(2026-08-21)。
## 许可证
本项目遵循 Apache License 2.0,详见 [LICENSE](LICENSE)。
This project is licensed under Apache License 2.0. See [LICENSE](LICENSE).