src/main/java/com/mindskip/xzs/controller/admin/DepartmentController.java
@@ -4,6 +4,7 @@ import com.mindskip.xzs.base.BaseApiController; import com.mindskip.xzs.base.RestResponse; import com.mindskip.xzs.domain.Department; import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.User; import com.mindskip.xzs.domain.UserDepartment; import com.mindskip.xzs.domain.vo.BaseSelect; @@ -93,7 +94,7 @@ } @RequestMapping(value = "/getDepartmentUser", method = RequestMethod.POST) public RestResponse<List<DepartmentVO>> getUserDepartment(){ public RestResponse<List<DepartmentVO>> getUserDepartment(Integer examPaperId){ User currentUser = webContext.getCurrentUser(); Integer deptId = null; if (Objects.nonNull(currentUser)) { @@ -108,7 +109,16 @@ List<UserDepartment> userDepartments = userDepartmentMapper.selectByDepartmentId(e.getId()); List<User> list = new ArrayList<>(); for (UserDepartment userDepartment : userDepartments) { User user = userService.getUserById(userDepartment.getUserId()); User user; // 选择补考用户时查询符合补考条件的用户 if (examPaperId != null) { ExamPaper examPaper = new ExamPaper(); examPaper.setCreateUser(userDepartment.getUserId()); examPaper.setId(examPaperId); user = userService.getUserByExam(examPaper); } else { user = userService.getUserById(userDepartment.getUserId()); } if (ObjectUtils.isNotEmpty(user)) { list.add(user); } src/main/java/com/mindskip/xzs/controller/admin/ExamPaperController.java
@@ -90,6 +90,17 @@ return RestResponse.ok(newVM); } /** * 补考 * @param model 数据 * @return 操作结果 */ @RequestMapping(value = "/missExam", method = RequestMethod.POST) public RestResponse<String> missExam(@RequestBody ExamPaperEditRequestVM model) { examPaperService.missExam(model); return RestResponse.ok("操作成功"); } @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) public RestResponse<ExamPaperEditRequestVO> select(@PathVariable Integer id) { ExamPaperEditRequestVO vm = examPaperService.examPaperToVM(id); src/main/java/com/mindskip/xzs/repository/ExamPaperAnswerMapper.java
@@ -6,6 +6,7 @@ import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.vo.ScoreTemplatesCountVO; import com.mindskip.xzs.domain.vo.TeamplatesUserExcelVO; import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM; import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradePageRequestVM; import com.mindskip.xzs.viewmodel.admin.paper.ExamPaperGradeQuery; import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM; @@ -46,7 +47,5 @@ List<TeamplatesUserExcelVO> getByTimeOne(); void setMissExam(ExamPaperEditRequestVM model); } src/main/java/com/mindskip/xzs/repository/UserMapper.java
@@ -1,5 +1,6 @@ package com.mindskip.xzs.repository; import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.ExamPaperAnswer; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.User; @@ -158,4 +159,6 @@ * @param deptId */ void clearDeptAdmin(List<Integer> userIds, @Param("deptId") Integer deptId); User getUserByExam(ExamPaper examPaper); } src/main/java/com/mindskip/xzs/service/ExamPaperService.java
@@ -38,4 +38,5 @@ List<PaperExcelVO> getPaperExcelById(Integer id); void missExam(ExamPaperEditRequestVM model); } src/main/java/com/mindskip/xzs/service/UserService.java
@@ -1,5 +1,6 @@ package com.mindskip.xzs.service; import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.User; import com.mindskip.xzs.domain.vo.UserVO; @@ -135,4 +136,6 @@ User getUserByRealName(String realName); void setStatus(UserVO user); User getUserByExam(ExamPaper examPaper); } src/main/java/com/mindskip/xzs/service/impl/ExamPaperServiceImpl.java
@@ -10,6 +10,7 @@ import com.mindskip.xzs.domain.exam.ExamPaperTitleItemObject; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.vo.PaperExcelVO; import com.mindskip.xzs.repository.ExamPaperAnswerMapper; import com.mindskip.xzs.repository.ExamPaperMapper; import com.mindskip.xzs.repository.QuestionMapper; import com.mindskip.xzs.repository.UserDepartmentMapper; @@ -25,11 +26,13 @@ import com.mindskip.xzs.viewmodel.student.dashboard.PaperFilter; import com.mindskip.xzs.viewmodel.student.dashboard.PaperInfo; import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageVM; import org.apache.commons.lang3.ObjectUtils; import org.modelmapper.ModelMapper; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -40,6 +43,7 @@ protected final static ModelMapper modelMapper = ModelMapperSingle.Instance(); private final ExamPaperMapper examPaperMapper; private final ExamPaperAnswerMapper examPaperAnswerMapper; private final QuestionMapper questionMapper; private final TextContentService textContentService; private final QuestionService questionService; @@ -55,9 +59,10 @@ @Autowired public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService, QuestionSubjectService questionSubjectService, ExamPaperUserService examPaperUserService, UserService userService, UserDepartmentMapper userDepartmentMapper, DepartmentService departmentService) { public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, ExamPaperAnswerMapper examPaperAnswerMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService, ExamPaperDepartmentService examPaperDepartmentService, ExamPaperSubjectService examPaperSubjectService, QuestionSubjectService questionSubjectService, ExamPaperUserService examPaperUserService, UserService userService, UserDepartmentMapper userDepartmentMapper, DepartmentService departmentService) { super(examPaperMapper); this.examPaperMapper = examPaperMapper; this.examPaperAnswerMapper = examPaperAnswerMapper; this.questionMapper = questionMapper; this.textContentService = textContentService; this.questionService = questionService; @@ -596,4 +601,18 @@ return randomNumber; } @Override @Transactional public void missExam(ExamPaperEditRequestVM model) { // 修改原来的试卷时间 if (ObjectUtils.isNotEmpty(model.getLimitDateTime())) { ExamPaper examPaper = new ExamPaper(); examPaper.setId(model.getExamPaperId()); examPaper.setLimitStartTime(DateTimeUtil.parse(model.getLimitDateTime().get(0), DateTimeUtil.STANDER_FORMAT)); examPaper.setLimitEndTime(DateTimeUtil.parse(model.getLimitDateTime().get(1), DateTimeUtil.STANDER_FORMAT)); examPaperMapper.updateByPrimaryKeySelective(examPaper); } // 根据考试id将选择的补考考生的考试成绩设置为无效 examPaperAnswerMapper.setMissExam(model); } } src/main/java/com/mindskip/xzs/service/impl/UserServiceImpl.java
@@ -1,5 +1,6 @@ package com.mindskip.xzs.service.impl; import com.mindskip.xzs.domain.ExamPaper; import com.mindskip.xzs.domain.other.KeyValue; import com.mindskip.xzs.domain.vo.UserVO; import com.mindskip.xzs.exception.BusinessException; @@ -178,4 +179,8 @@ userMapper.setStatus(user); } @Override public User getUserByExam(ExamPaper examPaper) { return userMapper.getUserByExam(examPaper); } } src/main/java/com/mindskip/xzs/viewmodel/admin/exam/ExamPaperEditRequestVM.java
@@ -54,5 +54,6 @@ private String type; private String status; private String menuIds; private Integer examPaperId; } src/main/resources/mapper/ExamPaperAnswerMapper.xml
@@ -231,11 +231,19 @@ where id = #{id,jdbcType=INTEGER} </update> <update id="setMissExam"> update t_exam_paper_answer set invalid = 1 where exam_paper_id = #{examPaperId} and create_user in ( <foreach collection="userIds" item="item" index="index" separator=","> #{item} </foreach> ) </update> <select id="studentPage" resultMap="BaseResultMap" parameterType="com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM"> <select id="studentPage" resultMap="BaseResultMap" parameterType="com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM"> SELECT <include refid="Base_Column_List"/> FROM t_exam_paper_answer src/main/resources/mapper/UserMapper.xml
@@ -494,4 +494,18 @@ tu.id desc </select> <select id="getUserByExam" resultType="com.mindskip.xzs.domain.User"> <![CDATA[ SELECT d.* FROM t_exam_paper a left join t_exam_paper_user b on a.id = b.exam_paper_id and b.deleted = 0 left join t_exam_paper_answer c on a.id = c.exam_paper_id and c.create_user = b.user_id left join t_user d on b.user_id = d.id WHERE a.id = #{id} and (c.id is null or (user_score / paper_score) < 0.6) and b.user_id = #{createUser} ]]> </select> </mapper>