|
@@ -1,11 +1,14 @@
|
|
|
package com.qmth.themis.admin.api;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.qmth.themis.business.annotation.ApiJsonObject;
|
|
|
import com.qmth.themis.business.annotation.ApiJsonProperty;
|
|
|
import com.qmth.themis.business.bean.admin.CountStopBean;
|
|
|
+import com.qmth.themis.business.bean.cloudmark.FileUploadParams;
|
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
|
+import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.business.dto.AuthDto;
|
|
|
import com.qmth.themis.business.dto.ExamPropCountDto;
|
|
@@ -15,11 +18,13 @@ import com.qmth.themis.business.entity.*;
|
|
|
import com.qmth.themis.business.enums.*;
|
|
|
import com.qmth.themis.business.service.*;
|
|
|
import com.qmth.themis.business.util.*;
|
|
|
+import com.qmth.themis.common.contanst.Constants;
|
|
|
import com.qmth.themis.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
|
import com.qmth.themis.common.util.Result;
|
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
|
import io.swagger.annotations.*;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
@@ -27,11 +32,17 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.validation.constraints.Max;
|
|
|
import javax.validation.constraints.Min;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.net.URLDecoder;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -223,7 +234,9 @@ public class TEExamController {
|
|
|
teExamActivity.setUpdateId(tbUser.getId());
|
|
|
}
|
|
|
teExamActivityService.saveOrUpdate(teExamActivity);
|
|
|
- teExamActivityService.updateExamActivityCacheBean(teExamActivity.getId());
|
|
|
+ if (Objects.isNull(teExamActivityService.updateExamActivityCacheBean(teExamActivity.getId()))) {
|
|
|
+ teExamActivityService.deleteExamActivityCacheBean(teExamActivity.getId());
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error(SystemConstant.LOG_ERROR, e);
|
|
@@ -247,7 +260,9 @@ public class TEExamController {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
}
|
|
|
- teExamService.updateExamCacheBean(teExam.getId());
|
|
|
+ if (Objects.isNull(teExamService.updateExamCacheBean(teExam.getId()))) {
|
|
|
+ teExamService.deleteExamCacheBean(teExam.getId());
|
|
|
+ }
|
|
|
examPaperService.disposeObjectiveAnswer(teExam.getId());
|
|
|
return ResultUtil.ok(true);
|
|
|
}
|
|
@@ -328,7 +343,9 @@ public class TEExamController {
|
|
|
teExam.setEnable(enable);
|
|
|
teExam.setUpdateId(tbUser.getId());
|
|
|
teExamService.updateById(teExam);
|
|
|
- teExamService.updateExamCacheBean(teExam.getId());
|
|
|
+ if (Objects.isNull(teExamService.updateExamCacheBean(teExam.getId()))) {
|
|
|
+ teExamService.deleteExamCacheBean(teExam.getId());
|
|
|
+ }
|
|
|
return ResultUtil.ok(true);
|
|
|
}
|
|
|
|
|
@@ -672,4 +689,101 @@ public class TEExamController {
|
|
|
}
|
|
|
return ResultUtil.ok(Collections.singletonMap(SystemConstant.TASK_ID, tbTaskHistory.getId()));
|
|
|
}
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ CloudMarkUtil cloudMarkUtil;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TEExamPaperService teExamPaperService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TEExamStudentService teExamStudentService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "http测试发送接口")
|
|
|
+ @RequestMapping(value = "/http/test/send", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
|
|
|
+ public Result httpTestSend() throws IOException {
|
|
|
+ Long orgId = 240069373300576256L, examId = 307119709605072896L, paperId = 307120792277622784L,
|
|
|
+ examStudentId = 1574244332533293057L, examRecordId = 307148263382851584L;
|
|
|
+ TBOrg tbOrg = cacheService.addOrgCache(orgId);
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
|
|
|
+
|
|
|
+// //测试考试
|
|
|
+// SaveExamParams saveExamParams = new SaveExamParams(orgId, examCacheBean.getId(), examCacheBean.getName(), DateUtil.format(new Date(examCacheBean.getStartTime()), Constants.DEFAULT_DATE_PATTERN));
|
|
|
+// cloudMarkUtil.callExamSaveApi(saveExamParams);
|
|
|
+//
|
|
|
+// //测试科目试卷
|
|
|
+// ExamPaperCacheBean examPaperCacheBean = teExamPaperService.getExamPaperCacheBean(paperId);
|
|
|
+// SaveSubjectParams saveSubjectParams = new SaveSubjectParams(orgId, examCacheBean.getId(), examPaperCacheBean.getCode(), examPaperCacheBean.getName());
|
|
|
+// cloudMarkUtil.callSubjectSaveApi(saveSubjectParams);
|
|
|
+//
|
|
|
+// //测试考生
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
+// SaveStudentParams saveStudentParams = new SaveStudentParams(orgId, examId, String.valueOf(examRecordId),
|
|
|
+// examStudentCacheBean.getIdentity(),
|
|
|
+// examStudentCacheBean.getName(),
|
|
|
+// tbOrg.getName(),
|
|
|
+// examStudentCacheBean.getClassNo(), "#",
|
|
|
+// examStudentCacheBean.getCourseCode(),
|
|
|
+// examStudentCacheBean.getCourseName());
|
|
|
+// cloudMarkUtil.callStudentSaveApi(saveStudentParams);
|
|
|
+
|
|
|
+// //测试上传文件json
|
|
|
+// File fileJson = new File("/Users/king/Downloads/41a9c68b71c9486db62de90980bd7e9a");
|
|
|
+// FileUploadParams fileUploadParamsJson = new FileUploadParams(orgId, examId, String.valueOf(examRecordId), fileJson);
|
|
|
+// fileUploadParamsJson.setFormat(CloudMarkFileUploadTypeEnum.JSON.getCode());
|
|
|
+// cloudMarkUtil.callFileUploadApi(fileUploadParamsJson);
|
|
|
+//
|
|
|
+ File filePaper = new File("/Users/king/Downloads/1");
|
|
|
+ FileUploadParams fileUploadParamsPaper = new FileUploadParams(orgId, examId, examStudentCacheBean.getIdentity(), CloudMarkFileUploadTypeEnum.PAPER, filePaper);
|
|
|
+ cloudMarkUtil.callFileUploadApi(fileUploadParamsPaper);
|
|
|
+ return ResultUtil.ok(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "http测试考试接口")
|
|
|
+ @RequestMapping(value = "/http/test/save", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
|
|
|
+ public Result httpTestApiExamSave(@ApiParam(value = "接收数据信息", required = true) @RequestBody String result) throws UnsupportedEncodingException {
|
|
|
+ Optional.ofNullable(result).orElseThrow(() -> new BusinessException("数据为空"));
|
|
|
+ String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
|
+ log.info("httpTestApiExamSave,result:{}", decodeJson);
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("id", 1L));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "http测试科目接口")
|
|
|
+ @RequestMapping(value = "/http/test/subject/save", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
|
|
|
+ public Result httpTestApiSubjectSave(@ApiParam(value = "接收数据信息", required = true) @RequestBody String result) throws UnsupportedEncodingException {
|
|
|
+ Optional.ofNullable(result).orElseThrow(() -> new BusinessException("数据为空"));
|
|
|
+ String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
|
+ log.info("httpTestApiSubjectSave,result:{}", JacksonUtil.parseJson(decodeJson));
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("updateTime", DateUtil.format(new Date(), Constants.DEFAULT_DATE_PATTERN)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "http测试考生接口")
|
|
|
+ @RequestMapping(value = "/http/test/student/save", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
|
|
|
+ public Result httpTestApiStudentSave(@ApiParam(value = "接收数据信息", required = true) @RequestBody String result) throws UnsupportedEncodingException {
|
|
|
+ Optional.ofNullable(result).orElseThrow(() -> new BusinessException("数据为空"));
|
|
|
+ String decodeJson = URLDecoder.decode(result, SystemConstant.CHARSET_NAME);
|
|
|
+ log.info("httpTestApiStudentSave,result:{}", decodeJson);
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("updateTime", DateUtil.format(new Date(), Constants.DEFAULT_DATE_PATTERN)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "http测试文件接口")
|
|
|
+ @RequestMapping(value = "/http/test/file/{type}/upload", method = RequestMethod.POST)
|
|
|
+ @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
|
|
|
+ public Result httpTestFileUpload(@PathVariable("type") String type,
|
|
|
+ @ApiParam(value = "考试id", required = true) @RequestParam Long examId,
|
|
|
+ @ApiParam(value = "准考证号") @RequestParam(required = false) String examNumber,
|
|
|
+ @ApiParam(value = "科目编码") @RequestParam(required = false) String subjectCode,
|
|
|
+ @ApiParam(value = "格式") @RequestParam(required = false) String format,
|
|
|
+ @ApiParam(value = "文件", required = true) @RequestParam MultipartFile file,
|
|
|
+ @ApiParam(value = "文件md5", required = true) @RequestParam String md5) throws IOException {
|
|
|
+ if (Objects.nonNull(file)) {
|
|
|
+ File fileNew = new File("/Users/king/Downloads/41a9c68b71c9486db62de90980bd7e9a-new");
|
|
|
+ IOUtils.copy(file.getInputStream(), new FileOutputStream(fileNew));
|
|
|
+ }
|
|
|
+ return ResultUtil.ok(Collections.singletonMap("success", true));
|
|
|
+ }
|
|
|
}
|