校园设备维护报修系统是每个学校都需要的核心管理系统之一。作为一名在高校信息化部门工作多年的开发者,我深知传统纸质报修流程的痛点:报修信息容易丢失、维修进度不透明、统计管理困难。去年我们团队基于SpringBoot重构了学校的报修系统,上线后维修响应时间缩短了60%,师生满意度提升了45%。下面我就来详细分享这个系统的设计与实现。
这个系统主要解决以下几个实际问题:
我们选择SpringBoot作为基础框架,主要基于以下考虑:
数据库选用MySQL 5.7,主要因为:
java复制// 典型的主启动类配置
@SpringBootApplication
@MapperScan("com.campus.repair.mapper")
public class RepairApplication {
public static void main(String[] args) {
SpringApplication.run(RepairApplication.class, args);
}
}
前端采用Vue.js + ElementUI的组合,主要优势:
特别在地图集成上,我们选择了高德地图API:
报修流程是系统的核心,我们设计了状态机模型:
mermaid复制stateDiagram
[*] --> 待审核
待审核 --> 已分配: 管理员审核通过
已分配 --> 维修中: 维修员接单
维修中 --> 已完成: 维修结束
已完成 --> 已评价: 用户评价
实际代码实现采用状态模式:
java复制public interface RepairState {
void handle(RepairOrder order);
}
@Component
public class PendingState implements RepairState {
@Override
public void handle(RepairOrder order) {
// 发送审核通知给管理员
notificationService.notifyAdmins(order);
}
}
使用SpringSecurity + JWT实现细粒度权限控制:
java复制@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/api/repair/**").hasAnyRole("USER","ADMIN")
.antMatchers("/api/admin/**").hasRole("ADMIN")
.and()
.addFilter(new JwtAuthenticationFilter(authenticationManager()))
.addFilter(new JwtAuthorizationFilter(authenticationManager()));
}
}
权限设计要点:
开学季经常出现报修高峰,我们通过以下方案优化:
java复制@RabbitListener(queues = "repair.notify")
public void processNotify(RepairMessage message) {
// 异步发送短信/邮件通知
smsService.sendRepairNotify(message);
}
针对校园环境特别优化:
javascript复制// 高德地图初始化
const map = new AMap.Map('map-container', {
resizeEnable: true,
zoom: 17,
center: [116.397428, 39.90923] // 默认中心点
});
// 添加校园建筑标记
buildings.forEach(b => {
new AMap.Marker({
position: new AMap.LngLat(b.lng, b.lat),
title: b.name,
map: map
});
});
生产环境采用双机部署:
推荐配置:
| 组件 | CPU | 内存 | 磁盘 |
|---|---|---|---|
| 应用服务器 | 4核 | 8G | SSD 100G |
| MySQL | 8核 | 16G | SSD 200G |
| Redis | 2核 | 4G | SSD 50G |
采用Prometheus + Grafana监控体系:
yaml复制# application-prometheus.yml
management:
endpoints:
web:
exposure:
include: health,metrics,prometheus
metrics:
export:
prometheus:
enabled: true
xml复制<insert id="batchInsert">
INSERT INTO repair_order(...) VALUES
<foreach collection="list" item="item" separator=",">
(#{item.field1}, #{item.field2})
</foreach>
</insert>
sql复制SELECT * FROM repair_order
WHERE id IN (
SELECT id FROM repair_order
WHERE building_id = ? AND status = ?
LIMIT ?, ?
)
python复制# 故障预测示例代码
from sklearn.ensemble import RandomForestClassifier
model = RandomForestClassifier()
model.fit(X_train, y_train)
joblib.dump(model, 'repair_model.pkl')
这个系统我们已经稳定运行了一年多,期间根据用户反馈迭代了3个大版本。最大的体会是:校园信息化系统一定要重视用户体验,不能只追求技术先进性。比如我们最初使用了很复杂的流程引擎,后来发现简单的状态机反而更符合用户习惯。