Browse Source

新生报到模块

dzx 6 months ago
parent
commit
9e7822693e

+ 48 - 17
src/main/java/com/xjrsoft/module/student/controller/StudentReportRecordController.java

@@ -6,12 +6,18 @@ import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.xjrsoft.common.enums.EnrollTypeEnum;
+import com.xjrsoft.common.enums.GenderDictionaryEnum;
+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.base.entity.BaseGrade;
 import com.xjrsoft.module.base.entity.BaseSemester;
+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.AddStudentReportRecordDto;
 import com.xjrsoft.module.student.dto.StudentReportRecordPageDto;
 import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
@@ -19,6 +25,7 @@ import com.xjrsoft.module.student.dto.UpdateStudentReportRecordDto;
 import com.xjrsoft.module.student.entity.StudentReportRecord;
 import com.xjrsoft.module.student.service.IStudentReportRecordService;
 import com.xjrsoft.module.student.vo.StudentReportRecordPageVo;
+import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsListVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordVo;
 import io.swagger.annotations.Api;
@@ -36,8 +43,11 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.validation.Valid;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
 * @title: 学生报到记录表
@@ -54,6 +64,7 @@ public class StudentReportRecordController {
 
     private final IStudentReportRecordService studentReportRecordService;
     private final IBaseSemesterService semesterService;
+    private final IBaseGradeService gradeService;
 
     @GetMapping(value = "/page")
     @ApiOperation(value="学生报到记录表列表(分页)")
@@ -163,6 +174,10 @@ public class StudentReportRecordController {
             }
         }
         StudentReportRecordStatisticsVo statisticsVo = studentReportRecordService.getClassStatistics(dto);
+        if(statisticsVo == null){
+            statisticsVo = new StudentReportRecordStatisticsVo();
+            return RT.ok(statisticsVo);
+        }
         long notArrivedCount = statisticsVo.getAllCount() - statisticsVo.getArrivedCount();
         statisticsVo.setNotArrivedCount(notArrivedCount);
         BigDecimal divide = BigDecimal.ZERO;
@@ -177,27 +192,43 @@ public class StudentReportRecordController {
     @ApiOperation(value="领导统计")
     @SaCheckPermission("studentreportrecord:detail")
     public RT<StudentReportRecordStatisticsVo> statistics(@Valid StudentReportRecordStatisticsDto dto){
-        if(dto.getTeacherId() == null){
-            dto.setTeacherId(StpUtil.getLoginIdAsLong());
-        }
-        if(dto.getBaseSemesterId() == null){
-            LambdaQueryWrapper<BaseSemester> queryWrapper = new LambdaQueryWrapper<>();
+        if(dto.getGradeId() == null){
+            LambdaQueryWrapper<BaseGrade> queryWrapper = new LambdaQueryWrapper<>();
             queryWrapper
-                    .orderByDesc(BaseSemester::getStartDate)
-                    .select(BaseSemester.class,x -> VoToColumnUtil.fieldsToColumns(BaseSemester.class).contains(x.getProperty()));
-            List<BaseSemester> semesterList = semesterService.list(queryWrapper);
-            if(!semesterList.isEmpty()){
-                dto.setBaseSemesterId(semesterList.get(0).getId());
+                    .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());
             }
         }
-        StudentReportRecordStatisticsVo statisticsVo = studentReportRecordService.getClassStatistics(dto);
-        long notArrivedCount = statisticsVo.getAllCount() - statisticsVo.getArrivedCount();
-        statisticsVo.setNotArrivedCount(notArrivedCount);
-        BigDecimal divide = BigDecimal.ZERO;
-        if( statisticsVo.getAllCount() != 0){
-            divide = BigDecimal.valueOf(statisticsVo.getArrivedCount()).divide(BigDecimal.valueOf(statisticsVo.getAllCount()), 4, RoundingMode.HALF_UP);
+        if(dto.getEnrollType() == null || dto.getEnrollType().isEmpty()){
+            dto.setEnrollType(EnrollTypeEnum.AUTUMN_ENROLLMENT.getCode());
         }
-        statisticsVo.setReportRate(divide.doubleValue());
+        List<StudentReportRecordStatisticsListVo> dataList = studentReportRecordService.getStatisticsDataList(dto);
+        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.getStduyStatus())).count());
+        statisticsVo.setStayFemaleCount(dataList.stream().filter(x -> GenderDictionaryEnum.FEMALE.getCode().equals(x.getGender()) && StudyStatusEnum.InResidence.getCode().equals(x.getStduyStatus())).count());
+        statisticsVo.setNotStayMaleCount(dataList.stream().filter(x -> GenderDictionaryEnum.MALE.getCode().equals(x.getGender()) && StudyStatusEnum.AttendDaySchool.getCode().equals(x.getStduyStatus())).count());
+        statisticsVo.setNotStayFemaleCount(dataList.stream().filter(x -> GenderDictionaryEnum.FEMALE.getCode().equals(x.getGender()) && StudyStatusEnum.AttendDaySchool.getCode().equals(x.getStduyStatus())).count());
+        Map<String, List<StudentReportRecordStatisticsListVo>> graduatedUniversityMap = dataList.stream().collect(Collectors.groupingBy(StudentReportRecordStatisticsListVo::getGraduatedUniversity));
+        List<ItemCountVo> graduatedUniversityList = new ArrayList<>();
+        for (String graduatedUniversity : graduatedUniversityMap.keySet()) {
+            graduatedUniversityList.add(
+                    new ItemCountVo(){{
+                        setItem(graduatedUniversity);
+                        setCount(graduatedUniversityMap.get(graduatedUniversity).size());
+                    }}
+            );
+        }
+        statisticsVo.setGraduatedUniversityList(graduatedUniversityList);
         return RT.ok(statisticsVo);
     }
 

