|
@@ -15,6 +15,7 @@ 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;
|
|
@@ -23,12 +24,14 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.RowMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
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.common.util.ErrorMsg;
|
|
|
import cn.com.qmth.examcloud.common.util.excel.ExcelError;
|
|
|
import cn.com.qmth.examcloud.common.util.excel.ExcelReader;
|
|
@@ -329,6 +332,92 @@ public class ExamStudentService {
|
|
|
return msgs;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取重考考生
|
|
|
+ * @param examCriteria
|
|
|
+ * @param pageable
|
|
|
+ * @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.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(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(getSqlSpecification(examCriteria));
|
|
|
+ return this.jdbcTemplate.queryForObject(sql.toString(), Integer.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getSqlSpecification(CommonExamStudent examCriteria){
|
|
|
+ StringBuffer sql = new StringBuffer("");
|
|
|
+ if(!StringUtils.isEmpty(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 = "+examCriteria.getIdentityNumber());
|
|
|
+ }
|
|
|
+ sql.append(" order by t1.id ");
|
|
|
+ return sql.toString();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 生成查询条件
|
|
|
* @param examCriteria
|
|
@@ -612,4 +701,20 @@ public class ExamStudentService {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 设置考生重考信息
|
|
|
+ * @param examStudentId
|
|
|
+ */
|
|
|
+ public void setExamStudentIsReexamine(CommonExamStudent commonExamStudent){
|
|
|
+ if(commonExamStudent.getId() == null){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ExamStudent examStudent = examStudentRepo.findOne(commonExamStudent.getId());
|
|
|
+ if(examStudent!=null){
|
|
|
+ examStudent.setIsReexamine(true);
|
|
|
+ examStudent.setReexamineType(commonExamStudent.getReexamineType());
|
|
|
+ examStudent.setReexamineDetail(commonExamStudent.getReexamineDetail());
|
|
|
+ examStudentRepo.save(examStudent);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|