wangliang %!s(int64=5) %!d(string=hai) anos
pai
achega
687a20fa21

+ 34 - 0
themis-exam/src/main/java/com/qmth/themis/exam/api/SysController.java

@@ -0,0 +1,34 @@
+package com.qmth.themis.exam.api;
+
+import com.qmth.themis.business.constant.SystemConstant;
+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.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Objects;
+
+@Api(tags = "系统信息Controller")
+@RestController
+@RequestMapping("/${prefix.url.exam}/sys")
+public class SysController {
+
+    @ApiOperation(value = "获取环境接口")
+    @RequestMapping(value = "/env", method = RequestMethod.GET)
+    @ApiResponses({@ApiResponse(code = 200, message = "环境信息", response = Result.class)})
+    public Result env(@ApiParam(value = "机构id", required = true) @RequestParam Long orgId) {
+        if (Objects.isNull(orgId) || Objects.equals(orgId, "")) {
+            throw new BusinessException(ExceptionResultEnum.ORG_ID_IS_NULL);
+        }
+//        SchoolDto schoolDto = (SchoolDto) redisTemplate.opsForValue().get(SystemConstant.SCHOOL_CACHE + orgId);
+//        Map map = new HashMap();
+//        map.put(SystemConstant.ENV_FILEHOST, schoolDto.getFileHost());
+//        return ResultUtil.ok(map);
+        return ResultUtil.ok(SystemConstant.SUCCESS);
+    }
+}

+ 229 - 225
themis-exam/src/main/java/com/qmth/themis/exam/api/TEExamController.java

@@ -1,31 +1,16 @@
 package com.qmth.themis.exam.api;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-import javax.annotation.Resource;
-
-import com.qmth.themis.business.util.ServletUtil;
-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.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
-
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.qmth.themis.business.bean.exam.ExamFileUploadBean;
-import com.qmth.themis.business.bean.exam.ExamFinishBean;
-import com.qmth.themis.business.bean.exam.ExamPrepareBean;
-import com.qmth.themis.business.bean.exam.ExamResultBean;
-import com.qmth.themis.business.bean.exam.ExamResumeBean;
-import com.qmth.themis.business.bean.exam.ExamStartBean;
+import com.qmth.themis.business.bean.exam.*;
 import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.dto.response.TEExamDto;
+import com.qmth.themis.business.dto.response.TEExamResultDto;
 import com.qmth.themis.business.entity.TEExam;
 import com.qmth.themis.business.entity.TEStudent;
 import com.qmth.themis.business.enums.MqEnum;
 import com.qmth.themis.business.service.TEExamService;
 import com.qmth.themis.business.util.RedisUtil;
+import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
@@ -34,223 +19,242 @@ import com.qmth.themis.mq.dto.MqDto;
 import com.qmth.themis.mq.enums.MqTagEnum;
 import com.qmth.themis.mq.enums.MqTopicEnum;
 import com.qmth.themis.mq.service.MqDtoService;
