mingfu преди 1 месец
родител
ревизия
5eeaee0efc

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

@@ -1,5 +1,7 @@
 package com.ruoyi.web.controller.learn;
 
+import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.common.annotation.Anonymous;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.AjaxResult2;
@@ -14,10 +16,15 @@ import com.ruoyi.web.service.LearnTeacherService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/learn/teaching")
@@ -26,13 +33,11 @@ public class LearnTeacherController extends BaseController {
     private final IDzControlService dzControlService;
     private final IDzSubjectService dzSubjectService;
     private final LearnTeacherService learnTeacherService;
-    private final IAMarjorPlanService marjorPlanService;
 
-    public LearnTeacherController(IDzControlService dzControlService, IDzSubjectService dzSubjectService, LearnTeacherService learnTeacherService, IAMarjorPlanService marjorPlanService) {
+    public LearnTeacherController(IDzControlService dzControlService, IDzSubjectService dzSubjectService, LearnTeacherService learnTeacherService) {
         this.dzControlService = dzControlService;
         this.dzSubjectService = dzSubjectService;
         this.learnTeacherService = learnTeacherService;
-        this.marjorPlanService = marjorPlanService;
     }
 
     /**
@@ -46,6 +51,43 @@ public class LearnTeacherController extends BaseController {
      -- 9. 设置题型数量(预置题型要求,或人工指定,不指定时平均分配, 题型是针对院校的)
      */
 
+
+    @GetMapping(value = "provinces")
+    @Anonymous
+    @ApiOperation("省份列表")
+    public AjaxResult provinces()
+    {
+        DzControl cond = new DzControl();
+        cond.setIsValid(1);
+        return AjaxResult.success(dzControlService.selectDzControlList(cond).stream().map(t -> {
+            JSONObject o = new JSONObject();
+            o.put("dictValue", t.getLocation());
+            o.put("dictLabel", t.getLocation());
+            return o;
+        }).collect(Collectors.toList()));
+    }
+
+    @GetMapping(value = "examTypes")
+    @Anonymous
+    @ApiOperation("考生类型列表")
+    public AjaxResult examTypes(@RequestParam String location)
+    {
+        DzControl cond = new DzControl();
+        cond.setIsValid(1);
+        cond.setLocation(location);
+        List<DzControl> list = dzControlService.selectDzControlList(cond);
+        String examTypes;
+        if(CollectionUtils.isEmpty(list) || StringUtils.isBlank(examTypes = list.get(0).getExamTypes())) {
+            return AjaxResult.success(Collections.emptyList());
+        }
+        return AjaxResult.success(Arrays.stream(examTypes.split(",")).map(t -> {
+            JSONObject o = new JSONObject();
+            o.put("dictValue", t);
+            o.put("dictLabel", ExamType.valueOf(t).title());
+            return o;
+        }).collect(Collectors.toList()));
+    }
+
     @GetMapping("/classes")
     @ApiOperation("2. 班级列表")
     public AjaxResult classes()
@@ -55,17 +97,17 @@ public class LearnTeacherController extends BaseController {
 
     @GetMapping("/universities")
     @ApiOperation("院校列表")
-    public AjaxResult universities()
+    public AjaxResult universities(@ApiParam("批次ID") Long batchId)
     {
-        return AjaxResult.success(learnTeacherService.selectUniversityList(getUserId()));
+        return AjaxResult.success(learnTeacherService.selectUniversityList(getUserId(), batchId));
     }
 
     @GetMapping("/majors")
     @ApiOperation("专业列表")
-    public AjaxResult majors(@ApiParam("省份") String location, @ApiParam("考生类型") ExamType examType, @RequestParam(required = false) @ApiParam("院校列表") Long universityId)
+    public AjaxResult majors(@ApiParam("省份") String location, @ApiParam("考生类型") ExamType examType, @ApiParam("批次ID") Long batchId, @RequestParam(required = false) @ApiParam("院校列表") Long universityId)
     {
         DzControl control = dzControlService.selectDzControl(location, examType);
-        return AjaxResult.success(learnTeacherService.selectMajorList(universityId, control.getPlanYear()));
+        return AjaxResult.success(learnTeacherService.selectMajorList(universityId, control.getPlanYear(), batchId));
     }
 
     @GetMapping("/subjects")

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

@@ -36,13 +36,13 @@ public class LearnTeacherService {
         return dzClassesMapper.selectClassesForTeacher(teacherId);
     }
 
-    public List<BBusiWishUniversities> selectUniversityList(Long teacherId) {
-        return busiWishUniversitiesMapper.selectUniversityListForTeacher(teacherId);
+    public List<BBusiWishUniversities> selectUniversityList(Long teacherId, Long batchId) {
+        return busiWishUniversitiesMapper.selectUniversityListForTeacher(teacherId, batchId);
     }
 
-    public List<Dict> selectMajorList(Long universityId, Integer year) {
-        return marjorPlanMapper.selectMajorForUniversity(universityId, year).stream().map(t -> Dict.create().set("id", t.getId()).set("majorGroup", t.getMajorGroup())
-                .set("majorName", t.getMajorName()).set("count", t.getPlanTotal())).collect(Collectors.toList());
+    public List<Dict> selectMajorList(Long universityId, Integer year, Long batchId) {
+        return marjorPlanMapper.selectMajorForUniversity(universityId, year, batchId).stream().map(t -> Dict.create().set("id", t.getId()).set("majorGroup", t.getMajorGroup())
+                .set("majorName", t.getMajorName()).set("count", t.getXuefei()).set("total", t.getPlanTotal())).collect(Collectors.toList());
     }
 
     public List<TreeNode> getKnowledgeTree(Long subjectId, Long[] planIds) {

+ 1 - 1
ie-system/src/main/java/com/ruoyi/ie/mapper/AMarjorPlanMapper.java

@@ -14,7 +14,7 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface AMarjorPlanMapper 
 {
-    public List<AMarjorPlan>  selectMajorForUniversity(@Param("universityId") Long universityId, @Param("year") Integer year);
+    public List<AMarjorPlan>  selectMajorForUniversity(@Param("universityId") Long universityId, @Param("year") Integer year, @Param("batchId") Long batchId);
     /**
      * 查询专业计划要求
      * 

+ 1 - 1
ie-system/src/main/java/com/ruoyi/syzy/mapper/BBusiWishUniversitiesMapper.java

@@ -15,7 +15,7 @@ import org.springframework.security.core.parameters.P;
  */
 public interface BBusiWishUniversitiesMapper {
 
-    public List<BBusiWishUniversities> selectUniversityListForTeacher(@Param("teacherId") Long teacherId);
+    public List<BBusiWishUniversities> selectUniversityListForTeacher(@Param("teacherId") Long teacherId, @Param("batchId") Long batchId);
 
 
     public List<BBusiWishUniversities> listMyByPage(String customerCode);

+ 4 - 3
ie-system/src/main/resources/mapper/ie/AMarjorPlanMapper.xml

@@ -39,11 +39,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectMajorForUniversity" parameterType="Map" resultMap="AMarjorPlanResult">
-        SELECT mp.`majorGroup`, mp.`majorName`, COUNT(DISTINCT sl.`student_id`) planTotal
+        SELECT mp.id, mp.`majorGroup`, mp.`majorName`, COUNT(DISTINCT sl.`student_id`) planTotal, COUNT(DISTINCT ts.`id`) xuefei
         FROM `learn_student` sl
-        JOIN `a_marjor_plan` mp ON sl.`major_plan_id` = mp.`id`
+         LEFT JOIN `learn_test_student` ts ON ts.`batch_id` = #{batchId} and ts.`student_id` = sl.`student_id`
+         JOIN `a_marjor_plan` mp ON sl.`major_plan_id` = mp.`id`
         WHERE sl.`university_id` = #{universityId} and mp.year = #{year}
-        GROUP BY mp.`majorGroup`, mp.`majorName`
+        GROUP BY mp.id, mp.`majorGroup`, mp.`majorName`
         ORDER BY mp.`majorGroup`, mp.`majorName`
     </select>
 

+ 6 - 4
ie-system/src/main/resources/mapper/syzy/BBusiWishUniversitiesMapper.xml

@@ -71,12 +71,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         from b_busi_wish_universities
   </sql>
 
-  <select id="selectUniversityListForTeacher" parameterType="Long" resultType="java.lang.Long">
-    SELECT DISTINCT sl.`university_id`, u.`name`
+  <select id="selectUniversityListForTeacher" resultMap="BBusiWishUniversitiesResult">
+    SELECT u.`id`, u.`name`, COUNT(*) collect, SUM(IF(ts.`id` IS NULL, 0, 1)) hits
     FROM `dz_teacher_class` tc
-    JOIN `learn_student` sl ON tc.`class_id` = sl.`class_id`
-    JOIN `b_busi_wish_universities` u ON sl.`university_id` = u.`id`
+           JOIN `learn_student` sl ON tc.`class_id` = sl.`class_id`
+           LEFT JOIN `learn_test_student` ts ON ts.`batch_id` = #{batchId} AND ts.`student_id` = sl.`student_id`
+           JOIN `b_busi_wish_universities` u ON sl.`university_id` = u.`id`
     WHERE tc.`teacher_id` = #{teacherId} AND NOW() &lt; tc.`out_date`
+    GROUP BY sl.`university_id`, u.`name`
   </select>
 
   <select id="listForCourses" parameterType="String" resultType="java.lang.Long">