您现在的位置是:首页 >技术交流 >基于Java(SpringBoot)+MySQL+Vue实现的平行志愿录取系统网站首页技术交流
基于Java(SpringBoot)+MySQL+Vue实现的平行志愿录取系统
基于spring boot+vue实现的平行志愿录取系统
1.项目简介
这两天干上高考出成绩,有不少亲戚家的孩子今年高考,和我询问关于报志愿的问题。老家河北今年是采用所谓的平行志愿。我看了很多的资料才明白什么叫所谓的“平行志愿”。
整个流程好像很是复杂。我突发奇想,心想何不自己编写一个程序来模拟一下这个所谓的录取过程呢。
考生成绩和志愿是机密类的数据,向我们这样的平头百姓向那倒是不太可能的事情,那么就只能自己写个程序生成一份模拟的成绩和志愿数据。
成绩比较好办,因为有个参考,那就是省教育考试院放出的“一分一段成绩统计表”。这个东西提供了我们模拟成绩数据的很多信息:一是考生的人数,每个分数下的人数都写得很清楚;二是成绩的分布情况,即在不同成绩段的考生人数都十分详细的列出。
2.思路分析
高考填报志愿非常重要,关于志愿填报及院校录取规则,我们看完院校投档原理就明白了。
假如甲同学610分乙同学609分。甲报考的志愿,第一个是北邮,第二个是北林;乙同学,第一个报北林,第二个报了北京工业大学。那么问题来了,如果考生甲没有被他的第一志愿北京邮电大学提档,那么对于北京林业大学来说,会优先检索谁的志愿呢?当然是甲同学的,因为平行志愿的录取规则是分数优先,遵循志愿。那什么叫分数优先,甲乙高考分数,谁的分数高,甲同学高。那么,甲同学的就会优先被他所在省份的教育考试院的电脑检索系统检索。那在检索的时候,考生乙的档案是属于停滞状态的。先看甲同学报的所有志愿,然后再看乙同学报的志愿。所以通过这个案例,我们就知道分数优先,遵循志愿。按照每个考生他所报的志愿从第一个到第二个都是按照这种平行的顺序依次进行提档。那么被提档之后,这名考生等同于他的提档机会就没有了。
那再看第二个问题,如果说考生甲被第一志愿提档了,但是报专业的时候因为一些因素被退档了。那么考生甲被退档之后,它还能再向北京林业大学继续投档吗?答案是否定的。因为一轮投档就一次机会,如果北京邮电大学被退了,那么我们就会去一批征集志愿,或者是二批次。如果是整个本科批次合并的,就会一退到底,直接到专科或者复读。很多省份在2019年是最后一届文理分科。那么对于2020年之后,我们都是新高考选科,那么您想复读的话可能不符合复读,或者再报考的要求。所以今年对于2019年高三的家长来说,今年压力比往年都要大,我们必须要保证我们孩子报考的志愿一次性成功,不能复读。
3.项目开发
3.1技术栈
- JDK8
- MySQL5.7
- springboot2.3
- maven3.6.3(需要安装,否则没有依赖)
- vue2.0(前端开发环境,并不必需)
- vue-cli3(前端开发环境,并不必需)
3.2环境配置
- 打开Mysql,创建数据库
CREATE DATABASE `<你的数据库名>` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci';
-- 例如:CREATE DATABASE `db_enroll` CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_general_ci';
- 进入数据库,运行sql文件,在sql文件夹下,可以把sql放在一个没有中文路径的地方,否则有可能出错
-- 进入刚刚创建的数据库
use db_enroll;
-- 运行路径下的sql文件
source /path/to/sql/db_enroll.sql
- 修改springboot配置文件application.yml,找到下面配置
enroll:
login:
# 登录用户名
adminName: admin
# 登录密码
adminPass: 123456
# 改为自己的数据库名
database: DATABASE_NAME
# 改为自己的数据库密码(账号默认root)
dbpass: MYSQL_PASSWORD
3.3项目配置
spring:
datasource:
username: root
password: ${enroll.dbpass}
url: jdbc:mysql://localhost:3306/${enroll.database}?serverTimezone=GMT%2B8&allowMultiQueries=true
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
druid:
# 连接池的配置信息
# 初始化大小,最小,最大
initial-size: 5
min-idle: 5
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
filters: stat,slf4j
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
# 配置DruidStatFilter
web-stat-filter:
enabled: true
url-pattern: "/*"
exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
# 配置DruidStatViewServlet
stat-view-servlet:
url-pattern: "/druid/*"
# IP白名单(没有配置或者为空,则允许所有访问)
allow: 127.0.0.1,192.168.163.1
# IP黑名单 (存在共同时,deny优先于allow)
reset-enable: false
# 登录名
login-username: admin
# 登录密码
login-password: 123456
filter:
wall:
config:
multi-statement-allow: true
initialization-mode: ALWAYS
schema:
- classpath:sql/schema.sql
initialize: true
devtools:
restart:
enabled: true
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
mybatis:
configuration:
map-underscore-to-camel-case: true
mapper-locations:
- classpath:mybatis/mapper/*.xml
type-aliases-package: org.enroll.pojo
enroll:
login:
adminName: admin
adminPass: 123456
database: db_enroll
dbpass: 15975867048
3.4配置类
全局异常捕捉
package org.enroll.configuration;
import org.enroll.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.jdbc.datasource.init.DataSourceInitializer;
import org.springframework.jdbc.datasource.init.DatabasePopulator;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.sql.DataSource;
import java.util.HashMap;
@Configuration
public class EnrollConfig implements WebMvcConfigurer {
@Autowired
LoginInterceptor interceptor;
@Value("classpath:sql/schema.sql")
private Resource dataScript;
@Override
public void addInterceptors(InterceptorRegistry registry) {
InterceptorRegistration registration = registry.addInterceptor(interceptor);
registration.addPathPatterns("/**");
registration.excludePathPatterns("/login/doLogin");
}
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:8000")
.allowedMethods("GET","HEAD","POST","PUT","DELETE","OPTIONS")
.allowedHeaders("*")
.allowCredentials(true)
.maxAge(3600)
.allowedHeaders("*");
}
@Bean
public HashMap<String, Object> globalStorage(){
return new HashMap<>();
}
@Bean
public DataSourceInitializer dataSourceInitializer(final DataSource dataSource) {
final DataSourceInitializer initializer = new DataSourceInitializer();
initializer.setDataSource(dataSource);
initializer.setDatabasePopulator(databasePopulator());
initializer.afterPropertiesSet();
return initializer;
}
private DatabasePopulator databasePopulator() {
final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
populator.addScript(dataScript);
return populator;
}
}
登陆信息类
package org.enroll.configuration;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "enroll.login")
public class LoginProperties {
private String adminName;
private String adminPass;
}
拦截器
@Component
public class LoginInterceptor implements HandlerInterceptor {
@Resource(name = "globalStorage")
Map<String, Object> storage;
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// if(request.getSession().equals(storage.get("authSession")))
// return true;
// response.setCharacterEncoding("UTF-8");
// response.setContentType("application/json");
// response.getWriter().println("{"code":"010","data":null,"message":"未登录"}");
// return false;
return true;
}
}
3.5常用工具类
查询结果集
@Data
public class QueryResultOption {
private Integer rank;
private Integer departmentId;
private String majorId;
}
json常量
@Getter
@Setter
@AllArgsConstructor
public class JsonResponse {
public static final String OK = "000";
public static final String SYSTEM_ERROR = "100";
public static final String INVALID_REQUEST = "001";
public static final String AUTH_ERR = "010";
private String code;
private Object data;
private String message;
}
3.6业务代码
@RestController
@RequestMapping("/student")
public class StudentController {
@Autowired
IStudentService studentService;
@RequestMapping("/getStudentRaw")
public JsonResponse getStudentRaw(@RequestParam(required = false, defaultValue = "1") Integer currentPage){
if(currentPage == null || currentPage<=0)
return new JsonResponse(JsonResponse.INVALID_REQUEST,null, null);
return new JsonResponse(JsonResponse.OK, studentService.getStudentRaw(currentPage), null);
}
@RequestMapping("/getAdjustStudentRaw")
public JsonResponse getAdjustStudentRaw(@RequestParam(required = false, defaultValue = "1") int currentPage){
return new JsonResponse(JsonResponse.OK, studentService.getAdjustStudentRaw(currentPage), null);
}
@RequestMapping("/getExitStudentRaw")
public JsonResponse getExitStudentRaw(@RequestParam(required = false, defaultValue = "1") int currentPage){
return new JsonResponse(JsonResponse.OK, studentService.getExitStudentRaw(currentPage), null);
}
@RequestMapping("/doEnroll")
public JsonResponse doEnroll(){
studentService.doEnroll();
return new JsonResponse(JsonResponse.OK, null, null);
}
@RequestMapping("/doAdjust")
public JsonResponse doAdjust(){
studentService.doAdjust();
return new JsonResponse(JsonResponse.OK, null, null);
}
// StatisticsResult getResult(int currentPage, boolean desc);
@RequestMapping("/getResult")
public JsonResponse getResult(@RequestParam(required = false, defaultValue = "1") int currentPage,
@RequestParam(required = false, defaultValue = "false") boolean desc,
QueryResultOption option){
return new JsonResponse(JsonResponse.OK, studentService.getResult(currentPage, desc, option), null);
}
// StatisticsResult getResultByDepartment( int departmentId, int currentPage, boolean desc);
/**
* @description t通过学院、专业、排名查询已弃用,请使用上面的getResult
* @author 李宏鑫
* @param null
* @return
* @updateTime 2021/1/7 20:53
* @throws
*/
@RequestMapping("/getResultByDepartment")
@Deprecated
public JsonResponse getResultByDepartment(int departmentId, @RequestParam(required = false, defaultValue = "1") int currentPage, @RequestParam(required = false, defaultValue = "false") boolean desc){
return new JsonResponse(JsonResponse.OK, studentService.getResultByDepartment(departmentId, currentPage, desc), null);
}
// StatisticsResult getResultByMajor( String majorId, int currentPage, boolean desc);
@RequestMapping("/getResultByMajor")
@Deprecated
public JsonResponse getResultByMajor(String majorId, @RequestParam(required = false, defaultValue = "1") int currentPage, @RequestParam(required = false, defaultValue = "false") boolean desc){
return new JsonResponse(JsonResponse.OK, studentService.getResultByMajor(majorId, currentPage, desc), null);
}
@RequestMapping("/searchStudent")
@Deprecated
public JsonResponse searchStudent(@RequestParam(required = false, defaultValue = "1") int currentPage,String keyword){
return new JsonResponse(JsonResponse.OK, studentService.searchStudent(currentPage,keyword), null);
}
@RequestMapping("/searchStudentByCandidate")
public JsonResponse searchStudentByCandidate(@RequestParam(required = false, defaultValue = "1") int currentPage,String keyword){
return new JsonResponse(JsonResponse.OK, studentService.searchStudentByCandidate(currentPage,keyword), null);
}
@RequestMapping("/getStudentBeforeRank")
public JsonResponse getStudentBeforeRank(@RequestParam(required = false, defaultValue = "1") int currentPage, int rank){
return new JsonResponse(JsonResponse.OK, studentService.getStudentBeforeRank(currentPage, rank), null);
}
@RequestMapping("/getStatisticsResult")
public JsonResponse getStatisticsResult(){
return new JsonResponse(JsonResponse.OK, studentService.getStatisticsResult(), null);
}
// List<Map<String, Object>> getResultInDepartment(int departmentId);
@RequestMapping("/getStatisticsResultInDepartment")
public JsonResponse getStatisticsResultInDepartment(){
return new JsonResponse(JsonResponse.OK, studentService.getStatisticsResultInDepartment(), null);
}
// List<Map<String, Object>> getResultInMajor(String majorId);
@RequestMapping("/getStatisticsResultInMajor")
public JsonResponse getStatisticsResultInMajor(){
return new JsonResponse(JsonResponse.OK, studentService.getStatisticsResultInMajor(), null);
}
// Map<String, Integer> getDistribute();
@RequestMapping("/getDistribute")
public JsonResponse getDistribute(){
return new JsonResponse(JsonResponse.OK, studentService.getDistribute(), null);
}
// Map<String, Integer> getDistributeInProvince(String province);
@RequestMapping("/getDistributeInProvince")
public JsonResponse getDistributeInProvince(String province){
return new JsonResponse(JsonResponse.OK, studentService.getDistributeInProvince(province), null);
}
// Map<String, Integer> getGradeDistribute();
@RequestMapping("/getGradeDistribute")
public JsonResponse getGradeDistribute(){
return new JsonResponse(JsonResponse.OK, studentService.getGradeDistribute(), null);
}
// Map<String, Integer> getGradeDistributeByDepartment( int departmentId);
@RequestMapping("/getGradeDistributeByDepartment")
public JsonResponse getGradeDistributeByDepartment(int departmentId){
return new JsonResponse(JsonResponse.OK, studentService.getGradeDistributeByDepartment(departmentId), null);
}
// Map<String, Integer> getGradeDistributeByMajor(String majorId);
@RequestMapping("/getGradeDistributeByMajor")
public JsonResponse getGradeDistributeByMajor(String majorId){
return new JsonResponse(JsonResponse.OK, studentService.getGradeDistributeByMajor(majorId), null);
}
// Map<String, Integer> getCountDistributeInDepartment();
@RequestMapping("/getCountDistributeInDepartment")
public JsonResponse getCountDistributeInDepartment(){
return new JsonResponse(JsonResponse.OK, studentService.getCountDistributeInDepartment(), null);
}
// Map<String, Integer> getCountDistributeInMajor();
@RequestMapping("/getCountDistributeInMajor")
public JsonResponse getCountDistributeInMajor(){
return new JsonResponse(JsonResponse.OK, studentService.getCountDistributeInMajor(), null);
}
// Map<String, Integer> getCountDistributeInMajorByDepartment(int departmentId);
@RequestMapping("/getCountDistributeInMajorByDepartment")
public JsonResponse getCountDistributeInMajorByDepartment(int departmentId){
return new JsonResponse(JsonResponse.OK, studentService.getCountDistributeInMajorByDepartment(departmentId), null);
}
@RequestMapping("/reset")
@Deprecated
public JsonResponse reset(){
studentService.reset();
return new JsonResponse(JsonResponse.OK, null, null);
}
@RequestMapping("/formalReady")
@Deprecated
public JsonResponse formalReady(){
studentService.formallyReady();
return new JsonResponse(JsonResponse.OK, null, null);
}
}
3.7前端代码
<template>
<div id="back-stage-student-info">
<empty-data v-if="studentInfo == null || studentInfo.length === 0"/>
<div id="student-plan-info" v-else>
<table-row-count :count="total"></table-row-count>
<el-table
:data="studentInfo"
stripe
style="width: 100%">
<el-table-column
prop="candidate"
label="准考证号"
width="110"
>
</el-table-column>
<el-table-column
prop="studentName"
label="姓名"
>
</el-table-column>
<el-table-column
prop="totalGrade"
label="总分"
>
</el-table-column>
<el-table-column
prop="rank"
label="排名">
</el-table-column>
<el-table-column
prop="will1"
label="志愿1">
</el-table-column>
<el-table-column
prop="will2"
label="志愿2">
</el-table-column>
<el-table-column
prop="will3"
label="志愿3">
</el-table-column>
<el-table-column
prop="will4"
label="志愿4">
</el-table-column>
<el-table-column
prop="will5"
label="志愿5">
</el-table-column>
<el-table-column
prop="will6"
label="志愿6">
</el-table-column>
<el-table-column
prop="province"
label="省份">
</el-table-column>
<el-table-column
prop="city"
label="城市">
</el-table-column>
<el-table-column
prop="subjectType"
label="科类">
</el-table-column>
</el-table>
<div class="page-bar" >
<el-pagination
layout="prev, pager, next, jumper"
@current-change="changePage"
:page-size="50"
:current-page.sync="currentPage"
hide-on-single-page
:total="total">
</el-pagination>
</div>
</div>
</div>
</template>
<script>
import {request} from "../../network/request";
import EmptyData from "./EmptyData"
import TableRowCount from './TableRowCount'
export default {
name: "StudentInfo",
data() {
return {
studentInfo: null,
currentPage: 1,
total: 0,
loading: null
}
},
methods: {
changePage(){
this.loadStudentInfo();
},
loadStudentInfo(){
this.setLoading();
request({
url: 'student/getStudentRaw',
params: {
currentPage: this.currentPage
}
}) .then( res => {
if (res.code === '000'){
this.studentInfo = res.data.list;
this.total = res.data.total;
} else {
this.$message.error(res.message)
}
}).catch( err => {
this.$message.error('系统错误')
}).finally( () => {this.setUnloading();})
},
setLoading(){
this.loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
},
setUnloading(){
this.loading.close();
}
},
created(){
this.loadStudentInfo();
},
components: {
EmptyData,
TableRowCount
}
}
</script>
<style scoped lang="less">
.page-bar{
width: 500px;
margin: 30px auto;
}
</style>
4.项目演示
4.1登录
4.2导入(测试文件在excel文件夹下,数据为随机模拟)
表格信息
4.3统计信息
4.4生源地分布
4.5导出结果
5.总结
广东工业大学课程设计 数据库课程设计 平行志愿录取系统(后端代码,广东工业大学数据库大作业) 基于java、spring、MySQL数据库、vue.js的课程设计