|
@@ -1,25 +1,21 @@
|
|
package com.qmth.themis.admin.api;
|
|
package com.qmth.themis.admin.api;
|
|
|
|
|
|
-import cn.hutool.core.date.DateUtil;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.cache.bean.ExamCacheBean;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
-import com.qmth.themis.business.dto.MqDto;
|
|
|
|
-import com.qmth.themis.business.entity.*;
|
|
|
|
-import com.qmth.themis.business.enums.AudioTypeEnum;
|
|
|
|
|
|
+import com.qmth.themis.business.entity.TBAttachment;
|
|
|
|
+import com.qmth.themis.business.entity.TBUser;
|
|
|
|
+import com.qmth.themis.business.entity.TEAudio;
|
|
|
|
+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.MonitorVideoSourceEnum;
|
|
import com.qmth.themis.business.enums.MonitorVideoSourceEnum;
|
|
-import com.qmth.themis.business.enums.MqTagEnum;
|
|
|
|
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;
|
|
-import com.qmth.themis.business.util.JacksonUtil;
|
|
|
|
-import com.qmth.themis.business.util.MqUtil;
|
|
|
|
import com.qmth.themis.business.util.OssUtil;
|
|
import com.qmth.themis.business.util.OssUtil;
|
|
import com.qmth.themis.business.util.ServletUtil;
|
|
import com.qmth.themis.business.util.ServletUtil;
|
|
-import com.qmth.themis.common.contanst.Constants;
|
|
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.common.exception.BusinessException;
|
|
import com.qmth.themis.common.util.Result;
|
|
import com.qmth.themis.common.util.Result;
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
import com.qmth.themis.common.util.ResultUtil;
|
|
@@ -36,7 +32,9 @@ import javax.annotation.Resource;
|
|
import javax.validation.constraints.Max;
|
|
import javax.validation.constraints.Max;
|
|
import javax.validation.constraints.Min;
|
|
import javax.validation.constraints.Min;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
-import java.util.*;
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Objects;
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 考试场次 前端控制器
|
|
* @Description: 考试场次 前端控制器
|
|
@@ -70,11 +68,17 @@ public class TEExamActivityController {
|
|
@Resource
|
|
@Resource
|
|
CacheService cacheService;
|
|
CacheService cacheService;
|
|
|
|
|
|
- @Resource
|
|
|
|
- private MqUtil mqUtil;
|
|
|
|
|
|
+// @Resource
|
|
|
|
+// private MqUtil mqUtil;
|
|
|
|
+//
|
|
|
|
+// @Resource
|
|
|
|
+// private MqDtoService mqDtoService;
|
|
|
|
+
|
|
|
|
+// @Resource
|
|
|
|
+// TBAttachmentService tbAttachmentService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private MqDtoService mqDtoService;
|
|
|
|
|
|
+ TOeExamRecordService tOeExamRecordService;
|
|
|
|
|
|
@ApiOperation(value = "考试场次修改/新增接口")
|
|
@ApiOperation(value = "考试场次修改/新增接口")
|
|
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/save", method = RequestMethod.POST)
|
|
@@ -151,7 +155,7 @@ public class TEExamActivityController {
|
|
teAudio.updateInfo(tbUser.getId());
|
|
teAudio.updateInfo(tbUser.getId());
|
|
}
|
|
}
|
|
teAudioService.saveOrUpdate(teAudio);
|
|
teAudioService.saveOrUpdate(teAudio);
|
|
- teAudioService.sendAudioMessage(teAudio);
|
|
|
|
|
|
+// teAudioService.sendAudioMessage(teAudio);
|
|
return ResultUtil.ok(true);
|
|
return ResultUtil.ok(true);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -164,9 +168,9 @@ public class TEExamActivityController {
|
|
TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
|
|
TEAudio teAudio = teAudioService.getById(audioId);
|
|
TEAudio teAudio = teAudioService.getById(audioId);
|
|
Optional.ofNullable(teAudio).orElseThrow(() -> new BusinessException("语音信息不存在"));
|
|
Optional.ofNullable(teAudio).orElseThrow(() -> new BusinessException("语音信息不存在"));
|
|
|
|
+ ExamActivityCacheBean examActivityCacheBean = teExamActivityService.getExamActivityCacheBean(teAudio.getActivityId());
|
|
|
|
+ ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examActivityCacheBean.getExamId());
|
|
if (enable) {
|
|
if (enable) {
|
|
- ExamActivityCacheBean examActivityCacheBean = teExamActivityService.getExamActivityCacheBean(teAudio.getActivityId());
|
|
|
|
- ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examActivityCacheBean.getExamId());
|
|
|
|
if (Objects.nonNull(examCacheBean) && examCacheBean.getMode() == ExamModeEnum.ANYTIME) {
|
|
if (Objects.nonNull(examCacheBean) && examCacheBean.getMode() == ExamModeEnum.ANYTIME) {
|
|
throw new BusinessException("只有集中统一的考试才能使用语音播报");
|
|
throw new BusinessException("只有集中统一的考试才能使用语音播报");
|
|
}
|
|
}
|
|
@@ -177,6 +181,11 @@ public class TEExamActivityController {
|
|
&& !examCacheBean.getMonitorRecord().contains(MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
|
|
&& !examCacheBean.getMonitorRecord().contains(MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
|
|
throw new BusinessException("考试未启用手机直播");
|
|
throw new BusinessException("考试未启用手机直播");
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ Integer examCount = tOeExamRecordService.findByExamIdOrExamActivityIdCount(examCacheBean.getId(), teAudio.getActivityId());
|
|
|
|
+ if (Objects.nonNull(examCount) && examCount.intValue() > 0) {
|
|
|
|
+ throw new BusinessException("已有考试记录不能禁用");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
teAudio.setEnable(enable);
|
|
teAudio.setEnable(enable);
|
|
teAudio.updateInfo(tbUser.getId());
|
|
teAudio.updateInfo(tbUser.getId());
|
|
@@ -185,40 +194,40 @@ public class TEExamActivityController {
|
|
return ResultUtil.ok(true);
|
|
return ResultUtil.ok(true);
|
|
}
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "考试场次语音测试接口")
|
|
|
|
- @RequestMapping(value = "/audio/test", method = RequestMethod.POST)
|
|
|
|
- @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
|
|
|
|
- public Result audioTest(@ApiParam(value = "考试场次语音id", required = true) @RequestParam Long audioId) {
|
|
|
|
- TEAudio teAudio = teAudioService.getById(audioId);
|
|
|
|
- Optional.ofNullable(teAudio).orElseThrow(() -> new BusinessException("语音信息不存在"));
|
|
|
|
- ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(teAudio.getActivityId());
|
|
|
|
- ExamCacheBean examCacheBean = teExamService.getExamCacheBean(ac.getExamId());
|
|
|
|
- TEExam teExam = teExamService.cacheConvert(examCacheBean);
|
|
|
|
-// Long start = ac.getStartTime();
|
|
|
|
-// Long end = ac.getStartTime() + (ac.getOpeningSeconds() * 1000);
|
|
|
|
- long currentTime = System.currentTimeMillis();
|
|
|
|
- Long execTime = null, realExecTime = null;
|
|
|
|
- if (teAudio.getType() == AudioTypeEnum.BEFORE) {//开考前语音
|
|
|
|
- realExecTime = currentTime + (60 * 1000);//当前时间往后一分钟
|
|
|
|
- } else if (teAudio.getType() == AudioTypeEnum.AFTER) {//考试结束前语音
|
|
|
|
- realExecTime = currentTime + (120 * 1000);//当前时间往后二分钟
|
|
|
|
- }
|
|
|
|
- execTime = realExecTime - SystemConstant.EXAM_AUDIO_BEFORE_TIME;
|
|
|
|
- //新增quartz任务,发送mq消息start
|
|
|
|
- Map<String, Object> prop = new HashMap<>();
|
|
|
|
- prop.put(SystemConstant.OPER, SystemConstant.INSERT);
|
|
|
|
- prop.put(SystemConstant.EXAM, teExam);
|
|
|
|
- prop.put(SystemConstant.EXEC_TIME, execTime);
|
|
|
|
- prop.put(SystemConstant.REAL_EXEC_TIME, realExecTime);
|
|
|
|
- log.info(SystemConstant.EXEC_TIME + ":{}," + SystemConstant.REAL_EXEC_TIME + ":{}", DateUtil.format(new Date(execTime), Constants.DEFAULT_DATE_PATTERN), DateUtil.format(new Date(realExecTime), Constants.DEFAULT_DATE_PATTERN));
|
|
|
|
-// if (execTime >= System.currentTimeMillis()) {
|
|
|
|
- cacheService.updateExamAudioCache(teAudio.getId());
|
|
|
|
- MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.EXAM_AUDIO.name(),
|
|
|
|
- JacksonUtil.parseJson(teAudio), MqTagEnum.EXAM_AUDIO,
|
|
|
|
- String.valueOf(teExam.getId()), prop, "test");
|
|
|
|
- mqDtoService.assembleSendOneOrderMsg(mqDto);
|
|
|
|
|
|
+// @ApiOperation(value = "考试场次语音测试接口")
|
|
|
|
+// @RequestMapping(value = "/audio/test", method = RequestMethod.POST)
|
|
|
|
+// @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = Result.class)})
|
|
|
|
+// public Result audioTest(@ApiParam(value = "考试场次语音id", required = true) @RequestParam Long audioId) {
|
|
|
|
+// TEAudio teAudio = teAudioService.getById(audioId);
|
|
|
|
+// Optional.ofNullable(teAudio).orElseThrow(() -> new BusinessException("语音信息不存在"));
|
|
|
|
+// ExamActivityCacheBean ac = teExamActivityService.getExamActivityCacheBean(teAudio.getActivityId());
|
|
|
|
+// ExamCacheBean examCacheBean = teExamService.getExamCacheBean(ac.getExamId());
|
|
|
|
+// TEExam teExam = teExamService.cacheConvert(examCacheBean);
|
|
|
|
+//// Long start = ac.getStartTime();
|
|
|
|
+//// Long end = ac.getStartTime() + (ac.getOpeningSeconds() * 1000);
|
|
|
|
+// long currentTime = System.currentTimeMillis();
|
|
|
|
+// Long execTime = null, realExecTime = null;
|
|
|
|
+// if (teAudio.getType() == AudioTypeEnum.BEFORE) {//开考前语音
|
|
|
|
+// realExecTime = currentTime + (60 * 1000);//当前时间往后一分钟
|
|
|
|
+// } else if (teAudio.getType() == AudioTypeEnum.AFTER) {//考试结束前语音
|
|
|
|
+// realExecTime = currentTime + (120 * 1000);//当前时间往后二分钟
|
|
// }
|
|
// }
|
|
- //新增quartz任务,发送mq消息end
|
|
|
|
- return ResultUtil.ok(true);
|
|
|
|
- }
|
|
|
|
|
|
+// execTime = realExecTime - SystemConstant.EXAM_AUDIO_BEFORE_TIME;
|
|
|
|
+// //新增quartz任务,发送mq消息start
|
|
|
|
+// Map<String, Object> prop = new HashMap<>();
|
|
|
|
+// prop.put(SystemConstant.OPER, SystemConstant.INSERT);
|
|
|
|
+// prop.put(SystemConstant.EXAM, teExam);
|
|
|
|
+// prop.put(SystemConstant.EXEC_TIME, execTime);
|
|
|
|
+// prop.put(SystemConstant.REAL_EXEC_TIME, realExecTime);
|
|
|
|
+// log.info(SystemConstant.EXEC_TIME + ":{}," + SystemConstant.REAL_EXEC_TIME + ":{}", DateUtil.format(new Date(execTime), Constants.DEFAULT_DATE_PATTERN), DateUtil.format(new Date(realExecTime), Constants.DEFAULT_DATE_PATTERN));
|
|
|
|
+//// if (execTime >= System.currentTimeMillis()) {
|
|
|
|
+// cacheService.updateExamAudioCache(teAudio.getId());
|
|
|
|
+// MqDto mqDto = new MqDto(mqUtil.getMqGroupDomain().getTopic(), MqTagEnum.EXAM_AUDIO.name(),
|
|
|
|
+// JacksonUtil.parseJson(teAudio), MqTagEnum.EXAM_AUDIO,
|
|
|
|
+// String.valueOf(teExam.getId()), prop, "test");
|
|
|
|
+// mqDtoService.assembleSendOneOrderMsg(mqDto);
|
|
|
|
+//// }
|
|
|
|
+// //新增quartz任务,发送mq消息end
|
|
|
|
+// return ResultUtil.ok(true);
|
|
|
|
+// }
|
|
}
|
|
}
|