Kaynağa Gözat

新生报到

dzx 8 ay önce
ebeveyn
işleme
4edd819f4b

+ 263 - 0
src/main/java/com/xjrsoft/module/student/controller/BaseNewStudentReportController.java

@@ -2,21 +2,34 @@ package com.xjrsoft.module.student.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.support.ExcelTypeEnum;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xjrsoft.common.annotation.XjrLog;
 import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.common.enums.EnrollTypeEnum;
+import com.xjrsoft.common.enums.GenderDictionaryEnum;
+import com.xjrsoft.common.enums.RoleCodeEnum;
+import com.xjrsoft.common.enums.StudyStatusEnum;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
+import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.banding.entity.BandingTask;
 import com.xjrsoft.module.banding.service.IBandingTaskClassService;
 import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
 import com.xjrsoft.module.banding.service.IBandingTaskService;
+import com.xjrsoft.module.banding.vo.BandingTaskClassReportStatisticsVo;
+import com.xjrsoft.module.base.entity.BaseGrade;
 import com.xjrsoft.module.base.service.IBaseGradeService;
 import com.xjrsoft.module.base.service.IBaseSemesterService;
+import com.xjrsoft.module.databoard.vo.ItemCountVo;
 import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
 import com.xjrsoft.module.student.dto.StudentTryReadingReportPageDto;
 import com.xjrsoft.module.student.entity.EnrollmentPlan;
 import com.xjrsoft.module.student.entity.StudentReportPlan;
@@ -25,16 +38,32 @@ import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
 import com.xjrsoft.module.student.service.IEnrollmentPlanService;
 import com.xjrsoft.module.student.service.IStudentReportPlanService;
 import com.xjrsoft.module.student.service.IStudentReportRecordService;
+import com.xjrsoft.module.student.vo.StudentReportRecordExcelVo;
+import com.xjrsoft.module.student.vo.StudentReportRecordItemVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo;
+import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.io.ByteArrayOutputStream;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @title: 新生报到信息
@@ -93,4 +122,238 @@ public class BaseNewStudentReportController {
     }
 
 
