Ver Fonte

getCourseInfoByExamRecordDataId

deason há 3 anos atrás
pai
commit
8da8e2b669

+ 8 - 3
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/controller/ExamControlController.java

@@ -5,6 +5,7 @@ import cn.com.qmth.examcloud.commons.exception.StatusException;
 import cn.com.qmth.examcloud.commons.util.Util;
 import cn.com.qmth.examcloud.core.oe.student.base.utils.Check;
 import cn.com.qmth.examcloud.core.oe.student.bean.*;
+import cn.com.qmth.examcloud.core.oe.student.bean.client.CourseInfo;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamControlService;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamFileAnswerService;
 import cn.com.qmth.examcloud.core.oe.student.service.ExamRecordDataService;
@@ -411,9 +412,13 @@ public class ExamControlController extends ControllerSupport {
         examControlService.switchScreen(examRecordDataId);
     }
 
-    @GetMapping("/courseName/{id}")
-    public String courseName(@PathVariable Long id) {
-        return examRecordDataService.findCourseNameById(id);
+    @GetMapping("/courseName/{examRecordDataId}")
+    public String courseName(@PathVariable Long examRecordDataId) {
+        CourseInfo info = examRecordDataService.getCourseInfo(examRecordDataId);
+        if (info != null) {
+            return info.getCourseName();
+        }
+        return null;
     }
 
 }

+ 6 - 8
examcloud-core-oe-student-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/student/api/controller/client/ExamProcessController.java

@@ -6,10 +6,7 @@ import cn.com.qmth.examcloud.commons.util.FileUtil;
 import cn.com.qmth.examcloud.commons.util.JsonMapper;
 import cn.com.qmth.examcloud.core.oe.student.base.utils.Check;
 import cn.com.qmth.examcloud.core.oe.student.bean.*;
-import cn.com.qmth.examcloud.core.oe.student.bean.client.FaceCaptureResult;
-import cn.com.qmth.examcloud.core.oe.student.bean.client.FaceCompareResult;
-import cn.com.qmth.examcloud.core.oe.student.bean.client.FaceLiveVerifyInfo;
-import cn.com.qmth.examcloud.core.oe.student.bean.client.FaceLiveVerifyResult;
+import cn.com.qmth.examcloud.core.oe.student.bean.client.*;
 import cn.com.qmth.examcloud.core.oe.student.service.*;
 import cn.com.qmth.examcloud.support.Constants;
 import cn.com.qmth.examcloud.support.examing.ExamQuestion;
@@ -22,6 +19,7 @@ import cn.com.qmth.examcloud.web.filestorage.FileStoragePathEnvInfo;
 import cn.com.qmth.examcloud.web.filestorage.YunPathInfo;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
 import cn.com.qmth.examcloud.web.support.ControllerSupport;
+import cn.com.qmth.examcloud.web.support.Naked;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -149,10 +147,10 @@ public class ExamProcessController extends ControllerSupport {
         examRecordQuestionsService.submitQuestionAnswer(user.getUserId(), examQuestionInfos, referer, agent);
     }
 
-    @ApiOperation(value = "获取课程名称")
-    @PostMapping("/courseName/{id}")
-    public String courseName(@PathVariable Long id) {
-        return examRecordDataService.findCourseNameById(id);
+    @ApiOperation(value = "获取课程信息")
+    @PostMapping("/getCourseInfo/{examRecordDataId}")
+    public CourseInfo courseInfo(@PathVariable Long examRecordDataId) {
+        return examRecordDataService.getCourseInfo(examRecordDataId);
     }
 
     @ApiOperation(value = "违纪(非法考生端应用)")

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

@@ -1,14 +1,13 @@
 package cn.com.qmth.examcloud.core.oe.student.dao;
 
-import java.util.List;
-
+import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamRecordDataEntity;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 import org.springframework.data.jpa.repository.Modifying;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
 
-import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamRecordDataEntity;
+import java.util.List;
 
 /**
  * @Description 考试记录
@@ -18,9 +17,10 @@ import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamRecordDataEntity;
  */
 @Repository
 public interface ExamRecordDataRepo extends JpaRepository<ExamRecordDataEntity, Long>, JpaSpecificationExecutor<ExamRecordDataEntity> {
+
     @Query(value = "select *  from ec_oes_exam_record_data where (batch_num is null or batch_num!=?1) and id>?2  "
-    		+ " and (sync_status is null or sync_status ='UNSYNC') and exam_record_status!='EXAM_ERROR' "
-    		+ " order by id limit ?3 ",nativeQuery = true)
+            + " and (sync_status is null or sync_status ='UNSYNC') and exam_record_status!='EXAM_ERROR' "
+            + " order by id limit ?3 ", nativeQuery = true)
     List<ExamRecordDataEntity> getLimitExamRecordDataList(Long batchNum, Long startId, Integer size);
 
     @Modifying
@@ -35,10 +35,10 @@ public interface ExamRecordDataRepo extends JpaRepository<ExamRecordDataEntity,
     @Query(value = "update ec_oes_exam_record_data set sync_status=?1 where id=?2", nativeQuery = true)
     int updateExamRecordSyncStatusById(String syncStatus, Long id);
 
-    @Query(value = "SELECT c.name from ec_oes_exam_record_data d LEFT JOIN ec_b_course c ON d.course_id = c.id " +
-            "WHERE d.id = ?1", nativeQuery = true)
-    String findCourseNameById(Long id);
-    
+    @Query(value = "SELECT course_id from ec_oes_exam_record_data WHERE id = ?1", nativeQuery = true)
+    Long findCourseIdByExamRecordDataId(Long examRecordDataId);
+
     @Query(value = "select t.id from ec_oes_exam_record_data t where t.base_paper_id=?1 limit 1", nativeQuery = true)
     Long getRecordIdByPaperId(String basePaperId);
+
 }

