StudentTryReadingReportController.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. package com.xjrsoft.module.student.controller;
  2. import cn.dev33.satoken.annotation.SaCheckPermission;
  3. import cn.dev33.satoken.stp.StpUtil;
  4. import cn.hutool.core.bean.BeanUtil;
  5. import com.alibaba.excel.EasyExcel;
  6. import com.alibaba.excel.support.ExcelTypeEnum;
  7. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  8. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  9. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  10. import com.xjrsoft.common.annotation.XjrLog;
  11. import com.xjrsoft.common.enums.DeleteMark;
  12. import com.xjrsoft.common.enums.EnabledMark;
  13. import com.xjrsoft.common.enums.EnrollTypeEnum;
  14. import com.xjrsoft.common.enums.GenderDictionaryEnum;
  15. import com.xjrsoft.common.enums.RoleCodeEnum;
  16. import com.xjrsoft.common.enums.StudyStatusEnum;
  17. import com.xjrsoft.common.model.result.RT;
  18. import com.xjrsoft.common.page.ConventPage;
  19. import com.xjrsoft.common.page.PageOutput;
  20. import com.xjrsoft.common.utils.VoToColumnUtil;
  21. import com.xjrsoft.module.banding.dto.BandingTaskClassPageDto;
  22. import com.xjrsoft.module.banding.entity.BandingTask;
  23. import com.xjrsoft.module.banding.service.IBandingTaskClassService;
  24. import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
  25. import com.xjrsoft.module.banding.service.IBandingTaskService;
  26. import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
  27. import com.xjrsoft.module.banding.vo.BandingTaskClassReportStatisticsVo;
  28. import com.xjrsoft.module.base.entity.BaseGrade;
  29. import com.xjrsoft.module.base.service.IBaseGradeService;
  30. import com.xjrsoft.module.base.service.IBaseSemesterService;
  31. import com.xjrsoft.module.databoard.vo.ItemCountVo;
  32. import com.xjrsoft.module.organization.dto.GetUserByParamDto;
  33. import com.xjrsoft.module.organization.entity.User;
  34. import com.xjrsoft.module.organization.service.IUserService;
  35. import com.xjrsoft.module.student.dto.ChangeBandingStatusDto;
  36. import com.xjrsoft.module.student.dto.StudentReportChangeClassBatchDto;
  37. import com.xjrsoft.module.student.dto.StudentReportRecordPageDto;
  38. import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
  39. import com.xjrsoft.module.student.dto.StudentReportSignDto;
  40. import com.xjrsoft.module.student.dto.StudentTryReadingReportPageDto;
  41. import com.xjrsoft.module.student.entity.BaseNewStudent;
  42. import com.xjrsoft.module.student.entity.EnrollmentPlan;
  43. import com.xjrsoft.module.student.entity.StudentReportPlan;
  44. import com.xjrsoft.module.student.entity.StudentReportRecord;
  45. import com.xjrsoft.module.student.service.IBaseNewStudentService;
  46. import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
  47. import com.xjrsoft.module.student.service.IEnrollmentPlanService;
  48. import com.xjrsoft.module.student.service.IStudentReportPlanService;
  49. import com.xjrsoft.module.student.service.IStudentReportRecordService;
  50. import com.xjrsoft.module.student.vo.StudentReportRecordExcelVo;
  51. import com.xjrsoft.module.student.vo.StudentReportRecordItemVo;
  52. import com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo;
  53. import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsVo;
  54. import io.swagger.annotations.Api;
  55. import io.swagger.annotations.ApiOperation;
  56. import lombok.AllArgsConstructor;
  57. import org.springframework.http.ResponseEntity;
  58. import org.springframework.web.bind.annotation.GetMapping;
  59. import org.springframework.web.bind.annotation.PostMapping;
  60. import org.springframework.web.bind.annotation.RequestBody;
  61. import org.springframework.web.bind.annotation.RequestMapping;
  62. import org.springframework.web.bind.annotation.RequestParam;
  63. import org.springframework.web.bind.annotation.RestController;
  64. import javax.validation.Valid;
  65. import java.io.ByteArrayOutputStream;
  66. import java.math.BigDecimal;
  67. import java.math.RoundingMode;
  68. import java.text.SimpleDateFormat;
  69. import java.util.ArrayList;
  70. import java.util.Collections;
  71. import java.util.Comparator;
  72. import java.util.List;
  73. import java.util.Map;
  74. import java.util.stream.Collectors;
  75. /**
  76. * @title: 新生维护信息
  77. * @Author dzx
  78. * @Date: 2024-06-27
  79. * @Version 1.0
  80. */
  81. @RestController
  82. @RequestMapping("/student" + "/tryReadingReport")
  83. @Api(value = "/student" + "/tryReadingReport",tags = "试读报到模块代码")
  84. @AllArgsConstructor
  85. public class StudentTryReadingReportController {
  86. private final IStudentReportRecordService recordService;
  87. private final IBandingTaskClassStudentService classStudentService;
  88. private final IStudentReportPlanService reportPlanService;
  89. private final IBandingTaskClassService bandingTaskClassService;
  90. private final IBaseSemesterService semesterService;
  91. private final IBaseGradeService gradeService;
  92. private final IEnrollmentPlanService enrollmentPlanService;
  93. private final IBandingTaskService bandingTaskService;
  94. private final IUserService userService;
  95. private final IBaseStudentSchoolRollService rollService;
  96. private final IBaseNewStudentService newStudentService;
  97. @GetMapping(value = "/page")
  98. @ApiOperation(value="试读报到(分页)")
  99. @SaCheckPermission("tryreadingreport:detail")
  100. @XjrLog(value="试读报到(分页)")
  101. public RT<PageOutput<StudentReportRecordPlanPageVo>> page(@Valid StudentTryReadingReportPageDto dto){
  102. List<String> roleList = StpUtil.getRoleList();
  103. if(roleList.contains("CLASSTE") && roleList.contains("TEACHER")){
  104. dto.setTeacherId(StpUtil.getLoginIdAsLong());
  105. }
  106. if(dto.getIsMoible() != null && dto.getIsMoible() == 1){
  107. StudentReportPlan plan = reportPlanService.getLastTryReadingPlan();
  108. BandingTask bandingTask = bandingTaskService.getById(plan.getBandingTaskId());
  109. List<EnrollmentPlan> enrollmentPlans = enrollmentPlanService.list(
  110. new QueryWrapper<EnrollmentPlan>().lambda()
  111. .eq(EnrollmentPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
  112. .eq(EnrollmentPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
  113. .eq(EnrollmentPlan::getEnrollType, bandingTask.getEnrollType())
  114. .eq(EnrollmentPlan::getGradeId, bandingTask.getGradeId())
  115. .orderByDesc(EnrollmentPlan::getId)
  116. );
  117. if(!enrollmentPlans.isEmpty()){
  118. dto.setEnrollmentPlanId(enrollmentPlans.get(0).getId());
  119. }
  120. }
  121. Page<StudentReportRecordPlanPageVo> page = recordService.getTryReadingPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
  122. PageOutput<StudentReportRecordPlanPageVo> pageOutput = ConventPage.getPageOutput(page, StudentReportRecordPlanPageVo.class);
  123. return RT.ok(pageOutput);
  124. }
  125. @PostMapping("/clear-class")
  126. @ApiOperation(value = "非本班学生")
  127. @SaCheckPermission("tryreadingreport:add")
  128. @XjrLog(value="非本班学生")
  129. public RT<Boolean> clearClass(@Valid @RequestBody ChangeBandingStatusDto dto){
  130. StudentReportRecord record = recordService.getById(dto.getId());
  131. StudentReportPlan reportPlan = reportPlanService.getById(record.getStudentReportPlanId());
  132. List<Long> list = new ArrayList<>();
  133. list.add(record.getUserId());
  134. classStudentService.removeStudent(list, reportPlan.getBandingTaskId());
  135. BaseNewStudent newStudent = newStudentService.getById(record.getUserId());
  136. if(newStudent != null){
  137. User user = userService.getUserByParam(new GetUserByParamDto() {{
  138. setCredentialNumber(newStudent.getCredentialNumber());
  139. }});
  140. if(user != null){
  141. rollService.disableStudent(user.getId());
  142. }
  143. }
  144. return RT.ok(true);
  145. }
  146. @PostMapping(value = "/sign")
  147. @ApiOperation(value="试读报到")
  148. @SaCheckPermission("tryreadingreport:detail")
  149. @XjrLog(value="试读报到")
  150. public RT<Boolean> sign(@Valid @RequestBody StudentReportSignDto dto){
  151. return RT.ok(recordService.tryReadingSign(dto));
  152. }
  153. @PostMapping(value = "/all-sign")
  154. @ApiOperation(value="变更为已报到")
  155. @SaCheckPermission("tryreadingreport:detail")
  156. @XjrLog(value="试读报到")
  157. public RT<Boolean> sign(@Valid @RequestBody List<Long> ids){
  158. for (Long id : ids) {
  159. recordService.tryReadingSign(new StudentReportSignDto(){{
  160. setId(id);
  161. }});
  162. }
  163. return RT.ok(true);
  164. }
  165. @PostMapping("/change-class")
  166. @ApiOperation(value = "调整班级")
  167. @SaCheckPermission("tryreadingreport:change-class")
  168. @XjrLog(value = "调整班级")
  169. public RT<Boolean> changeClass(@Valid @RequestBody StudentReportSignDto dto){
  170. boolean isSuccess = recordService.changeClass(dto);
  171. return RT.ok(isSuccess);
  172. }
  173. @PostMapping("/change-class-batch")
  174. @ApiOperation(value = "批量调整班级")
  175. @SaCheckPermission("tryreadingreport:change-class")
  176. @XjrLog(value = "批量调整班级")
  177. public RT<Boolean> changeClassBatch(@Valid @RequestBody StudentReportChangeClassBatchDto dto){
  178. boolean isSuccess = recordService.changeClassBatch(dto);
  179. return RT.ok(isSuccess);
  180. }
  181. @PostMapping(value = "/update-stduyStatus")
  182. @ApiOperation(value="切换就读方式")
  183. @SaCheckPermission("tryreadingreport:update-stduyStatus")
  184. @XjrLog(value = "切换就读方式")
  185. public RT<Boolean> updateStduyStatus(@Valid @RequestBody StudentReportSignDto dto){
  186. boolean isSuccess = recordService.updateStduyStatusByTryReading(dto);
  187. return RT.ok(isSuccess);
  188. }
  189. @PostMapping(value = "/export-query")
  190. @ApiOperation(value="导出")
  191. @SaCheckPermission("studentreportrecord:detail")
  192. @XjrLog(value = "导出")
  193. public ResponseEntity<byte[]> exportQuerty(@Valid @RequestBody StudentTryReadingReportPageDto dto){
  194. List<StudentReportRecordExcelVo> dataList = new ArrayList<>();
  195. List<String> roleList = StpUtil.getRoleList();
  196. if(roleList.contains(RoleCodeEnum.TEACHER.getCode()) && roleList.contains(RoleCodeEnum.CLASSTE.getCode())){
  197. if(dto.getClassId() == null){
  198. dto.setTeacherId(StpUtil.getLoginIdAsLong());
  199. }
  200. }
  201. List<StudentReportRecordPlanPageVo> planPageList = recordService.getTryReadingList(dto);
  202. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  203. for (StudentReportRecordPlanPageVo pageVo : planPageList) {
  204. StudentReportRecordExcelVo excelVo = BeanUtil.toBean(pageVo, StudentReportRecordExcelVo.class);
  205. if(pageVo.getReportTime() != null){
  206. excelVo.setReportTime(sdf.format(pageVo.getReportTime()));
  207. }
  208. excelVo.setIsReport("否");
  209. if(pageVo.getIsReport() != null && pageVo.getIsReport() == 1){
  210. excelVo.setIsReport("是");
  211. }
  212. dataList.add(excelVo);
  213. }
  214. ByteArrayOutputStream bot = new ByteArrayOutputStream();
  215. EasyExcel.write(bot, StudentReportRecordExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(dataList);
  216. String fileName = "exportQuerty" + ExcelTypeEnum.XLSX.getValue();
  217. return RT.fileStream(bot.toByteArray(), fileName);
  218. }
  219. @GetMapping(value = "/class-list")
  220. @ApiOperation(value="查询班级信息")
  221. @SaCheckPermission("studentreportrecord:detail")
  222. @XjrLog(value = "查询班级信息")
  223. public RT<List<BandingTaskClassPageVo>> classList(@Valid StudentReportRecordPageDto dto){
  224. BandingTaskClassPageDto classDto = new BandingTaskClassPageDto();
  225. if(dto.getEnrollmentPlanId() == null){
  226. if(dto.getTeacherId() != null){
  227. classDto.setTeacherId(dto.getTeacherId());
  228. }else{
  229. classDto.setTeacherId(StpUtil.getLoginIdAsLong());
  230. }
  231. StudentReportPlan plan = reportPlanService.getLastTryReadingPlan();
  232. if(plan == null){
  233. return RT.ok(new ArrayList<>());
  234. }
  235. classDto.setBandingTaskId(plan.getBandingTaskId());
  236. }else{
  237. EnrollmentPlan enrollmentPlan = enrollmentPlanService.getById(dto.getEnrollmentPlanId());
  238. if(enrollmentPlan != null){
  239. List<BandingTask> list = bandingTaskService.list(
  240. new QueryWrapper<BandingTask>().lambda()
  241. .eq(BandingTask::getEnrollType, enrollmentPlan.getEnrollType())
  242. .eq(BandingTask::getGradeId, enrollmentPlan.getGradeId())
  243. .eq(BandingTask::getDeleteMark, DeleteMark.NODELETE.getCode())
  244. .eq(BandingTask::getEnabledMark, EnabledMark.ENABLED.getCode())
  245. .orderByDesc(BandingTask::getId)
  246. );
  247. if(!list.isEmpty()){
  248. classDto.setBandingTaskId(list.get(0).getId());
  249. }
  250. }
  251. List<String> roleList = StpUtil.getRoleList();
  252. if(roleList.contains("CLASSTE") && roleList.contains("TEACHER")){
  253. classDto.setTeacherId(StpUtil.getLoginIdAsLong());
  254. }
  255. }
  256. List<BandingTaskClassPageVo> list = bandingTaskClassService.getList(classDto);
  257. return RT.ok(list);
  258. }
  259. @GetMapping(value = "/class-statistics")
  260. @ApiOperation(value="班级数据统计")
  261. @SaCheckPermission("studentreportrecord:detail")
  262. @XjrLog(value = "班级数据统计")
  263. public RT<BandingTaskClassReportStatisticsVo> classStatistics(@RequestParam Long classId){
  264. return RT.ok(bandingTaskClassService.getTryReadingReportClassStatistics(classId));
  265. }
  266. @GetMapping(value = "/statistics")
  267. @ApiOperation(value="领导统计")
  268. @SaCheckPermission("studentreportrecord:detail")
  269. @XjrLog(value = "领导统计")
  270. public RT<StudentReportRecordStatisticsVo> statistics(@Valid StudentReportRecordStatisticsDto dto){
  271. if(dto.getGradeId() == null && (dto.getCategory() == null || dto.getCategory() == 1)){
  272. LambdaQueryWrapper<BaseGrade> queryWrapper = new LambdaQueryWrapper<>();
  273. queryWrapper
  274. .orderByDesc(BaseGrade::getTitle)
  275. .select(BaseGrade.class,x -> VoToColumnUtil.fieldsToColumns(BaseGrade.class).contains(x.getProperty()));
  276. List<BaseGrade> gradeList = gradeService.list(queryWrapper);
  277. if(!gradeList.isEmpty()){
  278. dto.setGradeId(gradeList.get(0).getId());
  279. }
  280. }
  281. if(dto.getEnrollType() == null || dto.getEnrollType().isEmpty()){
  282. dto.setEnrollType(EnrollTypeEnum.AUTUMN_ENROLLMENT.getCode());
  283. }
  284. if(dto.getCategory() != null && dto.getCategory() == 2 && dto.getBaseSemesterId() == null){
  285. dto.setBaseSemesterId(semesterService.getLastSemester());
  286. }
  287. List<EnrollmentPlan> enrollmentPlanList = enrollmentPlanService.list(
  288. new QueryWrapper<EnrollmentPlan>().lambda()
  289. .eq(EnrollmentPlan::getEnrollType, dto.getEnrollType())
  290. .eq(EnrollmentPlan::getGradeId, dto.getGradeId())
  291. .eq(EnrollmentPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
  292. .eq(EnrollmentPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
  293. .orderByDesc(EnrollmentPlan::getId)
  294. );
  295. if(enrollmentPlanList.isEmpty()){
  296. return RT.ok(new StudentReportRecordStatisticsVo());
  297. }
  298. StudentTryReadingReportPageDto recordPageDto = new StudentTryReadingReportPageDto();
  299. recordPageDto.setEnrollmentPlanId(enrollmentPlanList.get(0).getId());
  300. List<StudentReportRecordPlanPageVo> dataList = recordService.getTryReadingList(recordPageDto);
  301. StudentReportRecordStatisticsVo statisticsVo = new StudentReportRecordStatisticsVo();
  302. statisticsVo.setAllCount(dataList.stream().count());
  303. statisticsVo.setArrivedCount(dataList.stream().filter(x -> x.getReportTime() != null).count());
  304. statisticsVo.setNotArrivedCount(dataList.stream().filter(x -> x.getReportTime() == null).count());
  305. statisticsVo.setArrivedMaleCount(dataList.stream().filter(x -> x.getReportTime() != null && GenderDictionaryEnum.MALE.getValue().equals(x.getGender())).count());
  306. statisticsVo.setArrivedFemaleCount(dataList.stream().filter(x -> x.getReportTime() != null && GenderDictionaryEnum.FEMALE.getValue().equals(x.getGender())).count());
  307. statisticsVo.setStayMaleCount(dataList.stream().filter(
  308. x -> GenderDictionaryEnum.MALE.getValue().equals(x.getGender())
  309. && StudyStatusEnum.InResidence.getCode().equals(x.getStduyStatusCn())
  310. && x.getReportTime() != null
  311. ).count());
  312. statisticsVo.setStayFemaleCount(dataList.stream().filter(
  313. x -> GenderDictionaryEnum.FEMALE.getValue().equals(x.getGender())
  314. && StudyStatusEnum.InResidence.getCode().equals(x.getStduyStatusCn())
  315. && x.getReportTime() != null
  316. ).count());
  317. statisticsVo.setNotStayMaleCount(dataList.stream().filter(
  318. x -> GenderDictionaryEnum.MALE.getValue().equals(x.getGender())
  319. && StudyStatusEnum.AttendDaySchool.getCode().equals(x.getStduyStatusCn())
  320. && x.getReportTime() != null
  321. ).count());
  322. statisticsVo.setNotStayFemaleCount(dataList.stream().filter(
  323. x -> GenderDictionaryEnum.FEMALE.getValue().equals(x.getGender())
  324. && StudyStatusEnum.AttendDaySchool.getCode().equals(x.getStduyStatusCn())
  325. && x.getReportTime() != null
  326. ).count());
  327. if(dto.getCategory() != null && dto.getCategory() == 3){
  328. Map<String, List<StudentReportRecordPlanPageVo>> graduatedUniversityMap = dataList.stream().filter(x -> x.getReportTime() != null && x.getGraduateSchool() != null)
  329. .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getGraduateSchool));
  330. List<ItemCountVo> graduatedUniversityList = new ArrayList<>();
  331. for (String graduatedUniversity : graduatedUniversityMap.keySet()) {
  332. graduatedUniversityList.add(
  333. new ItemCountVo(){{
  334. setItem(graduatedUniversity);
  335. setCount(graduatedUniversityMap.get(graduatedUniversity).size());
  336. }}
  337. );
  338. }
  339. statisticsVo.setGraduatedUniversityList(graduatedUniversityList);
  340. }
  341. Map<String, List<StudentReportRecordPlanPageVo>> classMap = dataList.stream().filter(x -> x.getReportTime() != null && x.getClassName() != null)
  342. .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassName));
  343. Map<String, List<StudentReportRecordPlanPageVo>> classNotMap = dataList.stream().filter(x -> x.getReportTime() == null && x.getClassName() != null)
  344. .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassName));
  345. List<StudentReportRecordItemVo> classList = new ArrayList<>();
  346. for (String className : classMap.keySet()) {
  347. classList.add(
  348. new StudentReportRecordItemVo(){{
  349. setItem(className);
  350. setCount(classMap.get(className).size());
  351. if(classNotMap.get(className) != null && !(classNotMap.get(className).isEmpty())){
  352. setCount2(classNotMap.get(className).size());
  353. }
  354. }}
  355. );
  356. }
  357. statisticsVo.setClassList(classList);
  358. Map<String, List<StudentReportRecordPlanPageVo>> classTypeMap = dataList.stream().filter(x -> x.getReportTime() != null && x.getClassType() != null)
  359. .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassType));
  360. Map<String, List<StudentReportRecordPlanPageVo>> classTypeNotMap = dataList.stream().filter(x -> x.getReportTime() == null && x.getClassType() != null)
  361. .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassType));
  362. List<StudentReportRecordItemVo> classTypeList = new ArrayList<>();
  363. for (String classType : classTypeMap.keySet()) {
  364. classTypeList.add(
  365. new StudentReportRecordItemVo(){{
  366. setItem(classType);
  367. setCount(classTypeMap.get(classType).size());
  368. if(classTypeNotMap.get(classType) != null && !(classTypeNotMap.get(classType).isEmpty())){
  369. setCount2(classTypeNotMap.get(classType).size());
  370. }
  371. }}
  372. );
  373. }
  374. statisticsVo.setClassTypeList(classTypeList);
  375. Map<String, List<StudentReportRecordPlanPageVo>> majorMap = dataList.stream().filter(x -> x.getReportTime() != null && x.getMajorName() != null).collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getMajorName));
  376. Map<String, List<StudentReportRecordPlanPageVo>> majorNotMap = dataList.stream().filter(x -> x.getReportTime() == null && x.getMajorName() != null).collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getMajorName));
  377. List<StudentReportRecordItemVo> majorList = new ArrayList<>();
  378. for (String majorName : majorMap.keySet()) {
  379. majorList.add(
  380. new StudentReportRecordItemVo(){{
  381. setItem(majorName);
  382. setCount(majorMap.get(majorName).size());
  383. if(majorNotMap.get(majorName) != null && !(majorNotMap.get(majorName).isEmpty())){
  384. setCount2(majorNotMap.get(majorName).size());
  385. }
  386. }}
  387. );
  388. }
  389. statisticsVo.setMajorList(majorList);
  390. Map<String, List<StudentReportRecordPlanPageVo>> deptMap = dataList.stream().filter(x -> x.getReportTime() != null && x.getDeptName() != null).collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getDeptName));
  391. List<ItemCountVo> deptList = new ArrayList<>();
  392. for (String deptName : deptMap.keySet()) {
  393. deptList.add(
  394. new ItemCountVo(){{
  395. setItem(deptName);
  396. setCount(deptMap.get(deptName).size());
  397. }}
  398. );
  399. }
  400. statisticsVo.setDeptList(deptList);
  401. BigDecimal divide = BigDecimal.ZERO;
  402. if( statisticsVo.getAllCount() != 0){
  403. divide = BigDecimal.valueOf(statisticsVo.getArrivedCount()).divide(BigDecimal.valueOf(statisticsVo.getAllCount()), 4, RoundingMode.HALF_UP);
  404. }
  405. statisticsVo.setReportRate(divide.doubleValue());
  406. //查询年级趋势
  407. List<BaseGrade> gradeList = gradeService.list(
  408. new QueryWrapper<BaseGrade>().lambda()
  409. .eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode())
  410. .eq(BaseGrade::getEnabledMark, EnabledMark.ENABLED.getCode())
  411. .eq(BaseGrade::getStatus, 1)
  412. .orderByDesc(BaseGrade::getTitle)
  413. );
  414. List<ItemCountVo> gradeDataList = new ArrayList<>();
  415. for (int i = 0; i < 3; i ++){
  416. BaseGrade baseGrade = gradeList.get(i);
  417. List<EnrollmentPlan> enrollmentPlans = enrollmentPlanService.list(
  418. new QueryWrapper<EnrollmentPlan>().lambda()
  419. .eq(EnrollmentPlan::getGradeId, baseGrade.getId())
  420. .eq(EnrollmentPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
  421. .eq(EnrollmentPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
  422. .orderByDesc(EnrollmentPlan::getId)
  423. );
  424. int gradeCount = 0;
  425. for (EnrollmentPlan enrollmentPlan : enrollmentPlans) {
  426. StudentTryReadingReportPageDto gradeRecordPageDto = new StudentTryReadingReportPageDto();
  427. gradeRecordPageDto.setEnrollmentPlanId(enrollmentPlan.getId());
  428. gradeRecordPageDto.setIsReport(1);
  429. gradeCount += recordService.getTryReadingList(gradeRecordPageDto).size();
  430. }
  431. ItemCountVo itemCountVo = new ItemCountVo();
  432. itemCountVo.setItem(baseGrade.getName());
  433. itemCountVo.setCount(gradeCount);
  434. gradeDataList.add(itemCountVo);
  435. }
  436. Collections.sort(gradeDataList, Comparator.comparing(ItemCountVo::getItem));
  437. statisticsVo.setGradeList(gradeDataList);
  438. return RT.ok(statisticsVo);
  439. }
  440. }