| | |
| | | import com.ycl.jxkg.enums.general.ExamSubmitTempStatusEnum; |
| | | import com.ycl.jxkg.mapper.*; |
| | | import com.ycl.jxkg.rabbitmq.msg.ExamStatusMsg; |
| | | import com.ycl.jxkg.rabbitmq.product.Product; |
| | | import com.ycl.jxkg.rabbitmq.product.Producer; |
| | | import com.ycl.jxkg.server.WebsocketServer; |
| | | import com.ycl.jxkg.service.ExamPaperScoreService; |
| | | import com.ycl.jxkg.service.ExamPaperService; |
| | | import com.ycl.jxkg.service.ExamService; |
| | | import com.ycl.jxkg.utils.DateTimeUtil; |
| | |
| | | @RequiredArgsConstructor |
| | | public class ExamServiceImpl extends ServiceImpl<ExamMapper, Exam> implements ExamService { |
| | | |
| | | private static final String ANSWER_SPLIT = ","; |
| | | |
| | | private final ExamMapper examMapper; |
| | | private final WebContext webContext; |
| | | private final QuestionMapper questionMapper; |
| | |
| | | private final WebsocketServer websocketServer; |
| | | private final UserMapper userMapper; |
| | | private final ExamPaperScoreMapper examPaperScoreMapper; |
| | | private final ExamPaperScoreService examPaperScoreService; |
| | | private static final String ANSWER_SPLIT = ","; |
| | | private final Product product; |
| | | private final Producer producer; |
| | | |
| | | /** |
| | | * 添加 |
| | |
| | | ingMsg.setVersion(version); |
| | | ingMsg.setExamId(entity.getId()); |
| | | ingMsg.setTargetStatus(ExamStatusEnum.ING); |
| | | product.examMsg(entity.getId(), JSON.toJSONString(ingMsg), DateTimeUtil.getTwoTimeDiffMS(entity.getStartTime(), new Date())); |
| | | producer.examMsg(entity.getId(), JSON.toJSONString(ingMsg), DateTimeUtil.getTwoTimeDiffMS(entity.getStartTime(), new Date())); |
| | | // 结束状态消息 |
| | | ExamStatusMsg finishedMsg = new ExamStatusMsg(); |
| | | finishedMsg.setVersion(version); |
| | | finishedMsg.setExamId(entity.getId()); |
| | | finishedMsg.setTargetStatus(ExamStatusEnum.FINISHED); |
| | | product.examMsg(entity.getId(), JSON.toJSONString(finishedMsg), DateTimeUtil.getTwoTimeDiffMS(entity.getEndTime(), new Date())); |
| | | producer.examMsg(entity.getId(), JSON.toJSONString(finishedMsg), DateTimeUtil.getTwoTimeDiffMS(entity.getEndTime(), new Date())); |
| | | } else if (ExamStatusEnum.ING.equals(entity.getStatus())) { // 当前是进行中状态则只需发送结束消息 |
| | | // 结束状态消息 |
| | | ExamStatusMsg finishedMsg = new ExamStatusMsg(); |
| | | finishedMsg.setVersion(0); |
| | | finishedMsg.setExamId(entity.getId()); |
| | | finishedMsg.setTargetStatus(ExamStatusEnum.FINISHED); |
| | | product.examMsg(entity.getId(), JSON.toJSONString(finishedMsg), DateTimeUtil.getTwoTimeDiffMS(entity.getEndTime(), new Date())); |
| | | producer.examMsg(entity.getId(), JSON.toJSONString(finishedMsg), DateTimeUtil.getTwoTimeDiffMS(entity.getEndTime(), new Date())); |
| | | } |
| | | } |
| | | |