+    @GetMapping(value = "/class-statistics")
+    @ApiOperation(value="班级数据统计")
+    @SaCheckPermission("studentreportrecord:detail")
+    @XjrLog(value = "班级数据统计")
+    public RT<BandingTaskClassReportStatisticsVo> classStatistics(@RequestParam Long classId){
+        return RT.ok(bandingTaskClassService.getTryReadingReportClassStatistics(classId));
+    }
+
+    @GetMapping(value = "/statistics")
+    @ApiOperation(value="领导统计")
+    @SaCheckPermission("studentreportrecord:detail")
+    @XjrLog(value = "领导统计")
+    public RT<StudentReportRecordStatisticsVo> statistics(@Valid StudentReportRecordStatisticsDto dto){
+        if(dto.getGradeId() == null && (dto.getCategory() == null || dto.getCategory() == 1)){
+            LambdaQueryWrapper<BaseGrade> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper
+                    .orderByDesc(BaseGrade::getTitle)
+                    .select(BaseGrade.class,x -> VoToColumnUtil.fieldsToColumns(BaseGrade.class).contains(x.getProperty()));
+            List<BaseGrade> gradeList = gradeService.list(queryWrapper);
+            if(!gradeList.isEmpty()){
+                dto.setGradeId(gradeList.get(0).getId());
+            }
+        }
+        if(dto.getEnrollType() == null || dto.getEnrollType().isEmpty()){
+            dto.setEnrollType(EnrollTypeEnum.AUTUMN_ENROLLMENT.getCode());
+        }
+        if(dto.getCategory() != null && dto.getCategory() == 2 && dto.getBaseSemesterId() == null){
+            dto.setBaseSemesterId(semesterService.getLastSemester());
+        }
+
+        List<EnrollmentPlan> enrollmentPlanList = enrollmentPlanService.list(
+                new QueryWrapper<EnrollmentPlan>().lambda()
+                        .eq(EnrollmentPlan::getEnrollType, dto.getEnrollType())
+                        .eq(EnrollmentPlan::getGradeId, dto.getGradeId())
+                        .eq(EnrollmentPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .eq(EnrollmentPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
+                        .orderByDesc(EnrollmentPlan::getId)
+        );
+        if(enrollmentPlanList.isEmpty()){
+            return RT.ok(new StudentReportRecordStatisticsVo());
+        }
+
+        StudentTryReadingReportPageDto recordPageDto = new StudentTryReadingReportPageDto();
+        recordPageDto.setEnrollmentPlanId(enrollmentPlanList.get(0).getId());
+
+        List<StudentReportRecordPlanPageVo> dataList = recordService.getTryReadingList(recordPageDto);
+        StudentReportRecordStatisticsVo statisticsVo = new StudentReportRecordStatisticsVo();
+        statisticsVo.setAllCount(dataList.stream().count());
+
+        statisticsVo.setArrivedCount(dataList.stream().filter(x -> x.getReportTime() != null).count());
+        statisticsVo.setNotArrivedCount(dataList.stream().filter(x -> x.getReportTime() == null).count());
+        statisticsVo.setArrivedMaleCount(dataList.stream().filter(x -> x.getReportTime() != null && GenderDictionaryEnum.MALE.getValue().equals(x.getGender())).count());
+        statisticsVo.setArrivedFemaleCount(dataList.stream().filter(x -> x.getReportTime() != null && GenderDictionaryEnum.FEMALE.getValue().equals(x.getGender())).count());
+
+        statisticsVo.setStayMaleCount(dataList.stream().filter(
+                x -> GenderDictionaryEnum.MALE.getValue().equals(x.getGender())
+                        && StudyStatusEnum.InResidence.getCode().equals(x.getStduyStatusCn())
+                        && x.getReportTime() != null
+        ).count());
+        statisticsVo.setStayFemaleCount(dataList.stream().filter(
+                x -> GenderDictionaryEnum.FEMALE.getValue().equals(x.getGender())
+                        && StudyStatusEnum.InResidence.getCode().equals(x.getStduyStatusCn())
+                        && x.getReportTime() != null
+        ).count());
+        statisticsVo.setNotStayMaleCount(dataList.stream().filter(
+                x -> GenderDictionaryEnum.MALE.getValue().equals(x.getGender())
+                        && StudyStatusEnum.AttendDaySchool.getCode().equals(x.getStduyStatusCn())
+                        && x.getReportTime() != null
+        ).count());
+        statisticsVo.setNotStayFemaleCount(dataList.stream().filter(
+                x -> GenderDictionaryEnum.FEMALE.getValue().equals(x.getGender())
+                        && StudyStatusEnum.AttendDaySchool.getCode().equals(x.getStduyStatusCn())
+                        && x.getReportTime() != null
+        ).count());
+
+        if(dto.getCategory() != null && dto.getCategory() == 3){
+            Map<String, List<StudentReportRecordPlanPageVo>> graduatedUniversityMap = dataList.stream().filter(x -> x.getReportTime() != null && x.getGraduateSchool() != null)
+                    .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getGraduateSchool));
+            List<ItemCountVo> graduatedUniversityList = new ArrayList<>();
+            for (String graduatedUniversity : graduatedUniversityMap.keySet()) {
+                graduatedUniversityList.add(
+                        new ItemCountVo(){{
+                            setItem(graduatedUniversity);
+                            setCount(graduatedUniversityMap.get(graduatedUniversity).size());
+                        }}
+                );
+            }
+            statisticsVo.setGraduatedUniversityList(graduatedUniversityList);
+        }
+
+        Map<String, List<StudentReportRecordPlanPageVo>> classMap = dataList.stream().filter(x -> x.getReportTime() != null && x.getClassName() != null)
+                .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassName));
+        Map<String, List<StudentReportRecordPlanPageVo>> classNotMap = dataList.stream().filter(x -> x.getReportTime() == null && x.getClassName() != null)
+                .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassName));
+        List<StudentReportRecordItemVo> classList = new ArrayList<>();
+        for (String className : classMap.keySet()) {
+            classList.add(
+                    new StudentReportRecordItemVo(){{
+                        setItem(className);
+                        setCount(classMap.get(className).size());
+                        if(classNotMap.get(className) != null && !(classNotMap.get(className).isEmpty())){
+                            setCount2(classNotMap.get(className).size());
+                        }
+                    }}
+            );
+        }
+        statisticsVo.setClassList(classList);
+
+        Map<String, List<StudentReportRecordPlanPageVo>> classTypeMap = dataList.stream().filter(x -> x.getReportTime() != null && x.getClassType() != null)
+                .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassType));
+        Map<String, List<StudentReportRecordPlanPageVo>> classTypeNotMap = dataList.stream().filter(x -> x.getReportTime() == null && x.getClassType() != null)
+                .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassType));
+        List<StudentReportRecordItemVo> classTypeList = new ArrayList<>();
+        for (String classType : classTypeMap.keySet()) {
+            classTypeList.add(
+                    new StudentReportRecordItemVo(){{
+                        setItem(classType);
+                        setCount(classTypeMap.get(classType).size());
+                        if(classTypeNotMap.get(classType) != null && !(classTypeNotMap.get(classType).isEmpty())){
+                            setCount2(classTypeNotMap.get(classType).size());
+                        }
+                    }}
+            );
+        }
+        statisticsVo.setClassTypeList(classTypeList);
+
+        Map<String, List<StudentReportRecordPlanPageVo>> majorMap = dataList.stream().filter(x -> x.getReportTime() != null && x.getMajorName() != null).collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getMajorName));
+        Map<String, List<StudentReportRecordPlanPageVo>> majorNotMap = dataList.stream().filter(x -> x.getReportTime() == null && x.getMajorName() != null).collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getMajorName));
+        List<StudentReportRecordItemVo> majorList = new ArrayList<>();
+        for (String majorName : majorMap.keySet()) {
+            majorList.add(
+                    new StudentReportRecordItemVo(){{
+                        setItem(majorName);
+                        setCount(majorMap.get(majorName).size());
+                        if(majorNotMap.get(majorName) != null && !(majorNotMap.get(majorName).isEmpty())){
+                            setCount2(majorNotMap.get(majorName).size());
+                        }
+                    }}
+            );
+        }
+        statisticsVo.setMajorList(majorList);
+
+        Map<String, List<StudentReportRecordPlanPageVo>> deptMap = dataList.stream().filter(x -> x.getReportTime() != null && x.getDeptName() != null).collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getDeptName));
+        List<ItemCountVo> deptList = new ArrayList<>();
+        for (String deptName : deptMap.keySet()) {
+            deptList.add(
+                    new ItemCountVo(){{
+                        setItem(deptName);
+                        setCount(deptMap.get(deptName).size());
+                    }}
+            );
+        }
+        statisticsVo.setDeptList(deptList);
+
+        BigDecimal divide = BigDecimal.ZERO;
+        if( statisticsVo.getAllCount() != 0){
+            divide = BigDecimal.valueOf(statisticsVo.getArrivedCount()).divide(BigDecimal.valueOf(statisticsVo.getAllCount()), 4, RoundingMode.HALF_UP);
+        }
+        statisticsVo.setReportRate(divide.doubleValue());
+
+        //查询年级趋势
+        List<BaseGrade> gradeList = gradeService.list(
+                new QueryWrapper<BaseGrade>().lambda()
+                        .eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .eq(BaseGrade::getEnabledMark, EnabledMark.ENABLED.getCode())
+                        .eq(BaseGrade::getStatus, 1)
+                        .orderByDesc(BaseGrade::getTitle)
+        );
+        List<ItemCountVo> gradeDataList = new ArrayList<>();
+        for (int i = 0; i < 3; i ++){
+            BaseGrade baseGrade = gradeList.get(i);
+
+            List<EnrollmentPlan> enrollmentPlans = enrollmentPlanService.list(
+                    new QueryWrapper<EnrollmentPlan>().lambda()
+                            .eq(EnrollmentPlan::getGradeId, baseGrade.getId())
+                            .eq(EnrollmentPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
+                            .eq(EnrollmentPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
+                            .orderByDesc(EnrollmentPlan::getId)
+            );
+            int gradeCount = 0;
+            for (EnrollmentPlan enrollmentPlan : enrollmentPlans) {
+                StudentTryReadingReportPageDto gradeRecordPageDto = new StudentTryReadingReportPageDto();
+                gradeRecordPageDto.setEnrollmentPlanId(enrollmentPlan.getId());
+                gradeRecordPageDto.setIsReport(1);
+                gradeCount += recordService.getTryReadingList(gradeRecordPageDto).size();
+            }
+            ItemCountVo itemCountVo = new ItemCountVo();
+            itemCountVo.setItem(baseGrade.getName());
+            itemCountVo.setCount(gradeCount);
+            gradeDataList.add(itemCountVo);
+        }
+        Collections.sort(gradeDataList, Comparator.comparing(ItemCountVo::getItem));
+        statisticsVo.setGradeList(gradeDataList);
+
+        return RT.ok(statisticsVo);
+    }
+
+    @PostMapping(value = "/export-query")
+    @ApiOperation(value="导出")
+    @SaCheckPermission("studentreportrecord:detail")
+    @XjrLog(value = "导出")
+    public ResponseEntity<byte[]> exportQuerty(@Valid @RequestBody StudentTryReadingReportPageDto dto){
+        List<StudentReportRecordExcelVo> dataList = new ArrayList<>();
+
+        List<String> roleList = StpUtil.getRoleList();
+        if(roleList.contains(RoleCodeEnum.TEACHER.getCode()) && roleList.contains(RoleCodeEnum.CLASSTE.getCode())){
+            if(dto.getClassId() == null){
+                dto.setTeacherId(StpUtil.getLoginIdAsLong());
+            }
+        }
+        dto.setReportCategory(3);
+        List<StudentReportRecordPlanPageVo> planPageList = recordService.getTryReadingList(dto);
+
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        for (StudentReportRecordPlanPageVo pageVo : planPageList) {
+            StudentReportRecordExcelVo excelVo = BeanUtil.toBean(pageVo, StudentReportRecordExcelVo.class);
+            if(pageVo.getReportTime() != null){
+                excelVo.setReportTime(sdf.format(pageVo.getReportTime()));
+            }
+            excelVo.setIsReport("否");
+            if(pageVo.getIsReport() != null && pageVo.getIsReport() == 1){
+                excelVo.setIsReport("是");
+            }
+
+            dataList.add(excelVo);
+        }
+        ByteArrayOutputStream bot = new ByteArrayOutputStream();
+        EasyExcel.write(bot, StudentReportRecordExcelVo.class).automaticMergeHead(false).excelType(ExcelTypeEnum.XLSX).sheet().doWrite(dataList);
+        String fileName = "exportQuerty" + ExcelTypeEnum.XLSX.getValue();
+        return RT.fileStream(bot.toByteArray(), fileName);
+    }
+
+
 }

+ 1 - 0
src/main/java/com/xjrsoft/module/student/controller/StudentTryReadingReportController.java

@@ -216,6 +216,7 @@ public class StudentTryReadingReportController {
                 dto.setTeacherId(StpUtil.getLoginIdAsLong());
             }
         }
+        dto.setReportCategory(2);
         List<StudentReportRecordPlanPageVo> planPageList = recordService.getTryReadingList(dto);
 
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+ 4 - 1
src/main/resources/mapper/student/StudentReportRecordMapper.xml

@@ -245,7 +245,10 @@
         WHERE t1.delete_mark = 0 AND t1.enabled_mark = 1
         and t12.status in(1,2)
         and t3.enrollment_plan_id = #{dto.enrollmentPlanId}
-        and t1.student_report_plan_id = #{dto.studentReportPlanId}
+        and t12.category = #{dto.reportCategory}
+        <if test="dto.studentReportPlanId != null">
+            and t1.student_report_plan_id = #{dto.studentReportPlanId}
+        </if>
         <if test="dto.keyword != null and dto.keyword != ''">
             and t1.name like concat('%', #{dto.keyword},'%')
         </if>