|
@@ -1,15 +1,25 @@
|
|
|
package cn.com.qmth.stmms.api.controller.admin;
|
|
|
|
|
|
-import java.io.*;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.HashSet;
|
|
|
+import java.util.LinkedList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
-import cn.com.qmth.stmms.biz.exam.bean.ResultMessage;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@@ -20,6 +30,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.core.task.AsyncTaskExecutor;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -44,23 +55,43 @@ import cn.com.qmth.stmms.api.controller.BaseApiController;
|
|
|
import cn.com.qmth.stmms.biz.common.domain.card.AnswerCardSubjectFile;
|
|
|
import cn.com.qmth.stmms.biz.common.domain.card.AnswerCardSubjectItem;
|
|
|
import cn.com.qmth.stmms.biz.common.domain.card.CardFile;
|
|
|
-import cn.com.qmth.stmms.biz.exam.model.*;
|
|
|
-import cn.com.qmth.stmms.biz.exam.service.*;
|
|
|
+import cn.com.qmth.stmms.biz.exam.bean.ExamVo;
|
|
|
+import cn.com.qmth.stmms.biz.exam.bean.ResultMessage;
|
|
|
+import cn.com.qmth.stmms.biz.exam.bean.SubjectSplit;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.AnswerCard;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.Exam;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.ExamQuestion;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.ExamSubject;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.MarkGroup;
|
|
|
+import cn.com.qmth.stmms.biz.exam.model.SelectiveGroup;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.AnswerCardService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamStudentService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.ExamSubjectService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.InspectHistoryService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.MarkGroupService;
|
|
|
+import cn.com.qmth.stmms.biz.exam.service.SelectiveGroupService;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.query.ExamQuestionSearchQuery;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.query.ExamSubjectSearchQuery;
|
|
|
import cn.com.qmth.stmms.biz.file.enums.FormatType;
|
|
|
import cn.com.qmth.stmms.biz.file.service.FileService;
|
|
|
import cn.com.qmth.stmms.biz.lock.LockService;
|
|
|
-import cn.com.qmth.stmms.biz.mark.service.MarkService;
|
|
|
import cn.com.qmth.stmms.biz.report.service.ReportService;
|
|
|
import cn.com.qmth.stmms.biz.utils.PageUtil;
|
|
|
import cn.com.qmth.stmms.common.annotation.Logging;
|
|
|
import cn.com.qmth.stmms.common.domain.ApiUser;
|
|
|
-import cn.com.qmth.stmms.common.enums.*;
|
|
|
+import cn.com.qmth.stmms.common.enums.CardSource;
|
|
|
+import cn.com.qmth.stmms.common.enums.ExamStatus;
|
|
|
+import cn.com.qmth.stmms.common.enums.LockType;
|
|
|
+import cn.com.qmth.stmms.common.enums.LogType;
|
|
|
+import cn.com.qmth.stmms.common.enums.ObjectiveStatus;
|
|
|
+import cn.com.qmth.stmms.common.enums.SubjectiveStatus;
|
|
|
import cn.com.qmth.stmms.common.utils.ExportExcel;
|
|
|
import cn.com.qmth.stmms.common.utils.ImportExcel;
|
|
|
import cn.com.qmth.stmms.common.utils.RequestUtils;
|
|
|
-import net.sf.json.JSONArray;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
|
@Api(tags = "科目管理")
|
|
@@ -70,8 +101,6 @@ public class SubjectController extends BaseApiController {
|
|
|
|
|
|
protected static final Logger log = LoggerFactory.getLogger(SubjectController.class);
|
|
|
|
|
|
- private static final String NULL_PAPER_TYPE_PLACEHOLDER = "#";
|
|
|
-
|
|
|
private static final String[] SUBJECTIVE_EXCEL_HEADER = new String[] { "科目代码*", "科目名称", "大题名称*", "题目昵称",
|
|
|
"大题号(只能用小写数字)*", "小题号(只能用小写数字)*", "小题满分*", "给分次数", "间隔分*", "评卷分组(只能用小写数字)*", "图片序号(用英文逗号分割)",
|
|
|
"仲裁方式(0-分组,1-小题)", "双评比例(0~1)", "仲裁阀值", "合分策略(1-平均,2-最高,3-最低)", "评卷模式(common-普通,track-轨迹)", "试评数量(0-跳过试评)",
|
|
@@ -108,12 +137,6 @@ public class SubjectController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private ReportService reportService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private MarkService markService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private MarkerService markerService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private SelectiveGroupService selectiveGroupService;
|
|
|
|
|
@@ -141,6 +164,7 @@ public class SubjectController extends BaseApiController {
|
|
|
int examId = getSessionExamId(request);
|
|
|
return subjectService.listLevel(examId);
|
|
|
}
|
|
|
+
|
|
|
@ApiOperation(value = "科目专业下拉列表")
|
|
|
@RequestMapping(value = "/category/list", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
@@ -212,7 +236,6 @@ public class SubjectController extends BaseApiController {
|
|
|
@ResponseBody
|
|
|
public List<String> query(HttpServletRequest request, @RequestParam String subjectCode) {
|
|
|
int examId = getSessionExamId(request);
|
|
|
- JSONArray array = new JSONArray();
|
|
|
List<String> list = this.questionService.getPaperType(examId, subjectCode);
|
|
|
return list;
|
|
|
}
|
|
@@ -272,6 +295,7 @@ public class SubjectController extends BaseApiController {
|
|
|
}
|
|
|
return set;
|
|
|
}
|
|
|
+
|
|
|
@ApiOperation(value = "导出客or主观题")
|
|
|
@Logging(menu = "导出客/主观题", type = LogType.EXPORT)
|
|
|
@RequestMapping(value = "/export", method = RequestMethod.POST)
|
|
@@ -436,6 +460,7 @@ public class SubjectController extends BaseApiController {
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
@ApiOperation(value = "导入主观题评卷分组")
|
|
|
@Logging(menu = "导入主观题分组", type = LogType.IMPORT_FILE)
|
|
|
@RequestMapping(value = "/importGroup", method = RequestMethod.POST)
|
|
@@ -521,6 +546,7 @@ public class SubjectController extends BaseApiController {
|
|
|
RequestUtils.setLog(request, success + "个科目导入成功;");
|
|
|
return result(StringUtils.join(error, " "));
|
|
|
}
|
|
|
+
|
|
|
@ApiOperation(value = "科目成绩分析计算")
|
|
|
@Logging(menu = "科目成绩分析计算", type = LogType.UPDATE)
|
|
|
@RequestMapping(value = "/report", method = RequestMethod.POST)
|
|
@@ -583,6 +609,7 @@ public class SubjectController extends BaseApiController {
|
|
|
}
|
|
|
return resultOk();
|
|
|
}
|
|
|
+
|
|
|
@ApiOperation(value = "导入数据包")
|
|
|
@Logging(menu = "导入数据包", type = LogType.IMPORT_FILE)
|
|
|
@RequestMapping(value = "/importData", method = RequestMethod.POST)
|
|
@@ -775,4 +802,73 @@ public class SubjectController extends BaseApiController {
|
|
|
return error;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "拆分科目-考试列表")
|
|
|
+ @RequestMapping(value = "split/exam", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public List<ExamVo> splitExam(@RequestParam Integer schoolId) {
|
|
|
+ List<Exam> examList = examService.findBySchoolId(schoolId);
|
|
|
+ List<ExamVo> ret = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(examList)) {
|
|
|
+ for (Exam e : examList) {
|
|
|
+ if (!ExamStatus.FINISH.equals(e.getStatus())) {
|
|
|
+ ret.add(ExamVo.of(e));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "拆分科目-导入")
|
|
|
+ @RequestMapping(value = "split/save", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public ResultMessage splitSave(MultipartFile file, @RequestParam Integer schoolId, @RequestParam Integer examId) {
|
|
|
+ try {
|
|
|
+ ImportExcel ei = new ImportExcel(file, 1, 0);
|
|
|
+ List<SubjectSplit> list = ei.getDataList(SubjectSplit.class);
|
|
|
+ String errMsg = subjectService.split(schoolId, examId, list);
|
|
|
+ if (!StringUtils.isBlank(errMsg)) {
|
|
|
+ ApiUser wu = getApiUser();
|
|
|
+ File errFile = new File(getSubjectSplitErrFile(wu.getId()));
|
|
|
+ errFile.getParentFile().mkdirs();
|
|
|
+ if (errFile.exists()) {
|
|
|
+ errFile.delete();
|
|
|
+ }
|
|
|
+ FileUtils.write(errFile, errMsg, "utf-8");
|
|
|
+ throw new StatusException("导入信息有误,请查看error.txt文件");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("导入失败", e);
|
|
|
+ throw new StatusException("导入失败:" + e.getMessage(), e);
|
|
|
+ }
|
|
|
+ return resultOk();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "拆分科目-错误信息")
|
|
|
+ @RequestMapping(value = "split/err", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public void splitErr(HttpServletResponse response) {
|
|
|
+ ApiUser wu = getApiUser();
|
|
|
+ File file = new File(getSubjectSplitErrFile(wu.getId()));
|
|
|
+ exportFile("error.txt", file, response);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getSubjectSplitErrFile(Integer userId) {
|
|
|
+ String path = tempFile + File.separator + "subject-split-err" + File.separator + userId + File.separator
|
|
|
+ + "error.txt";
|
|
|
+ return path;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "拆分科目-下载模版")
|
|
|
+ @RequestMapping(value = "split/template", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public void splitTemplate(HttpServletResponse response) {
|
|
|
+ try {
|
|
|
+ List<SubjectSplit> list = new ArrayList<>();
|
|
|
+ list.add(new SubjectSplit());
|
|
|
+ new ExportExcel("科目拆分数据", SubjectSplit.class, 2).setDataList(list).write(response, "科目拆分导入模板.xlsx")
|
|
|
+ .dispose();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new StatusException("导入模板下载失败!失败信息:" + e.getMessage(), e);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|