|
@@ -14,14 +14,18 @@ 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;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
import cn.com.qmth.stmms.admin.dto.SubjectiveQuestionDTO;
|
|
|
import cn.com.qmth.stmms.admin.thread.DataSyncThread;
|
|
|
import cn.com.qmth.stmms.admin.utils.HttpUtil;
|
|
|
+import cn.com.qmth.stmms.admin.utils.SessionExamUtils;
|
|
|
+import cn.com.qmth.stmms.admin.utils.UpyunConfig;
|
|
|
import cn.com.qmth.stmms.biz.exam.model.DataSync;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.DataSyncService;
|
|
|
import cn.com.qmth.stmms.biz.exam.service.ExamQuestionService;
|
|
@@ -87,39 +91,53 @@ public class DataSyncController extends BaseExamController {
|
|
|
@Value("${file.root}")
|
|
|
private String baseDir;
|
|
|
|
|
|
- @RequestMapping
|
|
|
- public ModelAndView index(HttpServletRequest request) {
|
|
|
- int examId = getSessionExamId(request);
|
|
|
+ @Autowired
|
|
|
+ private UpyunConfig config;
|
|
|
+
|
|
|
+ @RequestMapping()
|
|
|
+ public ModelAndView index(HttpServletRequest request, @RequestParam Integer examId) {
|
|
|
+ if (examId != null) {
|
|
|
+ SessionExamUtils.setExamId(request, examId);
|
|
|
+ }
|
|
|
+ examId = getSessionExamId(request);
|
|
|
+
|
|
|
+ DataSync dataSync = dataSyncService.findByExamId(examId);
|
|
|
+ if (dataSync == null) {
|
|
|
+ dataSync = new DataSync();
|
|
|
+ dataSync.setExamId(examId);
|
|
|
+ dataSync.setRootOrgId(rootOrgId);
|
|
|
+ dataSync.setStudentUrl("http://" + host + ":" + port + studentUri);
|
|
|
+ dataSync.setSubjectUrl("http://" + host + ":" + port + subjectUri);
|
|
|
+ dataSync.setAppId(appId);
|
|
|
+ dataSync.setSecretKey(secretKey);
|
|
|
+ }
|
|
|
ModelAndView view = new ModelAndView("modules/exam/dataSync");
|
|
|
view.addObject("running", lockService.isLocked(LockType.DATA_SYNC, examId));
|
|
|
- view.addObject("host", host);
|
|
|
- view.addObject("port", port);
|
|
|
- view.addObject("rootOrgId", rootOrgId);
|
|
|
- view.addObject("subjectUri", subjectUri);
|
|
|
- view.addObject("studentUri", studentUri);
|
|
|
+ view.addObject("exam", examService.findById(examId));
|
|
|
+ view.addObject("dataSync", dataSync);
|
|
|
return view;
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/start", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
|
- public ModelAndView sync1(HttpServletRequest request, DataSync dataSync) {
|
|
|
+ public String save(HttpServletRequest request, DataSync dataSync) {
|
|
|
int examId = getSessionExamId(request);
|
|
|
if (lockService.trylock(LockType.DATA_SYNC, examId)) {
|
|
|
- DataSyncThread thread = new DataSyncThread(dataSync, secretKey, appId, pageSize, baseDir, lockService,
|
|
|
+ DataSyncThread thread = new DataSyncThread(dataSync, pageSize, baseDir, config, lockService,
|
|
|
dataSyncService, examService, studentService);
|
|
|
taskExecutor.submit(thread);
|
|
|
}
|
|
|
- return new ModelAndView("redirect:/admin/exam/dataSync");
|
|
|
+ return "redirect:/admin/exam-list";
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/export", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/{cloudExamId}/export", method = RequestMethod.GET)
|
|
|
@RoleRequire(Role.SCHOOL_ADMIN)
|
|
|
- public ModelAndView exportFile(String url, HttpServletRequest request, HttpServletResponse response,
|
|
|
- RedirectAttributes redirectAttributes) {
|
|
|
+ public ModelAndView exportFile(@PathVariable Long cloudExamId, HttpServletRequest request,
|
|
|
+ HttpServletResponse response, RedirectAttributes redirectAttributes) {
|
|
|
int examId = getSessionExamId(request);
|
|
|
DataSync sync = dataSyncService.findByExamId(examId);
|
|
|
- List<SubjectiveQuestionDTO> list = getPaperStruct(url, sync.getCloudExamId());
|
|
|
try {
|
|
|
+ List<SubjectiveQuestionDTO> list = getPaperStruct(sync.getSubjectUrl(), cloudExamId);
|
|
|
new ExportExcel("主观题数据", SubjectiveQuestionDTO.class, 2).setDataList(list).write(response, "主观题数据.xlsx")
|
|
|
.dispose();
|
|
|
return null;
|