專案編號:BS-GX-009
開發工具:IDEA /Eclipse
資料庫:MYSQL5.7+Redis
前端開發:Layui+Bootstrap
后端開發:SSM開發框架
功能需求:
總共分為三個階段
第一個階段是:教研室比賽階段(同一個教研室的老師比賽),同一學院下多個教研室分別選取該教研室分數高的數人晉級到第二階段:學院比賽,
第二個階段是:學院比賽階段:從第一階段晉級過來的老師中選取分數最高的數名代表學院參加第三階段(總決賽)比賽
第三個階段是:總決賽:從第二階段晉級來的選手比賽,排名,選出冠軍、亞軍、季軍,
該管理系統主要實作以下幾個主要功能:
1、教研室比賽(線上比賽)階段主要內容:
(1)教師注冊,登錄、退出功能;
(2)教師個人資訊管理;
(3)教師報名功能;(不是所有注冊過的老師都會報名只有報名之后才是選手)
(4)教師上傳參賽視頻功能;
(5)評委打分功能;(每個評委給某一場比賽的選手打分 資料庫表:比賽ID 選手ID 評委ID 分數)
(6)管理員登錄、查看老師資訊(包括上傳的視頻) 修改老師分數(把評委打的分計算得到的值(十個評委去掉最高分和最低分剩下的取平均值)錄入)
(7)晉級功能,(第1階段選取成績最高的數名選手晉級到第2階段學院比賽)
2、學院比賽(線下比賽)階段主要內容:
(1)評委打分(每個評委給某一場比賽的選手打分 資料庫表:比賽ID 選手ID 評委ID 分數)
(2)管理員登錄、查看老師資訊 修改老師分數(把評委打的分計算得到的值(十個評委去掉最高分和最低分剩下的取平均值)錄入)
(3)晉級功能,(第2階段選取成績最高的數名選手晉級到第3階段學院比賽)
3、學校決賽(線下比賽)主要內容:
(1)評委打分(每個評委給某一場比賽的選手打分 資料庫表:比賽ID 選手ID 評委ID 分數)
(2)管理員登錄、查看老師資訊 修改老師分數(把評委打的分計算得到的值(十個評委去掉最高分和最低分剩下的取平均值)錄入)
(3)排名 選出冠軍、亞軍、季軍
下面展示一下系統的部分實作功能:

參賽用戶登陸:


報名參賽:


報名成功后上傳視頻:

評委登陸系統開始打分:所有評委進入系統為每個作品打分





管理員登陸:


晉級管理:可以分階段管理,依次是教研室,學校,學院決賽,主要根據各評委打分生成平均分進行排名


前端主頁可以查看各階段比較排名結果:

