1446 lines
52 KiB
Plaintext
1446 lines
52 KiB
Plaintext
package com.bonus.score.controller;
|
||
|
||
import com.bonus.core.DocumentHandler;
|
||
import com.bonus.core.ZipCompress;
|
||
import com.bonus.grade.beans.gradeBean;
|
||
import com.bonus.grade.service.gradeService;
|
||
import com.bonus.question.beans.QuestionBean;
|
||
import com.bonus.question.service.QuestionService;
|
||
import com.bonus.registration.beans.RegistrationBean;
|
||
import com.bonus.registration.service.RegistrationService;
|
||
import com.bonus.score.beans.ExamQuestionBean;
|
||
import com.bonus.score.beans.ScoreBean;
|
||
import com.bonus.score.exp.POIOutputHelperNumBer;
|
||
import com.bonus.score.service.ScoreService;
|
||
import com.bonus.seat.service.SeatService;
|
||
import com.bonus.sys.*;
|
||
import com.bonus.sys.beans.UserBean;
|
||
import com.bonus.sys.service.UserService;
|
||
import com.bonus.utils.DocToPdf;
|
||
|
||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||
import org.apache.poi.ss.formula.functions.T;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Controller;
|
||
import org.springframework.ui.Model;
|
||
import org.springframework.web.bind.annotation.RequestBody;
|
||
import org.springframework.web.bind.annotation.RequestMapping;
|
||
import org.springframework.web.bind.annotation.RequestMethod;
|
||
import org.springframework.web.bind.annotation.ResponseBody;
|
||
|
||
import javax.servlet.ServletOutputStream;
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import javax.servlet.http.HttpServletResponse;
|
||
import java.io.*;
|
||
import java.net.URLEncoder;
|
||
import java.util.*;
|
||
import java.util.regex.Matcher;
|
||
import java.util.regex.Pattern;
|
||
|
||
@Controller
|
||
@RequestMapping("/backstage/score/")
|
||
public class ScoreController extends BaseController<T> {
|
||
|
||
@Autowired
|
||
private ScoreService service;
|
||
|
||
@Autowired
|
||
private gradeService gradeService;
|
||
|
||
@Autowired
|
||
private QuestionService questionService;
|
||
|
||
@Autowired
|
||
RegistrationService registservice;
|
||
|
||
@Autowired
|
||
private SeatService seatService;
|
||
|
||
@Autowired
|
||
private UserService userService;
|
||
|
||
/**
|
||
* 导出试卷的人员基本考试信息
|
||
*
|
||
* @param request
|
||
* @param response
|
||
* @param examId
|
||
* @param filename
|
||
*/
|
||
@RequestMapping("exportallpeople")
|
||
public void exportallpeople(HttpServletRequest request, HttpServletResponse response, String examId) {
|
||
String filename = "";
|
||
gradeBean gbean = gradeService.findIsActice(examId);
|
||
filename = gbean.getExamName() + "-考试结果";
|
||
// 通过试卷id去exam_person_record表里面去查询考试人员的历史记录
|
||
List<RegistrationBean> registlist = registservice.findExamPerson(examId);
|
||
// 导出所有人员基本信息
|
||
try {
|
||
excelOut(response, registlist, filename);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
/**
|
||
*
|
||
* 导出试卷考生信息
|
||
*
|
||
* @param
|
||
* @return
|
||
* @throws IOException
|
||
*/
|
||
|
||
@RequestMapping("exportcj")
|
||
public void exportcj(HttpServletRequest request, HttpServletResponse response, String examId, String filename)
|
||
throws IOException {
|
||
File filePath = null;
|
||
File zipPath = null;
|
||
InputStream fin = null;
|
||
ServletOutputStream outs = null;
|
||
// 通过试卷id去查询本场考试的基本信息
|
||
gradeBean gradeis = gradeService.findIsActice(examId);
|
||
String[] split = gradeis.getStartTime().split(" ");
|
||
String fname = split[0] + "场次" + gradeis.getExamCount();
|
||
// 根据examId查询examName
|
||
String examName = gradeService.findIsActice(examId).getExamName();
|
||
String path = examName;
|
||
int exportAllExamWord = exportAllExamWord(examId, filename, fname, response, request);
|
||
if (exportAllExamWord != 0) {
|
||
String relPath = request.getSession().getServletContext().getRealPath("/uploadfiles/");
|
||
filePath = new File(relPath + path);
|
||
zipPath = new File(relPath + path + ".zip");
|
||
new ZipCompress().zip(filePath, relPath + path + ".zip");
|
||
|
||
try {
|
||
fin = new FileInputStream(zipPath);
|
||
response.setCharacterEncoding("utf-8");
|
||
response.setContentType("application/msword");
|
||
System.out.println(filename + "时间" + gradeis.getStartTime() + "场次" + gradeis.getExamCount());
|
||
response.addHeader("Content-Disposition",
|
||
"attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".zip");
|
||
outs = response.getOutputStream();
|
||
} catch (FileNotFoundException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
byte[] buffer = new byte[512]; // 缓冲区
|
||
int bytesToRead = -1;
|
||
// 通过循环将读入的Word文件的内容输出到浏览器中
|
||
while ((bytesToRead = fin.read(buffer)) != -1) {
|
||
outs.write(buffer, 0, bytesToRead);
|
||
}
|
||
} else {
|
||
response.getWriter().write("<script>alert('沒有查询到考试人员')</script>");
|
||
}
|
||
}
|
||
|
||
@RequestMapping("scoreList")
|
||
public String index(Model model) {
|
||
return "/score/scoreManagement";
|
||
}
|
||
|
||
@RequestMapping(value = "findByPage")
|
||
public String findByPage(@RequestBody Page<ScoreBean> page, ScoreBean o, Model model) {
|
||
try {
|
||
o = page.getObj();
|
||
page = service.findByPage(o, page);
|
||
model.addAttribute("page", page);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
e.printStackTrace();
|
||
}
|
||
return "/score/scoreList";
|
||
}
|
||
|
||
@RequestMapping(value = "saveExamPerson")
|
||
@ResponseBody
|
||
public AjaxRes saveExamPerson(@RequestBody ScoreBean o, Model model) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
UserBean user = UserShiroHelper.getRealCurrentUser();
|
||
o.setUser(user);
|
||
Integer re = 0;
|
||
re = service.findUserByExamId(o);
|
||
if (re == 0) {
|
||
Integer res = 0;
|
||
res = service.saveExamPerson(o);
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
e.printStackTrace();
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
private int exportAllExamWord(String examId, String filename, String fname, HttpServletResponse response,
|
||
HttpServletRequest request) {
|
||
// 通过examId去查询有多少个人参加考试
|
||
ScoreBean bean = new ScoreBean();
|
||
bean.setExamId(examId);
|
||
List<ScoreBean> getpersonGrade = service.getpersonLimit(bean);
|
||
String path = filename;
|
||
Map<String, Object> dataMap = new HashMap<String, Object>();
|
||
dataMap.put("xytitle", fname);
|
||
int index = 1;
|
||
ExamQuestionBean be = new ExamQuestionBean();
|
||
be.setExamId(examId);
|
||
// 判断本场考试有多少人参加
|
||
int size2 = getpersonGrade.size();
|
||
for (int j = 0; j < size2; j++) {
|
||
be.setExamUser(getpersonGrade.get(j).getUserId());
|
||
String getname = getpersonGrade.get(j).getExamPerson();
|
||
|
||
ScoreBean o = new ScoreBean();
|
||
o.setExamId(examId);
|
||
String userId = getpersonGrade.get(j).getUserId();
|
||
UserBean ubean = userService.findUserBeanById(userId);
|
||
o.setUserId(ubean.getLoginName());
|
||
gradeBean grbean = new gradeBean();
|
||
grbean.setExamId(examId);
|
||
grbean.setUserId(ubean.getLoginName());
|
||
// 获取这个人基本考试信息
|
||
grbean = gradeService.findByExamIdPlus(grbean);
|
||
dataMap.put("examName", grbean.getExamName());
|
||
dataMap.put("userName", grbean.getUserName());
|
||
dataMap.put("idCard", ubean.getLoginName());
|
||
dataMap.put("specialName", grbean.getPerfessionName());
|
||
// 获取这个人的每个类型成绩
|
||
ScoreBean bean11 = service.findAllGrade(o);
|
||
double singleGrade = 0;
|
||
double multiGrade = 0 ;
|
||
double judgeGrade =0;
|
||
double fillGrade = 0;
|
||
double soluGrade = 0;
|
||
double caseGrade = 0;
|
||
double totalGrade = 0;
|
||
if(bean11 != null){
|
||
singleGrade = (bean11.getSingleGrade() == null || bean11.getSingleGrade() == "") ? 0
|
||
: Double.parseDouble(bean11.getSingleGrade());
|
||
multiGrade = (bean11.getMultiGrade() == null || bean11.getMultiGrade() == "") ? 0
|
||
: Double.parseDouble(bean11.getMultiGrade());
|
||
judgeGrade = (bean11.getJudgeGrade() == null || bean11.getJudgeGrade() == "") ? 0
|
||
: Double.parseDouble(bean11.getJudgeGrade());
|
||
fillGrade = (bean11.getFillGrade() == null || bean11.getFillGrade() == "") ? 0
|
||
: Double.parseDouble(bean11.getFillGrade());
|
||
soluGrade = (bean11.getSoluGrade() == null || bean11.getSoluGrade() == "") ? 0
|
||
: Double.parseDouble(bean11.getSoluGrade());
|
||
caseGrade = (bean11.getCaseGrade() == null || bean11.getCaseGrade() == "") ? 0
|
||
: Double.parseDouble(bean11.getCaseGrade());
|
||
totalGrade = singleGrade + multiGrade + judgeGrade + fillGrade + soluGrade + caseGrade;
|
||
}
|
||
dataMap.put("totg", totalGrade);
|
||
dataMap.put("sing", singleGrade);
|
||
dataMap.put("mulg", multiGrade);
|
||
dataMap.put("judg", judgeGrade);
|
||
dataMap.put("filg", fillGrade);
|
||
dataMap.put("solg", soluGrade);
|
||
dataMap.put("casg", caseGrade);
|
||
dataMap.put("totg", totalGrade);
|
||
// 获取所有的考试试题
|
||
ExamQuestionBean bean1 = new ExamQuestionBean();
|
||
for (int i = 1; i <= 6; i++) {
|
||
if (i == 1) {
|
||
be.setClassification(String.valueOf(i));
|
||
bean1.setSinList(gradeService.findExamContent(be));
|
||
} else if (i == 2) {
|
||
be.setClassification(String.valueOf(i));
|
||
bean1.setMulList(gradeService.findExamContent(be));
|
||
} else if (i == 3) {
|
||
be.setClassification(String.valueOf(i));
|
||
bean1.setJudgeList(gradeService.findExamContent(be));
|
||
} else if (i == 4) {
|
||
be.setClassification(String.valueOf(i));
|
||
bean1.setComList(gradeService.findExamContent(be));
|
||
} else if (i == 5) {
|
||
be.setClassification(String.valueOf(i));
|
||
bean1.setShortList(gradeService.findExamContent(be));
|
||
} else {
|
||
be.setClassification(String.valueOf(i));
|
||
bean1.setCaseList(gradeService.findExamContent(be));
|
||
}
|
||
}
|
||
// 抽取选择题
|
||
index = 1;
|
||
List<Map<String, Object>> list1 = new ArrayList<Map<String, Object>>();
|
||
int size = bean1.getSinList().size();
|
||
List<ExamQuestionBean> list2 = standardListsPlus(bean1.getSinList(), 1);
|
||
for (int i = 0; i < size; i++) {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("dxt", index + ".");
|
||
map.put("txtest", bean1.getSinList().get(i).getQuestionTitle());
|
||
map.put("dxt1", list2.get(i).getOperation());
|
||
System.out.println("-----" + bean1.getSinList().get(i).getTrueAnswer());
|
||
|
||
map.put("dxzqda", list2.get(i).getTrueAnswer());
|
||
String team = "无";
|
||
if (bean1.getSinList().get(i).getAnswer() != null) {
|
||
team = list2.get(i).getAnswer();
|
||
map.put("dxsxda", team);
|
||
} else {
|
||
map.put("dxsxda", "无");
|
||
}
|
||
list1.add(map);
|
||
index++;
|
||
}
|
||
if (size == 0) {
|
||
dataMap.put("sinflag", "本专业无此类型题目");
|
||
} else {
|
||
dataMap.put("sinflag", "");
|
||
}
|
||
dataMap.put("table1", list1);
|
||
// 多选题
|
||
List<Map<String, Object>> dxlist = new ArrayList<Map<String, Object>>();
|
||
index = 1;
|
||
size = bean1.getMulList().size();
|
||
List<ExamQuestionBean> list3 = standardListsPlus(bean1.getMulList(), 2);
|
||
for (int i = 0; i < size; i++) {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("dxtx", index + ".");
|
||
map.put("dxtext", bean1.getMulList().get(i).getQuestionTitle());
|
||
map.put("dxtx1", list3.get(i).getOperation());
|
||
map.put("dxtzqda", list3.get(i).getTrueAnswer());
|
||
String team = "无";
|
||
if (bean1.getMulList().get(i).getAnswer() != null) {
|
||
team = list3.get(i).getAnswer();
|
||
}
|
||
map.put("dxtsxda", team);
|
||
dxlist.add(map);
|
||
index++;
|
||
}
|
||
if (size == 0) {
|
||
dataMap.put("mulflag", "本专业无此类型题目");
|
||
} else {
|
||
dataMap.put("mulflag", "");
|
||
}
|
||
dataMap.put("table2", dxlist);
|
||
// 判断题
|
||
List<Map<String, Object>> pdlist = new ArrayList<Map<String, Object>>();
|
||
index = 1;
|
||
List<ExamQuestionBean> list4 = standardListsPlus(bean1.getJudgeList(), 3);
|
||
|
||
size = bean1.getJudgeList().size();
|
||
for (int i = 0; i < size; i++) {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("pdtx", index + ".");
|
||
map.put("pdtest", bean1.getJudgeList().get(i).getQuestionTitle());
|
||
String temp = splitselect(bean1.getJudgeList().get(i).getOperation(), 3);
|
||
temp = temp.substring(0, temp.length() - 1);
|
||
map.put("pdtx1", temp);
|
||
map.put("pdtzqda", bean1.getJudgeList().get(i).getTrueAnswer());
|
||
String team = "无";
|
||
if (bean1.getJudgeList().get(i).getAnswer() != null) {
|
||
team = numToAB(bean1.getJudgeList().get(i).getAnswer());
|
||
}
|
||
map.put("pdtsxda", team);
|
||
pdlist.add(map);
|
||
index++;
|
||
}
|
||
|
||
if (size == 0) {
|
||
dataMap.put("judflag", "本专业无此类型题目");
|
||
} else {
|
||
dataMap.put("judflag", "");
|
||
}
|
||
|
||
dataMap.put("table3", pdlist);
|
||
// 填空题
|
||
List<Map<String, Object>> tklist = new ArrayList<Map<String, Object>>();
|
||
index = 1;
|
||
size = bean1.getComList().size();
|
||
for (int i = 0; i < size; i++) {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("tktx", index + ".");
|
||
map.put("tktest", bean1.getComList().get(i).getQuestionTitle());
|
||
map.put("tktx1", " ");
|
||
map.put("tktzqda", bean1.getComList().get(i).getTrueAnswer());
|
||
String team = "无";
|
||
if (bean1.getComList().get(i).getAnswer() != null) {
|
||
team = bean1.getComList().get(i).getAnswer();
|
||
}
|
||
map.put("tktsxda", team);
|
||
tklist.add(map);
|
||
index++;
|
||
}
|
||
if (size == 0) {
|
||
dataMap.put("filflag", "本专业无此类型题目");
|
||
} else {
|
||
dataMap.put("filflag", "");
|
||
}
|
||
dataMap.put("table4", tklist);
|
||
// 解答题
|
||
List<Map<String, Object>> jdlist = new ArrayList<Map<String, Object>>();
|
||
index = 1;
|
||
size = bean1.getShortList().size();
|
||
for (int i = 0; i < size; i++) {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("jdtx", index + ".");
|
||
map.put("jdtest", bean1.getShortList().get(i).getQuestionTitle());
|
||
map.put("jdtx1", " ");
|
||
// 处理简答题标准答案末尾多了一个分号问题
|
||
String standardAnswer = bean1.getShortList().get(i).getStandAnswer();
|
||
if (standardAnswer.charAt(standardAnswer.length() - 1) == ';'
|
||
|| standardAnswer.charAt(standardAnswer.length() - 1) == ';') {
|
||
standardAnswer = standardAnswer.substring(0, standardAnswer.length() - 1);
|
||
}
|
||
map.put("jdtzqda", standardAnswer);
|
||
String team = "无";
|
||
if (bean1.getShortList().get(i).getAnswer() != null) {
|
||
team = bean1.getShortList().get(i).getAnswer();
|
||
}
|
||
map.put("jdtsxda", team);
|
||
jdlist.add(map);
|
||
index++;
|
||
}
|
||
if (size == 0) {
|
||
dataMap.put("casflag", "本专业无此类型题目");
|
||
} else {
|
||
dataMap.put("casflag", "");
|
||
}
|
||
dataMap.put("table5", jdlist);
|
||
// 案例题
|
||
List<Map<String, Object>> allist = new ArrayList<Map<String, Object>>();
|
||
index = 1;
|
||
|
||
size = bean1.getCaseList().size();
|
||
for (int i = 0; i < size; i++) {
|
||
Map<String, Object> map = new HashMap<String, Object>();
|
||
map.put("altx", index + ".");
|
||
map.put("altest", bean1.getCaseList().get(i).getQuestionTitle());
|
||
map.put("altx1", " ");
|
||
// 处理案例题标准答案末尾多了一个分号问题
|
||
String standardAnswer = bean1.getCaseList().get(i).getStandAnswer();
|
||
if (standardAnswer.charAt(standardAnswer.length() - 1) == ';'
|
||
|| standardAnswer.charAt(standardAnswer.length() - 1) == ';') {
|
||
standardAnswer = standardAnswer.substring(0, standardAnswer.length() - 1);
|
||
}
|
||
map.put("altzqda", standardAnswer);
|
||
String team = "无";
|
||
if (bean1.getCaseList().get(i).getAnswer() != null) {
|
||
team = bean1.getCaseList().get(i).getAnswer();
|
||
}
|
||
map.put("altsxda", team);
|
||
allist.add(map);
|
||
index++;
|
||
}
|
||
if (size == 0) {
|
||
dataMap.put("totflag", "本专业无此类型题目");
|
||
} else {
|
||
dataMap.put("totflag", "");
|
||
}
|
||
|
||
dataMap.put("table6", allist);
|
||
try {
|
||
String relPath = request.getSession().getServletContext().getRealPath("/uploadfiles/");
|
||
String path1 = relPath + path + "/" + path;
|
||
File filePath = new File(path1);
|
||
if (!filePath.exists()) {
|
||
filePath.mkdirs();
|
||
}
|
||
DocumentHandler handler = new DocumentHandler();
|
||
handler.createDoc(dataMap, path1 + "/" + getname + ".doc", 1);
|
||
|
||
// doc转pdf,然后删除doc
|
||
DocToPdf.doc2pdf(path1 + "/" + getname + ".doc", path1 + "/" + getname + ".pdf");
|
||
File docFile = new File(path1 + "/" + getname + ".doc");
|
||
docFile.delete();
|
||
|
||
} catch (UnsupportedEncodingException e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
return size2;
|
||
}
|
||
|
||
private static String dxtselect(String operation, int i) {
|
||
String team = "";
|
||
String[] split = operation.split(",");
|
||
for (int k = 0; k < split.length; k++) {
|
||
team += selectanswer(split[k]);
|
||
}
|
||
|
||
return team;
|
||
}
|
||
|
||
private static String numToAB(String num) {
|
||
if (num.equals("1")) {
|
||
num = "A";
|
||
}
|
||
if (num.equals("2")) {
|
||
num = "B";
|
||
}
|
||
return num;
|
||
}
|
||
|
||
private static String selectanswer(String answer) {
|
||
String str = "";
|
||
if (answer.equals("1")) {
|
||
str = "A";
|
||
} else if (answer.equals("2")) {
|
||
str = "B";
|
||
} else if (answer.equals("3")) {
|
||
str = "C";
|
||
} else if (answer.equals("4")) {
|
||
str = "D";
|
||
} else if (answer.equals("5")) {
|
||
str = "E";
|
||
} else if (answer.equals("6")) {
|
||
str = "F";
|
||
} else if (answer.equals("7")) {
|
||
str = "G";
|
||
}
|
||
return str;
|
||
}
|
||
|
||
private static String splitselect(String operation, int i) {
|
||
String[] split = operation.split(";");
|
||
String replaceFirst = null;
|
||
String replaceSecond = null;
|
||
String replaceThird = null;
|
||
String replaceForth = null;
|
||
String replaceFive = null;
|
||
String replaceSix = null;
|
||
String replaceSeven = null;
|
||
String replaceEight = null;
|
||
if (split.length == 4) {
|
||
replaceFirst = split[0].replaceFirst("1", "A") + ";";
|
||
replaceSecond = split[1].replaceFirst("2", "B") + ";";
|
||
replaceThird = split[2].replaceFirst("3", "C") + ";";
|
||
replaceForth = split[3].replaceFirst("4", "D") + ";";
|
||
return replaceFirst + replaceSecond + replaceThird + replaceForth;
|
||
} else if (split.length == 3) {
|
||
replaceFirst = split[0].replaceFirst("1", "A") + ";";
|
||
replaceSecond = split[1].replaceFirst("2", "B") + ";";
|
||
replaceThird = split[2].replaceFirst("3", "C") + ";";
|
||
return replaceFirst + replaceSecond + replaceThird;
|
||
} else if (split.length == 2) {
|
||
replaceFirst = split[0].replaceFirst("1", "A") + ";";
|
||
replaceSecond = split[1].replaceFirst("2", "B") + ";";
|
||
return replaceFirst + replaceSecond;
|
||
} else if (split.length == 5) {
|
||
replaceFirst = split[0].replaceFirst("1", "A") + ";";
|
||
replaceSecond = split[1].replaceFirst("2", "B") + ";";
|
||
replaceThird = split[2].replaceFirst("3", "C") + ";";
|
||
replaceForth = split[3].replaceFirst("4", "D") + ";";
|
||
replaceFive = split[4].replaceFirst("5", "E") + ";";
|
||
return replaceFirst + replaceSecond + replaceThird + replaceForth + replaceFive;
|
||
} else if (split.length == 6) {
|
||
replaceFirst = split[0].replaceFirst("1", "A") + ";";
|
||
replaceSecond = split[1].replaceFirst("2", "B") + ";";
|
||
replaceThird = split[2].replaceFirst("3", "C") + ";";
|
||
replaceForth = split[3].replaceFirst("4", "D") + ";";
|
||
replaceFive = split[4].replaceFirst("5", "E") + ";";
|
||
replaceSix = split[5].replaceFirst("6", "F") + ";";
|
||
return replaceFirst + replaceSecond + replaceThird + replaceForth + replaceFive + replaceSix;
|
||
} else if (split.length == 7) {
|
||
replaceFirst = split[0].replaceFirst("1", "A") + ";";
|
||
replaceSecond = split[1].replaceFirst("2", "B") + ";";
|
||
replaceThird = split[2].replaceFirst("3", "C") + ";";
|
||
replaceForth = split[3].replaceFirst("4", "D") + ";";
|
||
replaceFive = split[4].replaceFirst("5", "E") + ";";
|
||
replaceSix = split[5].replaceFirst("6", "F") + ";";
|
||
replaceSeven = split[6].replaceFirst("7", "G") + ";";
|
||
return replaceFirst + replaceSecond + replaceThird + replaceForth + replaceFive + replaceSix + replaceSeven;
|
||
} else if (split.length == 8) {
|
||
replaceFirst = split[0].replaceFirst("1", "A") + ";";
|
||
replaceSecond = split[1].replaceFirst("2", "B") + ";";
|
||
replaceThird = split[2].replaceFirst("3", "C") + ";";
|
||
replaceForth = split[3].replaceFirst("4", "D") + ";";
|
||
replaceFive = split[4].replaceFirst("5", "E") + ";";
|
||
replaceSix = split[5].replaceFirst("6", "F") + ";";
|
||
replaceSeven = split[6].replaceFirst("7", "G") + ";";
|
||
replaceEight = split[7].replaceFirst("8", "H") + ";";
|
||
return replaceFirst + replaceSecond + replaceThird + replaceForth + replaceFive + replaceSix + replaceSeven
|
||
+ replaceEight;
|
||
}
|
||
|
||
return replaceFirst + replaceSecond + replaceThird + replaceForth;
|
||
}
|
||
|
||
public List<QuestionBean> getpersonGrade(ScoreBean o) {
|
||
List<QuestionBean> totalList = new ArrayList<>();
|
||
try {
|
||
o.setClassification("1");
|
||
List<QuestionBean> singleList = standardList(service.findGradeReport(o), 1);
|
||
o.setClassification("2");
|
||
List<QuestionBean> multiList = standardList(service.findGradeReport(o), 2);
|
||
o.setClassification("3");
|
||
List<QuestionBean> judgeList = standardList(service.findGradeReport(o), 3);
|
||
o.setClassification("4");
|
||
List<QuestionBean> fillList = service.findGradeReport(o);
|
||
o.setClassification("5");
|
||
List<QuestionBean> soluList = service.findGradeReport(o);
|
||
o.setClassification("6");
|
||
List<QuestionBean> caseList = service.findGradeReport(o);
|
||
if (singleList != null && singleList.size() != 0) {
|
||
for (int i = 0; i < singleList.size(); i++) {
|
||
totalList.add(singleList.get(i));
|
||
}
|
||
}
|
||
if (multiList != null && multiList.size() != 0) {
|
||
for (int i = 0; i < multiList.size(); i++) {
|
||
totalList.add(multiList.get(i));
|
||
}
|
||
}
|
||
if (judgeList != null && judgeList.size() != 0) {
|
||
for (int i = 0; i < judgeList.size(); i++) {
|
||
totalList.add(judgeList.get(i));
|
||
}
|
||
}
|
||
if (fillList != null && fillList.size() != 0) {
|
||
for (int i = 0; i < fillList.size(); i++) {
|
||
totalList.add(fillList.get(i));
|
||
}
|
||
}
|
||
if (soluList != null && soluList.size() != 0) {
|
||
for (int i = 0; i < soluList.size(); i++) {
|
||
totalList.add(soluList.get(i));
|
||
}
|
||
}
|
||
if (caseList != null && caseList.size() != 0) {
|
||
for (int i = 0; i < caseList.size(); i++) {
|
||
totalList.add(caseList.get(i));
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return totalList;
|
||
}
|
||
|
||
@RequestMapping(value = "gradeReport")
|
||
public String gradeReport(ScoreBean o, Model model) {
|
||
String url = "";
|
||
String examType = o.getExamType();
|
||
try {
|
||
if ("1".equals(examType)) {
|
||
gradeBean bean = new gradeBean();
|
||
bean.setExamId(o.getExamId());
|
||
bean.setUserId(o.getId());
|
||
String perfessionName = gradeService.findByExamId(bean).getPerfessionName();
|
||
List<QuestionBean> totalList = new ArrayList<>();
|
||
o.setClassification("1");
|
||
List<QuestionBean> singleList = standardLists(service.findGradeReport(o), 1);
|
||
o.setClassification("2");
|
||
List<QuestionBean> multiList = standardLists(service.findGradeReport(o), 2);
|
||
o.setClassification("3");
|
||
List<QuestionBean> judgeList = standardLists(service.findGradeReport(o), 3);
|
||
o.setClassification("4");
|
||
List<QuestionBean> fillList = service.findGradeReport(o);
|
||
o.setClassification("5");
|
||
List<QuestionBean> soluList = service.findGradeReport(o);
|
||
o.setClassification("6");
|
||
List<QuestionBean> caseList = service.findGradeReport(o);
|
||
if (singleList != null && singleList.size() != 0) {
|
||
for (int i = 0; i < singleList.size(); i++) {
|
||
totalList.add(singleList.get(i));
|
||
}
|
||
}
|
||
if (multiList != null && multiList.size() != 0) {
|
||
for (int i = 0; i < multiList.size(); i++) {
|
||
totalList.add(multiList.get(i));
|
||
}
|
||
}
|
||
if (judgeList != null && judgeList.size() != 0) {
|
||
for (int i = 0; i < judgeList.size(); i++) {
|
||
totalList.add(judgeList.get(i));
|
||
}
|
||
}
|
||
if (fillList != null && fillList.size() != 0) {
|
||
for (int i = 0; i < fillList.size(); i++) {
|
||
totalList.add(fillList.get(i));
|
||
}
|
||
}
|
||
if (soluList != null && soluList.size() != 0) { // 处理简答题标准答案末尾多一个分号问题
|
||
for (int i = 0; i < soluList.size(); i++) {
|
||
String standardAnswer = soluList.get(i).getStandardAnswer();
|
||
if (standardAnswer.charAt(standardAnswer.length() - 1) == ';'
|
||
|| standardAnswer.charAt(standardAnswer.length() - 1) == ';') {
|
||
soluList.get(i).setStandardAnswer(standardAnswer.substring(0, standardAnswer.length() - 1));
|
||
}
|
||
totalList.add(soluList.get(i));
|
||
}
|
||
}
|
||
if (caseList != null && caseList.size() != 0) { // 处理案例题标准答案末尾多一个分号问题
|
||
for (int i = 0; i < caseList.size(); i++) {
|
||
String standardAnswer = caseList.get(i).getStandardAnswer();
|
||
if (standardAnswer.charAt(standardAnswer.length() - 1) == ';'
|
||
|| standardAnswer.charAt(standardAnswer.length() - 1) == ';') {
|
||
caseList.get(i).setStandardAnswer(standardAnswer.substring(0, standardAnswer.length() - 1));
|
||
}
|
||
totalList.add(caseList.get(i));
|
||
}
|
||
}
|
||
model.addAttribute("singleList", singleList);
|
||
model.addAttribute("multiList", multiList);
|
||
model.addAttribute("judgeList", judgeList);
|
||
model.addAttribute("fillList", fillList);
|
||
model.addAttribute("soluList", soluList);
|
||
model.addAttribute("caseList", caseList);
|
||
model.addAttribute("totalList", totalList);
|
||
model.addAttribute("perfessionName", perfessionName);
|
||
url = "/score/gradeReportForm";
|
||
} else {
|
||
gradeBean bean = new gradeBean();
|
||
bean.setExamId(o.getExamId());
|
||
String perfessionName = gradeService.findSelfByExamId(bean).getPerfessionName();
|
||
List<QuestionBean> totalList = new ArrayList<>();
|
||
o.setClassification("1");
|
||
List<QuestionBean> singleList = standardLists(service.findSelfGradeReport(o), 1);
|
||
o.setClassification("2");
|
||
List<QuestionBean> multiList = standardLists(service.findSelfGradeReport(o), 2);
|
||
o.setClassification("3");
|
||
List<QuestionBean> judgeList = standardLists(service.findSelfGradeReport(o), 3);
|
||
o.setClassification("4");
|
||
List<QuestionBean> fillList = service.findSelfGradeReport(o);
|
||
o.setClassification("5");
|
||
List<QuestionBean> soluList = service.findSelfGradeReport(o);
|
||
o.setClassification("6");
|
||
List<QuestionBean> caseList = service.findSelfGradeReport(o);
|
||
if (singleList != null && singleList.size() != 0) {
|
||
for (int i = 0; i < singleList.size(); i++) {
|
||
totalList.add(singleList.get(i));
|
||
}
|
||
}
|
||
if (multiList != null && multiList.size() != 0) {
|
||
for (int i = 0; i < multiList.size(); i++) {
|
||
totalList.add(multiList.get(i));
|
||
}
|
||
}
|
||
if (judgeList != null && judgeList.size() != 0) {
|
||
for (int i = 0; i < judgeList.size(); i++) {
|
||
totalList.add(judgeList.get(i));
|
||
}
|
||
}
|
||
if (fillList != null && fillList.size() != 0) {
|
||
for (int i = 0; i < fillList.size(); i++) {
|
||
totalList.add(fillList.get(i));
|
||
}
|
||
}
|
||
if (soluList != null && soluList.size() != 0) { // 处理简答题标准答案末尾多一个分号问题
|
||
for (int i = 0; i < soluList.size(); i++) {
|
||
String standardAnswer = soluList.get(i).getStandardAnswer();
|
||
if (standardAnswer.charAt(standardAnswer.length() - 1) == ';'
|
||
|| standardAnswer.charAt(standardAnswer.length() - 1) == ';') {
|
||
soluList.get(i).setStandardAnswer(standardAnswer.substring(0, standardAnswer.length() - 1));
|
||
}
|
||
totalList.add(soluList.get(i));
|
||
}
|
||
}
|
||
if (caseList != null && caseList.size() != 0) { // 处理案例题标准答案末尾多一个分号问题
|
||
for (int i = 0; i < caseList.size(); i++) {
|
||
String standardAnswer = caseList.get(i).getStandardAnswer();
|
||
if (standardAnswer.charAt(standardAnswer.length() - 1) == ';'
|
||
|| standardAnswer.charAt(standardAnswer.length() - 1) == ';') {
|
||
caseList.get(i).setStandardAnswer(standardAnswer.substring(0, standardAnswer.length() - 1));
|
||
}
|
||
totalList.add(caseList.get(i));
|
||
}
|
||
}
|
||
model.addAttribute("singleList", singleList);
|
||
model.addAttribute("multiList", multiList);
|
||
model.addAttribute("judgeList", judgeList);
|
||
model.addAttribute("fillList", fillList);
|
||
model.addAttribute("soluList", soluList);
|
||
model.addAttribute("caseList", caseList);
|
||
model.addAttribute("totalList", totalList);
|
||
model.addAttribute("perfessionName", perfessionName);
|
||
// url = "/score/gradeSelfReportForm";
|
||
url = "/score/gradeReportForm";
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return url;
|
||
}
|
||
|
||
public List<QuestionBean> standardLists(List<QuestionBean> list, int classs) {
|
||
if (list != null && list.size() != 0) {
|
||
for (int i = 0; i < list.size(); i++) {
|
||
if (classs == 2) { // 处理多选题
|
||
String trueAnswer = "";
|
||
String[] tAnswer = list.get(i).getTrueAnswer().split(",");
|
||
HashSet<Integer> set1 = new HashSet<>();
|
||
for (int j = 0; j < tAnswer.length; j++) {
|
||
int num = (int) tAnswer[j].charAt(0) - (int) 'A' + 1; // 将A
|
||
// B
|
||
// C
|
||
// D..转化为1
|
||
// 2
|
||
// 3
|
||
// 4..
|
||
set1.add(num);
|
||
}
|
||
|
||
String[] op = list.get(i).getQuestionOperation().split(";");
|
||
for (int j = 0; j < op.length; j++) {
|
||
char numChar = op[j].charAt(0);
|
||
if(numChar == 'A'){
|
||
numChar = '1';
|
||
}else if(numChar == 'B'){
|
||
numChar = '2';
|
||
}else if(numChar == 'C'){
|
||
numChar = '3';
|
||
}else if(numChar == 'D'){
|
||
numChar = '4';
|
||
}
|
||
int num = Integer.parseInt(numChar + "");
|
||
if (set1.contains(num)) {
|
||
trueAnswer += AZ(j);
|
||
}
|
||
}
|
||
list.get(i).setTrueAnswer(trueAnswer);
|
||
|
||
if (list.get(i).getAnswer() != null && list.get(i).getAnswer() != "") {
|
||
String answer = "";
|
||
String[] dAnswer = list.get(i).getAnswer().split(",");
|
||
HashSet<Integer> set2 = new HashSet<>();
|
||
for (int j = 0; j < dAnswer.length; j++) {
|
||
set2.add(Integer.parseInt(dAnswer[j]));
|
||
}
|
||
String[] ops = list.get(i).getQuestionOperation().split(";");
|
||
for (int j = 0; j < ops.length; j++) {
|
||
int num = Integer.parseInt(op[j].charAt(0) + "");
|
||
if (set2.contains(num)) {
|
||
answer += AZ(j);
|
||
}
|
||
}
|
||
list.get(i).setAnswer(answer);
|
||
}
|
||
} else if (classs == 1) { // 处理单选题
|
||
String trueAnswer = "";
|
||
String answer = "";
|
||
String[] op = list.get(i).getQuestionOperation().split(";");
|
||
for (int j = 0; j < op.length; j++) {
|
||
int num = Integer.parseInt(op[j].charAt(0) + "");
|
||
int tAnswer = (int) list.get(i).getTrueAnswer().charAt(0) - (int) 'A' + 1;
|
||
if (tAnswer == num) {
|
||
trueAnswer = AZ(j);
|
||
}
|
||
if (list.get(i).getAnswer() != null && list.get(i).getAnswer() != "") {
|
||
int dAnswer = Integer.parseInt(list.get(i).getAnswer());
|
||
if (dAnswer == num) {
|
||
answer = AZ(j);
|
||
}
|
||
}
|
||
}
|
||
list.get(i).setTrueAnswer(trueAnswer);
|
||
list.get(i).setAnswer(answer);
|
||
} else if (classs == 3) {
|
||
String trueAnswer = "";
|
||
String answer = "";
|
||
String[] op = list.get(i).getQuestionOperation().split(";");
|
||
for (int j = 0; j < op.length; j++) {
|
||
int num = Integer.parseInt(op[j].charAt(0) + "");
|
||
int tAnswer = (int) list.get(i).getTrueAnswer().charAt(0) - (int) 'A' + 1;
|
||
if (tAnswer == num) {
|
||
trueAnswer = AZ(j);
|
||
}
|
||
if (list.get(i).getAnswer() != null && list.get(i).getAnswer() != "") {
|
||
int dAnswer = Integer.parseInt(list.get(i).getAnswer());
|
||
if (dAnswer == num) {
|
||
answer = AZ(j);
|
||
}
|
||
}
|
||
}
|
||
list.get(i).setTrueAnswer(trueAnswer);
|
||
list.get(i).setAnswer(answer);
|
||
}
|
||
// 处理乱序后的选项
|
||
String operation = "";
|
||
String op = list.get(i).getQuestionOperation();
|
||
String[] ops = op.split(";");
|
||
for (int j = 0; j < ops.length; j++) {
|
||
String temp = ops[j].substring(1, ops[j].length());
|
||
operation += AZ(j) + temp + "; ";
|
||
}
|
||
list.get(i).setOperation(operation);
|
||
}
|
||
}
|
||
return list;
|
||
}
|
||
|
||
public List<ExamQuestionBean> standardListsPlus(List<ExamQuestionBean> list, int classs) {
|
||
if (list != null && list.size() != 0) {
|
||
for (int i = 0; i < list.size(); i++) {
|
||
if (classs == 2) { // 处理多选题
|
||
String trueAnswer = "";
|
||
String[] tAnswer = list.get(i).getTrueAnswer().split(",");
|
||
HashSet<Integer> set1 = new HashSet<>();
|
||
for (int j = 0; j < tAnswer.length; j++) {
|
||
int num = (int) tAnswer[j].charAt(0) - (int) 'A' + 1; // 将A
|
||
// B
|
||
// C
|
||
// D..转化为1
|
||
// 2
|
||
// 3
|
||
// 4..
|
||
set1.add(num);
|
||
}
|
||
String[] op = list.get(i).getQuestionOption().split(";");
|
||
for (int j = 0; j < op.length; j++) {
|
||
int num = Integer.parseInt(op[j].charAt(0) + "");
|
||
if (set1.contains(num)) {
|
||
trueAnswer += AZ(j);
|
||
}
|
||
}
|
||
list.get(i).setTrueAnswer(trueAnswer);
|
||
|
||
if (list.get(i).getAnswer() != null && list.get(i).getAnswer() != "") {
|
||
String answer = "";
|
||
String[] dAnswer = list.get(i).getAnswer().split(",");
|
||
HashSet<Integer> set2 = new HashSet<>();
|
||
for (int j = 0; j < dAnswer.length; j++) {
|
||
set2.add(Integer.parseInt(dAnswer[j]));
|
||
}
|
||
String[] ops = list.get(i).getQuestionOption().split(";");
|
||
for (int j = 0; j < ops.length; j++) {
|
||
int num = Integer.parseInt(op[j].charAt(0) + "");
|
||
if (set2.contains(num)) {
|
||
answer += AZ(j);
|
||
}
|
||
}
|
||
list.get(i).setAnswer(answer);
|
||
}
|
||
} else if (classs == 1) { // 处理单选题
|
||
String trueAnswer = "";
|
||
String answer = "";
|
||
String[] op = list.get(i).getQuestionOption().split(";");
|
||
for (int j = 0; j < op.length; j++) {
|
||
try {
|
||
int num = Integer.parseInt(op[j].charAt(0) + "");
|
||
int tAnswer = (int) list.get(i).getTrueAnswer().charAt(0) - (int) 'A' + 1;
|
||
if (tAnswer == num) {
|
||
trueAnswer = AZ(j);
|
||
}
|
||
if (list.get(i).getAnswer() != null && list.get(i).getAnswer() != "") {
|
||
int dAnswer = Integer.parseInt(list.get(i).getAnswer());
|
||
if (dAnswer == num) {
|
||
answer = AZ(j);
|
||
}
|
||
}
|
||
} catch (NumberFormatException e) {
|
||
System.err.println("getQuestionOption:"+list.get(i).getQuestionOption());
|
||
}
|
||
}
|
||
list.get(i).setTrueAnswer(trueAnswer);
|
||
list.get(i).setAnswer(answer);
|
||
} else if (classs == 3) {
|
||
String trueAnswer = "";
|
||
String answer = "";
|
||
String[] op = list.get(i).getQuestionOption().split(";");
|
||
for (int j = 0; j < op.length; j++) {
|
||
int num = Integer.parseInt(op[j].charAt(0) + "");
|
||
int tAnswer = (int) list.get(i).getTrueAnswer().charAt(0) - (int) 'A' + 1;
|
||
if (tAnswer == num) {
|
||
trueAnswer = AZ(j);
|
||
}
|
||
if (list.get(i).getAnswer() != null && list.get(i).getAnswer() != "") {
|
||
int dAnswer = Integer.parseInt(list.get(i).getAnswer());
|
||
if (dAnswer == num) {
|
||
answer = AZ(j);
|
||
}
|
||
}
|
||
}
|
||
list.get(i).setTrueAnswer(trueAnswer);
|
||
list.get(i).setAnswer(answer);
|
||
}
|
||
// 处理乱序后的选项
|
||
String operation = "";
|
||
String op = list.get(i).getQuestionOption();
|
||
String[] ops = op.split(";");
|
||
for (int j = 0; j < ops.length; j++) {
|
||
String temp = ops[j].substring(1, ops[j].length());
|
||
operation += AZ(j) + temp + "; ";
|
||
}
|
||
list.get(i).setOperation(operation);
|
||
}
|
||
}
|
||
return list;
|
||
}
|
||
|
||
public List<QuestionBean> standardList(List<QuestionBean> list, int classs) { // 规范单选、多选、判断题的选项及所做答案
|
||
if (list != null && list.size() != 0) {
|
||
for (int i = 0; i < list.size(); i++) {
|
||
String operation = list.get(i).getOperation();
|
||
String op = "";
|
||
String[] operations = operation.split(";");
|
||
for (int j = 0; j < operations.length; j++) {
|
||
String temp = AZ(j) + operations[j].substring(1, operations[j].length());
|
||
op += temp + "; ";
|
||
}
|
||
op = op.substring(0, op.length() - 1);
|
||
list.get(i).setOperation(op);
|
||
// 所做答案
|
||
if (classs == 2) {
|
||
String answer = list.get(i).getAnswer();
|
||
String answ = "";
|
||
if (answer != null && !answer.equals("null")) {
|
||
String[] ans = answer.substring(0, answer.length() - 1).split(",");
|
||
ArrayList<Integer> count = new ArrayList<>();
|
||
for (int j = 0; j < ans.length; j++) {
|
||
count.add(Integer.parseInt(ans[j]));
|
||
}
|
||
Collections.sort(count);
|
||
for (int j = 0; j < count.size(); j++) {
|
||
answ += AZ(count.get(j) - 1);
|
||
}
|
||
list.get(i).setAnswer(answ);
|
||
}
|
||
} else {
|
||
String answer = list.get(i).getAnswer();
|
||
if (answer != null && !answer.equals("null")) {
|
||
String ans = AZ(Integer.parseInt(answer) - 1);
|
||
list.get(i).setAnswer(ans);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return list;
|
||
}
|
||
|
||
public String AZ(int num) { // 数字1 2 3 4..转化为A B C D..
|
||
char sl = (char) (num + (int) 'A');
|
||
String tcMsg = "" + sl;
|
||
return tcMsg;
|
||
}
|
||
|
||
@RequestMapping("temporaryUpdate")
|
||
@ResponseBody
|
||
public AjaxRes temporaryUpdate(@RequestBody ScoreBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
UserBean user = UserShiroHelper.getRealCurrentUser();
|
||
o.setUser(user);
|
||
o.setUserId(user.getLoginName());
|
||
System.out.println(o.getSingleAnswer());
|
||
System.out.println(o.getMultiAnswer());
|
||
if (o.getTypeNum() == 1) {
|
||
String singleContent = o.getSingleAnswer();
|
||
String[] singArr = singleContent.split(";");
|
||
|
||
for (String singlec : singArr) {
|
||
if (!singlec.equals("null")) {
|
||
String[] singArrs = singlec.split("-");
|
||
o.setQuestionId(singArrs[0]);
|
||
o.setAnswer(singArrs[1]);
|
||
o.setTrueGrade(Float.parseFloat(singArrs[2]));
|
||
QuestionBean bean = new QuestionBean();
|
||
bean.setUser(user);
|
||
bean.setExamId(o.getExamId());
|
||
bean.setQuestionId(singArrs[0]);
|
||
int eqid = questionService.findIdbyequ(bean); // 通过三个条件查询主键id
|
||
o.setEqId(eqid);
|
||
gradeService.saveQuestionContent(o);
|
||
}
|
||
}
|
||
} else if (o.getTypeNum() == 2) {
|
||
String mulContent = o.getMultiAnswer();
|
||
String[] mulArr = mulContent.split(";");
|
||
for (String mullec : mulArr) {
|
||
if (!mullec.equals("null")) {
|
||
String[] mulArrs = mullec.split("=");
|
||
o.setQuestionId(mulArrs[0]);
|
||
o.setAnswer(mulArrs[1]);
|
||
o.setTrueGrade(Float.parseFloat(mulArrs[2]));
|
||
QuestionBean bean = new QuestionBean();
|
||
bean.setUser(user);
|
||
bean.setExamId(o.getExamId());
|
||
bean.setQuestionId(mulArrs[0]);
|
||
int eqid = questionService.findIdbyequ(bean); // 通过三个条件查询主键id
|
||
o.setEqId(eqid);
|
||
gradeService.saveQuestionContent(o);
|
||
}
|
||
}
|
||
} else if (o.getTypeNum() == 3) {
|
||
String mulContent = o.getJudgeAnswer();
|
||
String[] mulArr = mulContent.split(";");
|
||
for (String mullec : mulArr) {
|
||
if (!mullec.equals("null")) {
|
||
String[] mulArrs = mullec.split("-");
|
||
o.setQuestionId(mulArrs[0]);
|
||
o.setAnswer(mulArrs[1]);
|
||
o.setTrueGrade(Float.parseFloat(mulArrs[2]));
|
||
QuestionBean bean = new QuestionBean();
|
||
bean.setUser(user);
|
||
bean.setExamId(o.getExamId());
|
||
bean.setQuestionId(mulArrs[0]);
|
||
int eqid = questionService.findIdbyequ(bean); // 通过三个条件查询主键id
|
||
o.setEqId(eqid);
|
||
gradeService.saveQuestionContent(o);
|
||
}
|
||
}
|
||
} else if (o.getTypeNum() == 4) {
|
||
String mulContent = o.getFillAnswer();
|
||
System.out.println(mulContent);
|
||
String[] mulArr = mulContent.split("]");
|
||
for (String mullec : mulArr) {
|
||
if (!mullec.equals("null") || mullec != null) {
|
||
String[] mulArrs = mullec.split("-");
|
||
o.setQuestionId(mulArrs[0]);
|
||
o.setAnswer(mulArrs[1]);
|
||
o.setTrueGrade(Float.parseFloat(mulArrs[2]));
|
||
QuestionBean bean = new QuestionBean();
|
||
bean.setUser(user);
|
||
bean.setExamId(o.getExamId());
|
||
bean.setQuestionId(mulArrs[0]);
|
||
int eqid = questionService.findIdbyequ(bean); // 通过三个条件查询主键id
|
||
o.setEqId(eqid);
|
||
gradeService.saveQuestionContent(o);
|
||
}
|
||
}
|
||
} else if (o.getTypeNum() == 5) {
|
||
String mulContent = o.getSoluAnswer();
|
||
String[] mulArr = mulContent.split("]");
|
||
for (String mullec : mulArr) {
|
||
if (!mullec.equals("null")) {
|
||
String[] mulArrs = mullec.split("-");
|
||
o.setQuestionId(mulArrs[0]);
|
||
o.setAnswer(mulArrs[1]);
|
||
o.setTrueGrade(Float.parseFloat(mulArrs[2]));
|
||
QuestionBean bean = new QuestionBean();
|
||
bean.setUser(user);
|
||
bean.setExamId(o.getExamId());
|
||
bean.setQuestionId(mulArrs[0]);
|
||
int eqid = questionService.findIdbyequ(bean); // 通过三个条件查询主键id
|
||
o.setEqId(eqid);
|
||
gradeService.saveQuestionContent(o);
|
||
}
|
||
}
|
||
} else if (o.getTypeNum() == 6) {
|
||
String mulContent = o.getCaseAnswer();
|
||
String[] mulArr = mulContent.split("]");
|
||
for (String mullec : mulArr) {
|
||
if (!mullec.equals("null")) {
|
||
String[] mulArrs = mullec.split("-");
|
||
o.setQuestionId(mulArrs[0]);
|
||
o.setAnswer(mulArrs[1]);
|
||
o.setTrueGrade(Float.parseFloat(mulArrs[2]));
|
||
QuestionBean bean = new QuestionBean();
|
||
bean.setUser(user);
|
||
bean.setExamId(o.getExamId());
|
||
bean.setQuestionId(mulArrs[0]);
|
||
int eqid = questionService.findIdbyequ(bean); // 通过三个条件查询主键id
|
||
o.setEqId(eqid);
|
||
gradeService.saveQuestionContent(o);
|
||
}
|
||
}
|
||
// 执行提交操作,从报名表逻辑删除此人
|
||
service.updateRegistration(o);
|
||
seatService.updateIsActive(o);
|
||
} else if (o.getTypeNum() == 7) { // 针对案例题没有题的此种专业
|
||
// 执行提交操作,从报名表逻辑删除此人
|
||
service.updateRegistration(o);
|
||
seatService.updateIsActive(o);
|
||
}
|
||
|
||
String greenScore = user.getGreenScore();
|
||
o.setUserId(user.getLoginName() + "");
|
||
service.update(o);
|
||
/*
|
||
* if(o.getType() != null && o.getType().equals("case")) { //提交
|
||
* String totalGrade = service.countTotalGrade(o);
|
||
* o.setGrade(Integer.parseInt(totalGrade)); service.update(o); }
|
||
*/
|
||
ScoreBean bean = service.findAllGrade(o);
|
||
double singleGrade = (bean.getSingleGrade() == null || bean.getSingleGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getSingleGrade());
|
||
double multiGrade = (bean.getMultiGrade() == null || bean.getMultiGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getMultiGrade());
|
||
double judgeGrade = (bean.getJudgeGrade() == null || bean.getJudgeGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getJudgeGrade());
|
||
double fillGrade = (bean.getFillGrade() == null || bean.getFillGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getFillGrade());
|
||
double soluGrade = (bean.getSoluGrade() == null || bean.getSoluGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getSoluGrade());
|
||
double caseGrade = (bean.getCaseGrade() == null || bean.getCaseGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getCaseGrade());
|
||
double totalGrade = singleGrade + multiGrade + judgeGrade + fillGrade + soluGrade + caseGrade;
|
||
// 如果是绿色通道人员
|
||
if (greenScore != null && isNumeric(greenScore)) {
|
||
double totalScore = Double.parseDouble(greenScore);
|
||
totalGrade = totalScore;
|
||
}
|
||
o.setGrade(String.valueOf(totalGrade));
|
||
service.update(o);
|
||
// 提交操作
|
||
/*
|
||
* if(o.getCaseTrue() != null) { service.updateRegistration(o); }
|
||
*/
|
||
ar.setSucceedMsg("更新成功");
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
ar.setFailMsg("更新失败");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping("temporarySelfUpdate")
|
||
@ResponseBody
|
||
public AjaxRes temporarySelfUpdate(@RequestBody ScoreBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
UserBean user = UserShiroHelper.getRealCurrentUser();
|
||
o.setUser(user);
|
||
o.setUserId(user.getLoginName());
|
||
String typeId = o.getTypeId();
|
||
System.out.println(o.getSingleAnswer());
|
||
System.out.println(o.getMultiAnswer());
|
||
if (o.getTypeNum() != null) {
|
||
if (o.getTypeNum() == 1) {
|
||
String singleContent = o.getSingleAnswer();
|
||
String[] singArr = singleContent.split(";");
|
||
for (String singlec : singArr) {
|
||
if (!singlec.equals("null")) {
|
||
String[] singArrs = singlec.split("-");
|
||
o.setQuestionId(singArrs[0]);
|
||
o.setAnswer(singArrs[1]);
|
||
float score = Float.parseFloat(singArrs[2]);
|
||
if ("2".equals(typeId)) {
|
||
score = score * 2;
|
||
}
|
||
o.setTrueGrade(score);
|
||
gradeService.saveQuestionSelfContent(o);
|
||
}
|
||
}
|
||
} else if (o.getTypeNum() == 2) {
|
||
String mulContent = o.getMultiAnswer();
|
||
String[] mulArr = mulContent.split(";");
|
||
for (String mullec : mulArr) {
|
||
if (!mullec.equals("null")) {
|
||
String[] mulArrs = mullec.split("=");
|
||
o.setQuestionId(mulArrs[0]);
|
||
o.setAnswer(mulArrs[1]);
|
||
o.setTrueGrade(Float.parseFloat(mulArrs[2]));
|
||
gradeService.saveQuestionSelfContent(o);
|
||
}
|
||
}
|
||
} else if (o.getTypeNum() == 3) {
|
||
String mulContent = o.getJudgeAnswer();
|
||
String[] mulArr = mulContent.split(";");
|
||
for (String mullec : mulArr) {
|
||
if (!mullec.equals("null")) {
|
||
String[] mulArrs = mullec.split("-");
|
||
o.setQuestionId(mulArrs[0]);
|
||
o.setAnswer(mulArrs[1]);
|
||
float score = Float.parseFloat(mulArrs[2]);
|
||
if ("2".equals(typeId)) {
|
||
score = score * 2;
|
||
}
|
||
o.setTrueGrade(score);
|
||
gradeService.saveQuestionSelfContent(o);
|
||
}
|
||
}
|
||
} else if (o.getTypeNum() == 4) {
|
||
String mulContent = o.getFillAnswer();
|
||
System.out.println(mulContent);
|
||
String[] mulArr = mulContent.split("]");
|
||
for (String mullec : mulArr) {
|
||
if (!mullec.equals("null") || mullec != null) {
|
||
String[] mulArrs = mullec.split("-");
|
||
o.setQuestionId(mulArrs[0]);
|
||
o.setAnswer(mulArrs[1]);
|
||
o.setTrueGrade(Float.parseFloat(mulArrs[2]));
|
||
gradeService.saveQuestionSelfContent(o);
|
||
}
|
||
}
|
||
} else if (o.getTypeNum() == 5) {
|
||
String mulContent = o.getSoluAnswer();
|
||
String[] mulArr = mulContent.split("]");
|
||
for (String mullec : mulArr) {
|
||
if (!mullec.equals("null")) {
|
||
String[] mulArrs = mullec.split("-");
|
||
o.setQuestionId(mulArrs[0]);
|
||
o.setAnswer(mulArrs[1]);
|
||
o.setTrueGrade(Float.parseFloat(mulArrs[2]));
|
||
gradeService.saveQuestionSelfContent(o);
|
||
}
|
||
}
|
||
} else if (o.getTypeNum() == 6) {
|
||
String mulContent = o.getCaseAnswer();
|
||
String[] mulArr = mulContent.split("]");
|
||
for (String mullec : mulArr) {
|
||
if (!mullec.equals("null")) {
|
||
String[] mulArrs = mullec.split("-");
|
||
o.setQuestionId(mulArrs[0]);
|
||
o.setAnswer(mulArrs[1]);
|
||
o.setTrueGrade(Float.parseFloat(mulArrs[2]));
|
||
gradeService.saveQuestionSelfContent(o);
|
||
}
|
||
}
|
||
|
||
} else if (o.getTypeNum() == 7) { // 针对案例题没有题的此种专业
|
||
System.out.println("针对案例题没有题的此种专业");
|
||
} else {
|
||
System.err.println("修改答题错误!!");
|
||
}
|
||
}
|
||
|
||
// String greenScore = user.getGreenScore();
|
||
o.setUserId(user.getLoginName() + "");
|
||
service.updateSelfRecord(o);
|
||
|
||
ScoreBean bean = service.findAllSelfGrade(o);
|
||
double singleGrade = (bean.getSingleGrade() == null || bean.getSingleGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getSingleGrade());
|
||
double multiGrade = (bean.getMultiGrade() == null || bean.getMultiGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getMultiGrade());
|
||
double judgeGrade = (bean.getJudgeGrade() == null || bean.getJudgeGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getJudgeGrade());
|
||
double fillGrade = (bean.getFillGrade() == null || bean.getFillGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getFillGrade());
|
||
double soluGrade = (bean.getSoluGrade() == null || bean.getSoluGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getSoluGrade());
|
||
double caseGrade = (bean.getCaseGrade() == null || bean.getCaseGrade() == "") ? 0
|
||
: Double.parseDouble(bean.getCaseGrade());
|
||
double totalGrade = singleGrade + multiGrade + judgeGrade + fillGrade + soluGrade + caseGrade;
|
||
// 如果是绿色通道人员
|
||
/*
|
||
* if(greenScore != null && isNumeric(greenScore)) { double
|
||
* totalScore = Double.parseDouble(greenScore); totalGrade =
|
||
* totalScore; }
|
||
*/
|
||
o.setGrade(String.valueOf(totalGrade));
|
||
service.updateSelfRecord(o);
|
||
// 提交操作
|
||
/*
|
||
* if(o.getCaseTrue() != null) { service.updateRegistration(o); }
|
||
*/
|
||
ar.setSucceedMsg("更新成功");
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
ar.setFailMsg("更新失败");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
public static boolean isNumeric(String str) { // 判断字符串为数字(包括小数)
|
||
Pattern pattern = Pattern.compile("[0-9]*\\.?[0-9]+");
|
||
Matcher isNum = pattern.matcher(str);
|
||
if (!isNum.matches()) {
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
@RequestMapping("delScore")
|
||
@ResponseBody
|
||
public AjaxRes delScore(ScoreBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
service.delete(o);
|
||
ar.setSucceedMsg("删除成功");
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
ar.setFailMsg("操作失败!");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping("editFormPage")
|
||
public String addFormPage(HttpServletRequest request, String id) {
|
||
if (id != null) {
|
||
ScoreBean bean = service.getinfoByid(id);
|
||
request.setAttribute("bean", bean);
|
||
}
|
||
return "/score/editFromPage";
|
||
}
|
||
|
||
@RequestMapping(value = "updateGrade", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes updateGrade(ScoreBean o) {
|
||
Integer grade = 0;
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
grade = service.updateGrade(o);
|
||
ar.setSucceedMsg(GlobalConst.UPDATE_SUCCEED);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.UPDATE_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "find", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes find(Page<ScoreBean> page, ScoreBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
List<ScoreBean> result = service.find(o);
|
||
ScoreBean bean = result.get(0);
|
||
ar.setSucceed(bean);
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg(GlobalConst.DATA_FAIL);
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
@RequestMapping(value = "update", method = RequestMethod.POST)
|
||
@ResponseBody
|
||
public AjaxRes update(ScoreBean o) {
|
||
AjaxRes ar = getAjaxRes();
|
||
try {
|
||
int res = service.updateGrade(o);
|
||
if (res == 1) {
|
||
ar.setSucceedMsg("修改成功");
|
||
} else {
|
||
ar.setFailMsg("成绩修改失败");
|
||
}
|
||
} catch (Exception e) {
|
||
logger.error(e.toString(), e);
|
||
ar.setFailMsg("成绩修改失败");
|
||
}
|
||
return ar;
|
||
}
|
||
|
||
private List<String> outVehicleOilHeaders() {
|
||
ArrayList<String> list = new ArrayList<String>();
|
||
list.add("序号");
|
||
list.add("身份证");
|
||
list.add("姓名");
|
||
list.add("场次");
|
||
list.add("分数");
|
||
list.add("专业");
|
||
return list;
|
||
}
|
||
|
||
private Map<String, Object> outVehicleOilBeanMap(int i, RegistrationBean bean) {
|
||
Map<String, Object> maps = new LinkedHashMap<String, Object>();
|
||
maps.put("id", i + 1);
|
||
maps.put("idcard", bean.getIdcard());
|
||
maps.put("name", bean.getName());
|
||
maps.put("times", bean.getTimes());
|
||
maps.put("grade", bean.getGrade());
|
||
maps.put("specialty", bean.getSpecialtyName());
|
||
return maps;
|
||
}
|
||
|
||
private void excelOut(HttpServletResponse response, List<RegistrationBean> registlist, String filename)
|
||
throws Exception {
|
||
if (registlist != null) {
|
||
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
|
||
int size = registlist.size();
|
||
for (int i = 0; i < size; i++) {
|
||
RegistrationBean bean = registlist.get(i);
|
||
Map<String, Object> maps = outVehicleOilBeanMap(i, bean);
|
||
results.add(maps);
|
||
}
|
||
List<String> headers = outVehicleOilHeaders();
|
||
HSSFWorkbook workbook = POIOutputHelperNumBer.excel(results, headers, filename);
|
||
OutputStream out = null;
|
||
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||
response.addHeader("Content-Disposition",
|
||
"attachment;filename=" + URLEncoder.encode(filename, "UTF-8") + ".xls");
|
||
response.setHeader("Pragma", "No-cache");
|
||
out = response.getOutputStream();
|
||
workbook.write(out);
|
||
out.flush();
|
||
out.close();
|
||
}
|
||
}
|
||
|
||
}
|