|
@@ -1,9 +1,5 @@
|
|
|
package cn.com.qmth.examcloud.core.examwork.service.impl;
|
|
|
|
|
|
-import java.io.InputStream;
|
|
|
-import java.sql.ResultSet;
|
|
|
-import java.sql.SQLException;
|
|
|
-import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -16,27 +12,14 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageImpl;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
-import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
-import org.springframework.jdbc.core.RowMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.common.dto.core.Course;
|
|
|
-import cn.com.qmth.examcloud.common.dto.core.Org;
|
|
|
-import cn.com.qmth.examcloud.common.dto.core.Student;
|
|
|
-import cn.com.qmth.examcloud.common.dto.core.User;
|
|
|
-import cn.com.qmth.examcloud.common.dto.core.enums.UserType;
|
|
|
-import cn.com.qmth.examcloud.common.dto.examwork.CommonExamStudent;
|
|
|
import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.base.util.BeanCopierUtil;
|
|
|
-import cn.com.qmth.examcloud.commons.base.util.ErrorMsg;
|
|
|
-import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
|
|
|
-import cn.com.qmth.examcloud.commons.base.util.excel.ExcelReader;
|
|
|
-import cn.com.qmth.examcloud.commons.base.util.excel.ExcelReaderHandle;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.OrgCloudService;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.StudentCloudService;
|
|
@@ -54,17 +37,12 @@ import cn.com.qmth.examcloud.core.examwork.dao.ExamRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.ExamStudentRepo;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamStudentAssembler;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.bean.ExamStudentDTO;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.dao.bean.OrgExamInfoDTO;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.Exam;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamOrgTime;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.entity.ExamStudent;
|
|
|
import cn.com.qmth.examcloud.core.examwork.dao.enums.ExamType;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.ExamStudentService;
|
|
|
import cn.com.qmth.examcloud.core.examwork.service.bean.ExamStudentInfo;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.service.rpc.CourseService;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.service.rpc.OrgService;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.service.rpc.SpecialtyService;
|
|
|
-import cn.com.qmth.examcloud.core.examwork.service.rpc.StudentService;
|
|
|
|
|
|
/**
|
|
|
* 考试学生服务类 Created by songyue on 17/1/14.
|
|
@@ -83,21 +61,6 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
@Autowired
|
|
|
ExamStudentAssembler examStudentAssembler;
|
|
|
|
|
|
- @Autowired
|
|
|
- StudentService studentService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- CourseService courseService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- OrgService orgService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private JdbcTemplate jdbcTemplate;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- SpecialtyService specialtyService;
|
|
|
-
|
|
|
@Autowired
|
|
|
ExamOrgTimeRepo examOrgTimeRepo;
|
|
|
|
|
@@ -213,299 +176,6 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
return examStudentRepo.findByExamId(examId, pageable);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 保存考试学生
|
|
|
- *
|
|
|
- * @param examStudent
|
|
|
- * @return
|
|
|
- */
|
|
|
- public ExamStudent saveExamStudent(String token, ExamStudent examStudent) {
|
|
|
- checkExamStudent(examStudent);
|
|
|
- return saveStudent(token, examStudent);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 导入考试学生
|
|
|
- *
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<ExcelError> importExamStudent(String userToken, Long examId,
|
|
|
- InputStream inputStream) {
|
|
|
- log.info("导入考生开始");
|
|
|
- Exam exam = examRepo.findOne(examId);
|
|
|
- List<ExcelError> excelErrors = new ArrayList<ExcelError>();
|
|
|
- if (exam == null) {
|
|
|
- ExcelError excelError = new ExcelError(1, "请先创建考试");
|
|
|
- excelErrors.add(excelError);
|
|
|
- return excelErrors;
|
|
|
- }
|
|
|
- List<ExamStudent> examStudents = new ArrayList<ExamStudent>();
|
|
|
- ExcelReader excelReader = new ExcelReader(ExamStudentDTO.class);
|
|
|
- excelErrors = excelReader.reader(inputStream, new ExcelReaderHandle() {
|
|
|
- @Override
|
|
|
- public ExcelError handle(Object obj) {
|
|
|
- ExamStudentDTO dto = (ExamStudentDTO) obj;
|
|
|
- dto.setRootOrgId(exam.getRootOrgId());
|
|
|
- dto.setExam(exam);
|
|
|
- ExcelError error = importCheck(userToken, dto);
|
|
|
- if (error == null) {
|
|
|
- examStudents.add(examStudentAssembler.toDomain(dto));
|
|
|
- }
|
|
|
- int stu_num = examStudents.size();
|
|
|
- if (stu_num % 5000 == 0) {
|
|
|
- saveStudentList(userToken, examStudents);
|
|
|
- log.info("已导入" + stu_num + "条数据");
|
|
|
- }
|
|
|
- return error;
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- int stu_num = examStudents.size();
|
|
|
- saveStudentList(userToken, examStudents);
|
|
|
- log.info("已导入" + stu_num + "条数据");
|
|
|
- log.info("导入考生结束");
|
|
|
- return excelErrors;
|
|
|
- }
|
|
|
-
|
|
|
- private void saveStudentList(String token, List<ExamStudent> examStudents) {
|
|
|
- for (ExamStudent examStudent : examStudents) {
|
|
|
- saveStudent(token, examStudent);
|
|
|
- }
|
|
|
- examStudents.removeAll(examStudents);
|
|
|
- }
|
|
|
-
|
|
|
- private ExamStudent saveStudent(String token, ExamStudent examStudent) {
|
|
|
- if (examStudent.getStudentId() == null) {
|
|
|
- Student student = new Student();
|
|
|
- student.setIdentityNumber(examStudent.getIdentityNumber());
|
|
|
- student.setName(examStudent.getName());
|
|
|
- student.setStudentCode(examStudent.getStudentCode());
|
|
|
- student.setRootOrgId(examStudent.getRootOrgId());
|
|
|
- student.setOrgId(examStudent.getOrgId());
|
|
|
- User user = new User();
|
|
|
- user.setOrgId(examStudent.getOrgId());
|
|
|
- user.setEnable(true);
|
|
|
- user.setType(UserType.STUDENT);
|
|
|
- user.setRootOrgId(examStudent.getRootOrgId());
|
|
|
- student.setUser(user);
|
|
|
- student = studentService.addStudent(token, student);
|
|
|
- examStudent.setStudentId(student.getId());
|
|
|
- } else {
|
|
|
- Student student = studentService.getStudent(token, examStudent.getStudentId());
|
|
|
- student.setOrgId(examStudent.getOrgId());
|
|
|
- student.setName(examStudent.getName());
|
|
|
- student.setRootOrgId(examStudent.getRootOrgId());
|
|
|
- student.setStudentCode(examStudent.getStudentCode());
|
|
|
- student.setIdentityNumber(examStudent.getIdentityNumber());
|
|
|
- studentService.updateStudent(token, student);
|
|
|
- }
|
|
|
-
|
|
|
- examStudent.setGraduated(false);
|
|
|
- examStudent.setDegree(false);
|
|
|
- examStudent.setRepair(false);
|
|
|
- return examStudentRepo.save(examStudent);
|
|
|
- }
|
|
|
-
|
|
|
- public void checkExamStudent(ExamStudent examStudent) {
|
|
|
- if (examStudent.getId() != null) {
|
|
|
- if (examStudentRepo.checkExamStuById(examStudent.getExam().getId(),
|
|
|
- examStudent.getRootOrgId(), examStudent.getIdentityNumber(),
|
|
|
- examStudent.getCourseCode(), examStudent.getId()) > 0) {
|
|
|
- throw new RuntimeException("该考生已存在");
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (examStudentRepo.checkExamStu(examStudent.getExam().getId(),
|
|
|
- examStudent.getRootOrgId(), examStudent.getIdentityNumber(),
|
|
|
- examStudent.getCourseCode()) > 0) {
|
|
|
- throw new RuntimeException("该考生已存在");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 考生导入验证
|
|
|
- *
|
|
|
- * @param dto
|
|
|
- * @return
|
|
|
- */
|
|
|
- public ExcelError importCheck(String token, ExamStudentDTO dto) {
|
|
|
- if (StringUtils.isEmpty(dto.getName())) {
|
|
|
- return new ExcelError("姓名不能为空");
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(dto.getStudentCode())
|
|
|
- || StringUtils.isEmpty(dto.getIdentityNumber())) {
|
|
|
- return new ExcelError("学号或身份证号不能为空");
|
|
|
- } else {
|
|
|
- if (!StringUtils.isEmpty(dto.getStudentCode()) && dto.getStudentCode().length() < 6) {
|
|
|
- return new ExcelError("学号至少为6位");
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(dto.getIdentityNumber())
|
|
|
- && dto.getIdentityNumber().length() < 6) {
|
|
|
- return new ExcelError("身份证号至少为6位");
|
|
|
- }
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(dto.getCourseCode())) {
|
|
|
- return new ExcelError("课程代码不能为空");
|
|
|
- }
|
|
|
- if (StringUtils.isEmpty(dto.getOrgCode())) {
|
|
|
- return new ExcelError("学习中心代码不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- Course course = courseService.findByOrgIdAndCode(token, dto.getRootOrgId(),
|
|
|
- dto.getCourseCode());
|
|
|
- if (course == null || !course.getEnable()) {
|
|
|
- return new ExcelError("课程不存在/被禁用");
|
|
|
- }
|
|
|
- dto.setCourseLevel(course.getLevel().toString());
|
|
|
- dto.setCourseName(course.getName());
|
|
|
- Org org = orgService.findByParentIdAndCode(token, dto.getRootOrgId(), dto.getOrgCode());
|
|
|
- if (org == null || !org.getEnable()) {
|
|
|
- return new ExcelError("学习中心不存在/禁用");
|
|
|
- }
|
|
|
- dto.setOrgId(org.getId());
|
|
|
- dto.setOrgName(org.getName());
|
|
|
- stuCheck(dto);
|
|
|
- if (StringUtils.isEmpty(dto.getPaperType())) {
|
|
|
- dto.setPaperType("O");
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- public void stuCheck(ExamStudentDTO dto) {
|
|
|
- ExamStudent examStudent = null;
|
|
|
- if (!StringUtils.isEmpty(dto.getIdentityNumber())) {
|
|
|
- examStudent = examStudentRepo.findFirstByExamId(dto.getExam().getId(),
|
|
|
- dto.getCourseCode(), dto.getIdentityNumber());
|
|
|
- } else {
|
|
|
- examStudent = examStudentRepo.findFirstByExamId(dto.getExam().getId(),
|
|
|
- dto.getCourseCode(), dto.getStudentCode());
|
|
|
- }
|
|
|
- if (examStudent != null) {
|
|
|
- dto.setId(examStudent.getId());
|
|
|
- dto.setStudentId(examStudent.getStudentId());
|
|
|
- dto.setFinished(examStudent.getFinished());
|
|
|
- } else {
|
|
|
- dto.setFinished(false);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 照片检验
|
|
|
- *
|
|
|
- * @param examId
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<ErrorMsg> photoCheck(Long examId) {
|
|
|
- List<ErrorMsg> msgs = new ArrayList<ErrorMsg>();
|
|
|
- List<ExamStudent> examStudents = examStudentRepo.findByExamId(examId);
|
|
|
- for (ExamStudent examStudent : examStudents) {
|
|
|
- ErrorMsg errorMsg = null;
|
|
|
- if (!StringUtils.isEmpty(examStudent.getStudentCode())) {
|
|
|
-
|
|
|
- errorMsg = new ErrorMsg(examStudent.getStudentCode());
|
|
|
- } else if (!StringUtils.isEmpty(examStudent.getIdentityNumber())) {
|
|
|
-
|
|
|
- errorMsg = new ErrorMsg(examStudent.getIdentityNumber());
|
|
|
- }
|
|
|
- if (errorMsg != null) {
|
|
|
- msgs.add(errorMsg);
|
|
|
- }
|
|
|
- }
|
|
|
- return msgs;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取重考考生
|
|
|
- *
|
|
|
- * @param examCriteria
|
|
|
- * @param curPage
|
|
|
- * @param pageSize
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Page<ExamStudent> getReexamineStudent(CommonExamStudent examCriteria, Integer curPage,
|
|
|
- Integer pageSize) {
|
|
|
- if (examCriteria.getExamId() == null) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- StringBuffer sql = new StringBuffer();
|
|
|
- sql.append("select " + "t1.id id," + "t1.exam_id exam_id,"
|
|
|
- + "t1.org_id org_id," + "t1.org_name org_name,"
|
|
|
- + "t1.course_code course_code," + "t1.course_name course_name,"
|
|
|
- + "t1.course_level course_level," + "t1.name name,"
|
|
|
- + "t1.student_code student_code," + "t1.identity_number identity_number"
|
|
|
- + " from ecs_exam_student t1 " + " where t1.exam_id=" + examCriteria.getExamId());
|
|
|
- sql.append(
|
|
|
- " and t1.normal_exam_times >= ( select t2.exam_times from ecs_exam t2 where t2.id = t1.exam_id ) ");
|
|
|
- // 没设置重考的或者设置了重考,重考已完成的
|
|
|
- sql.append(
|
|
|
- " and ((t1.is_reexamine is null OR t1.is_reexamine = 0) OR (t1.is_reexamine = 1 and t1.reexamine_completed = 1)) ");
|
|
|
- sql.append(
|
|
|
- " and NOT EXISTS ( select * from oe_exam_record t3 where t3.exam_student_id = t1.id and t3.status = 'EXAM_ING') ");
|
|
|
- sql.append(getSqlSpecification(examCriteria));
|
|
|
- sql.append(" limit " + (curPage - 1) * pageSize + "," + pageSize);
|
|
|
-
|
|
|
- Exam exam = examRepo.findOne(examCriteria.getExamId());
|
|
|
- List<ExamStudent> examStudents = this.jdbcTemplate.query(sql.toString(),
|
|
|
- new RowMapper<ExamStudent>() {
|
|
|
- @Override
|
|
|
- public ExamStudent mapRow(ResultSet rs, int arg) throws SQLException {
|
|
|
- ExamStudent examStudent = new ExamStudent();
|
|
|
- examStudent.setId(rs.getLong("id"));
|
|
|
- examStudent.setExam(exam);
|
|
|
- examStudent.setOrgId(rs.getLong("org_id"));
|
|
|
- examStudent.setOrgName(rs.getString("org_name"));
|
|
|
- examStudent.setCourseCode(rs.getString("course_code"));
|
|
|
- examStudent.setCourseName(rs.getString("course_name"));
|
|
|
- examStudent.setCourseLevel(rs.getString("course_level"));
|
|
|
- examStudent.setName(rs.getString("name"));
|
|
|
- examStudent.setStudentCode(rs.getString("student_code"));
|
|
|
- examStudent.setIdentityNumber(rs.getString("identity_number"));
|
|
|
- return examStudent;
|
|
|
- }
|
|
|
- });
|
|
|
- int total = countReexamineStudent(examCriteria);
|
|
|
- return new PageImpl<>(examStudents, null, total);
|
|
|
- }
|
|
|
-
|
|
|
- private int countReexamineStudent(CommonExamStudent examCriteria) {
|
|
|
- StringBuffer sql = new StringBuffer();
|
|
|
- sql.append("select count(t1.id) from ecs_exam_student t1 where t1.normal_exam_times = ( "
|
|
|
- + " select t2.exam_times from ecs_exam t2 where t2.id = t1.exam_id " + ")");
|
|
|
- sql.append(" and t1.exam_id=" + examCriteria.getExamId());
|
|
|
- // 没设置重考的或者设置了重考,重考已完成的
|
|
|
- sql.append(
|
|
|
- " and ((t1.is_reexamine is null OR t1.is_reexamine = 0) OR (t1.is_reexamine = 1 and t1.reexamine_completed = 1)) ");
|
|
|
- sql.append(
|
|
|
- " and NOT EXISTS ( select * from oe_exam_record t3 where t3.exam_student_id = t1.id and t3.status = 'EXAM_ING') ");
|
|
|
- sql.append(getSqlSpecification(examCriteria));
|
|
|
- return this.jdbcTemplate.queryForObject(sql.toString(), Integer.class);
|
|
|
- }
|
|
|
-
|
|
|
- private String getSqlSpecification(CommonExamStudent examCriteria) {
|
|
|
- StringBuffer sql = new StringBuffer("");
|
|
|
- if (null != examCriteria.getOrgId()) {
|
|
|
- sql.append(" and t1.org_id = " + examCriteria.getOrgId());
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(examCriteria.getName())) {
|
|
|
- sql.append(" and t1.name LIKE '%" + examCriteria.getName() + "%'");
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(examCriteria.getStudentCode())) {
|
|
|
- sql.append(" and t1.student_code LIKE '%" + examCriteria.getStudentCode() + "%'");
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(examCriteria.getCourseCode())) {
|
|
|
- sql.append(" and t1.course_code = '" + examCriteria.getCourseCode() + "'");
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(examCriteria.getCourseLevel())) {
|
|
|
- sql.append(" and t1.course_level = '" + examCriteria.getCourseLevel() + "'");
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(examCriteria.getIdentityNumber())) {
|
|
|
- sql.append(" and t1.identity_number LIKE '%" + examCriteria.getIdentityNumber() + "%'");
|
|
|
- }
|
|
|
- sql.append(" order by t1.id ");
|
|
|
- return sql.toString();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 生成查询条件
|
|
|
*
|
|
@@ -743,154 +413,6 @@ public class ExamStudentServiceImpl implements ExamStudentService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 学习中心考试进度信息
|
|
|
- *
|
|
|
- * @param examId
|
|
|
- * @param orgCode
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<OrgExamInfoDTO> findOrgExamInfos(String examId, Long orgId) {
|
|
|
- if (StringUtils.isBlank(examId)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- StringBuilder sql = new StringBuilder();
|
|
|
- sql.append("select t.org_id orgid," + " t.org_code orgcode," + " t.org_name orgname,"
|
|
|
- + " count(t.id) allNum,"
|
|
|
- + " sum(case when t.finished = 1 then 1 else 0 end) completedNum "
|
|
|
- + " from ecs_exam_student t" + " where t.exam_id = ?");
|
|
|
- if (orgId != null) {
|
|
|
- sql.append(" and t.org_id = " + orgId);
|
|
|
- }
|
|
|
- sql.append(" group by t.org_id, t.org_name order by t.org_id");
|
|
|
- return jdbcTemplate.query(sql.toString(), new Object[]{examId},
|
|
|
- new RowMapper<OrgExamInfoDTO>() {
|
|
|
- @Override
|
|
|
- public OrgExamInfoDTO mapRow(ResultSet rs, int rowNum) throws SQLException {
|
|
|
- OrgExamInfoDTO orgExamInfoDTO = new OrgExamInfoDTO();
|
|
|
- orgExamInfoDTO.setOrgId(rs.getLong("orgid") + "");
|
|
|
- orgExamInfoDTO.setOrgCode(rs.getString("orgcode"));
|
|
|
- orgExamInfoDTO.setOrgName(rs.getString("orgname"));
|
|
|
- orgExamInfoDTO.setAllNum(rs.getInt("allNum"));
|
|
|
- orgExamInfoDTO.setCompletedNum(rs.getInt("completedNum"));
|
|
|
- if (orgExamInfoDTO.getCompletedNum() == 0) {
|
|
|
- orgExamInfoDTO.setProportion("0");
|
|
|
- } else {
|
|
|
- DecimalFormat df = new DecimalFormat("#.00");
|
|
|
- double proportion = (double) orgExamInfoDTO.getCompletedNum()
|
|
|
- / orgExamInfoDTO.getAllNum();
|
|
|
- orgExamInfoDTO.setProportion(df.format(proportion * 100));
|
|
|
- }
|
|
|
- return orgExamInfoDTO;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据考试和学习中心查询课程
|
|
|
- *
|
|
|
- * @param examId
|
|
|
- * @param orgId
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<Course> findCoursesFromExamStudent(String examId, String orgId) {
|
|
|
- List<Object> paramsList = new ArrayList<Object>();
|
|
|
- if (StringUtils.isEmpty(examId)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- StringBuilder sql = new StringBuilder();
|
|
|
- paramsList.add(examId);
|
|
|
- sql.append("SELECT t.course_code course_code," + "t.course_level course_level,"
|
|
|
- + "t.course_name course_name " + " FROM ecs_exam_student t "
|
|
|
- + " where t.exam_id = ? ");
|
|
|
-
|
|
|
- if (!StringUtils.isEmpty(orgId)) {
|
|
|
- sql.append(" and t.org_id = ? ");
|
|
|
- paramsList.add(orgId);
|
|
|
- }
|
|
|
- sql.append(" group by course_code");
|
|
|
- Object[] params = new Object[paramsList.size()];
|
|
|
- for (int i = 0; i < paramsList.size(); i++) {
|
|
|
- params[i] = paramsList.get(i);
|
|
|
- }
|
|
|
- return jdbcTemplate.query(sql.toString(), params, new RowMapper<Course>() {
|
|
|
- @Override
|
|
|
- public Course mapRow(ResultSet resultSet, int rowNum) throws SQLException {
|
|
|
- Course course = new Course();
|
|
|
- course.setCode(resultSet.getString("course_code"));
|
|
|
- course.setName(resultSet.getString("course_name"));
|
|
|
- return course;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 当考生进入考试时 1.设置考生不缺考 2.考生考试次数加1
|
|
|
- *
|
|
|
- * @param examStuId
|
|
|
- */
|
|
|
- public void updateExamStudentInfo(Long examStuId) {
|
|
|
- ExamStudent examStudent = examStudentRepo.findOne(examStuId);
|
|
|
- examStudent.setFinished(true);
|
|
|
- /**
|
|
|
- * 进入考试时,判断正常考试次数是否小于考试信息(ecs_exam)中的考试次数 如果是,考试次数加一,将重考标识设置成false
|
|
|
- */
|
|
|
- long examTimes = examStudent.getExam().getExamTimes();
|
|
|
- Integer normalExamTimes = examStudent.getNormalExamTimes();
|
|
|
- if (normalExamTimes == null) {
|
|
|
- normalExamTimes = 0;
|
|
|
- }
|
|
|
- if (examTimes > normalExamTimes) {
|
|
|
- examStudent.setNormalExamTimes(normalExamTimes.intValue() + 1);
|
|
|
- examStudent.setIsReexamine(null);
|
|
|
- examStudent.setReexamineCompleted(null);
|
|
|
- }
|
|
|
- // 考生开始重考时,将重考已完成设置为true
|
|
|
- if (examStudent.getIsReexamine() != null && examStudent.getIsReexamine()) {
|
|
|
- examStudent.setReexamineCompleted(true);
|
|
|
- }
|
|
|
- examStudentRepo.save(examStudent);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 设置考生重考信息
|
|
|
- *
|
|
|
- * @param commonExamStudent
|
|
|
- */
|
|
|
- public void setExamStudentIsReexamine(CommonExamStudent commonExamStudent) {
|
|
|
- if (commonExamStudent.getId() == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- ExamStudent examStudent = examStudentRepo.findOne(commonExamStudent.getId());
|
|
|
- if (examStudent != null) {
|
|
|
- examStudent.setIsReexamine(true);
|
|
|
- // 设置了重考,但考生重考未完成,考生开始重考时,该字段改为true
|
|
|
- examStudent.setReexamineCompleted(false);
|
|
|
- examStudent.setReexamineType(commonExamStudent.getReexamineType());
|
|
|
- examStudent.setReexamineDetail(commonExamStudent.getReexamineDetail());
|
|
|
- examStudentRepo.save(examStudent);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 按照数量限制查询考生
|
|
|
- *
|
|
|
- * @param examId
|
|
|
- * 考试ID
|
|
|
- * @param startLimit
|
|
|
- * 数量开始限制
|
|
|
- * @param endLimit
|
|
|
- * 数量结束限制
|
|
|
- * @return
|
|
|
- */
|
|
|
- public List<ExamStudent> getExamStudentByLimit(Long examId, Integer startLimit,
|
|
|
- Integer endLimit) {
|
|
|
- if (examId == null || startLimit == null || endLimit == null || startLimit > endLimit) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- return examStudentRepo.findByLimit(examId, startLimit - 1, (endLimit - startLimit + 1));
|
|
|
- }
|
|
|
-
|
|
|
/*
|
|
|
* 实现
|
|
|
*
|