Quellcode durchsuchen

试读报到移动端班级统计

dzx vor 8 Monaten
Ursprung
Commit
26c0128153

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

@@ -5,25 +5,42 @@ 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.dto.BandingTaskClassPageDto;
 import com.xjrsoft.module.banding.service.IBandingTaskClassService;
 import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
 import com.xjrsoft.module.banding.vo.BandingTaskClassPageVo;
+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.student.dto.ChangeBandingStatusDto;
 import com.xjrsoft.module.student.dto.StudentReportRecordPageDto;
+import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
 import com.xjrsoft.module.student.dto.StudentReportSignDto;
+import com.xjrsoft.module.student.entity.EnrollmentPlan;
 import com.xjrsoft.module.student.entity.StudentReportPlan;
 import com.xjrsoft.module.student.entity.StudentReportRecord;
+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;
@@ -36,9 +53,13 @@ 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.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
 * @title: 新生维护信息
@@ -56,6 +77,9 @@ public class StudentTryReadingReportController {
     private final IBandingTaskClassStudentService classStudentService;
     private final IStudentReportPlanService reportPlanService;
     private final IBandingTaskClassService bandingTaskClassService;
+    private final IBaseSemesterService semesterService;
+    private final IBaseGradeService gradeService;
+    private final IEnrollmentPlanService enrollmentPlanService;
 
 
     @GetMapping(value = "/page")
@@ -199,5 +223,156 @@ public class StudentTryReadingReportController {
         return RT.ok(list);
     }
 
+    @GetMapping(value = "/statistics")
+    @ApiOperation(value="领导统计")
+    @SaCheckPermission("studentreportrecord:detail")
+    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());
+        }
+
+        StudentReportRecordPageDto recordPageDto = new StudentReportRecordPageDto();
+        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.getCode().equals(x.getGender())).count());
+        statisticsVo.setArrivedFemaleCount(dataList.stream().filter(x -> x.getReportTime() != null && GenderDictionaryEnum.FEMALE.getCode().equals(x.getGender())).count());
+
+        statisticsVo.setStayMaleCount(dataList.stream().filter(
+                x -> GenderDictionaryEnum.MALE.getCode().equals(x.getGender())
+                        && StudyStatusEnum.InResidence.getCode().equals(x.getStduyStatusCn())
+                        && x.getReportTime() != null
+        ).count());
+        statisticsVo.setStayFemaleCount(dataList.stream().filter(
+                x -> GenderDictionaryEnum.FEMALE.getCode().equals(x.getGender())
+                        && StudyStatusEnum.InResidence.getCode().equals(x.getStduyStatusCn())
+                        && x.getReportTime() != null
+        ).count());
+        statisticsVo.setNotStayMaleCount(dataList.stream().filter(
+                x -> GenderDictionaryEnum.MALE.getCode().equals(x.getGender())
+                        && StudyStatusEnum.AttendDaySchool.getCode().equals(x.getStduyStatusCn())
+                        && x.getReportTime() != null
+        ).count());
+        statisticsVo.setNotStayFemaleCount(dataList.stream().filter(
+                x -> GenderDictionaryEnum.FEMALE.getCode().equals(x.getGender())
+                        && StudyStatusEnum.AttendDaySchool.getCode().equals(x.getStduyStatusCn())
+                        && x.getReportTime() != null
+        ).count());
+
+        if(dto.getCategory() != null && dto.getCategory() == 1){
+            Map<String, List<StudentReportRecordPlanPageVo>> graduatedUniversityMap = dataList.stream().filter(x -> x.getReportTime() != 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)
+                .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassName));
+        Map<String, List<StudentReportRecordPlanPageVo>> classNotMap = dataList.stream().filter(x -> x.getReportTime() == 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).collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassType));
+        Map<String, List<StudentReportRecordPlanPageVo>> classTypeNotMap = dataList.stream().filter(x -> x.getReportTime() == 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());
+        return RT.ok(statisticsVo);
+    }
+
 
 }

+ 12 - 0
src/main/java/com/xjrsoft/module/student/vo/StudentReportRecordPlanPageVo.java

@@ -77,4 +77,16 @@ public class StudentReportRecordPlanPageVo {
     @ApiModelProperty("家长电话")
     private String parentMobile;
 
+    @ApiModelProperty("毕业学校")
+    private String graduateSchool;
+
+    @ApiModelProperty("专业名称")
+    private String majorName;
+
+    @ApiModelProperty("班级类型")
+    private String classType;
+
+    @ApiModelProperty("部门名称")
+    private String deptName;
+
 }

+ 16 - 10
src/main/resources/mapper/student/StudentReportRecordMapper.xml

@@ -224,21 +224,24 @@
     <select id="getTryReadingPage" parameterType="com.xjrsoft.module.student.dto.StudentReportRecordPageDto" resultType="com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo">
         SELECT t1.id, t1.user_id, t4.name AS grade_name,t5.name AS class_name,t6.name AS teacher_name,
         t3.name,t7.name AS gender,t3.credential_number,t3.mobile,t8.name AS student_type_cn,
