فهرست منبع

定向科目和知识点处理

mingfu 1 ماه پیش
والد
کامیت
cca1f66ddb

+ 24 - 3
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontPaperController.java

@@ -13,16 +13,21 @@ import com.ruoyi.dz.service.IDzControlService;
 import com.ruoyi.dz.service.IDzSubjectService;
 import com.ruoyi.enums.PaperType;
 import com.ruoyi.learn.domain.LearnPaper;
+import com.ruoyi.learn.domain.LearnStudent;
 import com.ruoyi.learn.domain.LearnTest;
 import com.ruoyi.learn.service.ILearnPaperQuestionService;
 import com.ruoyi.learn.service.ILearnPaperService;
+import com.ruoyi.learn.service.ILearnStudentService;
 import com.ruoyi.learn.service.ILearnTestService;
 import com.ruoyi.web.service.ExamService;
 import com.ruoyi.web.service.LearnTeacherService;
 import com.ruoyi.web.service.PaperService;
+import com.ruoyi.web.service.StudentService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.apache.commons.compress.utils.Lists;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -30,6 +35,8 @@ import org.springframework.web.bind.annotation.RestController;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/front/paper")
@@ -39,14 +46,18 @@ public class FrontPaperController {
     private final IDzSubjectService dzSubjectService;
     private final PaperService paperService;
     private final ILearnTestService testService;
+    private final ILearnStudentService learnStudentService;
     private final LearnTeacherService learnTeacherService;
+    private final StudentService studentService;
 
-    public FrontPaperController(IDzControlService dzControlService, IDzSubjectService dzSubjectService, PaperService paperService, ILearnTestService testService, LearnTeacherService learnTeacherService) {
+    public FrontPaperController(IDzControlService dzControlService, IDzSubjectService dzSubjectService, PaperService paperService, ILearnTestService testService, ILearnStudentService learnStudentService, LearnTeacherService learnTeacherService, StudentService studentService) {
         this.dzControlService = dzControlService;
         this.dzSubjectService = dzSubjectService;
         this.paperService = paperService;
         this.testService = testService;
+        this.learnStudentService = learnStudentService;
         this.learnTeacherService = learnTeacherService;
+        this.studentService = studentService;
     }
 
     @ApiOperation("01 考试批次")
@@ -66,13 +77,23 @@ public class FrontPaperController {
         sCond.setLocations(sysUser.getLocation());
         sCond.setExamTypes(sysUser.getExamType().name());
         List<DzSubject> list = dzSubjectService.selectDzSubjectList(sCond);
-        return AjaxResult2.success(list);
+        if(!directed) {
+            return AjaxResult2.success(list);
+        }
+        LearnStudent learnStudent = learnStudentService.selectLearnStudentByStudentId(SecurityUtils.getUserId());
+        Set<Long> subjectIdSet;
+        if(null == learnStudent || CollectionUtils.isEmpty((subjectIdSet = learnTeacherService.getSubjectIdSet(new Long[] {learnStudent.getMajorPlanId()})))) {
+            return AjaxResult2.success(list);
+        }
+        return AjaxResult2.success(list.stream().filter(t -> subjectIdSet.contains(t.getSubjectId())).collect(Collectors.toList()));
     }
 
     @ApiOperation("03 知识点树")
     @GetMapping(value = "knowledge")
     public AjaxResult getKnowledge(@ApiParam("定向") @RequestParam(defaultValue = "false") boolean directed, @ApiParam("科目ID") Long subjectId) {
-        return AjaxResult.success(learnTeacherService.getKnowledgeTree(subjectId, null, true));
+        LearnStudent learnStudent = learnStudentService.selectLearnStudentByStudentId(SecurityUtils.getUserId());
+        Long[] planIds = null != learnStudent ? new Long[] { learnStudent.getMajorPlanId() } : null;
+        return AjaxResult.success(learnTeacherService.getKnowledgeTree(subjectId, planIds, true));
     }
 
     @ApiOperation("04 取试卷")

+ 10 - 1
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontStudentController.java

@@ -25,6 +25,7 @@ import com.ruoyi.learn.service.ILearnPlanService;
 import com.ruoyi.learn.service.ILearnPlanStudyService;
 import com.ruoyi.sy.service.ISyMajorService;
 import com.ruoyi.system.service.ISysUserService;
+import com.ruoyi.web.service.LearnTeacherService;
 import com.ruoyi.web.service.StudentService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -56,9 +57,10 @@ public class FrontStudentController extends BaseController {
     private final ILearnDirectedKnowledgeService learnDirectedKnowledgeService;
     private final StudentService studentService;
     private final IDzSubjectService dzSubjectService;
+    private final LearnTeacherService learnTeacherService;
 
     public FrontStudentController(IDzControlService dzControlService, IAEnrollUniversityService universityService, ISyMajorService syMajorService, ISysUserService sysUserService,
-                                  ILearnPlanService learnPlanService, ILearnPlanStudyService learnPlanStudyService, IAMarjorPlanService marjorPlanService, ILearnDirectedKnowledgeService learnDirectedKnowledgeService, StudentService studentService, IDzSubjectService dzSubjectService) {
+                                  ILearnPlanService learnPlanService, ILearnPlanStudyService learnPlanStudyService, IAMarjorPlanService marjorPlanService, ILearnDirectedKnowledgeService learnDirectedKnowledgeService, StudentService studentService, IDzSubjectService dzSubjectService, LearnTeacherService learnTeacherService) {
         this.dzControlService = dzControlService;
         this.universityService = universityService;
         this.syMajorService = syMajorService;
@@ -69,6 +71,7 @@ public class FrontStudentController extends BaseController {
         this.learnDirectedKnowledgeService = learnDirectedKnowledgeService;
         this.studentService = studentService;
         this.dzSubjectService = dzSubjectService;
+        this.learnTeacherService = learnTeacherService;
     }
 
     @ApiOperation("02 全部科目")
@@ -165,6 +168,12 @@ public class FrontStudentController extends BaseController {
         SysUser user = new SysUser();
         user.setUserId(SecurityUtils.getLoginUser().getUserId());
         user.setDirectedStudy(directionStudy.toJSONString());
+        if(!directionStudy.isEmpty()) {
+            JSONObject directed = directionStudy.getJSONObject(0);
+            Long planId = directed.getLongValue("majorId");
+            Long universityId = directed.getLongValue("universityId");
+            learnTeacherService.updateDirected(user.getUserId(), universityId, planId);
+        }
         return sysUserService.updateUserProfile(user) > 0 ? AjaxResult.success("更新成功") : AjaxResult.success("无更新");
     }
 

+ 53 - 1
ie-admin/src/main/java/com/ruoyi/web/service/LearnTeacherService.java

@@ -4,7 +4,7 @@ import cn.hutool.core.lang.Dict;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
-import com.ruoyi.common.utils.NumberUtils;
+import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.dz.domain.DzClasses;
 import com.ruoyi.dz.mapper.DzClassesMapper;
@@ -287,6 +287,55 @@ public class LearnTeacherService {
         return buildTree(ktList, knowledgeIdSet, knowCountMap);
     }
 
+    public void updateDirected(Long studentId, Long universityId, Long planId) {
+        LearnStudent upStudent = new LearnStudent();
+        upStudent.setStudentId(studentId);
+        upStudent.setUniversityId(universityId);
+        upStudent.setMajorPlanId(planId);
+        upStudent.setDirectKey("");
+        AMarjorPlan plan = marjorPlanMapper.selectAMarjorPlanById(planId);
+        LearnDirectedKnowledge dkCond = new LearnDirectedKnowledge();
+        dkCond.setUniversityId(plan.getUniversityId());
+        dkCond.setYear(plan.getYear());
+        SysUser sysUser = SecurityUtils.getLoginUser().getUser();
+        dkCond.setLocations(sysUser.getLocation());
+        dkCond.setExamineeTypes(sysUser.getExamType().name());
+        Map<String, LearnDirectedKnowledge> directedKnowledgeMap = learnDirectedKnowledgeMapper.selectLearnDirectedKnowledgeList(dkCond).stream().collect(Collectors.toMap(LearnDirectedKnowledge::getDirectKey, t -> t));
+        LearnDirectedKnowledge directedKnowledge = null;
+        String groupName = StringUtils.trimToEmpty(plan.getMajorGroup());
+        if(null != (directedKnowledge = directedKnowledgeMap.get(groupName + "_" + plan.getMajorName()))) {
+            upStudent.setDirectKey(directedKnowledge.getDirectKey());
+        } else if(null != (directedKnowledge = directedKnowledgeMap.get(groupName))) {
+            upStudent.setDirectKey(directedKnowledge.getDirectKey());
+        }
+        learnStudentMapper.updateLearnStudent(upStudent);
+    }
+
+    public Set<Long> getSubjectIdSet(Long[] planIds) {
+        Set<Long> subjectIdSet = Sets.newHashSet();
+        if(ArrayUtils.isNotEmpty(planIds)) {
+            List<AMarjorPlan> planList = marjorPlanMapper.selectAMarjorPlanByIds(planIds);
+            AMarjorPlan curr = planList.get(0);
+            LearnDirectedKnowledge dkCond = new LearnDirectedKnowledge();
+            dkCond.setUniversityId(curr.getUniversityId());
+            dkCond.setYear(curr.getYear());
+            SysUser sysUser = SecurityUtils.getLoginUser().getUser();
+            dkCond.setLocations(sysUser.getLocation());
+            dkCond.setExamineeTypes(sysUser.getExamType().name());
+            Map<String, LearnDirectedKnowledge> directedKnowledgeMap = learnDirectedKnowledgeMapper.selectLearnDirectedKnowledgeList(dkCond).stream().collect(Collectors.toMap(LearnDirectedKnowledge::getDirectKey, t -> t));
+            LearnDirectedKnowledge directedKnowledge = null;
+            for(AMarjorPlan plan : planList) {
+                String groupName = StringUtils.trimToEmpty(plan.getMajorGroup());
+                if(null != (directedKnowledge = directedKnowledgeMap.get(groupName + "_" + plan.getMajorName()))) {
+                    subjectIdSet.addAll(Stream.of(directedKnowledge.getSubjects().split(",")).map(t -> Long.parseLong(t.trim())).collect(Collectors.toList()));
+                } else if(null != (directedKnowledge = directedKnowledgeMap.get(groupName))) {
+                    subjectIdSet.addAll(Stream.of(directedKnowledge.getSubjects().split(",")).map(t -> Long.parseLong(t.trim())).collect(Collectors.toList()));
+                }
+            }
+        }
+        return subjectIdSet;
+    }
+
     public Set<Long> getKnowledgeIdSet(Long[] planIds) {
         Set<Long> knowledgeIdSet = Sets.newHashSet();
         if(ArrayUtils.isNotEmpty(planIds)) {
@@ -295,6 +344,9 @@ public class LearnTeacherService {
             LearnDirectedKnowledge dkCond = new LearnDirectedKnowledge();
             dkCond.setUniversityId(curr.getUniversityId());
             dkCond.setYear(curr.getYear());
+            SysUser sysUser = SecurityUtils.getLoginUser().getUser();
+            dkCond.setLocations(sysUser.getLocation());
+            dkCond.setExamineeTypes(sysUser.getExamType().name());
             Map<String, LearnDirectedKnowledge> directedKnowledgeMap = learnDirectedKnowledgeMapper.selectLearnDirectedKnowledgeList(dkCond).stream().collect(Collectors.toMap(LearnDirectedKnowledge::getDirectKey, t -> t));
             LearnDirectedKnowledge directedKnowledge = null;
             for(AMarjorPlan plan : planList) {

+ 10 - 1
ie-admin/src/main/java/com/ruoyi/web/service/StudentService.java

@@ -1,11 +1,18 @@
 package com.ruoyi.web.service;
 
 import cn.hutool.core.lang.Dict;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.enums.ExamineeStatus;
 import com.ruoyi.learn.domain.LearnPaper;
+import com.ruoyi.learn.domain.LearnStudent;
 import com.ruoyi.learn.domain.LearnTestStudent;
 import com.ruoyi.learn.mapper.LearnPaperMapper;
+import com.ruoyi.learn.mapper.LearnStudentMapper;
 import com.ruoyi.learn.mapper.LearnTestStudentMapper;
+import com.ruoyi.learn.service.ILearnStudentService;
+import com.ruoyi.system.service.ISysUserService;
 import org.apache.commons.compress.utils.Lists;
 import org.springframework.stereotype.Service;
 
@@ -15,10 +22,12 @@ import java.util.List;
 public class StudentService {
     private final LearnPaperMapper learnPaperMapper;
     private final LearnTestStudentMapper learnTestStudentMapper;
+    private final ILearnStudentService learnStudentService;
 
-    public StudentService(LearnPaperMapper learnPaperMapper, LearnTestStudentMapper learnTestStudentMapper) {
+    public StudentService(LearnPaperMapper learnPaperMapper, LearnTestStudentMapper learnTestStudentMapper, ILearnStudentService learnStudentService) {
         this.learnPaperMapper = learnPaperMapper;
         this.learnTestStudentMapper = learnTestStudentMapper;
+        this.learnStudentService = learnStudentService;
     }
 
     public List<Dict> selectStatsForStudent(Long studentId) {

+ 12 - 0
ie-admin/src/main/java/com/ruoyi/web/service/SysRegisterService.java

@@ -11,6 +11,8 @@ import com.ruoyi.dz.service.IDzCardsService;
 import com.ruoyi.enums.CardStatus;
 import com.ruoyi.enums.UserTypeEnum;
 import com.ruoyi.framework.web.service.TokenService;
+import com.ruoyi.learn.domain.LearnStudent;
+import com.ruoyi.learn.mapper.LearnStudentMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import com.ruoyi.common.constant.CacheConstants;
@@ -51,6 +53,8 @@ public class SysRegisterService
 
     @Autowired
     private TokenService tokenService;
+    @Autowired
+    private LearnStudentMapper learnStudentMapper;
 
     /**
      * 注册
@@ -169,7 +173,15 @@ public class SysRegisterService
         if(null == user.getUserId()) {
             user.setUserType(UserTypeEnum.Card.getVal());
             userService.insertUser(user);
+            LearnStudent upStudent = new LearnStudent();
+            upStudent.setStudentId(user.getUserId());
+            upStudent.setClassId(user.getClassId());
+            learnStudentMapper.insertLearnStudent(upStudent);
         } else {
+            LearnStudent upStudent = new LearnStudent();
+            upStudent.setStudentId(user.getUserId());
+            upStudent.setClassId(user.getClassId());
+            learnStudentMapper.updateLearnStudent(upStudent);
             userService.updateUser(user);
         }
         if(null != card) {