Prechádzať zdrojové kódy

考试记录遍历接口

xiatian 5 rokov pred
rodič
commit
48fa074669

+ 54 - 0
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/provider/ExamRecordDataCloudServiceProvider.java

@@ -0,0 +1,54 @@
+package cn.com.qmth.examcloud.core.oe.student.api.provider;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import cn.com.qmth.examcloud.core.oe.student.api.ExamRecordDataCloudService;
+import cn.com.qmth.examcloud.core.oe.student.api.request.GetExamRecordDataIdsReq;
+import cn.com.qmth.examcloud.core.oe.student.api.request.UpdateExamRecordDataBatchNumReq;
+import cn.com.qmth.examcloud.core.oe.student.api.response.GetExamRecordDataIdsResp;
+import cn.com.qmth.examcloud.core.oe.student.api.response.UpdateExamRecordDataBatchNumResp;
+import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+@Api(tags = "考试记录接口")
+@RestController
+@RequestMapping("${$rmp.cloud.oe.student}/examRecordData")
+public class ExamRecordDataCloudServiceProvider extends ControllerSupport implements ExamRecordDataCloudService{
+
+	
+	/**
+     * 
+     */
+    private static final long serialVersionUID = 6142107111834463854L;
+    @Autowired
+	private ExamRecordDataService examRecordDataService;
+	
+	@Override
+	@ApiOperation(value = "批量获取考试记录ID")
+	@PostMapping("/getExamRecordDataIds")
+	public GetExamRecordDataIdsResp getExamRecordDataIds(@RequestBody GetExamRecordDataIdsReq req) {
+		GetExamRecordDataIdsResp res = new GetExamRecordDataIdsResp();
+		List<Long> ids=examRecordDataService.getExamRecordDataIds(req);
+		res.setExamRecordDataIds(ids);
+		return res;
+	}
+	
+    @ApiOperation(value = "批量修改考试记录batchNum")
+    @PostMapping("/updateBatchNum")
+    @Override
+    public UpdateExamRecordDataBatchNumResp updateExamRecordDataBatchNum(@RequestBody UpdateExamRecordDataBatchNumReq req) {
+        examRecordDataService.updateExamRecordDataBatchNum(req);
+        UpdateExamRecordDataBatchNumResp res=new UpdateExamRecordDataBatchNumResp();
+        return res;
+    }
+
+
+}

+ 5 - 0
examcloud-core-oe-student-base/pom.xml

@@ -56,6 +56,11 @@
             <artifactId>examcloud-core-oe-task-api-client</artifactId>
             <version>${examcloud.version}</version>
         </dependency>
+        <dependency>
+            <groupId>cn.com.qmth.examcloud.rpc</groupId>
+            <artifactId>examcloud-core-oe-student-api-client</artifactId>
+            <version>${examcloud.version}</version>
+        </dependency>
         <dependency>
             <groupId>cn.com.qmth.examcloud.rpc</groupId>
             <artifactId>examcloud-global-api</artifactId>

+ 19 - 10
examcloud-core-oe-student-dao/src/main/java/cn/com/qmth/examcloud/core/oe/student/dao/ExamRecordDataRepo.java

@@ -1,6 +1,7 @@
 package cn.com.qmth.examcloud.core.oe.student.dao;
 
-import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamRecordDataEntity;
+import java.util.List;
+
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
@@ -8,7 +9,7 @@ import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.List;
+import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamRecordDataEntity;
 
 /**
  * @Description 考试记录
@@ -22,7 +23,7 @@ public interface ExamRecordDataRepo extends JpaRepository<ExamRecordDataEntity,
     public List<ExamRecordDataEntity> findByExamStudentId(Long examStudentId);
 
     @Query(value = "select erd.* " +
-            "from ec_oe_exam_record_data erd " +
+            "from ec_oes_exam_record_data erd " +
             "where erd.exam_record_status in('EXAM_END','EXAM_OVERDUE') " +
             "and erd.is_illegality=0 and (is_warn=0 or is_warn=1  and erd.is_audit=1) and erd.exam_student_id in ?1", nativeQuery = true)
     public List<ExamRecordDataEntity> findByExamStudentIdList(List<Long> examStudentIdList);
@@ -40,17 +41,17 @@ public interface ExamRecordDataRepo extends JpaRepository<ExamRecordDataEntity,
      */
     @javax.transaction.Transactional
     @Modifying