+ 43 - 0
examcloud-core-oe-student-service/src/main/java/cn/com/qmth/examcloud/core/oe/student/bean/client/CourseInfo.java

@@ -0,0 +1,43 @@
+package cn.com.qmth.examcloud.core.oe.student.bean.client;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+import io.swagger.annotations.ApiModelProperty;
+
+public class CourseInfo implements JsonSerializable {
+
+    private static final long serialVersionUID = 3567311334163339241L;
+
+    @ApiModelProperty(value = "课程ID")
+    private Long courseId;
+
+    @ApiModelProperty(value = "课程代码")
+    private String courseCode;
+
+    @ApiModelProperty(value = "课程名称")
+    private String courseName;
+
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+}

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

@@ -4,6 +4,7 @@ import cn.com.qmth.examcloud.core.oe.student.api.request.*;
 import cn.com.qmth.examcloud.core.oe.student.api.response.CalcExamScoreResp;
 import cn.com.qmth.examcloud.core.oe.student.api.response.CalcFaceBiopsyResultResp;
 import cn.com.qmth.examcloud.core.oe.student.api.response.CheckPaperInExamResp;
+import cn.com.qmth.examcloud.core.oe.student.bean.client.CourseInfo;
 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;
@@ -75,7 +76,7 @@ public interface ExamRecordDataService {
      */
     void updatePartialExamRecord(UpdatePartialExamRecordReq req);
 
-    String findCourseNameById(Long id);
+    CourseInfo getCourseInfo(Long examRecordDataId);
 
     CheckPaperInExamResp checkPaperInExam(CheckPaperInExamReq req);
 

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

@@ -4,11 +4,16 @@ import cn.com.qmth.examcloud.api.commons.enums.ExamSpecialSettingsType;
 import cn.com.qmth.examcloud.api.commons.enums.ExamStageStartExamStatus;
 import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
+import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
+import cn.com.qmth.examcloud.core.basic.api.request.GetCoursesByIdListReq;
+import cn.com.qmth.examcloud.core.basic.api.response.GetCoursesByIdListResp;
 import cn.com.qmth.examcloud.core.oe.student.api.request.*;
 import cn.com.qmth.examcloud.core.oe.student.api.response.CalcExamScoreResp;
 import cn.com.qmth.examcloud.core.oe.student.api.response.CalcFaceBiopsyResultResp;
 import cn.com.qmth.examcloud.core.oe.student.api.response.CheckPaperInExamResp;
 import cn.com.qmth.examcloud.core.oe.student.base.utils.QuestionTypeUtil;
+import cn.com.qmth.examcloud.core.oe.student.bean.client.CourseInfo;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamFaceLiveVerifyRepo;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamFaceLivenessVerifyRepo;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamRecordDataRepo;
@@ -38,6 +43,7 @@ import cn.com.qmth.examcloud.support.examing.ExamingSession;
 import cn.com.qmth.examcloud.support.helper.FaceBiopsyHelper;
 import cn.com.qmth.examcloud.support.redis.RedisKeyHelper;
 import cn.com.qmth.examcloud.web.redis.RedisClient;
+import com.google.common.collect.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -81,6 +87,9 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     @Autowired
     private ExamStageCloudService examStageCloudService;
 
+    @Autowired
+    private CourseCloudService courseCloudService;
+
     @Transactional
     @Override
     public ExamRecordData createExamRecordData(ExamingSession examingSession, ExamSettingsCacheBean examBean,
@@ -399,8 +408,26 @@ public class ExamRecordDataServiceImpl implements ExamRecordDataService {
     }
 
     @Override
-    public String findCourseNameById(Long id) {
-        return examRecordDataRepo.findCourseNameById(id);
+    public CourseInfo getCourseInfo(Long examRecordDataId) {
+        Long courseId = examRecordDataRepo.findCourseIdByExamRecordDataId(examRecordDataId);
+        if (courseId == null) {
+            throw new StatusException("考试记录不存在!");
+        }
+
+        GetCoursesByIdListReq req = new GetCoursesByIdListReq();
+        req.setCourseIdList(Lists.newArrayList(courseId));
+        GetCoursesByIdListResp resp = courseCloudService.getCoursesByIdList(req);
+        if (CollectionUtils.isEmpty(resp.getCourseList())) {
+            throw new StatusException("课程不存在!");
+        }
+
+        CourseBean bean = resp.getCourseList().get(0);
+
+        CourseInfo info = new CourseInfo();
+        info.setCourseId(bean.getId());
+        info.setCourseCode(bean.getCode());
+        info.setCourseName(bean.getName());
+        return info;
     }
 
     /**