系統核心實作代碼:
package controller;
import com.alibaba.fastjson.JSON;
import entity.Response;
import entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.LoginService;
@Controller
@RequestMapping(value = "login")
public class LoginController {
@Autowired
private LoginService loginService;
@ResponseBody
@RequestMapping(value = "login.do")
public Response login(String userName,String password){
User user = loginService.login(userName,password);
Response res = new Response();
if (user != null){
Integer flag = loginService.loginStatus(user);
if (flag == 1){
res.setMessage("登陸成功!");
user.setIslogin(true);
res.setTag(true);
res.setUser(user);
}
}else {
res.setMessage("登錄失敗,請檢查賬號或密碼是否正確!");
res.setTag(false);
}
return res;
}
@ResponseBody
@RequestMapping(value = "register.do")
public Response register(User user){
Response res = new Response();
System.out.println("data=>"+user+user.getName()+user.getPhonenum());
Integer flag = loginService.checkUser(user.getUsername(),user.getPhonenum());
if (flag == 1){
res.setTag(false);
res.setMessage("該用戶已注冊!");
}else {
User userInfo = loginService.register(user);
if (userInfo != null) {
res.setTag(true);
res.setMessage("賬號注冊成功!");
res.setUser(userInfo);
}else {
res.setTag(false);
res.setMessage("賬號注冊失敗!");
}
}
return res;
}
@ResponseBody
@RequestMapping(value = "logout.do")
public Response logout(String id){
Response res = new Response();
int flag = loginService.logout(id);
if (flag == 1){
res.setTag(true);
res.setMessage("賬號退出登錄成功!");
}else {
res.setTag(false);
res.setMessage("退出登錄失敗!請聯系管理員");
}
return res;
}
@ResponseBody
@RequestMapping(value = "updateUserInfo.do")
public Response updateUserInfo(User user){
Response res = new Response();
int flag = loginService.updateUser(user);
if (flag == 1){
res.setMessage("資料修改成功!");
res.setUser(loginService.getUserInfo(user.getId()));
res.setTag(true);
}else {
res.setMessage("資料修改失敗!");
res.setTag(false);
}
return res;
}
}
package controller;
import entity.Match;
import entity.ResponseJSON;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import service.DateTimeService;
import service.MatchService;
import util.DateUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
@Controller
@RequestMapping("file")
public class VideoController {
String path = "D:\\uploadFiles\\";
@Autowired
private MatchService matchService;
@Autowired
private DateTimeService dateTimeService;
@RequestMapping(value="upload.do")
@ResponseBody
public ResponseJSON upload(MultipartHttpServletRequest request) {
String deadLine = dateTimeService.getDeadLine();
// 獲取檔案map集合
Map<String, MultipartFile> fileMap = request.getFileMap();
MultipartFile file1 = fileMap.get("file");
String mediaType = file1.getContentType();
ResponseJSON rsp = new ResponseJSON();
String[] un = request.getParameterMap().get("id");
String[] ftl = request.getParameterMap().get("mediaType");
String playerId = un[0];
if (file1.isEmpty()) {
rsp.setTag(false);
rsp.setMessage("上傳檔案不能為空");
} else {
String originalFilename = file1.getOriginalFilename();
try {
// 創建要上傳的路
// File fdir = new File("/home/uploadFiles");
File fdir = new File(path);
if (!fdir.exists()) {
fdir.mkdirs();
}
// 檔案上傳到路徑下
FileUtils.copyInputStreamToFile(file1.getInputStream(), new File(fdir, originalFilename));
// coding
rsp.setTag(true);
rsp.setMessage("上傳檔案成功");
} catch (Exception e) {
rsp.setTag(false);
rsp.setMessage("上傳檔案失敗");
}
}
Match req = new Match();
req.setPlayerid(playerId);
req.setVideourl(file1.getOriginalFilename());
req.setMediaType(mediaType);
if(matchService.fileIsExist(req)>0) {
File file = new File(matchService.getFileUrl(req).getVideourl());// 讀取
file.delete();
int flag = matchService.uploadVideo(req);
if (flag == 1) {
rsp.setMessage("上傳檔案成功,已覆寫源檔案");
}
}else {
Match match = new Match();
String filePath = file1.getOriginalFilename();
match.setVideourl(filePath);
match.setPlayerid(playerId);
match.setMediaType(mediaType);
matchService.uploadVideo(match);
Date date = new Date();
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
matchService.uploadVideo(match);
}
return rsp;
}
@RequestMapping(value="download",produces = "application/json;charset=UTF-8")
@ResponseBody
public ResponseJSON download(HttpServletRequest request, HttpServletResponse response) {
String fn = request.getParameter("fileName").toString();
ResponseJSON rsp = new ResponseJSON();
//模擬檔案,myfile.txt為需要下載的檔案
// String path = "/home/uploadFiles/"+fn;
String paths = path + fn;
System.out.println(paths+"下載路徑");
//獲取輸入流
InputStream bis;
try {
bis = new BufferedInputStream(new FileInputStream(new File(paths)));
System.out.println("獲取file成功");
String filename = URLEncoder.encode(fn,"UTF-8");
//設定檔案下載頭
response.addHeader("Content-Disposition", "attachment;filename=" + filename);
//1.設定檔案ContentType型別,這樣設定,會自動判斷下載檔案型別
// response.setContentType("multipart/form-data");
response.setContentType("application/json;charset=UTF-8");
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
System.out.println("開始轉成流");
int len = 0;
while((len = bis.read()) != -1){
out.write(len);
out.flush();
}
out.close();
rsp.setTag(true);
rsp.setMessage("下載檔案成功");
} catch (IOException e) {
rsp.setTag(false);
rsp.setMessage("下載檔案失敗");
}
return rsp;
}
}
package controller;
import entity.Judges;
import entity.Match;
import entity.Response;
import entity.ResponseJSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import service.JudgeService;
import java.util.List;
@Controller
@RequestMapping(value = "judge")
public class JudgeController {
@Autowired
private JudgeService judgeService;
@ResponseBody
@RequestMapping(value = "rateMatch")
public ResponseJSON rateMatch(Judges match){
ResponseJSON res = new ResponseJSON();
int flag = judgeService.getVideoMenu(match);
if (flag == 0) {
res.setMessage("打分失敗!");
res.setTag(true);
}else {
res.setMessage("打分成功!");
res.setTag(true);
}
return res;
}
@ResponseBody
@RequestMapping(value = "checkScored")
public ResponseJSON checkScored(Judges match){
ResponseJSON res = new ResponseJSON();
return res;
}
@ResponseBody
@RequestMapping(value = "calculationAverage")
public ResponseJSON calculationAverage(String matchId,String playerId,String adminId){
ResponseJSON res = new ResponseJSON();
int flag = judgeService.checkAdmin(adminId);
int judgeNum =judgeService.checkJudged(matchId,playerId);
if (flag == 0){
res.setTag(false);
res.setMessage("您沒有權限錄入分數");
}
if (judgeNum < 3 ){
res.setTag(false);
res.setMessage("評分尚未完成!");
}else {
int updated = judgeService.updateTotalScore(matchId,playerId);
if (updated == 1){
res.setTag(true);
res.setMessage("修改分數完成!");
}else {
res.setTag(false);
res.setMessage("更新總分失敗!");
}
int ended = judgeService.checkMatchEnd(matchId);
if (ended == 0){
String level = judgeService.getCurrentLevel(matchId);
if (level.equals("已結束")){
res.setTag(true);
res.setMessage("已決出關亞季軍!");
}else {
int promote = judgeService.updatePromotion(matchId, level);
if (promote == 1) {
res.setMessage("所有參賽人員總分已產生,該場比賽結果已產生!");
res.setTag(true);
} else {
res.setMessage("所有參賽人員總分已產生,該場比賽結果產生失敗,請聯系管理員!");
res.setTag(false);
}
}
}
}
return res;
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/390638.html
標籤:其他
上一篇:VSCode中Vim使用手冊
