|
@@ -1,8 +1,5 @@
|
|
package cn.com.qmth.examcloud.core.examwork.api.controller;
|
|
package cn.com.qmth.examcloud.core.examwork.api.controller;
|
|
|
|
|
|
-import java.io.File;
|
|
|
|
-import java.io.FileInputStream;
|
|
|
|
-import java.io.FileNotFoundException;
|
|
|
|
import java.math.BigInteger;
|
|
import java.math.BigInteger;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -15,6 +12,7 @@ import javax.persistence.criteria.Predicate;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
+import org.apache.commons.fileupload.disk.DiskFileItem;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -46,20 +44,19 @@ import cn.com.qmth.examcloud.common.dto.examwork.CommonExamStudent;
|
|
import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
|
|
import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
|
|
import cn.com.qmth.examcloud.commons.web.helpers.page.PageInfo;
|
|
import cn.com.qmth.examcloud.commons.web.helpers.page.PageInfo;
|
|
-import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.InsertOrUpdateStudentReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.InsertOrUpdateStudentReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.InsertOrUpdateStudentResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.InsertOrUpdateStudentResp;
|
|
import cn.com.qmth.examcloud.core.examwork.api.controller.bean.ExamStudentDomain;
|
|
import cn.com.qmth.examcloud.core.examwork.api.controller.bean.ExamStudentDomain;
|
|
import cn.com.qmth.examcloud.core.examwork.base.util.ExportUtils;
|
|
import cn.com.qmth.examcloud.core.examwork.base.util.ExportUtils;
|
|
-import cn.com.qmth.examcloud.core.examwork.base.util.ImportUtils;
|
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamStudentAssembler;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamStudentAssembler;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamStudentDTO;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamStudentDTO;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.bean.OrgExamInfoDTO;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.bean.OrgExamInfoDTO;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
|
|
|
|
+import cn.com.qmth.examcloud.core.examwork.service.ExamStudentImportService;
|
|
import cn.com.qmth.examcloud.core.examwork.service.impl.ExamStudentService;
|
|
import cn.com.qmth.examcloud.core.examwork.service.impl.ExamStudentService;
|
|
import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
|
|
import cn.com.qmth.examcloud.examwork.api.ExamStudentCloudService;
|
|
import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean;
|
|
import cn.com.qmth.examcloud.examwork.api.bean.ExamStudentBean;
|
|
@@ -95,6 +92,9 @@ public class ExamStudentController extends ControllerSupport {
|
|
@Autowired
|
|
@Autowired
|
|
ExamStudentCloudService examStudentCloudService;
|
|
ExamStudentCloudService examStudentCloudService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ ExamStudentImportService examStudentImportService;
|
|
|
|
+
|
|
@GetMapping("/query")
|
|
@GetMapping("/query")
|
|
public List<ExamStudent> find(
|
|
public List<ExamStudent> find(
|
|
@RequestParam(value = "student_id", required = false) Long studentId) {
|
|
@RequestParam(value = "student_id", required = false) Long studentId) {
|
|
@@ -396,16 +396,24 @@ public class ExamStudentController extends ControllerSupport {
|
|
return examId;
|
|
return examId;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 重构
|
|
|
|
+ *
|
|
|
|
+ * @author WANGWEI
|
|
|
|
+ * @param examId
|
|
|
|
+ * @param file
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
@ApiOperation(value = "导入考试学生", notes = "导入")
|
|
@ApiOperation(value = "导入考试学生", notes = "导入")
|
|
@PostMapping("/import")
|
|
@PostMapping("/import")
|
|
public List<ExcelError> importExamStudent(@RequestParam Long examId,
|
|
public List<ExcelError> importExamStudent(@RequestParam Long examId,
|
|
@RequestParam CommonsMultipartFile file) throws Exception {
|
|
@RequestParam CommonsMultipartFile file) throws Exception {
|
|
- User accessUser = getAccessUser();
|
|
|
|
|
|
|
|
- File tempFile = ImportUtils.getUploadFile(file);
|
|
|
|
- List<ExcelError> excelErrors = examStudentService.importExamStudent(
|
|
|
|
- accessUser.getUserToken(), examId, new FileInputStream(tempFile));
|
|
|
|
- return excelErrors;
|
|
|
|
|
|
+ DiskFileItem item = (DiskFileItem) file.getFileItem();
|
|
|
|
+ examStudentImportService.importExamStudent(item.getStoreLocation(),
|
|
|
|
+ file.getOriginalFilename());
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "下载导入模板", notes = "下载导入模板")
|
|
@ApiOperation(value = "下载导入模板", notes = "下载导入模板")
|
|
@@ -436,6 +444,7 @@ public class ExamStudentController extends ControllerSupport {
|
|
list.add(examStudentAssembler.toDTO(c));
|
|
list.add(examStudentAssembler.toDTO(c));
|
|
});
|
|
});
|
|
ExportUtils.exportEXCEL("课程列表", ExamStudentDTO.class, list, response);
|
|
ExportUtils.exportEXCEL("课程列表", ExamStudentDTO.class, list, response);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "复制考试学生", notes = "复制")
|
|
@ApiOperation(value = "复制考试学生", notes = "复制")
|