自建网站百度,深圳住房建设厅网站,淘宝网站框架,福州百度推广排名优化一、项目介绍
实验室预约管理系统是一个基于Java全栈技术开发的Web应用系统#xff0c;旨在提供便捷的实验室预约、管理和使用体验。本系统主要面向高校师生#xff0c;实现实验室资源的智能化、信息化管理。
二、技术栈
前端技术
Vue.jsElement UIAxiosVue RouterVuex
…一、项目介绍
实验室预约管理系统是一个基于Java全栈技术开发的Web应用系统旨在提供便捷的实验室预约、管理和使用体验。本系统主要面向高校师生实现实验室资源的智能化、信息化管理。
二、技术栈
前端技术
Vue.jsElement UIAxiosVue RouterVuex
后端技术
Spring BootSpring SecurityMyBatis PlusMySQLRedisJWT
三、核心功能模块
1. 用户管理模块
用户注册与登录角色权限管理个人信息维护
2. 实验室管理模块
实验室信息管理设备资源管理实验室状态监控
3. 预约管理模块
在线预约申请预约审批流程预约记录查询使用情况统计
4. 系统管理模块
系统参数配置日志管理数据备份
四、数据库设计
主要数据表
-- 用户表
CREATE TABLE user (id BIGINT PRIMARY KEY,username VARCHAR(50),password VARCHAR(100),role VARCHAR(20),create_time DATETIME
);-- 实验室表
CREATE TABLE laboratory (id BIGINT PRIMARY KEY,name VARCHAR(100),capacity INT,status VARCHAR(20),description TEXT
);-- 预约记录表
CREATE TABLE reservation (id BIGINT PRIMARY KEY,user_id BIGINT,lab_id BIGINT,start_time DATETIME,end_time DATETIME,status VARCHAR(20)
);五、核心功能实现
1. 预约流程实现
Service
public class ReservationService {Autowiredprivate ReservationMapper reservationMapper;Transactionalpublic Result createReservation(ReservationDTO dto) {// 检查实验室是否可用if (!checkLabAvailable(dto.getLabId())) {return Result.fail(实验室不可用);}// 检查时间冲突if (checkTimeConflict(dto)) {return Result.fail(预约时间冲突);}// 创建预约记录Reservation reservation new Reservation();BeanUtils.copyProperties(dto, reservation);reservationMapper.insert(reservation);return Result.success();}
}2. 权限控制实现
Configuration
EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeRequests().antMatchers(/api/public/**).permitAll().antMatchers(/api/admin/**).hasRole(ADMIN).antMatchers(/api/user/**).hasRole(USER).anyRequest().authenticated().and().addFilter(new JWTAuthenticationFilter(authenticationManager())).addFilter(new JWTAuthorizationFilter(authenticationManager()));}
}六、系统特点
用户友好直观的界面设计操作简单便捷实时响应采用WebSocket实现实验室状态实时更新高可用性使用Redis缓存提升系统性能安全可靠完善的权限控制和数据加密机制
七、项目部署
环境要求
JDK 1.8Maven 3.6MySQL 5.7Redis 6.0Node.js 12
部署步骤
数据库初始化后端服务部署前端项目打包Nginx配置
八、总结与展望
本项目实现了实验室预约管理的核心功能通过现代化的技术栈提供了良好的用户体验。未来计划添加以下功能
引入人脸识别功能集成物联网设备开发移动端应用添加数据分析功能 本文介绍了实验室预约管理系统的主要功能和技术实现希望能为相似项目的开发提供参考。
实验室预约管理系统核心模块详解上
一、用户管理模块
1. 数据库设计
-- 用户表
CREATE TABLE sys_user (id BIGINT PRIMARY KEY AUTO_INCREMENT,username VARCHAR(50) NOT NULL COMMENT 用户名,password VARCHAR(100) NOT NULL COMMENT 密码,real_name VARCHAR(50) COMMENT 真实姓名,phone VARCHAR(20) COMMENT 手机号,email VARCHAR(100) COMMENT 邮箱,avatar VARCHAR(200) COMMENT 头像URL,status TINYINT DEFAULT 1 COMMENT 状态:0-禁用,1-启用,create_time DATETIME COMMENT 创建时间,update_time DATETIME COMMENT 更新时间
);-- 角色表
CREATE TABLE sys_role (id BIGINT PRIMARY KEY AUTO_INCREMENT,role_name VARCHAR(50) NOT NULL COMMENT 角色名称,role_code VARCHAR(50) NOT NULL COMMENT 角色编码,description VARCHAR(200) COMMENT 角色描述,status TINYINT DEFAULT 1 COMMENT 状态
);-- 用户角色关联表
CREATE TABLE sys_user_role (id BIGINT PRIMARY KEY AUTO_INCREMENT,user_id BIGINT NOT NULL COMMENT 用户ID,role_id BIGINT NOT NULL COMMENT 角色ID
);-- 权限表
CREATE TABLE sys_permission (id BIGINT PRIMARY KEY AUTO_INCREMENT,name VARCHAR(50) COMMENT 权限名称,code VARCHAR(50) COMMENT 权限编码,type TINYINT COMMENT 类型:1-菜单,2-按钮,parent_id BIGINT COMMENT 父级ID,path VARCHAR(200) COMMENT 路由路径,icon VARCHAR(50) COMMENT 图标
);2. 核心功能实现
2.1 用户注册
Service
public class UserService {Autowiredprivate PasswordEncoder passwordEncoder;Autowiredprivate UserMapper userMapper;Transactionalpublic Result register(UserRegisterDTO dto) {// 验证用户名是否存在if(checkUsernameExist(dto.getUsername())) {return Result.fail(用户名已存在);}// 密码加密String encodedPassword passwordEncoder.encode(dto.getPassword());// 创建用户SysUser user new SysUser();user.setUsername(dto.getUsername());user.setPassword(encodedPassword);user.setPhone(dto.getPhone());user.setEmail(dto.getEmail());user.setCreateTime(new Date());userMapper.insert(user);// 分配默认角色assignDefaultRole(user.getId());return Result.success();}
}2.2 用户登录
Service
public class AuthService {Autowiredprivate UserService userService;Autowiredprivate JwtUtils jwtUtils;public Result login(LoginDTO loginDTO) {// 用户认证UsernamePasswordAuthenticationToken authenticationToken new UsernamePasswordAuthenticationToken(loginDTO.getUsername(), loginDTO.getPassword());Authentication authentication authenticationManager.authenticate(authenticationToken);if (authentication null) {throw new BadCredentialsException(用户名或密码错误);}// 生成JWT tokenString token jwtUtils.generateToken(authentication);// 获取用户信息UserVO userInfo userService.getUserInfo(loginDTO.getUsername());MapString, Object result new HashMap();result.put(token, token);result.put(userInfo, userInfo);return Result.success(result);}
}2.3 角色权限管理
Service
public class RoleService {Autowiredprivate RoleMapper roleMapper;Autowiredprivate UserRoleMapper userRoleMapper;Transactionalpublic Result assignRoles(Long userId, ListLong roleIds) {// 删除原有角色userRoleMapper.deleteByUserId(userId);// 分配新角色if (!CollectionUtils.isEmpty(roleIds)) {ListSysUserRole userRoles roleIds.stream().map(roleId - new SysUserRole(userId, roleId)).collect(Collectors.toList());userRoleMapper.batchInsert(userRoles);}return Result.success();}public ListPermissionVO getRolePermissions(Long roleId) {return roleMapper.selectPermissionsByRoleId(roleId);}
}二、实验室管理模块
1. 数据库设计
-- 实验室表
CREATE TABLE lab_info (id BIGINT PRIMARY KEY AUTO_INCREMENT,name VARCHAR(100) NOT NULL COMMENT 实验室名称,location VARCHAR(200) COMMENT 位置,capacity INT COMMENT 容量,description TEXT COMMENT 描述,status TINYINT DEFAULT 1 COMMENT 状态:0-维护中,1-可用,create_time DATETIME,update_time DATETIME
);-- 设备表
CREATE TABLE lab_equipment (id BIGINT PRIMARY KEY AUTO_INCREMENT,lab_id BIGINT COMMENT 实验室ID,name VARCHAR(100) COMMENT 设备名称,model VARCHAR(100) COMMENT 型号,serial_number VARCHAR(100) COMMENT 序列号,status TINYINT COMMENT 状态:0-故障,1-正常,purchase_date DATE COMMENT 购买日期,maintenance_date DATE COMMENT 上次维护日期
);-- 实验室状态记录表
CREATE TABLE lab_status_log (id BIGINT PRIMARY KEY AUTO_INCREMENT,lab_id BIGINT COMMENT 实验室ID,status TINYINT COMMENT 状态,remark VARCHAR(500) COMMENT 备注,create_time DATETIME
);2. 核心功能实现
2.1 实验室信息管理
Service
public class LabService {Autowiredprivate LabMapper labMapper;Autowiredprivate LabEquipmentMapper equipmentMapper;Transactionalpublic Result createLab(LabCreateDTO dto) {// 创建实验室基本信息LabInfo lab new LabInfo();BeanUtils.copyProperties(dto, lab);lab.setCreateTime(new Date());labMapper.insert(lab);// 添加设备信息if (!CollectionUtils.isEmpty(dto.getEquipments())) {ListLabEquipment equipments dto.getEquipments().stream().map(e - {LabEquipment equipment new LabEquipment();equipment.setLabId(lab.getId());BeanUtils.copyProperties(e, equipment);return equipment;}).collect(Collectors.toList());equipmentMapper.batchInsert(equipments);}return Result.success();}public PageResultLabVO queryLabs(LabQueryDTO query) {PageLabInfo page new Page(query.getPageNum(), query.getPageSize());IPageLabVO labPage labMapper.selectLabPage(page, query);return new PageResult(labPage);}
}2.2 设备资源管理
Service
public class EquipmentService {Autowiredprivate LabEquipmentMapper equipmentMapper;Autowiredprivate MaintenanceRecordMapper maintenanceMapper;public Result updateEquipmentStatus(Long equipmentId, Integer status, String remark) {LabEquipment equipment equipmentMapper.selectById(equipmentId);if (equipment null) {return Result.fail(设备不存在);}// 更新设备状态equipment.setStatus(status);equipmentMapper.updateById(equipment);// 记录维护信息if (status EquipmentStatusEnum.MAINTENANCE.getCode()) {MaintenanceRecord record new MaintenanceRecord();record.setEquipmentId(equipmentId);record.setMaintenanceDate(new Date());record.setRemark(remark);maintenanceMapper.insert(record);}return Result.success();}public ListEquipmentVO getLabEquipments(Long labId) {return equipmentMapper.selectByLabId(labId);}
}2.3 实验室状态监控
Service
public class LabMonitorService {Autowiredprivate LabStatusLogMapper statusLogMapper;Autowiredprivate WebSocketServer webSocketServer;Asyncpublic void monitorLabStatus() {// 定时检查实验室状态ListLabInfo labs labMapper.selectList(null);for (LabInfo lab : labs) {LabStatusDTO status checkLabStatus(lab.getId());// 记录状态变更if (isStatusChanged(lab.getId(), status.getStatus())) {LabStatusLog log new LabStatusLog();log.setLabId(lab.getId());log.setStatus(status.getStatus());log.setRemark(status.getRemark());statusLogMapper.insert(log);// 推送状态更新webSocketServer.sendMessage(String.format(lab_%d, lab.getId()),JSON.toJSONString(status));}}}public ListLabStatusVO getLabStatusHistory(Long labId, Date startTime, Date endTime) {return statusLogMapper.selectStatusHistory(labId, startTime, endTime);}
}3. 前端实现示例
3.1 用户登录组件
templatediv classlogin-containerel-form :modelloginForm :rulesloginRules refloginFormel-form-item propusernameel-input v-modelloginForm.username placeholder用户名i slotprefix classel-icon-user/i/el-input/el-form-itemel-form-item proppasswordel-input typepassword v-modelloginForm.password placeholder密码i slotprefix classel-icon-lock/i/el-input/el-form-itemel-button typeprimary clickhandleLogin :loadingloading登录/el-button/el-form/div
/templatescript
export default {data() {return {loginForm: {username: ,password: },loginRules: {username: [{ required: true, message: 请输入用户名, trigger: blur }],password: [{ required: true, message: 请输入密码, trigger: blur }]},loading: false}},methods: {async handleLogin() {try {await this.$refs.loginForm.validate()this.loading trueconst res await this.$api.login(this.loginForm)if (res.code 0) {this.$store.commit(SET_TOKEN, res.data.token)this.$store.commit(SET_USER_INFO, res.data.userInfo)this.$router.push(/)}} catch (error) {console.error(error)} finally {this.loading false}}}
}
/script3.2 实验室管理组件
templatediv classlab-manage!-- 搜索栏 --div classsearch-barel-form :inlinetrue :modelqueryFormel-form-item label实验室名称el-input v-modelqueryForm.name placeholder请输入/el-input/el-form-itemel-form-item label状态el-select v-modelqueryForm.status placeholder请选择el-option label可用 :value1/el-optionel-option label维护中 :value0/el-option/el-select/el-form-itemel-form-itemel-button typeprimary clickhandleSearch查询/el-buttonel-button clickhandleReset重置/el-button/el-form-item/el-form/div!-- 实验室列表 --el-table :datalabList borderel-table-column propname label实验室名称/el-table-columnel-table-column proplocation label位置/el-table-columnel-table-column propcapacity label容量/el-table-columnel-table-column label状态template slot-scopescopeel-tag :typescope.row.status 1 ? success : danger{{ scope.row.status 1 ? 可用 : 维护中 }}/el-tag/template/el-table-columnel-table-column label操作 width200template slot-scopescopeel-button typetext clickhandleEdit(scope.row)编辑/el-buttonel-button typetext clickhandleEquipment(scope.row)设备管理/el-buttonel-button typetext clickhandleStatus(scope.row)状态记录/el-button/template/el-table-column/el-table!-- 分页 --el-paginationcurrent-changehandleCurrentChangesize-changehandleSizeChange:current-pagequeryForm.pageNum:page-sizes[10, 20, 50]:page-sizequeryForm.pageSizelayouttotal, sizes, prev, pager, next:totaltotal/el-pagination/div
/templatescript
export default {data() {return {queryForm: {name: ,status: ,pageNum: 1,pageSize: 10},labList: [],total: 0}},created() {this.fetchLabList()},methods: {async fetchLabList() {try {const res await this.$api.queryLabs(this.queryForm)this.labList res.data.recordsthis.total res.data.total} catch (error) {console.error(error)}},handleSearch() {this.queryForm.pageNum 1this.fetchLabList()},handleReset() {this.queryForm {name: ,status: ,pageNum: 1,pageSize: 10}this.fetchLabList()}// ... 其他方法实现}
}
/script以上是用户管理模块和实验室管理模块的详细实现。包括了:
完整的数据库表设计后端核心业务逻辑实现前端组件示例代码
这些代码展示了基本的CRUD操作、状态管理、实时监控等功能的实现方式。实际项目中还需要根据具体需求进行调整和扩展。
实验室预约管理系统模块详解(下)
一、预约管理模块
1. 数据库设计
-- 预约记录表
CREATE TABLE lab_reservation (id BIGINT PRIMARY KEY AUTO_INCREMENT,user_id BIGINT NOT NULL COMMENT 预约用户ID,lab_id BIGINT NOT NULL COMMENT 实验室ID,start_time DATETIME NOT NULL COMMENT 开始时间,end_time DATETIME NOT NULL COMMENT 结束时间,purpose VARCHAR(500) COMMENT 用途说明,participants INT COMMENT 使用人数,status TINYINT DEFAULT 0 COMMENT 状态:0-待审核,1-已通过,2-已拒绝,3-已取消,4-已完成,create_time DATETIME,update_time DATETIME
);-- 预约审批记录表
CREATE TABLE reservation_approval (id BIGINT PRIMARY KEY AUTO_INCREMENT,reservation_id BIGINT NOT NULL COMMENT 预约ID,approver_id BIGINT NOT NULL COMMENT 审批人ID,approval_status TINYINT COMMENT 审批状态:1-通过,2-拒绝,approval_comment VARCHAR(500) COMMENT 审批意见,approval_time DATETIME COMMENT 审批时间
);-- 实验室使用记录表
CREATE TABLE lab_usage_record (id BIGINT PRIMARY KEY AUTO_INCREMENT,reservation_id BIGINT COMMENT 预约ID,check_in_time DATETIME COMMENT 签到时间,check_out_time DATETIME COMMENT 签退时间,actual_participants INT COMMENT 实际使用人数,status TINYINT COMMENT 状态:1-正常,2-超时,3-爽约,remark VARCHAR(500) COMMENT 备注
);2. 核心功能实现
2.1 预约申请服务
Service
public class ReservationService {Autowiredprivate LabReservationMapper reservationMapper;Autowiredprivate LabService labService;Transactionalpublic Result createReservation(ReservationCreateDTO dto) {// 验证实验室是否可用LabInfo lab labService.getLabById(dto.getLabId());if (lab null || lab.getStatus() ! 1) {return Result.fail(实验室不可用);}// 检查时间冲突if (checkTimeConflict(dto.getLabId(), dto.getStartTime(), dto.getEndTime())) {return Result.fail(所选时间段已被预约);}// 创建预约记录LabReservation reservation new LabReservation();BeanUtils.copyProperties(dto, reservation);reservation.setUserId(SecurityUtils.getCurrentUserId());reservation.setStatus(ReservationStatusEnum.PENDING.getCode());reservation.setCreateTime(new Date());reservationMapper.insert(reservation);// 发送审批通知sendApprovalNotification(reservation);return Result.success();}private boolean checkTimeConflict(Long labId, Date startTime, Date endTime) {return reservationMapper.countConflictReservations(labId, startTime, endTime) 0;}
}2.2 预约审批服务
Service
public class ApprovalService {Autowiredprivate ReservationApprovalMapper approvalMapper;Autowiredprivate ReservationService reservationService;Transactionalpublic Result approveReservation(ApprovalDTO dto) {// 验证预约状态LabReservation reservation reservationService.getById(dto.getReservationId());if (reservation null || reservation.getStatus() ! ReservationStatusEnum.PENDING.getCode()) {return Result.fail(预约记录不存在或状态异常);}// 记录审批信息ReservationApproval approval new ReservationApproval();approval.setReservationId(dto.getReservationId());approval.setApproverId(SecurityUtils.getCurrentUserId());approval.setApprovalStatus(dto.getApprovalStatus());approval.setApprovalComment(dto.getComment());approval.setApprovalTime(new Date());approvalMapper.insert(approval);// 更新预约状态Integer newStatus dto.getApprovalStatus() 1 ? ReservationStatusEnum.APPROVED.getCode() : ReservationStatusEnum.REJECTED.getCode();reservationService.updateStatus(dto.getReservationId(), newStatus);// 发送通知sendNotification(reservation.getUserId(), newStatus, dto.getComment());return Result.success();}
}2.3 使用统计服务
Service
public class LabStatisticsService {Autowiredprivate LabUsageRecordMapper usageRecordMapper;public MapString, Object getLabUsageStatistics(StatisticsQueryDTO query) {MapString, Object result new HashMap();// 获取使用率统计ListLabUsageRateVO usageRates usageRecordMapper.selectUsageRateByLab(query.getStartDate(), query.getEndDate());result.put(usageRates, usageRates);// 获取预约状态分布ListReservationStatusVO statusDistribution usageRecordMapper.selectReservationStatusDistribution(query.getStartDate(), query.getEndDate());result.put(statusDistribution, statusDistribution);// 获取高峰时段分析ListPeakTimeVO peakTimes usageRecordMapper.selectPeakTimeAnalysis(query.getStartDate(), query.getEndDate());result.put(peakTimes, peakTimes);return result;}
}二、系统管理模块
1. 数据库设计
-- 系统参数表
CREATE TABLE sys_config (id BIGINT PRIMARY KEY AUTO_INCREMENT,param_key VARCHAR(50) NOT NULL COMMENT 参数键,param_value VARCHAR(500) COMMENT 参数值,param_desc VARCHAR(200) COMMENT 参数描述,type TINYINT COMMENT 参数类型:1-系统参数,2-业务参数,create_time DATETIME,update_time DATETIME
);-- 系统日志表
CREATE TABLE sys_log (id BIGINT PRIMARY KEY AUTO_INCREMENT,user_id BIGINT COMMENT 操作用户ID,module VARCHAR(50) COMMENT 操作模块,operation VARCHAR(50) COMMENT 操作类型,method VARCHAR(200) COMMENT 请求方法,params TEXT COMMENT 请求参数,time BIGINT COMMENT 执行时长(ms),ip VARCHAR(50) COMMENT IP地址,create_time DATETIME
);-- 数据备份记录表
CREATE TABLE sys_backup (id BIGINT PRIMARY KEY AUTO_INCREMENT,backup_name VARCHAR(100) COMMENT 备份名称,backup_type TINYINT COMMENT 备份类型:1-全量,2-增量,file_path VARCHAR(200) COMMENT 备份文件路径,file_size BIGINT COMMENT 文件大小(byte),status TINYINT COMMENT 状态:0-备份中,1-成功,2-失败,start_time DATETIME COMMENT 开始时间,end_time DATETIME COMMENT 结束时间,remark VARCHAR(500) COMMENT 备注
);2. 核心功能实现
2.1 系统参数配置服务
Service
public class SysConfigService {Autowiredprivate SysConfigMapper configMapper;Autowiredprivate RedisTemplateString, String redisTemplate;private static final String CONFIG_KEY_PREFIX sys:config:;public String getConfigValue(String key) {// 先从Redis缓存获取String value redisTemplate.opsForValue().get(CONFIG_KEY_PREFIX key);if (value ! null) {return value;}// 从数据库获取SysConfig config configMapper.selectByKey(key);if (config ! null) {// 放入缓存redisTemplate.opsForValue().set(CONFIG_KEY_PREFIX key, config.getParamValue(),24, TimeUnit.HOURS);return config.getParamValue();}return null;}Transactionalpublic Result updateConfig(ConfigUpdateDTO dto) {SysConfig config configMapper.selectByKey(dto.getKey());if (config null) {return Result.fail(参数不存在);}config.setParamValue(dto.getValue());config.setUpdateTime(new Date());configMapper.updateById(config);// 更新缓存redisTemplate.opsForValue().set(CONFIG_KEY_PREFIX dto.getKey(), dto.getValue(),24, TimeUnit.HOURS);return Result.success();}
}2.2 系统日志服务
Aspect
Component
public class SysLogAspect {Autowiredprivate SysLogMapper logMapper;Around(annotation(com.xxx.annotation.SysLog))public Object around(ProceedingJoinPoint point) throws Throwable {long beginTime System.currentTimeMillis();try {// 执行方法Object result point.proceed();// 保存日志saveLog(point, System.currentTimeMillis() - beginTime);return result;} catch (Exception e) {// 保存异常日志saveExceptionLog(point, e, System.currentTimeMillis() - beginTime);throw e;}}private void saveLog(ProceedingJoinPoint point, long time) {MethodSignature signature (MethodSignature) point.getSignature();Method method signature.getMethod();SysLog sysLog method.getAnnotation(SysLog.class);SysLogEntity log new SysLogEntity();log.setUserId(SecurityUtils.getCurrentUserId());log.setModule(sysLog.module());log.setOperation(sysLog.operation());log.setMethod(signature.getDeclaringTypeName() . signature.getName());log.setParams(JSON.toJSONString(point.getArgs()));log.setTime(time);log.setIp(IPUtils.getIpAddr());log.setCreateTime(new Date());logMapper.insert(log);}
}2.3 数据备份服务
Service
public class BackupService {Autowiredprivate SysBackupMapper backupMapper;Value(${backup.path})private String backupPath;Asyncpublic void createBackup(BackupCreateDTO dto) {SysBackup backup new SysBackup();backup.setBackupName(dto.getName());backup.setBackupType(dto.getType());backup.setStatus(0);backup.setStartTime(new Date());backupMapper.insert(backup);try {// 执行备份String fileName executeBackup(dto);// 更新备份记录File backupFile new File(fileName);backup.setFilePath(fileName);backup.setFileSize(backupFile.length());backup.setStatus(1);backup.setEndTime(new Date());backupMapper.updateById(backup);} catch (Exception e) {log.error(数据备份失败, e);backup.setStatus(2);backup.setRemark(e.getMessage());backup.setEndTime(new Date());backupMapper.updateById(backup);}}private String executeBackup(BackupCreateDTO dto) throws Exception {String fileName backupPath / DateUtils.format(new Date(), yyyyMMddHHmmss) .sql;ProcessBuilder builder new ProcessBuilder();if (dto.getType() 1) {// 全量备份builder.command(mysqldump, -h dbHost,-u dbUsername,-p dbPassword,dbName,--result-file fileName);} else {// 增量备份builder.command(mysqldump,-h dbHost,-u dbUsername,-p dbPassword,--skip-add-locks,--no-create-info,dbName,--result-file fileName);}Process process builder.start();int exitCode process.waitFor();if (exitCode ! 0) {throw new RuntimeException(备份执行失败);}return fileName;}
}3. 前端实现示例
3.1 预约管理组件
templatediv classreservation-manage!-- 预约表单 --el-form :modelreservationForm :rulesrules refreservationFormel-form-item label实验室 proplabIdel-select v-modelreservationForm.labId placeholder请选择实验室el-optionv-forlab in labList:keylab.id:labellab.name:valuelab.id/el-option/el-select/el-form-itemel-form-item label使用时间 proptimeRangeel-date-pickerv-modelreservationForm.timeRangetypedatetimerangerange-separator至start-placeholder开始时间end-placeholder结束时间/el-date-picker/el-form-itemel-form-item label用途说明 proppurposeel-inputtypetextareav-modelreservationForm.purposeplaceholder请输入用途说明/el-input/el-form-itemel-form-itemel-button typeprimary clicksubmitReservation提交预约/el-button/el-form-item/el-form!-- 预约记录列表 --el-table :datareservationList borderel-table-column proplabName label实验室/el-table-columnel-table-column label使用时间template slot-scopescope{{ formatDateTime(scope.row.startTime) }} 至 {{ formatDateTime(scope.row.endTime) }}/template/el-table-columnel-table-column proppurpose label用途 show-overflow-tooltip/el-table-columnel-table-column label状态template slot-scopescopeel-tag :typegetStatusType(scope.row.status){{ getStatusText(scope.row.status) }}/el-tag/template/el-table-columnel-table-column label操作 width150template slot-scopescopeel-button typetext clickcancelReservation(scope.row)v-ifscope.row.status 0取消预约/el-buttonel-button typetext clickviewDetail(scope.row)查看详情/el-button/template/el-table-column/el-table/div
/templatescript
export default {data() {return {reservationForm: {labId: ,timeRange: [],purpose: },rules: {labId: [{ required: true, message: 请选择实验室, trigger: change }],timeRange: [{ required: true, message: 请选择使用时间, trigger: change }],purpose: [{ required: true, message: 请输入用途说明, trigger: blur }]},labList: [],reservationList: []}},methods: {async submitReservation() {try {await this.$refs.reservationForm.validate()const [startTime, endTime] this.reservationForm.timeRangeconst params {labId: this.reservationForm.labId,startTime,endTime,purpose: this.reservationForm.purpose}await this.$api.createReservation(params)this.$message.success(预约申请提交成功)this.fetchReservationList()} catch (error) {console.error(error)}},getStatusType(status) {const typeMap {0: info,1: success,2: danger,3: info,4: }return typeMap[status]},getStatusText(status) {const textMap {0: 待审核,1: 已通过,2: 已拒绝,3: 已取消,4: 已完成}return textMap[status]}}
}
/script3.2 系统配置组件
templatediv classsys-configel-card classconfig-carddiv slotheaderspan系统参数配置/span/divel-form :modelconfigForm label-width120pxel-form-item v-foritem in configList:keyitem.key:labelitem.descel-input v-modelconfigForm[item.key]:placeholder请输入 item.desc/el-input/el-form-itemel-form-itemel-button typeprimary clicksaveConfig保存配置/el-button/el-form-item/el-form/el-cardel-card classbackup-carddiv slotheaderspan数据备份/span/divdiv classbackup-actionsel-button typeprimary clickcreateBackup(1)全量备份/el-buttonel-button typewarning clickcreateBackup(2)增量备份/el-button/divel-table :databackupList border stylemargin-top: 20px;el-table-column propbackupName label备份名称/el-table-columnel-table-column label备份类型template slot-scopescope{{ scope.row.backupType 1 ? 全量 : 增量 }}/template/el-table-columnel-table-column propfileSize label文件大小template slot-scopescope{{ formatFileSize(scope.row.fileSize) }}/template/el-table-columnel-table-column label状态template slot-scopescopeel-tag :typegetBackupStatusType(scope.row.status){{ getBackupStatusText(scope.row.status) }}/el-tag/template/el-table-columnel-table-column label操作 width150template slot-scopescopeel-button typetext clickdownloadBackup(scope.row)v-ifscope.row.status 1下载/el-buttonel-button typetext clickdeleteBackup(scope.row)删除/el-button/template/el-table-column/el-table/el-card/div
/templatescript
export default {data() {return {configForm: {},configList: [],backupList: []}},created() {this.fetchConfigList()this.fetchBackupList()},methods: {async fetchConfigList() {const res await this.$api.getConfigList()this.configList res.data// 初始化表单数据this.configList.forEach(item {this.$set(this.configForm, item.key, item.value)})},async saveConfig() {try {const params Object.entries(this.configForm).map(([key, value]) ({key,value}))await this.$api.updateConfig(params)this.$message.success(配置保存成功)} catch (error) {console.error(error)}},async createBackup(type) {try {const params {name: backup_${Date.now()},type}await this.$api.createBackup(params)this.$message.success(备份任务已启动)this.fetchBackupList()} catch (error) {console.error(error)}},formatFileSize(size) {if (size 1024) {return size B} else if (size 1024 * 1024) {return (size / 1024).toFixed(2) KB} else {return (size / 1024 / 1024).toFixed(2) MB}}}
}
/script以上是预约管理模块和系统管理模块的详细实现,包括:
完整的数据库表设计后端核心服务实现前端组件示例代码
这些代码展示了预约流程、审批流程、统计分析、系统配置、日志管理、数据备份等功能的具体实现方式。实际项目中还需要根据具体需求进行调整和扩展。