Browse Source

当更新新计划时,定向的旧计划需要自动忽略

mingfu 1 tháng trước cách đây
mục cha
commit
03b58e30d9

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

@@ -85,7 +85,7 @@ public class FrontPaperController {
         if(directed) {
             LearnStudent learnStudent = learnStudentService.selectLearnStudentByStudentId(sysUser.getUserId());
             if(null != learnStudent) {
-                knowledgeIdSet = learnTeacherService.getKnowledgeIdSet(learnStudent.getMajorPlanId(), sysUser.getExamType().name());
+                knowledgeIdSet = learnTeacherService.getKnowledgeIdSet(learnStudent.getMajorPlanId(), dzControlService.selectDzControl(sysUser).getPlanYear(), sysUser.getExamType().name());
             }
         }
         List<LearnTeacherService.TreeNode> nodeList = learnTeacherService.getKnowledgeTree(sysUser.getExamType().title(), subjectId, knowledgeIdSet, sysUser.getUserId(), questionType);

+ 16 - 6
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontStudentController.java

@@ -42,10 +42,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.validation.ValidationException;
 import java.text.ParseException;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @RestController
@@ -195,7 +192,20 @@ public class FrontStudentController extends BaseController {
     @GetMapping(value = "directed/school")
     public AjaxResult getDirectionSchools() {
         SysUser user = sysUserService.selectUserById(SecurityUtils.getLoginUser().getUserId());
-        return AjaxResult.success(JSONArray.parse(user.getDirectedStudy()));
+        List<JSONObject> resultList = Lists.newArrayList();
+        List<Long> idList = Lists.newArrayList();
+        JSONArray.parse(user.getDirectedStudy()).stream().forEach(t -> {
+            JSONObject o = (JSONObject) t;
+            idList.add(o.getLong("majorId"));
+            resultList.add(o);
+        });
+        if(idList.isEmpty()) {
+            return AjaxResult.success(resultList);
+        }
+        Integer planYear = dzControlService.selectDzControl(VistorContextHolder.getContext()).getPlanYear();
+        Set<Long> idSet = marjorPlanService.selectAMarjorPlanByIds(idList.toArray(new Long[idList.size()])).stream()
+                .filter(t -> t.getMatchYear().equals(planYear)).map(t -> t.getId()).collect(Collectors.toSet());
+        return AjaxResult.success(resultList.stream().filter(t -> idSet.contains(t.getLong("majorId"))));
     }
 
     @ApiOperation("04 保存学生定向院校")
@@ -341,7 +351,7 @@ public class FrontStudentController extends BaseController {
     @GetMapping("record/knowledge")
     public TableDataInfo getRecordKnowledge()
     {
-        List<JSONObject> list = learnStatService.getRecordKnowledge(SecurityUtils.getUserId());
+        List<JSONObject> list = learnStatService.getRecordKnowledge(SecurityUtils.getUserId(), dzControlService.selectDzControl(SecurityUtils.getLoginUser().getUser()).getPlanYear());
         return getDataTable(list);
     }
 

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

@@ -145,7 +145,7 @@ public class FrontTeacherController extends BaseController {
     @GetMapping("record/knowledge/{recordId}")
     public TableDataInfo getRecordKnowledgeDetail(@ApiParam("记录sid") @PathVariable("recordId") Long recordId)
     {
-        return getDataTable(learnStatService.getRecordKnowledge(recordId));
+        return getDataTable(learnStatService.getRecordKnowledge(recordId, null));
     }
 
     @ApiOperation("视频记录")

+ 1 - 1
ie-admin/src/main/java/com/ruoyi/web/controller/learn/LearnTeacherController.java

@@ -101,7 +101,7 @@ public class LearnTeacherController extends BaseController {
     {
         Set<Long> knowledgeIdSet = null;
         if("ExactHand".equals(buildType)) {
-            knowledgeIdSet = learnTeacherService.getKnowledgeIdSet(majorPlanId, examType);
+            knowledgeIdSet = learnTeacherService.getKnowledgeIdSet(majorPlanId, null, examType);
         }
         return AjaxResult.success(learnTeacherService.getKnowledgeTree(examType, subjectId, knowledgeIdSet, null, null));
     }

+ 7 - 3
ie-admin/src/main/java/com/ruoyi/web/service/ExamService.java

@@ -5,10 +5,12 @@ import com.alibaba.fastjson2.util.DateUtils;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+import com.ruoyi.common.core.content.VistorContextHolder;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.enums.ExamType;
 import com.ruoyi.common.enums.UserRegStatus;
 import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.dz.service.IDzControlService;
 import com.ruoyi.dz.service.IDzSubjectService;
 import com.ruoyi.enums.*;
 import com.ruoyi.ie.domain.AMarjorPlan;
@@ -52,8 +54,9 @@ public class ExamService {
     private final PaperService paperService;
     private final IAMarjorPlanService marjorPlanService;
     private final ISysUserService sysUserService;
+    private final IDzControlService dzControlService;
 
-    public ExamService(LearnPaperMapper paperMapper, LearnKnowledgeTreeMapper knowledgeTreeMapper, LearnExamineeMapper examineeMapper, ILearnPaperService learnPaperService, PaperService paperService, IAMarjorPlanService marjorPlanService, LearnAnswerMapper learnAnswerMapper, LearnExamineeMapper learnExamineeMapper, ISysUserService sysUserService, LearnStudentMapper learnStudentMapper, ILearnPlanService learnPlanService, LearnQuestionsMapper learnQuestionsMapper, IDzSubjectService dzSubjectService, LearnWrongBookMapper wrongBookMapper, LearnWrongDetailMapper wrongDetailMapper, LearnKnowledgeCourseMapper learnKnowledgeCourseMapper, LearnTestStudentMapper learnTestStudentMapper) {
+    public ExamService(LearnPaperMapper paperMapper, LearnKnowledgeTreeMapper knowledgeTreeMapper, LearnExamineeMapper examineeMapper, ILearnPaperService learnPaperService, PaperService paperService, IAMarjorPlanService marjorPlanService, LearnAnswerMapper learnAnswerMapper, LearnExamineeMapper learnExamineeMapper, ISysUserService sysUserService, LearnStudentMapper learnStudentMapper, ILearnPlanService learnPlanService, LearnQuestionsMapper learnQuestionsMapper, IDzSubjectService dzSubjectService, LearnWrongBookMapper wrongBookMapper, LearnWrongDetailMapper wrongDetailMapper, LearnKnowledgeCourseMapper learnKnowledgeCourseMapper, LearnTestStudentMapper learnTestStudentMapper, IDzControlService dzControlService) {
         this.paperMapper = paperMapper;
         this.knowledgeTreeMapper = knowledgeTreeMapper;
         this.examineeMapper = examineeMapper;
@@ -71,6 +74,7 @@ public class ExamService {
         this.wrongDetailMapper = wrongDetailMapper;
         this.learnKnowledgeCourseMapper = learnKnowledgeCourseMapper;
         this.learnTestStudentMapper = learnTestStudentMapper;
+        this.dzControlService = dzControlService;
     }
 
     /**
@@ -433,8 +437,8 @@ public class ExamService {
             throw new ValidationException("该专业只考技能展示/实践操作");
         }
         AMarjorPlan plan = marjorPlanService.selectAMarjorPlanById(ls.getMajorPlanId());
-        if(null == plan) {
-            throw new ValidationException("专业id无效");
+        if(null == plan || !plan.getMatchYear().equals(dzControlService.selectDzControl(VistorContextHolder.getContext()).getPlanYear())) {
+            throw new ValidationException("定向没设置或过期,请先重新选择定向");
         }
         LearnExaminee examinee = new LearnExaminee();
         examinee.setStudentId(SecurityUtils.getLoginUser().getUser().getUserId());

+ 2 - 2
ie-admin/src/main/java/com/ruoyi/web/service/LearnStatService.java

@@ -83,9 +83,9 @@ public class LearnStatService {
         return result;
     }
 
-    public List<JSONObject> getRecordKnowledge(Long studentId) {
+    public List<JSONObject> getRecordKnowledge(Long studentId, Integer planYear) {
         LearnStudent learnStudent = learnStudentService.selectLearnStudentByStudentId(studentId);
-        Set<Long> knowledgeIdSet = null != learnStudent ? learnTeacherService.getKnowledgeIdSet(learnStudent.getMajorPlanId(), learnStudent.getExamType()) : Sets.newHashSet(0L);
+        Set<Long> knowledgeIdSet = null != learnStudent ? learnTeacherService.getKnowledgeIdSet(learnStudent.getMajorPlanId(), planYear, learnStudent.getExamType()) : Sets.newHashSet(0L);
         knowledgeIdSet.add(0L);
         List<JSONObject> list = answerMapper.selectKnowledgeStats(Dict.create().set("studentId", studentId).set("knowIds", knowledgeIdSet));
         list.forEach(o -> {

+ 4 - 2
ie-admin/src/main/java/com/ruoyi/web/service/LearnTeacherService.java

@@ -568,7 +568,7 @@ public class LearnTeacherService {
         return subjectIdSet;
     }
 
-    public Set<Long> getKnowledgeIdSet(Long planId, String examType) {
+    public Set<Long> getKnowledgeIdSet(Long planId, Integer year, String examType) {
         if(NumberUtils.isPositive(planId)) {
             SysUser sysUser = SecurityUtils.getLoginUser().getUser();
             List<AMarjorPlan> planList = marjorPlanMapper.selectAMarjorPlanByIds(new Long[] { planId });
@@ -579,7 +579,9 @@ public class LearnTeacherService {
                 examType = null != sysUser.getExamType() ? sysUser.getExamType().name() : ExamType.OHS.name();
             }
             AMarjorPlan plan = planList.get(0);
-            return getStudentKnowledgeIdSet(plan.getMatchYear(), plan, sysUser.getLocation(), examType);
+            if(null == year || plan.getMatchYear().equals(year)) {
+                return getStudentKnowledgeIdSet(plan.getMatchYear(), plan, sysUser.getLocation(), examType);
+            }
         }
         return Sets.newHashSet();
     }

+ 1 - 0
ie-system/src/main/java/com/ruoyi/ie/service/IAMarjorPlanService.java

@@ -18,6 +18,7 @@ public interface IAMarjorPlanService
      * @return 专业计划要求
      */
     public AMarjorPlan selectAMarjorPlanById(Long id);
+    List<AMarjorPlan> selectAMarjorPlanByIds(Long[] ids);
 
     /**
      * 查询专业计划要求列表

+ 6 - 0
ie-system/src/main/java/com/ruoyi/ie/service/impl/AMarjorPlanServiceImpl.java

@@ -31,6 +31,12 @@ public class AMarjorPlanServiceImpl implements IAMarjorPlanService
         return aMarjorPlanMapper.selectAMarjorPlanById(id);
     }
 
+    @Override
+    public List<AMarjorPlan> selectAMarjorPlanByIds(Long[] ids)
+    {
+        return aMarjorPlanMapper.selectAMarjorPlanByIds(ids);
+    }
+
     /**
      * 查询专业计划要求列表
      *