-    @Query(nativeQuery = true, value = "update ec_oe_exam_record_data set student_name = ?2,student_code = ?3,info_collector=?4 where exam_student_id = ?1")
+    @Query(nativeQuery = true, value = "update ec_oes_exam_record_data set student_name = ?2,student_code = ?3,info_collector=?4 where exam_student_id = ?1")
     public void syncUpdateExamStudentInfo(Long examStudentId, String studentName, String studentCode, String infoCollector);
 
     @javax.transaction.Transactional
     @Modifying
-    @Query(nativeQuery = true, value = "update ec_oe_exam_record_data set student_name = ?2  where student_id = ?1")
+    @Query(nativeQuery = true, value = "update ec_oes_exam_record_data set student_name = ?2  where student_id = ?1")
     public void updateStudentName(Long studentId, String studentName);
 
     @javax.transaction.Transactional
     @Modifying
-    @Query(nativeQuery = true, value = "update ec_oe_exam_record_data set course_level = ?2 where course_id = ?1")
+    @Query(nativeQuery = true, value = "update ec_oes_exam_record_data set course_level = ?2 where course_id = ?1")
     public void updateCourse(Long courseId, String courseLevel);
 
     /**
@@ -59,7 +60,7 @@ public interface ExamRecordDataRepo extends JpaRepository<ExamRecordDataEntity,
      * @param studentId
      * @return
      */