+import io.swagger.annotations.*;
+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.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 @Api(tags = "考试Controller")
 @RestController
 @RequestMapping("/${prefix.url.exam}/exam")
 public class TEExamController {
 
-	@Resource
-	TEExamService teExamService;
-	@Resource
-	RedisUtil redisUtil;
-	@Resource
-	MqDtoService mqDtoService;
-	
-	@ApiOperation(value = "验证考试口令接口")
-	@RequestMapping(value = "/shortCode", method = RequestMethod.GET)
-	@ApiResponses({ @ApiResponse(code = 200, message = "考试信息", response = TEExam.class) })
-	public Result shortCode(@ApiParam(value = "考试口令", required = true) @RequestParam String shortCode) {
-		if (Objects.isNull(shortCode) || Objects.equals(shortCode, "")) {
-			throw new BusinessException(ExceptionResultEnum.SHORT_CODE_IS_NULL);
-		}
-		QueryWrapper<TEExam> teExamQueryWrapper = new QueryWrapper<>();
-		teExamQueryWrapper.lambda().eq(TEExam::getShortCode, shortCode);
-		TEExam teExam = teExamService.getOne(teExamQueryWrapper);
-		if (Objects.isNull(teExam)) {
-			throw new BusinessException(ExceptionResultEnum.EXAM_NO);
-		}
-		Map<String, Object> map = new HashMap<>();
-		map.put(SystemConstant.ID, teExam.getId());
-		map.put(SystemConstant.NAME, teExam.getName());
-		return ResultUtil.ok(map);
-	}
+    @Resource
+    TEExamService teExamService;
+    @Resource
+    RedisUtil redisUtil;
+    @Resource
+    MqDtoService mqDtoService;
+
+    @ApiOperation(value = "验证考试口令接口")
+    @RequestMapping(value = "/shortCode", method = RequestMethod.GET)
+    @ApiResponses({@ApiResponse(code = 200, message = "考试信息", response = TEExam.class)})
+    public Result shortCode(@ApiParam(value = "考试口令", required = true) @RequestParam String shortCode) {
+        if (Objects.isNull(shortCode) || Objects.equals(shortCode, "")) {
+            throw new BusinessException(ExceptionResultEnum.SHORT_CODE_IS_NULL);
+        }
+        QueryWrapper<TEExam> teExamQueryWrapper = new QueryWrapper<>();
+        teExamQueryWrapper.lambda().eq(TEExam::getShortCode, shortCode);
+        TEExam teExam = teExamService.getOne(teExamQueryWrapper);
+        if (Objects.isNull(teExam)) {
+            throw new BusinessException(ExceptionResultEnum.EXAM_NO);
+        }
+        Map<String, Object> map = new HashMap<>();
+        map.put(SystemConstant.ID, teExam.getId());
+        map.put(SystemConstant.NAME, teExam.getName());
+        return ResultUtil.ok(map);
+    }
+
+    @ApiOperation(value = "获取待考列表接口")
+    @RequestMapping(value = "/waiting", method = RequestMethod.GET)
+    @ApiResponses({@ApiResponse(code = 200, message = "考试信息", response = TEExamResultDto.class)})
+    public Result waiting() {
+        TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
+        List<TEExamDto> list = teExamService.getWaitingExam(teStudent.getId(), null, teStudent.getOrgId());
+        Map<String, Object> map = new HashMap<>();
+        if (Objects.nonNull(list) && list.size() > 0) {
+            map.put("waiting", list);
+        }
+        return ResultUtil.ok(map);
+    }
+
+    @ApiOperation(value = "开始候考")
+    @RequestMapping(value = "/prepare", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    public ExamPrepareBean prepare(@ApiParam(value = "考生ID", required = true) @RequestParam Long examStudentId) {
+        TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
+        String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
+        Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
+        if (!lock) {
+            throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
+        }
+        try {
+            return teExamService.prepare(teStudent.getId(), examStudentId);
+        } finally {
+            redisUtil.releaseLock(lockKey);
+        }
+    }
 
-	@ApiOperation(value = "开始候考")
-	@RequestMapping(value = "/prepare", method = RequestMethod.POST)
-	@ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
-	public ExamPrepareBean prepare(@ApiParam(value = "考生ID", required = true) @RequestParam Long examStudentId) {
-		TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
-		String lockKey=SystemConstant.REDIS_LOCK_STUDENT_PREFIX+teStudent.getId();
-		Boolean lock=redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
-		if(!lock) {
-			throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
-		}
-		try {
-			return teExamService.prepare(teStudent.getId(), examStudentId);
-		} finally {
-			redisUtil.releaseLock(lockKey);
-		}
-	}
-	
-	@ApiOperation(value = "开始考试")
-	@RequestMapping(value = "/start", method = RequestMethod.POST)
-	@ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
-	public ExamStartBean start(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
-			@ApiParam(value = "断点续考原因", required = false) @RequestParam String reason) {
-		TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
-		String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
-		Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
-		if (!lock) {
-			throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
-		}
-		try {
-			return teExamService.start(teStudent.getId(), recordId);
-		} finally {
-			redisUtil.releaseLock(lockKey);
-		}
-	}
-	
-	@ApiOperation(value = "上传个人试卷结构")
-	@RequestMapping(value = "/student_paper_struct/upload", method = RequestMethod.POST)
-	@ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
-	public Long studentPaperStruct(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
-			@ApiParam(value = "试卷结构json字符串", required = true) @RequestParam String content) {
-		TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
-		String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
-		Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
-		if (!lock) {
-			throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
-		}
-		try {
-			return teExamService.studentPaperStruct(teStudent.getId(), recordId,content);
-		} finally {
-			redisUtil.releaseLock(lockKey);
-		}
-	}
-	
-	@ApiOperation(value = "提交作答结果")
-	@RequestMapping(value = "/answer/submit", method = RequestMethod.POST)
-	@ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
-	public Long answerSubmit(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
-			@ApiParam(value = "大题号", required = true) @RequestParam Integer mainNumber,
-			@ApiParam(value = "小题号", required = true) @RequestParam Integer subNumber,
-			@ApiParam(value = "套题子题序号", required = false) @RequestParam Integer subIndex,
-			@ApiParam(value = "答案json字符串", required = true) @RequestParam String answer,
-			@ApiParam(value = "时间戳", required = true) @RequestParam Long version,
-			@ApiParam(value = "作答累计秒数", required = false) @RequestParam Integer durationSeconds) {
-		TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
-		String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
-		Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
-		if (!lock) {
-			throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
-		}
-		try {
-			Long ret=teExamService.answerSubmit(teStudent.getId(), recordId,mainNumber,subNumber,subIndex,answer,version,durationSeconds);
-			//发消息计算客观分
-			calculateObjectiveScore(recordId,mainNumber, subNumber, subIndex);
-			return ret;
-		} finally {
-			redisUtil.releaseLock(lockKey);
-		}
-	}
-	
-	@ApiOperation(value = "更新音频剩余播放次数")
-	@RequestMapping(value = "/audio_left_play_count/submit", method = RequestMethod.POST)
-	@ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
-	public Integer audioLeftPlayCountSubmit(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
-			@ApiParam(value = "音频标识", required = true) @RequestParam String key,
-			@ApiParam(value = "剩余播放次数", required = true) @RequestParam Integer count) {
-		TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
-		String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
-		Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
-		if (!lock) {
-			throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
-		}
-		try {
-			return teExamService.audioLeftPlayCountSubmit(teStudent.getId(), recordId,key,count);
-		} finally {
-			redisUtil.releaseLock(lockKey);
-		}
-	}
-	
-	@ApiOperation(value = "文件上传")
-	@RequestMapping(value = "/file/upload", method = RequestMethod.POST)
-	@ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
-	public ExamFileUploadBean fileUpload(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
-			@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
-			@ApiParam(value = "后缀名", required = true) @RequestParam String suffix,
-			@ApiParam(value = "md5", required = true) @RequestParam String md5) {
-		TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
-		String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
-		Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
-		if (!lock) {
-			throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
-		}
-		try {
-			return teExamService.fileUpload(teStudent.getId(), recordId,file,suffix,md5);
-		} finally {
-			redisUtil.releaseLock(lockKey);
-		}
-	}
-	
-	@ApiOperation(value = "断点恢复")
-	@RequestMapping(value = "/resume", method = RequestMethod.POST)
-	@ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
-	public ExamResumeBean resume(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId) {
-		TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
-		String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
-		Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
-		if (!lock) {
-			throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
-		}
-		try {
-			return teExamService.resume(teStudent.getId(), recordId);
-		} finally {
-			redisUtil.releaseLock(lockKey);
-		}
-	}
-	
-	@ApiOperation(value = "结束考试")
-	@RequestMapping(value = "/finish", method = RequestMethod.POST)
-	@ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
-	public ExamFinishBean finish(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
-			@ApiParam(value = "结束类型", required = true) @RequestParam String type,
-			@ApiParam(value = "总用时秒数", required = true) @RequestParam Integer durationSeconds) {
-		TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
-		String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
-		Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
-		if (!lock) {
-			throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
-		}
-		try {
-			return teExamService.finish(teStudent.getId(), recordId,type,durationSeconds);
-		} finally {
-			redisUtil.releaseLock(lockKey);
-		}
-	}
-	
-	private void calculateObjectiveScore(Long recordId,Integer mainNumber,Integer subNumber,Integer subIndex) {
-		Map<String, Object> transMap = new HashMap<String, Object>();
-		transMap.put("recordId", recordId);
-		transMap.put("mainNumber", mainNumber);
+    @ApiOperation(value = "开始考试")
+    @RequestMapping(value = "/start", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    public ExamStartBean start(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
+                               @ApiParam(value = "断点续考原因", required = false) @RequestParam String reason) {
+        TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
+        String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
+        Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
+        if (!lock) {
+            throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
+        }
+        try {
+            return teExamService.start(teStudent.getId(), recordId);
+        } finally {
+            redisUtil.releaseLock(lockKey);
+        }
+    }
+
+    @ApiOperation(value = "上传个人试卷结构")
+    @RequestMapping(value = "/student_paper_struct/upload", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    public Long studentPaperStruct(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
+                                   @ApiParam(value = "试卷结构json字符串", required = true) @RequestParam String content) {
+        TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
+        String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
+        Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
+        if (!lock) {
+            throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
+        }
+        try {
+            return teExamService.studentPaperStruct(teStudent.getId(), recordId, content);
+        } finally {
+            redisUtil.releaseLock(lockKey);
+        }
+    }
+
+    @ApiOperation(value = "提交作答结果")
+    @RequestMapping(value = "/answer/submit", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    public Long answerSubmit(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
+                             @ApiParam(value = "大题号", required = true) @RequestParam Integer mainNumber,
+                             @ApiParam(value = "小题号", required = true) @RequestParam Integer subNumber,
+                             @ApiParam(value = "套题子题序号", required = false) @RequestParam Integer subIndex,
+                             @ApiParam(value = "答案json字符串", required = true) @RequestParam String answer,
+                             @ApiParam(value = "时间戳", required = true) @RequestParam Long version,
+                             @ApiParam(value = "作答累计秒数", required = false) @RequestParam Integer durationSeconds) {
+        TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
+        String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
+        Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
+        if (!lock) {
+            throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
+        }
+        try {
+            Long ret = teExamService.answerSubmit(teStudent.getId(), recordId, mainNumber, subNumber, subIndex, answer, version, durationSeconds);
+            //发消息计算客观分
+            calculateObjectiveScore(recordId, mainNumber, subNumber, subIndex);
+            return ret;
+        } finally {
+            redisUtil.releaseLock(lockKey);
+        }
+    }
+
+    @ApiOperation(value = "更新音频剩余播放次数")
+    @RequestMapping(value = "/audio_left_play_count/submit", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    public Integer audioLeftPlayCountSubmit(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
+                                            @ApiParam(value = "音频标识", required = true) @RequestParam String key,
+                                            @ApiParam(value = "剩余播放次数", required = true) @RequestParam Integer count) {
+        TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
+        String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
+        Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
+        if (!lock) {
+            throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
+        }
+        try {
+            return teExamService.audioLeftPlayCountSubmit(teStudent.getId(), recordId, key, count);
+        } finally {
+            redisUtil.releaseLock(lockKey);
+        }
+    }
+
+    @ApiOperation(value = "文件上传")
+    @RequestMapping(value = "/file/upload", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    public ExamFileUploadBean fileUpload(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
+                                         @ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
+                                         @ApiParam(value = "后缀名", required = true) @RequestParam String suffix,
+                                         @ApiParam(value = "md5", required = true) @RequestParam String md5) {
+        TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
+        String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
+        Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
+        if (!lock) {
+            throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
+        }
+        try {
+            return teExamService.fileUpload(teStudent.getId(), recordId, file, suffix, md5);
+        } finally {
+            redisUtil.releaseLock(lockKey);
+        }
+    }
+
+    @ApiOperation(value = "断点恢复")
+    @RequestMapping(value = "/resume", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    public ExamResumeBean resume(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId) {
+        TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
+        String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
+        Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
+        if (!lock) {
+            throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
+        }
+        try {
+            return teExamService.resume(teStudent.getId(), recordId);
+        } finally {
+            redisUtil.releaseLock(lockKey);
+        }
+    }
+
+    @ApiOperation(value = "结束考试")
+    @RequestMapping(value = "/finish", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    public ExamFinishBean finish(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId,
+                                 @ApiParam(value = "结束类型", required = true) @RequestParam String type,
+                                 @ApiParam(value = "总用时秒数", required = true) @RequestParam Integer durationSeconds) {
+        TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
+        String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
+        Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
+        if (!lock) {
+            throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
+        }
+        try {
+            return teExamService.finish(teStudent.getId(), recordId, type, durationSeconds);
+        } finally {
+            redisUtil.releaseLock(lockKey);
+        }
+    }
+
+    private void calculateObjectiveScore(Long recordId, Integer mainNumber, Integer subNumber, Integer subIndex) {
+        Map<String, Object> transMap = new HashMap<String, Object>();
+        transMap.put("recordId", recordId);
+        transMap.put("mainNumber", mainNumber);
         transMap.put("subNumber", subNumber);
         transMap.put("subIndex", subIndex);
         //mq发送消息start
         MqDto mqDto = new MqDto(MqTopicEnum.themisTopic.getCode(), MqTagEnum.calculateObjectiveScore.name(), transMap, MqEnum.EXAM, null, null);
         mqDtoService.assembleSendOneWayMsg(mqDto);
-	}
-	
-	@ApiOperation(value = "查询交卷结果")
-	@RequestMapping(value = "/result", method = RequestMethod.POST)
-	@ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
-	public ExamResultBean result(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId) {
-		TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
-		String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
-		Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
-		if (!lock) {
-			throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
-		}
-		try {
-			return teExamService.result(teStudent.getId(), recordId);
-		} finally {
-			redisUtil.releaseLock(lockKey);
-		}
-	}
+    }
+
+    @ApiOperation(value = "查询交卷结果")
+    @RequestMapping(value = "/result", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    public ExamResultBean result(@ApiParam(value = "考试记录ID", required = true) @RequestParam Long recordId) {
+        TEStudent teStudent = (TEStudent) ServletUtil.getRequestStudentAccount();
+        String lockKey = SystemConstant.REDIS_LOCK_STUDENT_PREFIX + teStudent.getId();
+        Boolean lock = redisUtil.lock(lockKey, SystemConstant.REDIS_CACHE_TIME_OUT);
+        if (!lock) {
+            throw new BusinessException(ExceptionResultEnum.REQUEST_AWAIT);
+        }
+        try {
+            return teExamService.result(teStudent.getId(), recordId);
+        } finally {
+            redisUtil.releaseLock(lockKey);
+        }
+    }
 }

+ 0 - 51
themis-exam/src/main/java/com/qmth/themis/exam/api/TEExamStudentLogController.java

@@ -1,51 +0,0 @@
-package com.qmth.themis.exam.api;
-
-import com.qmth.themis.business.constant.SystemConstant;
-import com.qmth.themis.business.entity.TBUser;
-import com.qmth.themis.business.entity.TEExamStudentLog;
-import com.qmth.themis.business.service.TBUserService;
-import com.qmth.themis.common.util.Result;
-import com.qmth.themis.common.util.ResultUtil;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @Description: 考生轨迹 前端控制器
- * @Param:
- * @returnß:
- * @Author: wangliang
- * @Date: 2020/6/25
- */
-@Api(tags = "考生轨迹Controller")
-@RestController
-@RequestMapping("/${prefix.url.exam}/examStudentLog")
-public class TEExamStudentLogController {
-    private final static Logger log = LoggerFactory.getLogger(TEExamStudentLogController.class);
-
-    @Resource
-    TBUserService tbUserService;
-
-    @ApiOperation(value = "保存日志接口")
-    @RequestMapping(value = "/saveLog", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "用户信息", response = TEExamStudentLog.class)})
-    public Result saveLog(
-//            @ApiParam(value = "日志信息", required = true) @RequestBody TEExamStudentLog tEExamStudentLog
-    ) {
-        log.info("saveLog is come in");
-        Map<String, Object> map = new HashMap<>();
-//        return ResultUtil.ok(SystemConstant.SUCCESS);
-        return ResultUtil.ok(map);
-    }
-}

+ 1 - 1
themis-exam/src/main/resources/application.properties

@@ -146,4 +146,4 @@ prefix.url.exam=api/oe
 
 #\u65E0\u9700\u9274\u6743\u7684url
 no.auth.urls=/webjars/**,/druid/**,/swagger-ui.html,/doc.html,/swagger-resources/**,/v2/api-docs,/webjars/springfox-swagger-ui/**,/api/oe/student/login,/file/**,/upload/**,/client/**,/base_photo/**
-common.system.urls=/api/oe/student/logout
+common.system.urls=/api/oe/student/logout,/api/oe/sys/env