caozixuan 2 жил өмнө
parent
commit
9f26f63215

+ 2 - 5
paper-library-business/src/main/java/com/qmth/paper/library/business/enums/DictionaryEnum.java

@@ -8,12 +8,9 @@ import java.util.Objects;
  * @Date: 2021-11-02
  */
 public enum DictionaryEnum {
-    SEMESTER("学期"),
-    COLLEGE("学生学院"),
+    COLLEGE("学院"),
     MAJOR("专业"),
-    CLAZZ("班级"),
-    ALL_CLAZZ("教学班和基础班"),
-    STUDENT("学生");
+    CLAZZ("班级");
     private final String desc;
 
     DictionaryEnum(String desc) {

+ 61 - 4
paper-library/src/main/java/com/qmth/paper/library/api/ConditionController.java

@@ -1,28 +1,35 @@
 package com.qmth.paper.library.api;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.paper.library.business.bean.result.DictionaryResult;
 import com.qmth.paper.library.business.bean.result.EditResult;
 import com.qmth.paper.library.business.bean.result.SelectResult;
+import com.qmth.paper.library.business.enums.DictionaryEnum;
 import com.qmth.paper.library.business.service.PaperArchivesService;
 import com.qmth.paper.library.business.service.PaperArchivesTypeService;
 import com.qmth.paper.library.business.service.PaperScanTaskService;
+import com.qmth.paper.library.common.contant.SystemConstant;
 import com.qmth.paper.library.common.entity.BasicSemester;
+import com.qmth.paper.library.common.entity.BasicStudent;
 import com.qmth.paper.library.common.service.BasicSemesterService;
+import com.qmth.paper.library.common.service.BasicStudentService;
+import com.qmth.paper.library.common.service.SysOrgService;
 import com.qmth.paper.library.common.util.Result;
 import com.qmth.paper.library.common.util.ResultUtil;
+import com.qmth.paper.library.common.util.ServletUtil;
 import io.swagger.annotations.*;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * <p>
@@ -48,6 +55,12 @@ public class ConditionController {
     @Resource
     PaperScanTaskService paperScanTaskService;
 
+    @Resource
+    SysOrgService sysOrgService;
+
+    @Resource
+    BasicStudentService basicStudentService;
+
     @ApiOperation(value = "查询条件-学期")
     @PostMapping("/semester/query")
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
@@ -110,4 +123,48 @@ public class ConditionController {
         return ResultUtil.ok(scanTaskList);
     }
 
+    @ApiOperation(value = "查询条件-学生查询条件级联查询(学生学院-专业-班级)")
+    @RequestMapping(value = "/basic_student/condition", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
+    public Result findDictionaryList(@ApiParam(value = "学院id") @RequestParam(required = false) String collegeId,
+                                     @ApiParam(value = "专业名称") @RequestParam(required = false) String majorName,
+                                     @ApiParam(value = "查询字典对象", required = true) @RequestParam DictionaryEnum dictionaryEnum) {
+        Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
+        QueryWrapper<BasicStudent> studentQuery = new QueryWrapper<>();
+        studentQuery.lambda().eq(BasicStudent::getSchoolId, schoolId);
+        if (SystemConstant.longNotNull(SystemConstant.convertIdToLong(collegeId))) {
+            Long orgId = SystemConstant.convertIdToLong(collegeId);
+            studentQuery.lambda().eq(BasicStudent::getBelongOrgId, orgId);
+        }
+        if (SystemConstant.strNotNull(majorName)) {
+            studentQuery.lambda().eq(BasicStudent::getMajorName, majorName);
+        }
+        List<DictionaryResult> dictionaryResultList = new ArrayList<>();
+        switch (dictionaryEnum) {
+            case COLLEGE:
+                dictionaryResultList = sysOrgService.findCollegeLevelOrgList(schoolId).stream().flatMap(e -> {
+                    DictionaryResult dictionaryResult = new DictionaryResult();
+                    dictionaryResult.setId(e.getId());
+                    dictionaryResult.setCode(e.getCode());
+                    dictionaryResult.setName(e.getName());
+                    return Stream.of(dictionaryResult);
+                }).collect(Collectors.toList());
+                break;
+            case MAJOR:
+                dictionaryResultList = basicStudentService.list(studentQuery).stream().map(BasicStudent::getMajorName).distinct().flatMap(e -> {
+                    DictionaryResult dictionaryResult = new DictionaryResult();
+                    dictionaryResult.setName(e);
+                    return Stream.of(dictionaryResult);
+                }).collect(Collectors.toList());
+                break;
+            case CLAZZ:
+                dictionaryResultList = basicStudentService.list(studentQuery).stream().map(BasicStudent::getClazzName).distinct().flatMap(e -> {
+                    DictionaryResult dictionaryResult = new DictionaryResult();
+                    dictionaryResult.setName(e);
+                    return Stream.of(dictionaryResult);
+                }).collect(Collectors.toList());
+                break;
+        }
+        return ResultUtil.ok(dictionaryResultList);
+    }
 }

+ 0 - 54
paper-library/src/main/java/com/qmth/paper/library/api/SysController.java

@@ -419,58 +419,4 @@ public class SysController {
         String number = libraryCommonService.getSysIncrCode(type, sysUser);
         return ResultUtil.ok((Object) number);
     }
-
-    @ApiOperation(value = "共用接口-查询字典")
-    @RequestMapping(value = "/get_dictionary", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
-    public Result findDictionaryList(@ApiParam(value = "学生学院id") @RequestParam(required = false) String collegeId,
-                                     @ApiParam(value = "专业id") @RequestParam(required = false) String majorName,
-                                     @ApiParam(value = "班级id") @RequestParam(required = false) String clazzName,
-                                     @ApiParam(value = "学生id") @RequestParam(required = false) String studentId,
-                                     @ApiParam(value = "查询字典对象", required = true) @RequestParam DictionaryEnum dictionaryEnum) {
-        Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
-        List<DictionaryResult> dictionaryResultList = new ArrayList<>();
-        switch (dictionaryEnum) {
-            case SEMESTER:
-                List<BasicSemester> basicSemesterList = basicSemesterService.list(new QueryWrapper<BasicSemester>()
-                        .lambda()
-                        .eq(BasicSemester::getSchoolId, schoolId)
-                        .eq(BasicSemester::getEnable, true));
-                dictionaryResultList = basicSemesterList.stream().map(e -> {
-                    DictionaryResult dictionaryResult = new DictionaryResult();
-                    dictionaryResult.setId(e.getId());
-                    dictionaryResult.setCode(e.getCode());
-                    dictionaryResult.setName(e.getName());
-                    return dictionaryResult;
-                }).collect(Collectors.toList());
-                break;
-            case STUDENT:
-                QueryWrapper<BasicStudent> studentQueryWrapper = new QueryWrapper<>();
-                studentQueryWrapper.lambda().eq(BasicStudent::getSchoolId, schoolId).eq(BasicStudent::getEnable, true);
-                if (SystemConstant.longNotNull(SystemConstant.convertIdToLong(collegeId))) {
-                    studentQueryWrapper.lambda().eq(BasicStudent::getBelongOrgId, collegeId);
-                }
-                if (SystemConstant.strNotNull(majorName)) {
-                    studentQueryWrapper.lambda().eq(BasicStudent::getMajorName, majorName);
-                }
-                if (SystemConstant.strNotNull(clazzName)) {
-                    studentQueryWrapper.lambda().eq(BasicStudent::getClazzName, clazzName);
-                }
-                if (SystemConstant.longNotNull(SystemConstant.convertIdToLong(studentId))) {
-                    studentQueryWrapper.lambda().eq(BasicStudent::getId, studentId);
-                }
-                List<BasicStudent> basicStudentList = basicStudentService.list(studentQueryWrapper);
-                dictionaryResultList = basicStudentList.stream().map(e -> {
-                    DictionaryResult dictionaryResult = new DictionaryResult();
-                    dictionaryResult.setId(e.getId());
-                    dictionaryResult.setCode(e.getStudentCode());
-                    dictionaryResult.setName(e.getStudentName());
-                    return dictionaryResult;
-                }).collect(Collectors.toList());
-                break;
-            default:
-                break;
-        }
-        return ResultUtil.ok(dictionaryResultList);
-    }
 }