
1. 项目背景与意义随着企业业务规模的不断扩大传统的人工台账和Excel表格管理方式已难以满足仓储进销存业务对数据实时性、准确性和可追溯性的要求。库存数据分散、出入库记录滞后、采购与销售信息割裂等问题不仅增加了管理成本也容易造成库存积压或断货风险。本系统基于SpringBoot和Vue进行设计与实现旨在构建一套集采购入库、销售出库、库存查询、供应商与客户管理于一体的仓储进销存管理平台。通过信息化手段统一管理商品、订单和库存流水帮助企业实现库存数据的实时同步与精细化管理提升仓储运营效率降低人工差错率为经营决策提供可靠的数据支撑。2. 系统技术栈本系统采用前后端分离架构后端基于SpringBoot构建RESTful API服务前端基于Vue框架开发单页应用数据库选用MySQL存储业务数据。层次技术选型说明后端框架SpringBoot 2.x提供依赖注入、自动配置与嵌入式容器简化服务端开发部署持久层MyBatis-Plus简化数据库操作内置通用Mapper与分页插件数据库MySQL 8.0存储商品、供应商、客户、出入库单据及库存流水等核心数据前端框架Vue 3 Element Plus组件化开发提供表格、表单、弹窗等成熟UI组件构建工具Maven / npm后端依赖管理与前端工程化构建权限认证JWT Spring Security实现用户登录认证与接口访问控制3. 系统功能模块设计系统整体划分为基础数据管理、采购管理、销售管理、库存管理和系统管理五大功能模块各模块职责清晰、数据联动。基础数据管理维护商品分类、商品信息、计量单位、供应商档案和客户档案。采购管理创建采购入库单登记采购商品、数量和单价审核后自动增加对应商品库存。销售管理创建销售出库单登记销售商品和数量审核后自动扣减对应商品库存。库存管理提供实时库存查询、库存流水明细、库存预警和盘点调整功能。系统管理管理用户账号、角色权限和操作日志。4. 数据库设计系统核心数据表包括商品表、供应商表、客户表、采购入库单表、销售出库单表以及库存流水表。其中商品表与库存流水表通过商品ID关联采购单和销售单审核后分别写入对应的库存流水记录保证库存数据可追溯。CREATE TABLE product ( id BIGINT PRIMARY KEY AUTO_INCREMENT, product_code VARCHAR(50) NOT NULL, product_name VARCHAR(100) NOT NULL, category_id BIGINT, unit VARCHAR(20), stock_quantity INT DEFAULT 0, warning_quantity INT DEFAULT 0, create_time DATETIME ); CREATE TABLE stock_record ( id BIGINT PRIMARY KEY AUTO_INCREMENT, product_id BIGINT NOT NULL, change_type TINYINT COMMENT 1-入库 2-出库, change_quantity INT NOT NULL, before_quantity INT, after_quantity INT, related_order_no VARCHAR(50), create_time DATETIME );5. 核心代码实现5.1 后端采购入库接口采购入库单审核通过后系统需要同时更新商品库存并写入库存流水因此使用事务保证数据一致性。Service public class PurchaseOrderServiceImpl implements PurchaseOrderService { Resource private PurchaseOrderMapper purchaseOrderMapper; Resource private ProductMapper productMapper; Resource private StockRecordMapper stockRecordMapper; Transactional(rollbackFor Exception.class) public void auditPurchaseOrder(Long orderId) { PurchaseOrder order purchaseOrderMapper.selectById(orderId); if (order null || !待审核.equals(order.getStatus())) { throw new BusinessException(单据不存在或状态异常); } Product product productMapper.selectById(order.getProductId()); int beforeQuantity product.getStockQuantity(); int afterQuantity beforeQuantity order.getQuantity(); product.setStockQuantity(afterQuantity); productMapper.updateById(product); StockRecord record new StockRecord(); record.setProductId(product.getId()); record.setChangeType(1); record.setChangeQuantity(order.getQuantity()); record.setBeforeQuantity(beforeQuantity); record.setAfterQuantity(afterQuantity); record.setRelatedOrderNo(order.getOrderNo()); stockRecordMapper.insert(record); order.setStatus(已入库); purchaseOrderMapper.updateById(order); } }5.2 后端库存查询接口库存查询支持按商品名称和分类进行模糊筛选并返回分页结果。RestController RequestMapping(/api/stock) public class StockController { Resource private ProductMapper productMapper; GetMapping(/list) public ResultPageResultProduct list(RequestParam(defaultValue 1) Integer pageNum, RequestParam(defaultValue 10) Integer pageSize, RequestParam(required false) String keyword) { PageProduct page new Page(pageNum, pageSize); LambdaQueryWrapperProduct wrapper new LambdaQueryWrapper(); if (StringUtils.hasText(keyword)) { wrapper.like(Product::getProductName, keyword) .or().like(Product::getProductCode, keyword); } wrapper.orderByDesc(Product::getCreateTime); productMapper.selectPage(page, wrapper); return Result.success(new PageResult(page.getRecords(), page.getTotal())); } }5.3 前端库存列表页面前端使用Vue 3组合式API和Element Plus表格组件展示库存数据并支持关键字搜索。template el-card el-input v-modelkeyword placeholder请输入商品名称或编码 clearable stylewidth: 260px; margin-bottom: 16px keyup.enterloadData / el-table :datatableData border stripe el-table-column propproductCode label商品编码 width140 / el-table-column propproductName label商品名称 / el-table-column propunit label单位 width80 / el-table-column propstockQuantity label当前库存 width100 / el-table-column propwarningQuantity label预警值 width100 / /el-table el-pagination v-model:current-pagepageNum :page-sizepageSize :totaltotal layouttotal, prev, pager, next current-changeloadData / /el-card /template script setup import { ref, onMounted } from vue import request from /utils/request const keyword ref() const pageNum ref(1) const pageSize ref(10) const total ref(0) const tableData ref([]) const loadData async () { const res await request.get(/api/stock/list, { params: { pageNum: pageNum.value, pageSize: pageSize.value, keyword: keyword.value } }) tableData.value res.data.records total.value res.data.total } onMounted(loadData) /script6. 总结本系统基于SpringBoot和Vue实现了仓储进销存管理的核心业务流程覆盖采购入库、销售出库、库存查询与流水追溯等关键环节。通过前后端分离架构和事务化库存更新机制有效保障了库存数据的实时性与一致性。系统界面简洁、操作便捷能够满足中小型企业的日常仓储管理需求后续可进一步扩展报表统计、多仓库管理和移动端适配能力。