|
@@ -11,6 +11,7 @@ import com.qmth.themis.business.entity.TBUser;
|
|
import com.qmth.themis.business.entity.TEAudio;
|
|
import com.qmth.themis.business.entity.TEAudio;
|
|
import com.qmth.themis.business.entity.TEExamActivity;
|
|
import com.qmth.themis.business.entity.TEExamActivity;
|
|
import com.qmth.themis.business.enums.ExamModeEnum;
|
|
import com.qmth.themis.business.enums.ExamModeEnum;
|
|
|
|
+import com.qmth.themis.business.enums.FieldUniqueEnum;
|
|
import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
|
|
import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.service.impl.TEExamActivityServiceImpl;
|
|
import com.qmth.themis.business.service.impl.TEExamActivityServiceImpl;
|
|
@@ -22,6 +23,7 @@ import com.qmth.themis.common.util.ResultUtil;
|
|
import io.swagger.annotations.*;
|
|
import io.swagger.annotations.*;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.validation.BindingResult;
|
|
import org.springframework.validation.BindingResult;
|
|
@@ -135,27 +137,46 @@ public class TEExamActivityController {
|
|
if (bindingResult.hasErrors()) {
|
|
if (bindingResult.hasErrors()) {
|
|
return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
}
|
|
}
|
|
- TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
|
- teAudio.setOrgId(Objects.nonNull(tbUser.getOrgId()) ? tbUser.getOrgId() : -1L);
|
|
|
|
- ExamActivityCacheBean examActivityCacheBean = teExamActivityService.getExamActivityCacheBean(teAudio.getActivityId());
|
|
|
|
- ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examActivityCacheBean.getExamId());
|
|
|
|
- if (Objects.nonNull(examCacheBean) && examCacheBean.getMode() == ExamModeEnum.ANYTIME) {
|
|
|
|
- throw new BusinessException("只有集中统一的考试才能使用语音播报");
|
|
|
|
- }
|
|
|
|
- if (Objects.nonNull(examCacheBean.getForceFinish()) && examCacheBean.getForceFinish().intValue() == 0) {
|
|
|
|
- throw new BusinessException("考试未启用集中收卷");
|
|
|
|
- }
|
|
|
|
- if (Objects.nonNull(examCacheBean.getMonitorRecord()) && (!examCacheBean.getMonitorRecord().contains(MonitorVideoSourceEnum.MOBILE_FIRST.name())
|
|
|
|
- && !examCacheBean.getMonitorRecord().contains(MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
|
|
|
|
- throw new BusinessException("考试未启用手机直播");
|
|
|
|
- }
|
|
|
|
- if (Objects.isNull(teAudio.getId())) {
|
|
|
|
- teAudio.insertInfo(tbUser.getId());
|
|
|
|
- } else {
|
|
|
|
- teAudio.updateInfo(tbUser.getId());
|
|
|
|
- }
|
|
|
|
- teAudioService.saveOrUpdate(teAudio);
|
|
|
|
|
|
+ ExamActivityCacheBean examActivityCacheBean = null;
|
|
|
|
+ try {
|
|
|
|
+ TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
|
|
+ teAudio.setOrgId(Objects.nonNull(tbUser.getOrgId()) ? tbUser.getOrgId() : -1L);
|
|
|
|
+ examActivityCacheBean = teExamActivityService.getExamActivityCacheBean(teAudio.getActivityId());
|
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examActivityCacheBean.getExamId());
|
|
|
|
+ if (Objects.nonNull(examCacheBean) && examCacheBean.getMode() == ExamModeEnum.ANYTIME) {
|
|
|
|
+ throw new BusinessException("只有集中统一的考试才能使用语音播报");
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(examCacheBean.getForceFinish()) && examCacheBean.getForceFinish().intValue() == 0) {
|
|
|
|
+ throw new BusinessException("考试未启用集中收卷");
|
|
|
|
+ }
|
|
|
|
+ if (Objects.nonNull(examCacheBean.getMonitorRecord()) && (!examCacheBean.getMonitorRecord().contains(MonitorVideoSourceEnum.MOBILE_FIRST.name())
|
|
|
|
+ && !examCacheBean.getMonitorRecord().contains(MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
|
|
|
|
+ throw new BusinessException("考试未启用手机直播");
|
|
|
|
+ }
|
|
|
|
+ if (Objects.isNull(teAudio.getId())) {
|
|
|
|
+ teAudio.insertInfo(tbUser.getId());
|
|
|
|
+ } else {
|
|
|
|
+ Integer examCount = tOeExamRecordService.findByExamIdOrExamActivityIdCount(examCacheBean.getId(), teAudio.getActivityId());
|
|
|
|
+ if (Objects.nonNull(examCount) && examCount.intValue() > 0) {
|
|
|
|
+ throw new BusinessException("已有考试记录不能修改");
|
|
|
|
+ }
|
|
|
|
+ teAudio.updateInfo(tbUser.getId());
|
|
|
|
+ }
|
|
|
|
+ teAudioService.saveOrUpdate(teAudio);
|
|
// teAudioService.sendAudioMessage(teAudio);
|
|
// teAudioService.sendAudioMessage(teAudio);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(SystemConstant.LOG_ERROR, e);
|
|
|
|
+ if (e instanceof DuplicateKeyException) {
|
|
|
|
+ String errorColumn = e.getCause().toString();
|
|
|
|
+ String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length())
|
|
|
|
+ .replaceAll("'", "");
|
|
|
|
+ throw new BusinessException("场次[" + examActivityCacheBean.getCode() + "]下的" + teAudio.getType().getTitle() + teAudio.getPlayTime() / 60 + "分钟" + FieldUniqueEnum.convertToCode(columnStr) + "不允许重复插入");
|
|
|
|
+ } else if (e instanceof BusinessException) {
|
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
|
+ } else {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return ResultUtil.ok(true);
|
|
return ResultUtil.ok(true);
|
|
}
|
|
}
|
|
|
|
|