package cn.com.qmth.print.manage.controller; import cn.com.qmth.print.manage.entity.ExamStudentEntity; import cn.com.qmth.print.manage.enums.GroupType; import cn.com.qmth.print.manage.enums.RecordStatus; import cn.com.qmth.print.manage.enums.dto.EnumDto; import cn.com.qmth.print.manage.service.ExamStudentService; import cn.com.qmth.print.manage.utils.result.ResultUtil; import com.qmth.boot.api.constant.ApiConstant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * @Date: 2021/11/16. */ @RestController @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/condition") public class ConditionController { @Autowired private ExamStudentService examStudentService; /** * 分组字段列表 * * @return */ @RequestMapping(value = "/list_group_type", method = RequestMethod.POST) public Object listGroupType() { return GroupType.listGroupType(); } /** * 状态列表 * * @return */ @RequestMapping(value = "/list_record_status", method = RequestMethod.POST) public Object listRecordStatus() { return RecordStatus.listRecordStatus(); } /** * 准考证列表 * * @param examId 批次ID * @return */ @RequestMapping(value = "/list_exam_number", method = RequestMethod.POST) public Object listExamNumber(@RequestParam Long examId) { List studentEntityList = examStudentService.listByExamId(examId); List examNumberList = new ArrayList<>(); if (!CollectionUtils.isEmpty(studentEntityList)) { examNumberList = studentEntityList.stream().map(m -> m.getExamNumber()).distinct().collect(Collectors.toList()); } return examNumberList; } /** * 科目列表 * * @param examId 批次ID * @return */ @RequestMapping(value = "/list_course_code", method = RequestMethod.POST) public Object listCourseCode(@RequestParam Long examId) { List studentEntityList = examStudentService.listByExamId(examId); List courseCodeList = new ArrayList<>(); if (!CollectionUtils.isEmpty(studentEntityList)) { courseCodeList = studentEntityList.stream().map(m -> m.getCourseCode()).distinct().collect(Collectors.toList()); } return courseCodeList; } /** * 考点列表 * * @param examId 批次ID * @return */ @RequestMapping(value = "/list_exam_site", method = RequestMethod.POST) public Object listExamSite(@RequestParam Long examId) { List studentEntityList = examStudentService.listByExamId(examId); List examSiteList = new ArrayList<>(); if (!CollectionUtils.isEmpty(studentEntityList)) { examSiteList = studentEntityList.stream().map(m -> m.getExamSite()).distinct().collect(Collectors.toList()); } return examSiteList; } /** * 考场列表 * * @param examId 批次ID * @return */ @RequestMapping(value = "/list_exam_room", method = RequestMethod.POST) public Object listExamRoom(@RequestParam Long examId) { List studentEntityList = examStudentService.listByExamId(examId); List examRoomList = new ArrayList<>(); if (!CollectionUtils.isEmpty(studentEntityList)) { examRoomList = studentEntityList.stream().map(m -> m.getExamRoom()).distinct().collect(Collectors.toList()); } return examRoomList; } }