
1. 项目概述这个药品管理系统是我在2022年完成的毕业设计项目采用SpringBootVue前后端分离架构配合MySQL数据库实现了药品信息管理、库存预警、销售统计等核心功能。系统从需求分析到最终部署上线历时3个月期间踩过不少坑也积累了很多实战经验。作为一个典型的医院/药店信息化解决方案这个系统最突出的特点是采用主流技术栈组合符合企业级开发规范实现了完整的药品生命周期管理包含详细的部署文档和数据库设计说明配套完整的毕业论文和技术文档提示系统源码已通过Gitee开源仓库地址见文末建议配合部署文档边看边操作。2. 技术架构解析2.1 后端技术选型SpringBoot 2.7.3作为后端框架主要基于以下考虑自动配置特性大幅减少XML配置内嵌Tomcat简化部署流程与MyBatis-Plus的完美整合丰富的starter依赖如spring-boot-starter-security核心依赖项dependency groupIdcom.baomidou/groupId artifactIdmybatis-plus-boot-starter/artifactId version3.5.2/version /dependency dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-data-redis/artifactId /dependency2.2 前端技术方案Vue 3 Element Plus的组合提供了响应式数据绑定组件化开发体验丰富的UI组件库Axios HTTP请求封装关键配置示例// axios拦截器配置 service.interceptors.request.use(config { if (store.getters.token) { config.headers[Authorization] Bearer getToken() } return config })2.3 数据库设计MySQL 8.0数据库包含12张核心表药品基础表medicine库存记录表inventory供应商表supplier采购记录表purchase销售记录表salesCREATE TABLE medicine ( id bigint NOT NULL AUTO_INCREMENT, code varchar(32) COMMENT 药品编码, name varchar(100) NOT NULL, spec varchar(50) COMMENT 规格, unit varchar(10) COMMENT 单位, price decimal(10,2) NOT NULL, stock int DEFAULT 0, warning_value int DEFAULT 10, PRIMARY KEY (id), UNIQUE KEY idx_code (code) ) ENGINEInnoDB DEFAULT CHARSETutf8mb4;3. 核心功能实现3.1 药品信息管理模块采用RBAC权限控制模型实现功能包括药品CRUD操作批量导入/导出条形码生成与识别多条件复合查询后端接口示例RestController RequestMapping(/api/medicine) public class MedicineController { Autowired private MedicineService medicineService; GetMapping(/list) public Result list(MedicineQuery query) { PageMedicine page medicineService.queryPage(query); return Result.success(page); } }3.2 库存预警系统实现策略定时任务每天凌晨检查库存使用Redis缓存热点药品数据多级预警机制邮件站内信Scheduled(cron 0 0 2 * * ?) public void checkStock() { ListMedicine medicines medicineService.listLowStock(); medicines.forEach(med - { String message String.format(药品[%s]库存不足当前数量%d, med.getName(), med.getStock()); alertService.sendWarning(med.getManagerId(), message); }); }3.3 销售统计报表技术要点ECharts可视化动态SQL构建多维度数据分析template div el-row el-col :span12 div refsalesChart styleheight:400px/div /el-col /el-row /div /template script import * as echarts from echarts export default { methods: { initChart() { const chart echarts.init(this.$refs.salesChart) chart.setOption({ tooltip: {...}, xAxis: {...}, series: [...] }) } } } /script4. 部署实践与优化4.1 环境准备推荐配置JDK 11Node.js 16MySQL 8.0Redis 6.2注意Windows环境下需手动配置MySQL大小写敏感参数lower_case_table_names14.2 后端部署要点修改application.yml中的数据库配置执行SQL初始化脚本打包命令mvn clean package -DskipTests启动命令java -jar medicine-system.jar --spring.profiles.activeprod4.3 前端部署方案生产环境建议开启Gzip压缩配置Nginx反向代理启用HTTPS安全协议典型Nginx配置server { listen 443 ssl; server_name medicine.example.com; location / { root /var/www/medicine-web; try_files $uri $uri/ /index.html; } location /api { proxy_pass http://127.0.0.1:8080; } }5. 开发经验总结5.1 常见问题排查跨域问题解决方案Configuration public class CorsConfig implements WebMvcConfigurer { Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping(/**) .allowedOrigins(*) .allowedMethods(*) .maxAge(3600); } }MyBatis-Plus分页失效 确保配置分页插件Configuration public class MyBatisPlusConfig { Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); return interceptor; } }5.2 性能优化建议接口响应慢添加二级缓存启用MyBatis-Plus性能分析插件Bean public PerformanceInterceptor performanceInterceptor() { PerformanceInterceptor interceptor new PerformanceInterceptor(); interceptor.setMaxTime(1000); interceptor.setFormat(true); return interceptor; }前端加载优化路由懒加载组件异步加载使用CDN加速5.3 扩展方向增加移动端适配Uniapp集成第三方支付接口开发微信小程序版本接入智能硬件如自动售药机项目完整源码 Gitee仓库https://gitee.com/example/medicine-system 包含完整部署文档和数据库脚本