-    @Query(value = " select * from ec_oe_exam_record_data t1 " +
+    @Query(value = " select * from ec_oes_exam_record_data t1 " +
             " where t1.student_id = ?1  " +
             " and t1.exam_record_status = 'EXAM_ING' " +
             " and t1.exam_type = 'ONLINE'", nativeQuery = true)
@@ -74,7 +75,7 @@ public interface ExamRecordDataRepo extends JpaRepository<ExamRecordDataEntity,
      */
     @Transactional
     @Modifying
-    @Query(value = "update ec_oe_exam_record_data set exam_record_questions_id=?1 where id=?2", nativeQuery = true)
+    @Query(value = "update ec_oes_exam_record_data set exam_record_questions_id=?1 where id=?2", nativeQuery = true)
     int updateExamRecordDataQuestionIdById(String examRecordQuestionId, Long id);
 
     /**
@@ -86,11 +87,19 @@ public interface ExamRecordDataRepo extends JpaRepository<ExamRecordDataEntity,
      */
     @Transactional
     @Modifying
-    @Query(value = "update ec_oe_exam_record_data set face_verify_result = ?1  where student_id = ?2", nativeQuery = true)
+    @Query(value = "update ec_oes_exam_record_data set face_verify_result = ?1  where student_id = ?2", nativeQuery = true)
     int updateFaceVerifyResult(String faceVerifyResult, Long id);
 
-    @Query(value = "select * from ec_oe_exam_record_data " +
+    @Query(value = "select * from ec_oes_exam_record_data " +
             "where exam_record_status in('EXAM_END','EXAM_OVERDUE') and is_illegality=0 and (is_warn=0 or is_warn=1  and is_audit=1) " +
             "and exam_id=?1 and id>=?2 order by id asc limit ?3", nativeQuery = true)
     List<ExamRecordDataEntity> findLimitedDataByExamIdAndIdMoreThan(Long examId, Long startExamRecordId, int rowCount);
+    
+    
+    @Query(value = "select *  from ec_oes_exam_record_data where batch_num!=?1 and id>?2 order by id limit ?3",nativeQuery = true)
+    List<ExamRecordDataEntity> getLimitExamRecordDataList(Long batchNum, Long startId, Integer size);
+    
+    @Modifying
+    @Query(value = "update ec_oes_exam_record_data set batch_num=?1 where id=?2", nativeQuery = true)
+    int updateBatchNumById(Long batchNum, Long id);
 }

+ 8 - 2
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/ExamRecordDataService.java

@@ -1,7 +1,9 @@
 package cn.com.qmth.examcloud.core.oe.student.service;
 
-import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
-import cn.com.qmth.examcloud.examwork.api.bean.ExamBean;
+import java.util.List;
+
+import cn.com.qmth.examcloud.core.oe.student.api.request.GetExamRecordDataIdsReq;
+import cn.com.qmth.examcloud.core.oe.student.api.request.UpdateExamRecordDataBatchNumReq;
 import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
 import cn.com.qmth.examcloud.support.examing.ExamRecordData;
@@ -49,5 +51,9 @@ public interface ExamRecordDataService {
      * @param examRecordDataId
      */
     public void deleteExamRecordDataCache(Long examRecordDataId);
+    
+    public List<Long> getExamRecordDataIds(GetExamRecordDataIdsReq req);
+    
+    public void updateExamRecordDataBatchNum(UpdateExamRecordDataBatchNumReq req);
 
 }

+ 44 - 1
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/service/impl/ExamRecordDataServiceImpl.java

@@ -1,19 +1,24 @@
 package cn.com.qmth.examcloud.core.oe.student.service.impl;
 
 import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
 
-import cn.com.qmth.examcloud.support.enums.SyncStatus;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.oe.student.api.request.GetExamRecordDataIdsReq;
+import cn.com.qmth.examcloud.core.oe.student.api.request.UpdateExamRecordDataBatchNumReq;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamRecordDataRepo;
 import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamRecordDataEntity;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
 import cn.com.qmth.examcloud.support.cache.bean.CourseCacheBean;
 import cn.com.qmth.examcloud.support.cache.bean.ExamSettingsCacheBean;
 import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
+import cn.com.qmth.examcloud.support.enums.SyncStatus;
 import cn.com.qmth.examcloud.support.examing.ExamRecordData;
 import cn.com.qmth.examcloud.support.examing.ExamingSession;
 import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
@@ -127,4 +132,42 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
         bean.setSyncStatus(et.getSyncStatus());
         return bean;
     }
+
+    @Override
+    public List<Long> getExamRecordDataIds(GetExamRecordDataIdsReq req) {
+        Long startId=req.getStartId();
+        Long batchNum=req.getBatchNum();
+        Integer size=req.getSize();
+        if(startId==null) {
+            throw new StatusException("1001", "startId 不能为空"); 
+        }
+        if(batchNum==null) {
+            throw new StatusException("1002", "batchNum 不能为空"); 
+        }
+        if(size==null) {
+            throw new StatusException("1003", "size 不能为空"); 
+        }
+        if(size>200) {
+            throw new StatusException("1004", "size 最大为200"); 
+        }
+        List<ExamRecordDataEntity> list= examRecordDataRepo.getLimitExamRecordDataList(batchNum, startId, size);
+        List<Long> ids=list.stream().map(et->et.getId()).collect(Collectors.toList());
+        return ids;
+    }
+
+    @Transactional
+    @Override
+    public void updateExamRecordDataBatchNum(UpdateExamRecordDataBatchNumReq req) {
+        List<Long> ids=req.getIds();
+        Long batchNum=req.getBatchNum();
+        if(ids==null) {
+            throw new StatusException("2001", "ids 不能为空"); 
+        }
+        if(batchNum==null) {
+            throw new StatusException("2002", "batchNum 不能为空"); 
+        }
+        for(Long id:ids) {
+            examRecordDataRepo.updateBatchNumById(batchNum, id);
+        }
+    }
 }