档案管理系统维护全攻略:常见问题排查+日常运维方案,看完就能上手
很多单位花几万甚至十几万上线档案管理系统,用个一两年就开始出问题:检索卡顿、上传失败、甚至数据莫名丢失,找厂商上门一次就要收大几百服务费,年运维费更是大几千起步。我们做了8年档案信息化落地服务,整理了...
2026年07月06日 03:25:22
使用SpringBoot框架快速实现,需提前安装:JDK1.8+、MySQL8.0+、Maven3.6+,所有工具均为通用开源工具,无需额外付费产品。
将以下内容替换到项目pom.xml的dependencies节点中,版本为稳定兼容版:
```xml登录MySQL执行以下建表语句,用于存储所有档案操作记录:
```sql CREATE TABLE `audit_log` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID', `operator` varchar(64) NOT NULL COMMENT '操作人', `operate_time` datetime NOT NULL COMMENT '操作时间', `operate_type` varchar(16) NOT NULL COMMENT '操作类型:新增/修改/删除', `archive_id` bigint DEFAULT NULL COMMENT '关联档案ID', `old_data` text COMMENT '修改前数据', `new_data` text COMMENT '修改后数据', `remark` varchar(256) DEFAULT NULL COMMENT '备注', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='审计日志表'; ```重点:执行前需先创建archive_db数据库,命令:CREATE DATABASE archive_db DEFAULT CHARSET=utf8mb4;

继承MyBatis Plus基础接口,无需额外实现:
```java import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @Mapper public interface AuditLogMapper extends BaseMapper用于拦截档案操作方法,自动记录日志:
```java import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.springframework.stereotype.Component; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; @Aspect @Component public class AuditLogAspect { @Autowired private AuditLogMapper auditLogMapper; @Around("execution( com.example.archive.service.ArchiveService.(..))") public Object recordAuditLog(ProceedingJoinPoint point) throws Throwable { // 获取当前操作人 Authentication auth = SecurityContextHolder.getContext().getAuthentication(); String operator = auth == null ? "匿名用户" : auth.getName(); // 判断操作类型 String methodName = point.getSignature().getName(); String operateType; if (methodName.startsWith("save")) operateType = "新增"; else if (methodName.startsWith("update")) operateType = "修改"; else if (methodName.startsWith("delete")) operateType = "删除"; else operateType = "其他"; // 获取操作参数(转JSON) Object[] args = point.getArgs(); String oldData = ""; String newData = ""; Long archiveId = null; if (args.length > 0) { Object param = args[0]; ObjectMapper objectMapper = new ObjectMapper(); if (operateType.equals("新增") || operateType.equals("修改")) { newData = objectMapper.writeValueAsString(param); if (operateType.equals("修改")) archiveId = ((com.example.archive.entity.Archive) param).getId(); } else if (operateType.equals("删除")) { archiveId = (Long) args[0]; oldData = "删除ID:" + archiveId; } } // 执行原档案操作方法 Object result = point.proceed(); // 插入审计日志 AuditLog auditLog = new AuditLog(); auditLog.setOperator(operator); auditLog.setOperateTime(java.time.LocalDateTime.now()); auditLog.setOperateType(operateType); auditLog.setArchiveId(archiveId); auditLog.setOldData(oldData); auditLog.setNewData(newData); auditLog.setRemark("档案操作"); auditLogMapper.insert(auditLog); return result; } } ```重点:将代码中的包路径com.example.archive替换为你项目的实际包路径,否则拦截不到档案操作方法
配置数据库连接和测试账号,方便快速验证:
```yaml spring: datasource: url: jdbc:mysql://localhost:3306/archive_db?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai username: root password: 123456 替换为你的MySQL root密码 driver-class-name: com.mysql.cj.jdbc.Driver security: user: name: admin password: admin123 测试登录账号密码 ```