Bladeren bron

考试业务功能接入按条件检索学生的api

zhaosongshan 7 maanden geleden
bovenliggende
commit
bcd50c1c53

+ 1 - 1
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/domain/ExamPaper.java

@@ -20,7 +20,7 @@ public class ExamPaper implements Serializable {
     private Integer subjectId;
 
     /**
-     * 试卷类型( 1.固定试卷 2.章节作业 3.章节测验 4.时段试卷 5.调查问卷 6.任务试卷 )
+     * 试卷类型( 1.固定试卷 2.章节作业 3.章节测验 4.时段试卷 5.调查问卷  )
      */
     private Integer paperType;
 

+ 13 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/domain/exam/TExamAddParam.java

@@ -68,4 +68,17 @@ public class TExamAddParam {
     /** 考试类型 1 考试 2 章节测验 3 调查问卷  */
     @ApiModelProperty(value = "考试类型", position = 12)
     private String examType;
+
+    /** 班级ID 仅入参 */
+    @ApiModelProperty(value = "班级ID", position = 13)
+    private String gradesId;
+
+    /** 课程ID 仅入参 */
+    @ApiModelProperty(value = "课程ID", position = 14)
+    private String courseId;
+
+    /** 课时ID 仅入参 */
+    @ApiModelProperty(value = "课时ID", position = 14)
+    private String hourId;
+
 }

+ 46 - 4
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/service/impl/TExamServiceImpl.java

@@ -32,6 +32,7 @@ import vip.xiaonuo.common.enums.CommonSortOrderEnum;
 import vip.xiaonuo.common.exception.CommonException;
 import vip.xiaonuo.common.page.CommonPageRequest;
 import vip.xiaonuo.dev.api.DevJobApi;
+import vip.xiaonuo.disk.api.NetDiskApi;
 import vip.xiaonuo.exam.domain.CourseChapterPaper;
 import vip.xiaonuo.exam.domain.ExamPaper;
 import vip.xiaonuo.exam.domain.TExam;
@@ -45,9 +46,8 @@ import vip.xiaonuo.exam.mapper.TExamMapper;
 import vip.xiaonuo.exam.service.ExamPaperService;
 import vip.xiaonuo.exam.service.TExamService;
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+
 import vip.xiaonuo.exam.utility.DateTimeUtil;
 
 /**
@@ -69,6 +69,9 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
     @Resource
     private DevJobApi devJobApi;
 
+    @Resource
+    private NetDiskApi netDiskApi;
+
     @Override
     public Page<TExam> page(TExamPageParam tExamPageParam) {
         QueryWrapper<TExam> queryWrapper = new QueryWrapper<>();
@@ -109,7 +112,42 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
             tExamAddParam.setEndTime(examPaper.getLimitEndTime());
         }
         TExam tExam = BeanUtil.toBean(tExamAddParam, TExam.class);
-        tExam.setStudentIds("1935565895337304066");
+
+        boolean query = false;
+        Map<String, Object> map = new HashMap<>();
+        if(tExamAddParam.getChapterId() != null && !tExamAddParam.getChapterId().isEmpty()){
+            map.put("chapterId",tExamAddParam.getChapterId());
+            query = true;
+        }
+        if(tExamAddParam.getGradesId() != null && !tExamAddParam.getGradesId().isEmpty()){
+            map.put("gradesId",tExamAddParam.getGradesId());
+            query = true;
+        }
+        if(tExamAddParam.getCourseId() != null && !tExamAddParam.getCourseId().isEmpty()){
+            map.put("courseId",tExamAddParam.getCourseId());
+            query = true;
+        }
+        if(tExamAddParam.getHourId() != null && !tExamAddParam.getHourId().isEmpty()){
+            map.put("hourId",tExamAddParam.getHourId());
+            query = true;
+        }
+        if(query){
+            JSONObject students = netDiskApi.downList(map);
+            if(students != null && students.getIntValue("code") == 200){
+                List<String> studentIds = new ArrayList<String>();
+                if(!students.getJSONArray("data").isEmpty()){
+                    students.getJSONArray("data").forEach(item -> {
+                        JSONObject student = (JSONObject) item;
+                        studentIds.add(student.getString("ACCOUNT"));
+                    });
+                }
+                String studentIdsStr = String.join(",", studentIds);
+                tExam.setStudentIds(studentIdsStr);
+            }else{
+                throw new CommonException("没有找到学生信息!!!");
+            }
+        }
+
         if(tExam.getExamType() == null){
             if(examPaper.getPaperType() == ExamPaperTypeEnum.Survey.getCode()){
                 tExam.setExamType("3"); // 调查问卷
@@ -161,6 +199,7 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
             cp.setChapterId(tExamEditParam.getChapterId());
             cp.setPaperId(tExamEditParam.getPaperId());
             courseChapterPaperMapper.add(cp);
+            tExam.setExamType("2"); // 2 章节测验
         }
 
         if(tExamEditParam.getPaperId() != null && !tExamEditParam.getPaperId().isEmpty()){
@@ -170,6 +209,9 @@ public class TExamServiceImpl extends ServiceImpl<TExamMapper, TExam> implements
                 tExamEditParam.setEndTime(examPaper.getLimitEndTime());
                 updateJob = true;
             }
+            if(ExamPaperTypeEnum.Survey.getCode() == examPaper.getPaperType()){
+                tExam.setExamType("3"); // 3 调查问卷
+            }
         }
 
         if(updateJob){