|
@@ -1,230 +1,230 @@
|
|
|
-package cn.com.qmth.examcloud.task.api.controller;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import javax.persistence.criteria.Predicate;
|
|
|
-import javax.transaction.Transactional;
|
|
|
-
|
|
|
-import org.apache.commons.fileupload.disk.DiskFileItem;
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
-import org.springframework.data.domain.Pageable;
|
|
|
-import org.springframework.data.domain.Sort;
|
|
|
-import org.springframework.data.jpa.domain.Specification;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
-
|
|
|
-import com.google.common.collect.Lists;
|
|
|
-
|
|
|
-import cn.com.qmth.examcloud.commons.base.util.DateUtil;
|
|
|
-import cn.com.qmth.examcloud.commons.base.util.DateUtil.DatePatterns;
|
|
|
-import cn.com.qmth.examcloud.commons.base.util.PathUtil;
|
|
|
-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.core.basic.api.OrgCloudService;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.request.GetExamReq;
|
|
|
-import cn.com.qmth.examcloud.examwork.api.response.GetExamResp;
|
|
|
-import cn.com.qmth.examcloud.task.api.controller.bean.ExamStudentImportDomain;
|
|
|
-import cn.com.qmth.examcloud.task.dao.ExamStudentImportRepo;
|
|
|
-import cn.com.qmth.examcloud.task.dao.entity.ExamStudentImportEntity;
|
|
|
-import cn.com.qmth.examcloud.task.dao.enums.ExamStudentImportStatus;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-
|
|
|
-/**
|
|
|
- * 考生导入
|
|
|
- *
|
|
|
- * @author WANGWEI
|
|
|
- * @date 2018年7月31日
|
|
|
- * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
- */
|
|
|
-@Transactional
|
|
|
-@RestController
|
|
|
-@RequestMapping("${$rmp.ctr.task}" + "examStudentImport")
|
|
|
-public class ExamStudentImportController extends ControllerSupport {
|
|
|
-
|
|
|
- @Value("${$dir}")
|
|
|
- private String dir;
|
|
|
-
|
|
|
- private static final String EXAM_STUDENT_IMPORT_FILES = "exam_student_import_files";
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamStudentImportRepo examStudentImportRepo;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- OrgCloudService orgCloudService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- ExamCloudService examCloudService;
|
|
|
-
|
|
|
- @ApiOperation(value = "导入考试学生", notes = "导入")
|
|
|
- @PostMapping("/import")
|
|
|
- public void importExamStudent(@RequestParam Long examId,
|
|
|
- @RequestParam CommonsMultipartFile file) throws Exception {
|
|
|
- User accessUser = getAccessUser();
|
|
|
- Long rootOrgId = accessUser.getRootOrgId();
|
|
|
-
|
|
|
- GetExamReq req = new GetExamReq();
|
|
|
- req.setId(examId);
|
|
|
- req.setRootOrgId(accessUser.getRootOrgId());
|
|
|
- examCloudService.getExam(req);
|
|
|
-
|
|
|
- DiskFileItem item = (DiskFileItem) file.getFileItem();
|
|
|
- File storeLocation = item.getStoreLocation();
|
|
|
- String originalFilename = file.getOriginalFilename();
|
|
|
-
|
|
|
- String suffix = originalFilename.substring(originalFilename.indexOf("."));
|
|
|
- long batchId = System.currentTimeMillis();
|
|
|
- String name = new StringBuilder().append(rootOrgId).append("_").append(examId).append("_")
|
|
|
- .append(DateUtil.getNow(DatePatterns.YYYYMMDDHHMM)).toString();
|
|
|
-
|
|
|
- String destFileName = name + suffix;
|
|
|
- String resultFileName = name + ".txt";
|
|
|
-
|
|
|
- String destFilePath = PathUtil
|
|
|
- .getCanonicalPath(dir + "/" + EXAM_STUDENT_IMPORT_FILES + "/" + destFileName);
|
|
|
- File destFile = new File(destFilePath);
|
|
|
-
|
|
|
- FileUtils.copyFile(storeLocation, destFile);
|
|
|
-
|
|
|
- ExamStudentImportEntity examStudentImport = new ExamStudentImportEntity();
|
|
|
- examStudentImport.setBatchId(batchId);
|
|
|
- examStudentImport.setFailNum(0L);
|
|
|
- examStudentImport.setSuccessNum(0L);
|
|
|
- examStudentImport.setTotalNum(0L);
|
|
|
- examStudentImport.setFilePath(destFileName);
|
|
|
- examStudentImport.setResultFilePath(resultFileName);
|
|
|
- examStudentImport.setStatus(ExamStudentImportStatus.NONE);
|
|
|
- examStudentImport.setRootOrgId(rootOrgId);
|
|
|
- examStudentImport.setExamId(examId);
|
|
|
- examStudentImport.setFileName(originalFilename);
|
|
|
-
|
|
|
- examStudentImportRepo.saveAndFlush(examStudentImport);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "查询导入记录", notes = "")
|
|
|
- @GetMapping("/all/{curPage}/{pageSize}")
|
|
|
- public PageInfo<ExamStudentImportDomain> getExamStudentImportList(@PathVariable Integer curPage,
|
|
|
- @PathVariable Integer pageSize) {
|
|
|
- User accessUser = getAccessUser();
|
|
|
- Long rootOrgId = accessUser.getRootOrgId();
|
|
|
-
|
|
|
- Specification<ExamStudentImportEntity> specification = (root, query, cb) -> {
|
|
|
- List<Predicate> predicates = new ArrayList<>();
|
|
|
- if (!isSuperAdmin()) {
|
|
|
- predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
- }
|
|
|
-
|
|
|
- return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
- };
|
|
|
-
|
|
|
- Pageable pageable = new PageRequest(curPage, pageSize, Sort.Direction.DESC, "creationTime");
|
|
|
- Page<ExamStudentImportEntity> list = examStudentImportRepo.findAll(specification, pageable);
|
|
|
-
|
|
|
- List<ExamStudentImportDomain> ret = Lists.newArrayList();
|
|
|
-
|
|
|
- for (ExamStudentImportEntity cur : list) {
|
|
|
- ExamStudentImportDomain domain = new ExamStudentImportDomain();
|
|
|
- domain.setBatchId(cur.getBatchId());
|
|
|
- domain.setExamId(cur.getExamId());
|
|
|
- domain.setFailNum(cur.getFailNum());
|
|
|
- domain.setFileName(cur.getFileName());
|
|
|
- domain.setFilePath(cur.getFilePath());
|
|
|
- domain.setId(cur.getId());
|
|
|
- domain.setResultFilePath(cur.getResultFilePath());
|
|
|
- domain.setRootOrgId(cur.getRootOrgId());
|
|
|
- domain.setStatus(cur.getStatus().name());
|
|
|
- domain.setStatusDesc(cur.getStatus().getDesc());
|
|
|
- domain.setSuccessNum(cur.getSuccessNum());
|
|
|
- domain.setTotalNum(cur.getTotalNum());
|
|
|
- domain.setErrorDesc(cur.getErrorDesc());
|
|
|
- domain.setCreationTime(cur.getCreationTime());
|
|
|
- domain.setUpdateTime(cur.getUpdateTime());
|
|
|
-
|
|
|
- GetExamReq req = new GetExamReq();
|
|
|
- req.setId(domain.getExamId());
|
|
|
- req.setRootOrgId(domain.getRootOrgId());
|
|
|
- GetExamResp examResp = examCloudService.getExam(req);
|
|
|
- ExamBean examBean = examResp.getExamBean();
|
|
|
- domain.setExamName(examBean.getName());
|
|
|
-
|
|
|
- GetOrgReq getOrgReq = new GetOrgReq();
|
|
|
- getOrgReq.setOrgId(domain.getRootOrgId());
|
|
|
- getOrgReq.setRootOrgId(rootOrgId);
|
|
|
- GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
|
|
|
- OrgBean org = getOrgResp.getOrg();
|
|
|
- domain.setRootOrgName(org.getName());
|
|
|
-
|
|
|
- ret.add(domain);
|
|
|
- }
|
|
|
-
|
|
|
- return new PageInfo<ExamStudentImportDomain>(list, ret);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "下载报告")
|
|
|
- @GetMapping("/getReports/{id}")
|
|
|
- public void importFileTemplate(@PathVariable Long id) {
|
|
|
-
|
|
|
- ExamStudentImportEntity entity = examStudentImportRepo.findOne(id);
|
|
|
- String resultFilePath = entity.getResultFilePath();
|
|
|
-
|
|
|
- if (!isSuperAdmin()) {
|
|
|
- if (!entity.getRootOrgId().equals(getRootOrgId())) {
|
|
|
- exportFile(resultFilePath, "非法请求.".getBytes());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String path = PathUtil
|
|
|
- .getCanonicalPath(dir + "/" + EXAM_STUDENT_IMPORT_FILES + "/" + resultFilePath);
|
|
|
-
|
|
|
- File file = new File(path);
|
|
|
-
|
|
|
- if (!file.exists()) {
|
|
|
- exportFile(resultFilePath, "报告未生成.".getBytes());
|
|
|
- }
|
|
|
-
|
|
|
- exportFile(resultFilePath, file);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "下载导入文件")
|
|
|
- @GetMapping("/getUploadedFile/{id}")
|
|
|
- public void getUploadedFile(@PathVariable Long id) {
|
|
|
-
|
|
|
- ExamStudentImportEntity entity = examStudentImportRepo.findOne(id);
|
|
|
- String fileName = entity.getFileName();
|
|
|
-
|
|
|
- if (!isSuperAdmin()) {
|
|
|
- if (!entity.getRootOrgId().equals(getRootOrgId())) {
|
|
|
- exportFile(fileName, "非法请求.".getBytes());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String filePath = entity.getFilePath();
|
|
|
- String path = PathUtil
|
|
|
- .getCanonicalPath(dir + "/" + EXAM_STUDENT_IMPORT_FILES + "/" + filePath);
|
|
|
-
|
|
|
- File file = new File(path);
|
|
|
-
|
|
|
- if (!file.exists()) {
|
|
|
- exportFile(fileName, "文件不存在.".getBytes());
|
|
|
- }
|
|
|
-
|
|
|
- exportFile(fileName, file);
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+package cn.com.qmth.examcloud.task.api.controller;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import javax.persistence.criteria.Predicate;
|
|
|
+import javax.transaction.Transactional;
|
|
|
+
|
|
|
+import org.apache.commons.fileupload.disk.DiskFileItem;
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
+import org.springframework.data.domain.Pageable;
|
|
|
+import org.springframework.data.domain.Sort;
|
|
|
+import org.springframework.data.jpa.domain.Specification;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
|
|
+
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.commons.util.DateUtil;
|
|
|
+import cn.com.qmth.examcloud.commons.util.PathUtil;
|
|
|
+import cn.com.qmth.examcloud.commons.util.DateUtil.DatePatterns;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.bean.OrgBean;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetOrgReq;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetOrgResp;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.ExamCloudService;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.request.GetExamReq;
|
|
|
+import cn.com.qmth.examcloud.examwork.api.response.GetExamResp;
|
|
|
+import cn.com.qmth.examcloud.task.api.controller.bean.ExamStudentImportDomain;
|
|
|
+import cn.com.qmth.examcloud.task.dao.ExamStudentImportRepo;
|
|
|
+import cn.com.qmth.examcloud.task.dao.entity.ExamStudentImportEntity;
|
|
|
+import cn.com.qmth.examcloud.task.dao.enums.ExamStudentImportStatus;
|
|
|
+import cn.com.qmth.examcloud.web.helpers.page.PageInfo;
|
|
|
+import cn.com.qmth.examcloud.web.security.bean.User;
|
|
|
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 考生导入
|
|
|
+ *
|
|
|
+ * @author WANGWEI
|
|
|
+ * @date 2018年7月31日
|
|
|
+ * @Copyright (c) 2018-? http://qmth.com.cn All Rights Reserved.
|
|
|
+ */
|
|
|
+@Transactional
|
|
|
+@RestController
|
|
|
+@RequestMapping("${$rmp.ctr.task}" + "examStudentImport")
|
|
|
+public class ExamStudentImportController extends ControllerSupport {
|
|
|
+
|
|
|
+ @Value("${$dir}")
|
|
|
+ private String dir;
|
|
|
+
|
|
|
+ private static final String EXAM_STUDENT_IMPORT_FILES = "exam_student_import_files";
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamStudentImportRepo examStudentImportRepo;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ OrgCloudService orgCloudService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ExamCloudService examCloudService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "导入考试学生", notes = "导入")
|
|
|
+ @PostMapping("/import")
|
|
|
+ public void importExamStudent(@RequestParam Long examId,
|
|
|
+ @RequestParam CommonsMultipartFile file) throws Exception {
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ Long rootOrgId = accessUser.getRootOrgId();
|
|
|
+
|
|
|
+ GetExamReq req = new GetExamReq();
|
|
|
+ req.setId(examId);
|
|
|
+ req.setRootOrgId(accessUser.getRootOrgId());
|
|
|
+ examCloudService.getExam(req);
|
|
|
+
|
|
|
+ DiskFileItem item = (DiskFileItem) file.getFileItem();
|
|
|
+ File storeLocation = item.getStoreLocation();
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
+
|
|
|
+ String suffix = originalFilename.substring(originalFilename.indexOf("."));
|
|
|
+ long batchId = System.currentTimeMillis();
|
|
|
+ String name = new StringBuilder().append(rootOrgId).append("_").append(examId).append("_")
|
|
|
+ .append(DateUtil.getNow(DatePatterns.YYYYMMDDHHMM)).toString();
|
|
|
+
|
|
|
+ String destFileName = name + suffix;
|
|
|
+ String resultFileName = name + ".txt";
|
|
|
+
|
|
|
+ String destFilePath = PathUtil
|
|
|
+ .getCanonicalPath(dir + "/" + EXAM_STUDENT_IMPORT_FILES + "/" + destFileName);
|
|
|
+ File destFile = new File(destFilePath);
|
|
|
+
|
|
|
+ FileUtils.copyFile(storeLocation, destFile);
|
|
|
+
|
|
|
+ ExamStudentImportEntity examStudentImport = new ExamStudentImportEntity();
|
|
|
+ examStudentImport.setBatchId(batchId);
|
|
|
+ examStudentImport.setFailNum(0L);
|
|
|
+ examStudentImport.setSuccessNum(0L);
|
|
|
+ examStudentImport.setTotalNum(0L);
|
|
|
+ examStudentImport.setFilePath(destFileName);
|
|
|
+ examStudentImport.setResultFilePath(resultFileName);
|
|
|
+ examStudentImport.setStatus(ExamStudentImportStatus.NONE);
|
|
|
+ examStudentImport.setRootOrgId(rootOrgId);
|
|
|
+ examStudentImport.setExamId(examId);
|
|
|
+ examStudentImport.setFileName(originalFilename);
|
|
|
+
|
|
|
+ examStudentImportRepo.saveAndFlush(examStudentImport);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询导入记录", notes = "")
|
|
|
+ @GetMapping("/all/{curPage}/{pageSize}")
|
|
|
+ public PageInfo<ExamStudentImportDomain> getExamStudentImportList(@PathVariable Integer curPage,
|
|
|
+ @PathVariable Integer pageSize) {
|
|
|
+ User accessUser = getAccessUser();
|
|
|
+ Long rootOrgId = accessUser.getRootOrgId();
|
|
|
+
|
|
|
+ Specification<ExamStudentImportEntity> specification = (root, query, cb) -> {
|
|
|
+ List<Predicate> predicates = new ArrayList<>();
|
|
|
+ if (!isSuperAdmin()) {
|
|
|
+ predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
|
|
|
+ }
|
|
|
+
|
|
|
+ return cb.and(predicates.toArray(new Predicate[predicates.size()]));
|
|
|
+ };
|
|
|
+
|
|
|
+ Pageable pageable = new PageRequest(curPage, pageSize, Sort.Direction.DESC, "creationTime");
|
|
|
+ Page<ExamStudentImportEntity> list = examStudentImportRepo.findAll(specification, pageable);
|
|
|
+
|
|
|
+ List<ExamStudentImportDomain> ret = Lists.newArrayList();
|
|
|
+
|
|
|
+ for (ExamStudentImportEntity cur : list) {
|
|
|
+ ExamStudentImportDomain domain = new ExamStudentImportDomain();
|
|
|
+ domain.setBatchId(cur.getBatchId());
|
|
|
+ domain.setExamId(cur.getExamId());
|
|
|
+ domain.setFailNum(cur.getFailNum());
|
|
|
+ domain.setFileName(cur.getFileName());
|
|
|
+ domain.setFilePath(cur.getFilePath());
|
|
|
+ domain.setId(cur.getId());
|
|
|
+ domain.setResultFilePath(cur.getResultFilePath());
|
|
|
+ domain.setRootOrgId(cur.getRootOrgId());
|
|
|
+ domain.setStatus(cur.getStatus().name());
|
|
|
+ domain.setStatusDesc(cur.getStatus().getDesc());
|
|
|
+ domain.setSuccessNum(cur.getSuccessNum());
|
|
|
+ domain.setTotalNum(cur.getTotalNum());
|
|
|
+ domain.setErrorDesc(cur.getErrorDesc());
|
|
|
+ domain.setCreationTime(cur.getCreationTime());
|
|
|
+ domain.setUpdateTime(cur.getUpdateTime());
|
|
|
+
|
|
|
+ GetExamReq req = new GetExamReq();
|
|
|
+ req.setId(domain.getExamId());
|
|
|
+ req.setRootOrgId(domain.getRootOrgId());
|
|
|
+ GetExamResp examResp = examCloudService.getExam(req);
|
|
|
+ ExamBean examBean = examResp.getExamBean();
|
|
|
+ domain.setExamName(examBean.getName());
|
|
|
+
|
|
|
+ GetOrgReq getOrgReq = new GetOrgReq();
|
|
|
+ getOrgReq.setOrgId(domain.getRootOrgId());
|
|
|
+ getOrgReq.setRootOrgId(rootOrgId);
|
|
|
+ GetOrgResp getOrgResp = orgCloudService.getOrg(getOrgReq);
|
|
|
+ OrgBean org = getOrgResp.getOrg();
|
|
|
+ domain.setRootOrgName(org.getName());
|
|
|
+
|
|
|
+ ret.add(domain);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new PageInfo<ExamStudentImportDomain>(list, ret);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "下载报告")
|
|
|
+ @GetMapping("/getReports/{id}")
|
|
|
+ public void importFileTemplate(@PathVariable Long id) {
|
|
|
+
|
|
|
+ ExamStudentImportEntity entity = examStudentImportRepo.findOne(id);
|
|
|
+ String resultFilePath = entity.getResultFilePath();
|
|
|
+
|
|
|
+ if (!isSuperAdmin()) {
|
|
|
+ if (!entity.getRootOrgId().equals(getRootOrgId())) {
|
|
|
+ exportFile(resultFilePath, "非法请求.".getBytes());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String path = PathUtil
|
|
|
+ .getCanonicalPath(dir + "/" + EXAM_STUDENT_IMPORT_FILES + "/" + resultFilePath);
|
|
|
+
|
|
|
+ File file = new File(path);
|
|
|
+
|
|
|
+ if (!file.exists()) {
|
|
|
+ exportFile(resultFilePath, "报告未生成.".getBytes());
|
|
|
+ }
|
|
|
+
|
|
|
+ exportFile(resultFilePath, file);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "下载导入文件")
|
|
|
+ @GetMapping("/getUploadedFile/{id}")
|
|
|
+ public void getUploadedFile(@PathVariable Long id) {
|
|
|
+
|
|
|
+ ExamStudentImportEntity entity = examStudentImportRepo.findOne(id);
|
|
|
+ String fileName = entity.getFileName();
|
|
|
+
|
|
|
+ if (!isSuperAdmin()) {
|
|
|
+ if (!entity.getRootOrgId().equals(getRootOrgId())) {
|
|
|
+ exportFile(fileName, "非法请求.".getBytes());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String filePath = entity.getFilePath();
|
|
|
+ String path = PathUtil
|
|
|
+ .getCanonicalPath(dir + "/" + EXAM_STUDENT_IMPORT_FILES + "/" + filePath);
|
|
|
+
|
|
|
+ File file = new File(path);
|
|
|
+
|
|
|
+ if (!file.exists()) {
|
|
|
+ exportFile(fileName, "文件不存在.".getBytes());
|
|
|
+ }
|
|
|
+
|
|
|
+ exportFile(fileName, file);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|