StudentTryReadingReportController.java 24 KB

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