Merge remote-tracking branch 'origin/dev' into dev
# Conflicts:
# src/main/java/com/ycl/jxkg/controller/wx/student/ExamPaperAnswerController.java
# src/main/java/com/ycl/jxkg/service/impl/ExamServiceImpl.java
# src/main/resources/mapper/ExamPaperScoreMapper.xml
| | |
| | | import org.springframework.boot.SpringApplication; |
| | | import org.springframework.boot.autoconfigure.SpringBootApplication; |
| | | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | | import org.springframework.transaction.annotation.EnableTransactionManagement; |
| | | |
| | | /** |
| | |
| | | * Copyright (C), 2020-2024, 武汉思维跳跃科技有限公司 |
| | | * @date 2021/12/25 9:45 |
| | | */ |
| | | @EnableScheduling |
| | | @SpringBootApplication |
| | | @EnableTransactionManagement |
| | | @EnableConfigurationProperties(value = { SystemConfig.class}) |
| | |
| | | package com.ycl.jxkg.controller.student; |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.*; |
| | | import com.ycl.jxkg.domain.ExamPaperAnswerInfo; |
| | | import com.ycl.jxkg.domain.entity.ExamPaperScore; |
| | | import com.ycl.jxkg.domain.entity.Subject; |
| | | import com.ycl.jxkg.domain.entity.User; |
| | | import com.ycl.jxkg.domain.entity.UserEventLog; |
| | | import com.ycl.jxkg.enums.ExamPaperAnswerStatusEnum; |
| | | import com.ycl.jxkg.event.CalculateExamPaperAnswerCompleteEvent; |
| | | import com.ycl.jxkg.event.UserEvent; |
| | | import com.ycl.jxkg.service.ExamPaperScoreService; |
| | | import com.ycl.jxkg.service.ExamPaperService; |
| | | import com.ycl.jxkg.service.SubjectService; |
| | | import com.ycl.jxkg.utils.DateTimeUtil; |
| | | import com.ycl.jxkg.utils.ExamUtil; |
| | | import com.ycl.jxkg.utils.PageInfoHelper; |
| | | import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperEditRequestVO; |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperReadVO; |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageVO; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.service.ExamPaperScoreService; |
| | | import com.ycl.jxkg.service.ExamPaperService; |
| | | import com.ycl.jxkg.service.SubjectService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.context.ApplicationEventPublisher; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | |
| | | @RequiredArgsConstructor |
| | | @RestController("StudentExamPaperAnswerController") |
| | |
| | | @RequestMapping(value = "/pageList", method = RequestMethod.POST) |
| | | public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageList(@RequestBody @Valid ExamPaperAnswerPageVO model) { |
| | | model.setCreateUser(getCurrentUser().getId()); |
| | | PageInfo<ExamPaperScore> pageInfo = examPaperScoreService.studentPage(model); |
| | | PageInfo<ExamPaperAnswerPageResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamPaperAnswerPageResponseVO vo = new ExamPaperAnswerPageResponseVO(); |
| | | // BeanUtils.copyProperties(e, vo); |
| | | // Subject subject = subjectService.getById(vo.getSubjectId()); |
| | | // vo.setDoTime(ExamUtil.secondToVM(e.getDoTime())); |
| | | // vo.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore())); |
| | | // vo.setUserScore(ExamUtil.scoreToVM(e.getUserScore())); |
| | | // vo.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore())); |
| | | // vo.setSubjectName(subject.getName()); |
| | | // vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | return vo; |
| | | }); |
| | | PageInfo<ExamPaperAnswerPageResponseVO> page = examPaperScoreService.studentPage(model); |
| | | return Result.ok(page); |
| | | } |
| | | |
| | |
| | | private final ApplicationEventPublisher eventPublisher; |
| | | private final ExamPaperService examPaperService; |
| | | |
| | | @RequestMapping(value = "/pageList", method = RequestMethod.POST) |
| | | public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageList(@Valid ExamPaperAnswerPageVO model) { |
| | | model.setCreateUser(getCurrentUser().getId()); |
| | | PageInfo<ExamPaperScore> pageInfo = examPaperScoreService.studentPage(model); |
| | | PageInfo<ExamPaperAnswerPageResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | ExamPaperAnswerPageResponseVO vo = new ExamPaperAnswerPageResponseVO(); |
| | | BeanUtils.copyProperties(e, vo); |
| | | Subject subject = subjectService.getById(vo.getSubjectId()); |
| | | vo.setDoTime(ExamUtil.secondToVM(e.getDoTime())); |
| | | // vo.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore())); |
| | | // vo.setUserScore(ExamUtil.scoreToVM(e.getUserScore())); |
| | | // vo.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore())); |
| | | vo.setSubjectName(subject.getName()); |
| | | // vo.setCreateTime(DateTimeUtil.dateFormat(e.get)); |
| | | return vo; |
| | | }); |
| | | return Result.ok(page); |
| | | } |
| | | // @RequestMapping(value = "/pageList", method = RequestMethod.POST) |
| | | // public Result<PageInfo<ExamPaperAnswerPageResponseVO>> pageList(@Valid ExamPaperAnswerPageVO model) { |
| | | // model.setCreateUser(getCurrentUser().getId()); |
| | | // PageInfo<ExamPaperScore> pageInfo = examPaperScoreService.studentPage(model); |
| | | // PageInfo<ExamPaperAnswerPageResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | // ExamPaperAnswerPageResponseVO vo = new ExamPaperAnswerPageResponseVO(); |
| | | // BeanUtils.copyProperties(e, vo); |
| | | // Subject subject = subjectService.getById(vo.getSubjectId()); |
| | | // vo.setDoTime(ExamUtil.secondToVM(e.getDoTime())); |
| | | // // vo.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore())); |
| | | // // vo.setUserScore(ExamUtil.scoreToVM(e.getUserScore())); |
| | | // // vo.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore())); |
| | | // vo.setSubjectName(subject.getName()); |
| | | // vo.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime())); |
| | | // return vo; |
| | | // }); |
| | | // return Result.ok(page); |
| | | // } |
| | | |
| | | |
| | | @RequestMapping(value = "/answerSubmit", method = RequestMethod.POST) |
| | |
| | | import com.ycl.jxkg.domain.base.AbsEntity; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | |
| | | |
| | | private Integer examPaperId; |
| | | |
| | | private Integer examId; |
| | | |
| | | private String name; |
| | | |
| | | private String userName; |
| | |
| | | private String userName; |
| | | |
| | | @ExcelProperty("分数") |
| | | private String userScore; |
| | | private String score; |
| | | |
| | | @ExcelProperty("总分") |
| | | private String paperScore; |
| | | private String totalScore; |
| | | |
| | | @ExcelProperty("正确题数") |
| | | private Integer questionCorrect; |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author gonghl |
| | | */ |
| | | @Data |
| | | public class ExamPaperAnswerPageResponseVO { |
| | | |
| | |
| | | |
| | | private String createTime; |
| | | |
| | | private String userScore; |
| | | private String submitTime; |
| | | |
| | | private String score; |
| | | |
| | | private String subjectName; |
| | | |
| | |
| | | |
| | | private Integer paperType; |
| | | |
| | | private String systemScore; |
| | | private String totalScore; |
| | | |
| | | private Integer status; |
| | | |
| | |
| | | @Data |
| | | public class ExamPaperAnswerPageVO extends BasePage { |
| | | |
| | | private Integer subjectId; |
| | | private String examName; |
| | | |
| | | private Integer createUser; |
| | | |
New file |
| | |
| | | package com.ycl.jxkg.job; |
| | | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.ycl.jxkg.domain.entity.Exam; |
| | | import com.ycl.jxkg.enums.general.ExamStatusEnum; |
| | | import com.ycl.jxkg.mapper.ExamMapper; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author:xp |
| | | * @date:2024/7/1 11:06 |
| | | */ |
| | | @Component |
| | | @RequiredArgsConstructor |
| | | public class ExamJob { |
| | | |
| | | private final ExamMapper examMapper; |
| | | |
| | | |
| | | @Scheduled(fixedRate = 120000) // 两分钟执行一次,定时任务作为mq消费失败的保底 |
| | | private void updateExamStatus() { |
| | | List<Exam> notFinishedExams = new LambdaQueryChainWrapper<>(examMapper) |
| | | .select(Exam::getId, Exam::getStatus, Exam::getStartTime, Exam::getEndTime) |
| | | .ne(Exam::getStatus, ExamStatusEnum.FINISHED) |
| | | .list(); |
| | | List<Exam> notStartExams = notFinishedExams.stream().filter(item -> ExamStatusEnum.NOT_START.equals(item.getStatus())).collect(Collectors.toList()); |
| | | List<Exam> ingExams = notFinishedExams.stream().filter(item -> ExamStatusEnum.ING.equals(item.getStatus())).collect(Collectors.toList()); |
| | | Date now = new Date(); |
| | | // 未开始的状态 到 进行中 |
| | | for (Exam exam : notStartExams) { |
| | | if (now.after(exam.getStartTime()) && now.before(exam.getEndTime())) { |
| | | exam.setStatus(ExamStatusEnum.ING); |
| | | examMapper.updateById(exam); |
| | | } |
| | | } |
| | | // 从进行中状态 到 结束 |
| | | for (Exam ingExam : ingExams) { |
| | | if (now.after(ingExam.getEndTime())) { |
| | | ingExam.setStatus(ExamStatusEnum.FINISHED); |
| | | examMapper.updateById(ingExam); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | @Mapper |
| | | public interface ExamPaperScoreMapper extends BaseMapper<ExamPaperScore> { |
| | | |
| | | List<ExamPaperScore> studentPage(ExamPaperAnswerPageVO requestVM); |
| | | List<ExamPaperAnswerPageResponseVO> studentPage(ExamPaperAnswerPageVO requestVM); |
| | | |
| | | Integer selectAllCount(); |
| | | Integer selectAllQuestionCount(); |
| | |
| | | * @param requestVM 过滤条件 |
| | | * @return PageInfo<ExamPaperAnswer> |
| | | */ |
| | | PageInfo<ExamPaperScore> studentPage(ExamPaperAnswerPageVO requestVM); |
| | | PageInfo<ExamPaperAnswerPageResponseVO> studentPage(ExamPaperAnswerPageVO requestVM); |
| | | |
| | | /** |
| | | * 计算试卷提交结果(不入库) |
| | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.domain.ExamPaperAnswerInfo; |
| | | import com.ycl.jxkg.domain.entity.*; |
| | | import com.ycl.jxkg.domain.other.ExamPaperAnswerUpdate; |
| | | import com.ycl.jxkg.domain.other.KeyValue; |
| | | import com.ycl.jxkg.domain.vo.admin.paper.ExamPaperAnswerPageRequestVO; |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitItemVO; |
| | | import com.ycl.jxkg.domain.vo.student.exam.ExamPaperSubmitVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO; |
| | | import com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageVO; |
| | | import com.ycl.jxkg.enums.ExamPaperAnswerStatusEnum; |
| | | import com.ycl.jxkg.enums.ExamPaperTypeEnum; |
| | | import com.ycl.jxkg.enums.QuestionTypeEnum; |
| | | import com.ycl.jxkg.mapper.ExamPaperScoreMapper; |
| | | import com.ycl.jxkg.mapper.ExamPaperMapper; |
| | | import com.ycl.jxkg.mapper.ExamPaperScoreMapper; |
| | | import com.ycl.jxkg.mapper.QuestionMapper; |
| | | import com.ycl.jxkg.mapper.TaskExamCustomerAnswerMapper; |
| | | import com.ycl.jxkg.service.ExamPaperScoreService; |
| | | import com.ycl.jxkg.service.ExamPaperScoreDetailService; |
| | | import com.ycl.jxkg.service.ExamPaperScoreService; |
| | | import com.ycl.jxkg.service.TextContentService; |
| | | import com.ycl.jxkg.utils.DateTimeUtil; |
| | | import com.ycl.jxkg.utils.ExamUtil; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<ExamPaperScore> studentPage(ExamPaperAnswerPageVO requestVM) { |
| | | public PageInfo<ExamPaperAnswerPageResponseVO> studentPage(ExamPaperAnswerPageVO requestVM) { |
| | | return PageHelper.startPage(requestVM.getPageIndex(), requestVM.getPageSize(), "id desc").doSelectPageInfo(() -> |
| | | examPaperScoreMapper.studentPage(requestVM)); |
| | | } |
| | |
| | | Exam entity = baseMapper.selectById(form.getId()); |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | // 判断考试状态 |
| | | if (! ExamStatusEnum.NOT_START.equals(entity.getStatus())) { |
| | | throw new RuntimeException("只能修改还未开始的考试"); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | entity.setStatus(ExamStatusEnum.getStatusByTime(form.getStartTime(), form.getEndTime(), null)); |
| | | baseMapper.updateById(entity); |
| | |
| | | <result column="navbar" property="navbar"/> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | id |
| | | , paper_id, paper_name, paper_type, score,total_score, |
| | | question_correct, question_count, do_time, status, user_id, exam_id,exam_name, |
| | | judge_user,submit_time,paper_content,judge_time,navbar |
| | | id, |
| | | exam_id, |
| | | exam_name, |
| | | paper_id, |
| | | paper_type, |
| | | score, |
| | | total_score, |
| | | question_correct, |
| | | question_count, |
| | | do_time, |
| | | status, |
| | | user_id, |
| | | judge_user, |
| | | submit_time, |
| | | paper_content, |
| | | navbar, |
| | | judge_time, |
| | | deleted |
| | | </sql> |
| | | |
| | | <select id="studentPage" resultMap="BaseResultMap" |
| | | parameterType="com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageVO"> |
| | | <select id="studentPage" resultType="com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO"> |
| | | SELECT |
| | | <include refid="Base_Column_List"/> |
| | | FROM t_exam_paper_answer |
| | | a.*, |
| | | ep.name as paperName |
| | | FROM t_exam_paper_score a |
| | | INNER JOIN t_exam_paper ep ON ep.id = paper_id AND ep.deleted = 0 |
| | | <where> |
| | | and user_id = #{createUser} |
| | | <if test="examName != null and examName != ''"> |
| | | and INSTR(exam_name, #{examName}) |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | |
| | | <select id="getByExamIdUserId" resultType="com.ycl.jxkg.domain.entity.ExamPaperScore"> |
| | | SELECT |
| | |
| | | and exam_id = #{examId} |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectAllCount" resultType="java.lang.Integer"> |
| | | SELECT count(*) |
| | | from t_exam_paper_score |
| | | </select> |
| | | |
| | | <select id="selectAllQuestionCount" resultType="java.lang.Integer"> |
| | | SELECT sum(question_count) |
| | | from t_exam_paper_score |
| | |
| | | |
| | | <select id="adminPage" resultType="com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO"> |
| | | SELECT |
| | | a.id , exam_paper_id, paper_name, paper_type, system_score, user_score, paper_score, |
| | | question_correct, question_count, do_time, a.status, create_user, a.create_time, b.real_name AS userName |
| | | FROM t_exam_paper_answer a |
| | | LEFT JOIN t_user b ON a.create_user = b.id |
| | | a.*, b.real_name AS userName, c.name as paperName |
| | | FROM t_exam_paper_score a |
| | | INNER JOIN t_user b ON a.user_id = b.id AND b.deleted = 0 |
| | | INNER JOIN t_exam_paper c ON a.paper_id = c.id AND c.deleted = 0 |
| | | <where> |
| | | <if test="examPaperId != null"> |
| | | AND paper_id = #{examPaperId} |
| | | </if> |
| | | exam_id = #{examId} |
| | | <if test="userName != null and userName != ''"> |
| | | AND INSTR(b.real_name, #{userName}) |
| | | </if> |
| | |
| | | |
| | | <select id="pageExamPaper" resultType="com.ycl.jxkg.domain.vo.student.exampaper.ExamPaperAnswerPageResponseVO"> |
| | | SELECT |
| | | a.id, |
| | | t.id, |
| | | a.name AS paperName, |
| | | a.score AS systemScore, |
| | | a.score AS totalScore, |
| | | a.num as questionCount, |
| | | a.subject_id, |
| | | a.paper_type, |
| | |
| | | t.exam_name |
| | | FROM t_exam_paper a |
| | | INNER JOIN t_exam t ON a.id = t.exam_paper_id AND t.deleted = 0 |
| | | LEFT JOIN t_subject b ON a.subject_id = b.id |
| | | LEFT JOIN t_user c ON t.teacher_id = c.id |
| | | LEFT JOIN t_exam_paper_answer d ON a.id = d.exam_paper_id |
| | | LEFT JOIN t_subject b ON a.subject_id = b.id AND b.deleted = 0 |
| | | LEFT JOIN t_user c ON t.teacher_id = c.id AND c.deleted = 0 |
| | | LEFT JOIN t_exam_paper_score d ON t.id = d.exam_id |
| | | LEFT JOIN t_exam_paper_classes e ON a.id = e.exam_paper_id |
| | | LEFT JOIN t_classes_user f ON e.classes_id = f.classes_id |
| | | <where> |