Преглед на файлове

提交成绩统计导出代码

chenken преди 7 години
родител
ревизия
71d19896c4

+ 9 - 0
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/api/ExamStudentApi.java

@@ -158,6 +158,15 @@ public class ExamStudentApi {
         }
         return new ResponseEntity(examStudentService.getAllExamStudent(examStudent), HttpStatus.OK);
     }
+    
+    @ApiOperation(value = "查询所有考试学生带条件", notes = "带条件按照限制查询")
+    @GetMapping("/limit/{examId}/{startLimit}/{endLimit}")
+    public ResponseEntity getExamStudentByLimit(@PathVariable("examId") Long examId,
+									            @PathVariable("startLimit") Integer startLimit,
+									            @PathVariable("endLimit") Integer endLimit){
+        List<ExamStudent> examStudents = examStudentService.getExamStudentByLimit(examId,startLimit,endLimit);
+        return new ResponseEntity(examStudents,HttpStatus.OK);
+    }
 
     @ApiOperation(value = "按ID查询考试学生", notes = "ID查询")
     @GetMapping("/{id}")

+ 17 - 1
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamStudentService.java

@@ -10,16 +10,17 @@ import java.util.List;
 import javax.persistence.criteria.Predicate;
 
 import cn.com.qmth.examcloud.common.util.BeanCopierUtil;
-
 import cn.com.qmth.examcloud.common.util.DateFormat;
 import cn.com.qmth.examcloud.service.examwork.dao.ExamOrgTimeRepo;
 import cn.com.qmth.examcloud.service.examwork.entity.ExamOrgTime;
 import cn.com.qmth.examcloud.service.examwork.enums.ExamType;
+
 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.PageRequest;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.domain.Sort.Direction;
@@ -27,6 +28,7 @@ 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 org.springframework.util.MultiValueMap;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.RequestBody;
 
@@ -794,4 +796,18 @@ public class ExamStudentService {
 			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));
+	}
 }

+ 3 - 0
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/dao/ExamStudentRepo.java

@@ -70,4 +70,7 @@ public interface ExamStudentRepo extends JpaRepository<ExamStudent, Long>, Query
     @Modifying
     @Query("update ExamStudent e set e.finished = ?2 where e.id = ?1")
     void updateForFinished(Long id,Boolean finished);
+    
+    @Query(value = "SELECT * FROM ecs_exam_student t WHERE t.exam_id = ?1 order by id desc limit ?2,?3 ",nativeQuery = true)
+    public List<ExamStudent> findByLimit(Long examId,Integer startLimit,Integer endLimit);
 }