+ 6 - 0
src/main/java/com/xjrsoft/module/student/dto/StudentReportRecordStatisticsDto.java

@@ -20,4 +20,10 @@ public class StudentReportRecordStatisticsDto extends PageInput {
 
     @ApiModelProperty("学期id(不传查询最新一学期的)")
     private Long baseSemesterId;
+
+    @ApiModelProperty("年级id")
+    private Long gradeId;
+
+    @ApiModelProperty("招生类型(xjr_dictionary_detail[enroll_type])")
+    private String enrollType;
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/student/mapper/StudentReportRecordMapper.java

@@ -3,10 +3,13 @@ package com.xjrsoft.module.student.mapper;
 import com.github.yulichang.base.MPJBaseMapper;
 import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
 import com.xjrsoft.module.student.entity.StudentReportRecord;
+import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsListVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
 * @title: 学生报到记录表
 * @Author dzx
@@ -18,4 +21,5 @@ public interface StudentReportRecordMapper extends MPJBaseMapper<StudentReportRe
 
     StudentReportRecordStatisticsVo getClassStatistics(@Param("dto") StudentReportRecordStatisticsDto dto);
 
+    List<StudentReportRecordStatisticsListVo> getStatisticsDataList(@Param("dto") StudentReportRecordStatisticsDto dto);
 }

+ 7 - 0
src/main/java/com/xjrsoft/module/student/service/IStudentReportRecordService.java

@@ -3,7 +3,11 @@ package com.xjrsoft.module.student.service;
 import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
 import com.xjrsoft.module.student.entity.StudentReportRecord;
+import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsListVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
 * @title: 学生报到记录表
@@ -15,4 +19,7 @@ import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsVo;
 public interface IStudentReportRecordService extends MPJBaseService<StudentReportRecord> {
 
     StudentReportRecordStatisticsVo getClassStatistics(StudentReportRecordStatisticsDto dto);
+
+
+    List<StudentReportRecordStatisticsListVo> getStatisticsDataList(StudentReportRecordStatisticsDto dto);
 }

+ 8 - 0
src/main/java/com/xjrsoft/module/student/service/impl/StudentReportRecordServiceImpl.java

@@ -5,10 +5,13 @@ import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
 import com.xjrsoft.module.student.entity.StudentReportRecord;
 import com.xjrsoft.module.student.mapper.StudentReportRecordMapper;
 import com.xjrsoft.module.student.service.IStudentReportRecordService;
+import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsListVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
 * @title: 学生报到记录表
 * @Author dzx
@@ -22,4 +25,9 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
     public StudentReportRecordStatisticsVo getClassStatistics(StudentReportRecordStatisticsDto dto) {
         return this.baseMapper.getClassStatistics(dto);
     }
+
+    @Override
+    public List<StudentReportRecordStatisticsListVo> getStatisticsDataList(StudentReportRecordStatisticsDto dto) {
+        return this.baseMapper.getStatisticsDataList(dto);
+    }
 }

+ 37 - 0
src/main/java/com/xjrsoft/module/student/vo/StudentReportRecordStatisticsListVo.java

@@ -0,0 +1,37 @@
+package com.xjrsoft.module.student.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+
+/**
+* @title: 学生报到记录表表单出参
+* @Author dzx
+* @Date: 2024-08-28
+* @Version 1.0
+*/
+@Data
+public class StudentReportRecordStatisticsListVo {
+
+
+    @ApiModelProperty("姓名")
+    private String name;
+
+    @ApiModelProperty("身份证号")
+    private String credentialNumber;
+
+    @ApiModelProperty("性别")
+    private String gender;
+
+    @ApiModelProperty("毕业学校")
+    private String graduatedUniversity;
+
+    @ApiModelProperty("就读方式")
+    private String stduyStatus;
+
+    @ApiModelProperty("报到时间")
+    private LocalDateTime reportTime;
+
+}

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

@@ -52,4 +52,16 @@ public class StudentReportRecordStatisticsVo {
     @ApiModelProperty("")
     private List<ItemCountVo> graduatedUniversityList;
 
+    @ApiModelProperty("住校男学生总人数")
+    private Long stayMaleCount;
+
+    @ApiModelProperty("住校女学生总人数")
+    private Long stayFemaleCount;
+
+    @ApiModelProperty("走读男学生总人数")
+    private Long notStayMaleCount;
+
+    @ApiModelProperty("走读女学生总人数")
+    private Long notStayFemaleCount;
+
 }

+ 1 - 1
src/main/resources/application.yml

@@ -5,7 +5,7 @@ server:
 spring:
   # 环 io境 dev|pre|prod
   profiles:
-    active: dev
+    active: pre
   # jackson时间格式化
   jackson:
     time-zone: GMT+8

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

@@ -48,4 +48,14 @@
         AND t2.class_id = #{dto.teacherId}
         ORDER BY t1.create_date DESC, t2.create_date DESC,t3.create_date DESC
     </select>
+    <select id="getStatisticsDataList" parameterType="com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto"
+            resultType="com.xjrsoft.module.student.vo.StudentReportRecordStatisticsListVo">
+            SELECT t1.name,t1.credential_number,t2.gender,t4.graduated_university,t4.stduy_status,t5.report_time FROM base_new_student t1
+            INNER JOIN xjr_user t2 ON t1.credential_number = t2.credential_number
+            INNER JOIN enrollment_plan t3 ON t3.id = t1.enrollment_plan_id
+            INNER JOIN base_student_school_roll t4 ON t4.user_id = t2.id
+            LEFT JOIN student_report_record t5 ON t2.id = t5.user_id
+            WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
+            AND t3.grade_id = #{dto.gradeId} AND t3.enroll_type = #{dto.enrollType}
+    </select>
 </mapper>