-        t9.name AS stduy_status_cn,
+        t9.name AS stduy_status_cn,t3.gender,t13.name as major_name,t14.name as class_type,
         t1.report_time,IF(t1.report_time IS NULL, 0, 1) AS is_report,
-        t3.family_mobile AS parent_mobile
+        t3.family_mobile AS parent_mobile,t15.name as dept_name
         FROM student_report_record t1
         INNER JOIN base_new_student t3 ON t3.id = t1.user_id
         LEFT JOIN banding_task_class_student t2 ON t1.user_id = t2.new_student_id and t2.delete_mark = 0
         LEFT JOIN banding_task_class t5 ON t2.banding_task_class_id = t5.id
         LEFT JOIN xjr_user t6 ON t5.teacher_id = t6.id
-        LEFT JOIN xjr_dictionary_detail t7 ON t3.gender = t7.code
-        LEFT JOIN xjr_dictionary_detail t8 ON t3.source = t8.code
-        LEFT JOIN xjr_dictionary_detail t9 ON t3.stduy_status = t9.code
+        LEFT JOIN xjr_dictionary_detail t7 ON t3.gender = t7.code and t7.delete_mark = 0
+        LEFT JOIN xjr_dictionary_detail t8 ON t3.source = t8.code and t8.delete_mark = 0
+        LEFT JOIN xjr_dictionary_detail t9 ON t3.stduy_status = t9.code and t9.delete_mark = 0
         LEFT JOIN banding_task t10 ON t5.banding_task_id = t10.id
         LEFT JOIN base_grade t4 ON t10.grade_id = t4.id
         LEFT JOIN enrollment_plan t11 ON t11.id = t3.enrollment_plan_id
         LEFT JOIN student_report_plan t12 ON t12.id = t1.student_report_plan_id
+        LEFT JOIN base_major_set t13 ON t13.id = t5.major_set_id
+        LEFT JOIN xjr_dictionary_detail t14 ON t5.class_type = t14.code and t14.delete_mark = 0
+        LEFT JOIN xjr_department t15 ON t15.id = t13.department_id
         WHERE t1.delete_mark = 0 AND t1.enabled_mark = 1
         and t12.status = 1
         and t3.enrollment_plan_id = #{dto.enrollmentPlanId}
@@ -293,21 +296,24 @@
     <select id="getTryReadingList" parameterType="com.xjrsoft.module.student.dto.StudentReportRecordPageDto" resultType="com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo">
         SELECT t1.id, t1.user_id, t4.name AS grade_name,t5.name AS class_name,t6.name AS teacher_name,
         t3.name,t7.name AS gender,t3.credential_number,t3.mobile,t8.name AS student_type_cn,
-        t9.name AS stduy_status_cn,t3.gender
+        t9.name AS stduy_status_cn,t3.gender,t13.name as major_name,t14.name as class_type,
         t1.report_time,IF(t1.report_time IS NULL, 0, 1) AS is_report,
-        t3.family_mobile AS parent_mobile
+        t3.family_mobile AS parent_mobile,t15.name as dept_name
         FROM student_report_record t1
         INNER JOIN base_new_student t3 ON t3.id = t1.user_id
         LEFT JOIN banding_task_class_student t2 ON t1.user_id = t2.new_student_id and t2.delete_mark = 0
         LEFT JOIN banding_task_class t5 ON t2.banding_task_class_id = t5.id
         LEFT JOIN xjr_user t6 ON t5.teacher_id = t6.id
-        LEFT JOIN xjr_dictionary_detail t7 ON t3.gender = t7.code
-        LEFT JOIN xjr_dictionary_detail t8 ON t3.source = t8.code
-        LEFT JOIN xjr_dictionary_detail t9 ON t3.stduy_status = t9.code
+        LEFT JOIN xjr_dictionary_detail t7 ON t3.gender = t7.code and t7.delete_mark = 0
+        LEFT JOIN xjr_dictionary_detail t8 ON t3.source = t8.code and t8.delete_mark = 0
+        LEFT JOIN xjr_dictionary_detail t9 ON t3.stduy_status = t9.code and t9.delete_mark = 0
         LEFT JOIN banding_task t10 ON t5.banding_task_id = t10.id
         LEFT JOIN base_grade t4 ON t10.grade_id = t4.id
         LEFT JOIN enrollment_plan t11 ON t11.id = t3.enrollment_plan_id
         LEFT JOIN student_report_plan t12 ON t12.id = t1.student_report_plan_id
+        LEFT JOIN base_major_set t13 ON t13.id = t5.major_set_id
+        LEFT JOIN xjr_dictionary_detail t14 ON t5.class_type = t14.code and t14.delete_mark = 0
+        LEFT JOIN xjr_department t15 ON t15.id = t13.department_id
         WHERE t1.delete_mark = 0 AND t1.enabled_mark = 1
         and t12.status = 1
         and t3.enrollment_plan_id = #{dto.enrollmentPlanId}