|
@@ -9,12 +9,13 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import net.sf.json.JSONArray;
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.core.task.AsyncTaskExecutor;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -42,6 +43,8 @@ import cn.com.qmth.stmms.common.utils.ExportExcel;
|
|
|
@RequestMapping("/admin/exam/data/sync")
|
|
|
public class DataSyncController extends BaseExamController {
|
|
|
|
|
|
+ protected static Logger log = LoggerFactory.getLogger(DataSyncController.class);
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamSubjectService subjectService;
|
|
|
|
|
@@ -124,7 +127,7 @@ public class DataSyncController extends BaseExamController {
|
|
|
int examId = getSessionExamId(request);
|
|
|
if (lockService.trylock(LockType.DATA_SYNC, examId)) {
|
|
|
DataSyncThread thread = new DataSyncThread(dataSync, pageSize, baseDir, config, lockService,
|
|
|
- dataSyncService, examService, studentService);
|
|
|
+ dataSyncService, examService, studentService, subjectService);
|
|
|
taskExecutor.submit(thread);
|
|
|
}
|
|
|
DataSync sync = dataSyncService.findByExamId(examId);
|
|
@@ -136,21 +139,22 @@ public class DataSyncController extends BaseExamController {
|
|
|
return "redirect:/admin/exam-list";
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/{cloudExamId}/export", method = RequestMethod.GET)
|
|
|
+ @RequestMapping(value = "/export", method = RequestMethod.GET)
|
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
|
- public ModelAndView exportFile(@PathVariable Long cloudExamId, HttpServletRequest request,
|
|
|
- HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
|
|
+ public ModelAndView exportFile(HttpServletRequest request, HttpServletResponse response,
|
|
|
+ RedirectAttributes redirectAttributes) {
|
|
|
int examId = getSessionExamId(request);
|
|
|
DataSync sync = dataSyncService.findByExamId(examId);
|
|
|
try {
|
|
|
- List<SubjectiveQuestionDTO> list = getPaperStruct(sync.getSubjectUrl(), cloudExamId);
|
|
|
+ List<SubjectiveQuestionDTO> list = getPaperStruct(sync.getSubjectUrl(), sync.getCloudExamId());
|
|
|
new ExportExcel("主观题数据", SubjectiveQuestionDTO.class, 2).setDataList(list).write(response, "主观题数据.xlsx")
|
|
|
.dispose();
|
|
|
return null;
|
|
|
} catch (Exception e) {
|
|
|
+ log.error("export sync subject:", e);
|
|
|
addMessage(redirectAttributes, "导出数据失败!失败信息:" + e.getMessage());
|
|
|
}
|
|
|
- return new ModelAndView("redirect:/admin/exam");
|
|
|
+ return new ModelAndView("redirect:/admin/exam/sync?examId=" + examId);
|
|
|
}
|
|
|
|
|
|
private List<SubjectiveQuestionDTO> getPaperStruct(String url, Long cloudExamId) {
|
|
@@ -166,7 +170,7 @@ public class DataSyncController extends BaseExamController {
|
|
|
JSONObject subject = subjectArray.getJSONObject(i);
|
|
|
JSONArray questionArray = subject.getJSONArray("questions");
|
|
|
for (int j = 0; j < questionArray.size(); j++) {
|
|
|
- JSONObject question = questionArray.getJSONObject(i);
|
|
|
+ JSONObject question = questionArray.getJSONObject(j);
|
|
|
SubjectiveQuestionDTO questionDTO = new SubjectiveQuestionDTO();
|
|
|
questionDTO.setSubjectCode(subject.getString("subjectCode"));
|
|
|
questionDTO.setSubjectName(subject.getString("subjectName"));
|