Browse Source

招生统计优化

dzx 8 months ago
parent
commit
84f835beb5

+ 113 - 0
src/main/java/com/xjrsoft/module/job/EnrollmentStatisticsInfoTask.java

@@ -0,0 +1,113 @@
+package com.xjrsoft.module.job;
+
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.module.student.dto.EnrollmentStatisticsCalendarInfoDto;
+import com.xjrsoft.module.student.dto.EnrollmentStatisticsGraduationInfoDto;
+import com.xjrsoft.module.student.dto.EnrollmentStatisticsInfoDto;
+import com.xjrsoft.module.student.entity.EnrollmentStatisticsInfo;
+import com.xjrsoft.module.student.mapper.EnrollmentStatisticsInfoMapper;
+import com.xjrsoft.module.student.service.IPbCseFeeobjupdateService;
+import com.xjrsoft.module.student.vo.EnrollmentStatisticsCalendarInfoVo;
+import com.xjrsoft.module.student.vo.EnrollmentStatisticsGraduationInfoVo;
+import com.xjrsoft.module.student.vo.EnrollmentStatisticsInfoVo;
+import com.yomahub.liteflow.util.JsonUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.time.DayOfWeek;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
+import java.util.Date;
+
+/**
+ * 将招生计划数据固化
+ *
+ * @author dzx
+ * @date 2025年3月17日
+ */
+@Component
+@Slf4j
+public class EnrollmentStatisticsInfoTask {
+
+
+    @Autowired
+    private IPbCseFeeobjupdateService pbCseFeeobjupdateService;
+
+    @Autowired
+    private EnrollmentStatisticsInfoMapper enrollmentStatisticsInfoMapper;
+
+    @Scheduled(cron = "0 */20 * * * ?")
+    public void execute() {
+        doExecute();
+    }
+
+    void doExecute() {
+        LocalDate now = LocalDate.now();
+        EnrollmentStatisticsInfoDto dto = new EnrollmentStatisticsInfoDto();
+//        dto.setDay(now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+        dto.setYear(now.getYear() + "");
+        EnrollmentStatisticsInfoVo info = pbCseFeeobjupdateService.getEnrollmentStatisticsInfo(dto);
+        if(info != null){
+
+            EnrollmentStatisticsInfo infoData = new EnrollmentStatisticsInfo();
+            infoData.setEnabledMark(EnabledMark.ENABLED.getCode());
+            infoData.setDeleteMark(DeleteMark.NODELETE.getCode());
+            infoData.setCreateDate(new Date());
+            infoData.setCreateUserId(1000000000000000000L);
+            infoData.setDataJson(JsonUtil.toJsonString(info));
+            infoData.setDataType(1);
+            enrollmentStatisticsInfoMapper.insert(infoData);
+        }
+
+        String dataDate = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        EnrollmentStatisticsGraduationInfoDto graduationInfoDto = new EnrollmentStatisticsGraduationInfoDto();
+        graduationInfoDto.setDay(dataDate);
+        EnrollmentStatisticsGraduationInfoVo graduationInfo = pbCseFeeobjupdateService.getEnrollmentStatisticsGraduationInfo(graduationInfoDto);
+
+        if(graduationInfo != null){
+            enrollmentStatisticsInfoMapper.deleteGraduationDataByDate(dataDate);
+
+            EnrollmentStatisticsInfo infoData = new EnrollmentStatisticsInfo();
+            infoData.setEnabledMark(EnabledMark.ENABLED.getCode());
+            infoData.setDeleteMark(DeleteMark.NODELETE.getCode());
+            infoData.setCreateDate(new Date());
+            infoData.setCreateUserId(1000000000000000000L);
+            infoData.setDataJson(JsonUtil.toJsonString(graduationInfo));
+            infoData.setDataType(2);
+            infoData.setDataDay(now);
+            enrollmentStatisticsInfoMapper.insert(infoData);
+        }
+
+
+        LocalDate thisSaturday = now.with(TemporalAdjusters.nextOrSame(DayOfWeek.SATURDAY));
+        LocalDate thisMonday = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+        LocalDate lastSunday = thisMonday.minusDays(1);
+
+        String thisSaturdayStr = thisSaturday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        String lastSundayStr = lastSunday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+
+        EnrollmentStatisticsCalendarInfoDto calendarInfoDto = new EnrollmentStatisticsCalendarInfoDto();
+        calendarInfoDto.setStartDay(lastSundayStr);
+        calendarInfoDto.setStartDay(thisSaturdayStr);
+        EnrollmentStatisticsCalendarInfoVo calendarInfoVo = pbCseFeeobjupdateService.getEnrollmentStatisticsCalendarInfo(calendarInfoDto);
+
+        if(graduationInfo != null){
+            enrollmentStatisticsInfoMapper.deleteCalendarDataByDate(lastSundayStr, thisSaturdayStr);
+
+            EnrollmentStatisticsInfo infoData = new EnrollmentStatisticsInfo();
+            infoData.setEnabledMark(EnabledMark.ENABLED.getCode());
+            infoData.setDeleteMark(DeleteMark.NODELETE.getCode());
+            infoData.setCreateDate(new Date());
+            infoData.setCreateUserId(1000000000000000000L);
+            infoData.setDataJson(JsonUtil.toJsonString(calendarInfoVo));
+            infoData.setDataType(3);
+            infoData.setDataStartDay(lastSunday);
+            infoData.setDataEndDay(thisSaturday);
+            enrollmentStatisticsInfoMapper.insert(infoData);
+        }
+    }
+}

+ 3 - 3
src/main/java/com/xjrsoft/module/student/controller/PbCseFeeobjupdateController.java

@@ -90,7 +90,7 @@ public class PbCseFeeobjupdateController {
     @SaCheckPermission("pbcsefeeobjupdate:detail")
     @XjrLog(value = "招生统计", saveResponseData = true)
     public RT<EnrollmentStatisticsInfoVo> getEnrollmentStatisticsInfo(@Valid EnrollmentStatisticsInfoDto dto) {
-        EnrollmentStatisticsInfoVo enrollmentStatisticsInfoVo = pbCseFeeobjupdateService.getEnrollmentStatisticsInfo(dto);
+        EnrollmentStatisticsInfoVo enrollmentStatisticsInfoVo = pbCseFeeobjupdateService.getLastEnrollmentStatisticsInfo(dto);
         return RT.ok(enrollmentStatisticsInfoVo);
     }
 
@@ -99,7 +99,7 @@ public class PbCseFeeobjupdateController {
     @SaCheckPermission("pbcsefeeobjupdate:detail")
     @XjrLog(value = "招生统计每日动态数据", saveResponseData = true)
     public RT<EnrollmentStatisticsCalendarInfoVo> getEnrollmentStatisticsCalendarInfo(@Valid EnrollmentStatisticsCalendarInfoDto dto) {
-        EnrollmentStatisticsCalendarInfoVo enrollmentStatisticsCalendarInfoVo = pbCseFeeobjupdateService.getEnrollmentStatisticsCalendarInfo(dto);
+        EnrollmentStatisticsCalendarInfoVo enrollmentStatisticsCalendarInfoVo = pbCseFeeobjupdateService.getLastEnrollmentStatisticsCalendarInfo(dto);
         return RT.ok(enrollmentStatisticsCalendarInfoVo);
     }
 
@@ -108,7 +108,7 @@ public class PbCseFeeobjupdateController {
     @SaCheckPermission("pbcsefeeobjupdate:detail")
     @XjrLog(value = "招生统计毕业学校数据", saveResponseData = true)
     public RT<EnrollmentStatisticsGraduationInfoVo> getEnrollmentStatisticsGraduationInfo(@Valid EnrollmentStatisticsGraduationInfoDto dto) {
-        EnrollmentStatisticsGraduationInfoVo enrollmentStatisticsGraduationInfoVo = pbCseFeeobjupdateService.getEnrollmentStatisticsGraduationInfo(dto);
+        EnrollmentStatisticsGraduationInfoVo enrollmentStatisticsGraduationInfoVo = pbCseFeeobjupdateService.getLastEnrollmentStatisticsGraduationInfo(dto);
         return RT.ok(enrollmentStatisticsGraduationInfoVo);
     }
 

+ 91 - 0
src/main/java/com/xjrsoft/module/student/entity/EnrollmentStatisticsInfo.java

@@ -0,0 +1,91 @@
+package com.xjrsoft.module.student.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDate;
+import java.util.Date;
+
+
+/**
+ * @title: 攀宝招生数据统计表
+ * @Author dzx
+ * @Date: 2025年3月17日
+ * @Version 1.0
+ */
+@Data
+@TableName("enrollment_statistics_info")
+@ApiModel(value = "enrollment_statistics_info", description = "攀宝招生数据统计表")
+public class EnrollmentStatisticsInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键编号
+     */
+    @ApiModelProperty("主键编号")
+    @TableId
+    private Long id;
+    /**
+     * 创建人
+     */
+    @ApiModelProperty("创建人")
+    @TableField(fill = FieldFill.INSERT)
+    private Long createUserId;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty("创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private Date createDate;
+    /**
+     * 修改人
+     */
+    @ApiModelProperty("修改人")
+    @TableField(fill = FieldFill.UPDATE)
+    private Long modifyUserId;
+    /**
+     * 修改时间
+     */
+    @ApiModelProperty("修改时间")
+    @TableField(fill = FieldFill.UPDATE)
+    private Date modifyDate;
+    /**
+     * 删除标记
+     */
+    @ApiModelProperty("删除标记")
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Integer deleteMark;
+    /**
+     * 有效标志
+     */
+    @ApiModelProperty("有效标志")
+    @TableField(fill = FieldFill.INSERT)
+    private Integer enabledMark;
+    /**
+     * 数据
+     */
+    @ApiModelProperty("数据")
+    private String dataJson;
+
+    @ApiModelProperty("统计类别(1:总统计 2:毕业中学招生统计 3:日期招生数量统计)")
+    private Integer dataType;
+
+    @ApiModelProperty("统计日期")
+    private LocalDate dataDay;
+
+    @ApiModelProperty("一周开始日期")
+    private LocalDate dataStartDay;
+
+    @ApiModelProperty("一周结束日期")
+    private LocalDate dataEndDay;
+
+}

+ 24 - 0
src/main/java/com/xjrsoft/module/student/mapper/EnrollmentStatisticsInfoMapper.java

@@ -0,0 +1,24 @@
+package com.xjrsoft.module.student.mapper;
+
+import com.github.yulichang.base.MPJBaseMapper;
+import com.xjrsoft.module.student.entity.EnrollmentPlan;
+import com.xjrsoft.module.student.entity.EnrollmentStatisticsInfo;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * @title: 攀宝招生数据统计表
+ * @Author dzx
+ * @Date: 2025年3月17日
+ * @Version 1.0
+ */
+@Mapper
+public interface EnrollmentStatisticsInfoMapper extends MPJBaseMapper<EnrollmentStatisticsInfo> {
+
+    @Delete("delete from enrollment_statistics_info where delete_mark = 0 and data_day = #{dataDay} and data_type = 2")
+    Boolean deleteGraduationDataByDate(@Param("dataDay") String dataDay);
+
+    @Delete("delete from enrollment_statistics_info where delete_mark = 0 and data_start_day = #{dataStartDay} and data_end_day = #{dataEndDay} and data_type = 3")
+    Boolean deleteCalendarDataByDate(@Param("dataStartDay") String dataStartDay, @Param("dataEndDay") String dataEndDay);
+}

+ 6 - 0
src/main/java/com/xjrsoft/module/student/service/IPbCseFeeobjupdateService.java

@@ -22,4 +22,10 @@ public interface IPbCseFeeobjupdateService extends MPJBaseService<PbCseFeeobjupd
     EnrollmentStatisticsCalendarInfoVo getEnrollmentStatisticsCalendarInfo(EnrollmentStatisticsCalendarInfoDto dto);
 
     EnrollmentStatisticsGraduationInfoVo getEnrollmentStatisticsGraduationInfo(EnrollmentStatisticsGraduationInfoDto dto);
+
+    EnrollmentStatisticsInfoVo getLastEnrollmentStatisticsInfo(EnrollmentStatisticsInfoDto dto);
+
+    EnrollmentStatisticsGraduationInfoVo getLastEnrollmentStatisticsGraduationInfo(EnrollmentStatisticsGraduationInfoDto dto);
+
+    EnrollmentStatisticsCalendarInfoVo getLastEnrollmentStatisticsCalendarInfo(EnrollmentStatisticsCalendarInfoDto dto);
 }

+ 204 - 141
src/main/java/com/xjrsoft/module/student/service/impl/PbCseFeeobjupdateServiceImpl.java

@@ -1,17 +1,23 @@
 package com.xjrsoft.module.student.service.impl;
 
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
 import com.xjrsoft.module.base.entity.BaseMajorSet;
 import com.xjrsoft.module.student.dto.EnrollmentStatisticsCalendarInfoDto;
 import com.xjrsoft.module.student.dto.EnrollmentStatisticsGraduationInfoDto;
 import com.xjrsoft.module.student.dto.EnrollmentStatisticsInfoDto;
 import com.xjrsoft.module.student.entity.*;
+import com.xjrsoft.module.student.mapper.EnrollmentStatisticsInfoMapper;
 import com.xjrsoft.module.student.mapper.PbCseFeeobjupdateMapper;
 import com.xjrsoft.module.student.mapper.PbVXsxxsfytbMapper;
 import com.xjrsoft.module.student.service.IPbCseFeeobjupdateService;
 import com.xjrsoft.module.student.service.IPbCseSpecplanService;
 import com.xjrsoft.module.student.vo.*;
+import com.yomahub.liteflow.util.JsonUtil;
 import lombok.AllArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -34,9 +40,9 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 public class PbCseFeeobjupdateServiceImpl extends MPJBaseServiceImpl<PbCseFeeobjupdateMapper, PbCseFeeobjupdate> implements IPbCseFeeobjupdateService {
 
-    @Autowired
     private final IPbCseSpecplanService pbCseSpecplanService;
     private final PbVXsxxsfytbMapper pbVXsxxsfytbMapper;
+    private final EnrollmentStatisticsInfoMapper enrollmentStatisticsInfoMapper;
 
     @Override
     public EnrollmentStatisticsInfoVo getEnrollmentStatisticsInfo(EnrollmentStatisticsInfoDto dto) {
@@ -57,100 +63,102 @@ public class PbCseFeeobjupdateServiceImpl extends MPJBaseServiceImpl<PbCseFeeobj
         ;
 
         List<PbCseFeeobjupdate> pbCseFeeobjupdateList = this.selectJoinList(PbCseFeeobjupdate.class, pbCseFeeobjupdateMPJLambdaWrapper);
+        if(pbCseFeeobjupdateList.isEmpty()){
+            return null;
+        }
 
-        if (pbCseFeeobjupdateList != null && !pbCseFeeobjupdateList.isEmpty()) {
-            //专业排行
-            Map<String, Long> professionalHeadCount = pbCseFeeobjupdateList.stream().filter(x -> x.getSpecname() != null).collect(Collectors.groupingBy(PbCseFeeobjupdate::getSpecname, Collectors.counting()));
-            if (!professionalHeadCount.isEmpty()) {
-                professionalHeadCount = professionalHeadCount.entrySet().stream()
-                        .sorted(Map.Entry.<String, Long>comparingByValue().reversed())
-                        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
-                                (e1, e2) -> e1, LinkedHashMap::new));
-            }
-            //查询每个专业的缴费人数
-            List<PbVXsxxsfytbSpecnameCountVo> specnameCountVos = pbVXsxxsfytbMapper.getSpecnameCount(dto);
-            Map<String, Integer> specnameCountMap = new HashMap<>();
-            for (PbVXsxxsfytbSpecnameCountVo specnameCountVo : specnameCountVos) {
-                specnameCountMap.put(specnameCountVo.getSpecname(), specnameCountVo.getStudentCount());
-            }
+        //专业排行
+        Map<String, Long> professionalHeadCount = pbCseFeeobjupdateList.stream().filter(x -> x.getSpecname() != null).collect(Collectors.groupingBy(PbCseFeeobjupdate::getSpecname, Collectors.counting()));
+        if (!professionalHeadCount.isEmpty()) {
+            professionalHeadCount = professionalHeadCount.entrySet().stream()
+                    .sorted(Map.Entry.<String, Long>comparingByValue().reversed())
+                    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
+                            (e1, e2) -> e1, LinkedHashMap::new));
+        }
+        //查询每个专业的缴费人数
+        List<PbVXsxxsfytbSpecnameCountVo> specnameCountVos = pbVXsxxsfytbMapper.getSpecnameCount(dto);
+        Map<String, Integer> specnameCountMap = new HashMap<>();
+        for (PbVXsxxsfytbSpecnameCountVo specnameCountVo : specnameCountVos) {
+            specnameCountMap.put(specnameCountVo.getSpecname(), specnameCountVo.getStudentCount());
+        }
 
 
-            //专业计划人数,余数
-            MPJLambdaWrapper<PbCseSpecplan> pbCseSpecplanMPJLambdaWrapper = new MPJLambdaWrapper<>();
-            pbCseSpecplanMPJLambdaWrapper
-                    .disableSubLogicDel()
-                    .distinct()
-                    .select("ifnull(t2.name,t.specname) as kkey")
-                    .selectAs(PbCseSpecplan::getNum, EnrollmentStatisticsInfoKeyValue::getValue)
-                    .leftJoin(BaseMajorSet.class, BaseMajorSet::getName, PbCseSpecplan::getSpecname)
-                    .leftJoin(BaseMajorCategor.class, BaseMajorCategor::getId, BaseMajorSet::getMajorCategorId)
-                    .eq(dto.getYear() != null, PbCseSpecplan::getXyear, dto.getYear())
-            ;
-
-            List<EnrollmentStatisticsInfoKeyValue> pbCseSpecplanList = pbCseSpecplanService.selectJoinList(EnrollmentStatisticsInfoKeyValue.class, pbCseSpecplanMPJLambdaWrapper);
-
-            Map<String, Long> pbCseSpecplanSumMap = pbCseSpecplanList.stream().collect(Collectors.groupingBy(EnrollmentStatisticsInfoKeyValue::getKkey, Collectors.summingLong(EnrollmentStatisticsInfoKeyValue::getValue)));
-
-            List<ProfessionalHeadCoun> professionalHeadCountRes = new ArrayList<>();
-            for (Map.Entry<String, Long> entry : professionalHeadCount.entrySet()) {
-                professionalHeadCountRes.add(new ProfessionalHeadCoun() {{
-                    setKey(entry.getKey());
-                    setValue(entry.getValue());
-                    if (pbCseSpecplanSumMap.get(entry.getKey()) != null) {
-                        setPlannedNumber(pbCseSpecplanSumMap.get(entry.getKey()));
-                        setRemainder(pbCseSpecplanSumMap.get(entry.getKey()) - entry.getValue());
-                        setPaymentCount(specnameCountMap.get(entry.getKey()));
-                    }
-                    if (specnameCountMap.get(entry.getKey()) != null) {
-                        setPaymentCount(specnameCountMap.get(entry.getKey()));
-                    }
-                }});
-            }
+        //专业计划人数,余数
+        MPJLambdaWrapper<PbCseSpecplan> pbCseSpecplanMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        pbCseSpecplanMPJLambdaWrapper
+                .disableSubLogicDel()
+                .distinct()
+                .select("ifnull(t2.name,t.specname) as kkey")
+                .selectAs(PbCseSpecplan::getNum, EnrollmentStatisticsInfoKeyValue::getValue)
+                .leftJoin(BaseMajorSet.class, BaseMajorSet::getName, PbCseSpecplan::getSpecname)
+                .leftJoin(BaseMajorCategor.class, BaseMajorCategor::getId, BaseMajorSet::getMajorCategorId)
+                .eq(dto.getYear() != null, PbCseSpecplan::getXyear, dto.getYear())
+        ;
 
-            //学生类型
+        List<EnrollmentStatisticsInfoKeyValue> pbCseSpecplanList = pbCseSpecplanService.selectJoinList(EnrollmentStatisticsInfoKeyValue.class, pbCseSpecplanMPJLambdaWrapper);
+
+        Map<String, Long> pbCseSpecplanSumMap = pbCseSpecplanList.stream().collect(Collectors.groupingBy(EnrollmentStatisticsInfoKeyValue::getKkey, Collectors.summingLong(EnrollmentStatisticsInfoKeyValue::getValue)));
+
+        List<ProfessionalHeadCoun> professionalHeadCountRes = new ArrayList<>();
+        for (Map.Entry<String, Long> entry : professionalHeadCount.entrySet()) {
+            professionalHeadCountRes.add(new ProfessionalHeadCoun() {{
+                setKey(entry.getKey());
+                setValue(entry.getValue());
+                if (pbCseSpecplanSumMap.get(entry.getKey()) != null) {
+                    setPlannedNumber(pbCseSpecplanSumMap.get(entry.getKey()));
+                    setRemainder(pbCseSpecplanSumMap.get(entry.getKey()) - entry.getValue());
+                    setPaymentCount(specnameCountMap.get(entry.getKey()));
+                }
+                if (specnameCountMap.get(entry.getKey()) != null) {
+                    setPaymentCount(specnameCountMap.get(entry.getKey()));
+                }
+            }});
+        }
+
+        //学生类型
 //            Map<String, Long> studentSource = pbCseFeeobjupdateList.stream().filter(x -> x.getResourcename() != null).collect(Collectors.groupingBy(PbCseFeeobjupdate::getResourcename, Collectors.counting()));
 //            List<EnrollmentStatisticsInfoKeyValue> studentSourceRes = new ArrayList<>();
 //            for (Map.Entry<String, Long> entry : studentSource.entrySet()) {
 //                studentSourceRes.add(new EnrollmentStatisticsInfoKeyValue(entry.getKey(), entry.getValue()));
 //            }
 
-            Map<String, Long> graduations = pbCseFeeobjupdateList.stream().filter(x -> x.getGraduations() != null).collect(Collectors.groupingBy(PbCseFeeobjupdate::getGraduations, Collectors.counting()));
-            List<EnrollmentStatisticsInfoKeyValue> graduationsRes = new ArrayList<>();
-            for (Map.Entry<String, Long> entry : graduations.entrySet()) {
-                graduationsRes.add(new EnrollmentStatisticsInfoKeyValue(entry.getKey(), entry.getValue()));
-            }
+        Map<String, Long> graduations = pbCseFeeobjupdateList.stream().filter(x -> x.getGraduations() != null).collect(Collectors.groupingBy(PbCseFeeobjupdate::getGraduations, Collectors.counting()));
+        List<EnrollmentStatisticsInfoKeyValue> graduationsRes = new ArrayList<>();
+        for (Map.Entry<String, Long> entry : graduations.entrySet()) {
+            graduationsRes.add(new EnrollmentStatisticsInfoKeyValue(entry.getKey(), entry.getValue()));
+        }
 
-            //住宿类型
-            Map<String, Long> accommodationType = pbCseFeeobjupdateList.stream().filter(x -> x.getQuartername() != null).collect(Collectors.groupingBy(PbCseFeeobjupdate::getQuartername, Collectors.counting()));
-            List<EnrollmentStatisticsInfoKeyValue> accommodationTypeRes = new ArrayList<>();
-            for (Map.Entry<String, Long> entry : accommodationType.entrySet()) {
-                accommodationTypeRes.add(new EnrollmentStatisticsInfoKeyValue(entry.getKey(), entry.getValue()));
-            }
+        //住宿类型
+        Map<String, Long> accommodationType = pbCseFeeobjupdateList.stream().filter(x -> x.getQuartername() != null).collect(Collectors.groupingBy(PbCseFeeobjupdate::getQuartername, Collectors.counting()));
+        List<EnrollmentStatisticsInfoKeyValue> accommodationTypeRes = new ArrayList<>();
+        for (Map.Entry<String, Long> entry : accommodationType.entrySet()) {
+            accommodationTypeRes.add(new EnrollmentStatisticsInfoKeyValue(entry.getKey(), entry.getValue()));
+        }
 
-            //性别
-            Map<String, Long> gender = pbCseFeeobjupdateList.stream().collect(Collectors.groupingBy(PbCseFeeobjupdate::getSex, Collectors.counting()));
-            List<EnrollmentStatisticsInfoKeyValue> genderRes = new ArrayList<>();
-            for (Map.Entry<String, Long> entry : gender.entrySet()) {
-                genderRes.add(new EnrollmentStatisticsInfoKeyValue(entry.getKey(), entry.getValue()));
-            }
+        //性别
+        Map<String, Long> gender = pbCseFeeobjupdateList.stream().collect(Collectors.groupingBy(PbCseFeeobjupdate::getSex, Collectors.counting()));
+        List<EnrollmentStatisticsInfoKeyValue> genderRes = new ArrayList<>();
+        for (Map.Entry<String, Long> entry : gender.entrySet()) {
+            genderRes.add(new EnrollmentStatisticsInfoKeyValue(entry.getKey(), entry.getValue()));
+        }
+
+        result.setRegistrationPopulation(pbCseFeeobjupdateList.size());
+        result.setProfessionalHeadCount(professionalHeadCountRes);
+        result.setStudentSource(graduationsRes);
+        result.setAccommodationType(accommodationTypeRes);
+        result.setGender(genderRes);
+
+        //获取所有学生的收费明细
+        MPJLambdaWrapper<PbCseFeeobjupdate> feeobjupdateXssfdetailMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        feeobjupdateXssfdetailMPJLambdaWrapper
+                .select("count(distinct t1.personalid) as payers")
+                .selectSum(PbVXssfdetail::getMny, EnrollmentStatisticsInfoVo::getRecordedAmountOfMoney)
+                .leftJoin(PbVXssfdetail.class, PbVXssfdetail::getPersonalid, PbCseFeeobjupdate::getPersonalid)
+                .eq(dto.getYear() != null, PbCseFeeobjupdate::getEnteryear, dto.getYear())
+        ;
+        EnrollmentStatisticsInfoVo enrollmentStatisticsInfoVo = this.selectJoinOne(EnrollmentStatisticsInfoVo.class, feeobjupdateXssfdetailMPJLambdaWrapper);
 
-            result.setRegistrationPopulation(pbCseFeeobjupdateList.size());
-            result.setProfessionalHeadCount(professionalHeadCountRes);
-            result.setStudentSource(graduationsRes);
-            result.setAccommodationType(accommodationTypeRes);
-            result.setGender(genderRes);
-
-            //获取所有学生的收费明细
-            MPJLambdaWrapper<PbCseFeeobjupdate> feeobjupdateXssfdetailMPJLambdaWrapper = new MPJLambdaWrapper<>();
-            feeobjupdateXssfdetailMPJLambdaWrapper
-                    .select("count(distinct t1.personalid) as payers")
-                    .selectSum(PbVXssfdetail::getMny, EnrollmentStatisticsInfoVo::getRecordedAmountOfMoney)
-                    .leftJoin(PbVXssfdetail.class, PbVXssfdetail::getPersonalid, PbCseFeeobjupdate::getPersonalid)
-                    .eq(dto.getYear() != null, PbCseFeeobjupdate::getEnteryear, dto.getYear())
-            ;
-            EnrollmentStatisticsInfoVo enrollmentStatisticsInfoVo = this.selectJoinOne(EnrollmentStatisticsInfoVo.class, feeobjupdateXssfdetailMPJLambdaWrapper);
-
-            //退费金额
+        //退费金额
 //            MPJLambdaWrapper<PbCseFeeobjupdate> feeobjupdateXssfdetailMPJLambdaWrapper = new MPJLambdaWrapper<>();
 //            feeobjupdateXssfdetailMPJLambdaWrapper
 //                    .selectCount(PbVXssfdetail::getPersonalid, EnrollmentStatisticsInfoVo::getPayers)
@@ -160,53 +168,52 @@ public class PbCseFeeobjupdateServiceImpl extends MPJBaseServiceImpl<PbCseFeeobj
 //            ;
 //            EnrollmentStatisticsInfoVo enrollmentStatisticsInfoVo = this.selectJoinOne(EnrollmentStatisticsInfoVo.class, feeobjupdateXssfdetailMPJLambdaWrapper);
 
-            //缴费人数,入账金额
-            if (enrollmentStatisticsInfoVo != null) {
-                result.setPayers(enrollmentStatisticsInfoVo.getPayers());
-                if (enrollmentStatisticsInfoVo.getRecordedAmountOfMoney() != null) {
-                    result.setRecordedAmountOfMoney(enrollmentStatisticsInfoVo.getRecordedAmountOfMoney().setScale(2, RoundingMode.DOWN));
-                }
+        //缴费人数,入账金额
+        if (enrollmentStatisticsInfoVo != null) {
+            result.setPayers(enrollmentStatisticsInfoVo.getPayers());
+            if (enrollmentStatisticsInfoVo.getRecordedAmountOfMoney() != null) {
+                result.setRecordedAmountOfMoney(enrollmentStatisticsInfoVo.getRecordedAmountOfMoney().setScale(2, RoundingMode.DOWN));
             }
+        }
 
-            //获取所有学生的缴费详情
-            MPJLambdaWrapper<PbCseFeeobjupdate> feeobjupdateMPJLambdaWrapper = new MPJLambdaWrapper<>();
-            feeobjupdateMPJLambdaWrapper
-                    .selectAs(PbCseFeeitem2::getShortname, PbVXssfdetail::getFeeitemname)
-                    .selectAs(PbCseFeeobjupdate::getPersonalid, PbVXssfdetail::getPersonalid)
-                    .selectAs(PbVXssfdetail::getMny, PbVXssfdetail::getMny)
-                    .leftJoin(PbVXssfdetail.class, PbVXssfdetail::getPersonalid, PbCseFeeobjupdate::getPersonalid)
-                    .leftJoin(PbCseFeeitem2.class, PbCseFeeitem2::getFeeitemname, PbVXssfdetail::getFeeitemname)
-                    .eq(dto.getYear() != null, PbCseFeeobjupdate::getEnteryear, dto.getYear())
-                    .isNotNull(PbVXssfdetail::getFeeitemname)
-            ;
-            List<PbVXssfdetail> pbVXssfdetails = this.selectJoinList(PbVXssfdetail.class, feeobjupdateMPJLambdaWrapper);
-
-            //收费项目情况统计
-            Map<String, Long> pbVXssfdetailMap = pbVXssfdetails.stream().collect(Collectors.groupingBy(PbVXssfdetail::getFeeitemname, Collectors.counting()));
-            Map<String, BigDecimal> pbVXssfdetailSumMap = pbVXssfdetails.stream()
-                    .collect(Collectors.groupingBy(PbVXssfdetail::getFeeitemname,
-                            Collectors.mapping(PbVXssfdetail::getMny, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
-
-            List<ChargingSituationVo> chargingSituationVoRes = new ArrayList<>();
-            DecimalFormat df = new DecimalFormat("#.##");
-            for (Map.Entry<String, Long> entry : pbVXssfdetailMap.entrySet()) {
-                chargingSituationVoRes.add(new ChargingSituationVo() {{
-                    setFeeitemname(entry.getKey());
-                    setPaid(entry.getValue());
-                    if (entry.getKey().equals("普通中专、职业高中、成人中专普通宿舍") && !accommodationType.isEmpty() && accommodationType.get("住宿") != null) {
-                        setUnpaid(accommodationType.get("住宿") - entry.getValue());
-                        setRateOfPayment(df.format((double) entry.getValue() / accommodationType.get("住宿") * 100) + "%");
-                    } else {
-                        setUnpaid(result.getRegistrationPopulation() - entry.getValue());
-                        setRateOfPayment(df.format((double) entry.getValue() / result.getRegistrationPopulation() * 100) + "%");
-                    }
-                    if (pbVXssfdetailSumMap.get(entry.getKey()) != null) {
-                        setRecordedmoney(pbVXssfdetailSumMap.get(entry.getKey()).setScale(2, RoundingMode.DOWN));
-                    }
-                }});
-            }
-            result.setChargingSituationVoList(chargingSituationVoRes);
+        //获取所有学生的缴费详情
+        MPJLambdaWrapper<PbCseFeeobjupdate> feeobjupdateMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        feeobjupdateMPJLambdaWrapper
+                .selectAs(PbCseFeeitem2::getShortname, PbVXssfdetail::getFeeitemname)
+                .selectAs(PbCseFeeobjupdate::getPersonalid, PbVXssfdetail::getPersonalid)
+                .selectAs(PbVXssfdetail::getMny, PbVXssfdetail::getMny)
+                .leftJoin(PbVXssfdetail.class, PbVXssfdetail::getPersonalid, PbCseFeeobjupdate::getPersonalid)
+                .leftJoin(PbCseFeeitem2.class, PbCseFeeitem2::getFeeitemname, PbVXssfdetail::getFeeitemname)
+                .eq(dto.getYear() != null, PbCseFeeobjupdate::getEnteryear, dto.getYear())
+                .isNotNull(PbVXssfdetail::getFeeitemname)
+        ;
+        List<PbVXssfdetail> pbVXssfdetails = this.selectJoinList(PbVXssfdetail.class, feeobjupdateMPJLambdaWrapper);
+
+        //收费项目情况统计
+        Map<String, Long> pbVXssfdetailMap = pbVXssfdetails.stream().collect(Collectors.groupingBy(PbVXssfdetail::getFeeitemname, Collectors.counting()));
+        Map<String, BigDecimal> pbVXssfdetailSumMap = pbVXssfdetails.stream()
+                .collect(Collectors.groupingBy(PbVXssfdetail::getFeeitemname,
+                        Collectors.mapping(PbVXssfdetail::getMny, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
+
+        List<ChargingSituationVo> chargingSituationVoRes = new ArrayList<>();
+        DecimalFormat df = new DecimalFormat("#.##");
+        for (Map.Entry<String, Long> entry : pbVXssfdetailMap.entrySet()) {
+            chargingSituationVoRes.add(new ChargingSituationVo() {{
+                setFeeitemname(entry.getKey());
+                setPaid(entry.getValue());
+                if (entry.getKey().equals("普通中专、职业高中、成人中专普通宿舍") && !accommodationType.isEmpty() && accommodationType.get("住宿") != null) {
+                    setUnpaid(accommodationType.get("住宿") - entry.getValue());
+                    setRateOfPayment(df.format((double) entry.getValue() / accommodationType.get("住宿") * 100) + "%");
+                } else {
+                    setUnpaid(result.getRegistrationPopulation() - entry.getValue());
+                    setRateOfPayment(df.format((double) entry.getValue() / result.getRegistrationPopulation() * 100) + "%");
+                }
+                if (pbVXssfdetailSumMap.get(entry.getKey()) != null) {
+                    setRecordedmoney(pbVXssfdetailSumMap.get(entry.getKey()).setScale(2, RoundingMode.DOWN));
+                }
+            }});
         }
+        result.setChargingSituationVoList(chargingSituationVoRes);
 
         return result;
     }
@@ -265,24 +272,80 @@ public class PbCseFeeobjupdateServiceImpl extends MPJBaseServiceImpl<PbCseFeeobj
                 .like(PbCseFeeobjupdate::getCratetime, day)
         ;
         List<PbCseFeeobjupdate> pbCseFeeobjupdateByDayList = this.selectJoinList(PbCseFeeobjupdate.class, pbCseFeeobjupdateByDay);
+        if(pbCseFeeobjupdateByDayList.isEmpty()){
+            return null;
+        }
 
-        if (pbCseFeeobjupdateByDayList != null && !pbCseFeeobjupdateByDayList.isEmpty()) {
-            //毕业学校排行
-            Map<String, Long> graduations = pbCseFeeobjupdateByDayList.stream().collect(Collectors.groupingBy(PbCseFeeobjupdate::getGraduations, Collectors.counting()));
-            if (!graduations.isEmpty()) {
-                graduations = graduations.entrySet().stream()
-                        .sorted(Map.Entry.<String, Long>comparingByValue().reversed())
-                        .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
-                                (e1, e2) -> e1, LinkedHashMap::new));
-            }
-            List<EnrollmentStatisticsInfoKeyValue> graduationRes = new ArrayList<>();
-            for (Map.Entry<String, Long> entry : graduations.entrySet()) {
-                graduationRes.add(new EnrollmentStatisticsInfoKeyValue(entry.getKey(), entry.getValue()));
-            }
-
-            result.setGraduationList(graduationRes);
+        //毕业学校排行
+        Map<String, Long> graduations = pbCseFeeobjupdateByDayList.stream().collect(Collectors.groupingBy(PbCseFeeobjupdate::getGraduations, Collectors.counting()));
+        if (!graduations.isEmpty()) {
+            graduations = graduations.entrySet().stream()
+                    .sorted(Map.Entry.<String, Long>comparingByValue().reversed())
+                    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
+                            (e1, e2) -> e1, LinkedHashMap::new));
+        }
+        List<EnrollmentStatisticsInfoKeyValue> graduationRes = new ArrayList<>();
+        for (Map.Entry<String, Long> entry : graduations.entrySet()) {
+            graduationRes.add(new EnrollmentStatisticsInfoKeyValue(entry.getKey(), entry.getValue()));
         }
 
+        result.setGraduationList(graduationRes);
+
         return result;
     }
+
+    @Override
+    public EnrollmentStatisticsInfoVo getLastEnrollmentStatisticsInfo(EnrollmentStatisticsInfoDto dto) {
+        List<EnrollmentStatisticsInfo> list = enrollmentStatisticsInfoMapper.selectList(
+                new QueryWrapper<EnrollmentStatisticsInfo>().lambda()
+                        .eq(EnrollmentStatisticsInfo::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .eq(EnrollmentStatisticsInfo::getEnabledMark, EnabledMark.ENABLED.getCode())
+                        .eq(EnrollmentStatisticsInfo::getDataType, 1)
+                        .orderByDesc(EnrollmentStatisticsInfo::getCreateDate)
+        );
+        if(!list.isEmpty()){
+            EnrollmentStatisticsInfo result = list.get(0);
+            EnrollmentStatisticsInfoVo resultVo = JsonUtil.parseObject(result.getDataJson(), EnrollmentStatisticsInfoVo.class);
+            resultVo.setUpdateDate(result.getCreateDate());
+            return resultVo;
+        }
+        return null;
+    }
+
+    @Override
+    public EnrollmentStatisticsGraduationInfoVo getLastEnrollmentStatisticsGraduationInfo(EnrollmentStatisticsGraduationInfoDto dto) {
+        List<EnrollmentStatisticsInfo> list = enrollmentStatisticsInfoMapper.selectList(
+                new QueryWrapper<EnrollmentStatisticsInfo>().lambda()
+                        .eq(EnrollmentStatisticsInfo::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .eq(EnrollmentStatisticsInfo::getEnabledMark, EnabledMark.ENABLED.getCode())
+                        .eq(EnrollmentStatisticsInfo::getDataType, 2)
+                        .eq(StrUtil.isNotEmpty(dto.getDay()), EnrollmentStatisticsInfo::getDataDay, dto.getDay())
+                        .orderByDesc(EnrollmentStatisticsInfo::getCreateDate)
+        );
+        if(!list.isEmpty()){
+            EnrollmentStatisticsInfo result = list.get(0);
+            EnrollmentStatisticsGraduationInfoVo resultVo = JsonUtil.parseObject(result.getDataJson(), EnrollmentStatisticsGraduationInfoVo.class);
+            return resultVo;
+        }
+        return null;
+    }
+
+    @Override
+    public EnrollmentStatisticsCalendarInfoVo getLastEnrollmentStatisticsCalendarInfo(EnrollmentStatisticsCalendarInfoDto dto) {
+        List<EnrollmentStatisticsInfo> list = enrollmentStatisticsInfoMapper.selectList(
+                new QueryWrapper<EnrollmentStatisticsInfo>().lambda()
+                        .eq(EnrollmentStatisticsInfo::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .eq(EnrollmentStatisticsInfo::getEnabledMark, EnabledMark.ENABLED.getCode())
+                        .eq(EnrollmentStatisticsInfo::getDataType, 3)
+                        .eq(StrUtil.isNotEmpty(dto.getStartDay()), EnrollmentStatisticsInfo::getDataStartDay, dto.getStartDay())
+                        .eq(StrUtil.isNotEmpty(dto.getEndDay()), EnrollmentStatisticsInfo::getDataEndDay, dto.getEndDay())
+                        .orderByDesc(EnrollmentStatisticsInfo::getCreateDate)
+        );
+        if(!list.isEmpty()){
+            EnrollmentStatisticsInfo result = list.get(0);
+            EnrollmentStatisticsCalendarInfoVo resultVo = JsonUtil.parseObject(result.getDataJson(), EnrollmentStatisticsCalendarInfoVo.class);
+            return resultVo;
+        }
+        return null;
+    }
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/student/vo/EnrollmentStatisticsInfoVo.java

@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 
 @Data
@@ -49,4 +50,7 @@ public class EnrollmentStatisticsInfoVo {
      */
     @ApiModelProperty("性别")
     private List<EnrollmentStatisticsInfoKeyValue> gender;
+
+    @ApiModelProperty("最后更新时间")
+    private Date updateDate;
 }

+ 81 - 0
src/test/java/com/xjrsoft/module/job/EnrollmentStatisticsInfoTaskTest.java

@@ -0,0 +1,81 @@
+package com.xjrsoft.module.job;
+
+import com.xjrsoft.XjrSoftApplication;
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.module.student.dto.EnrollmentStatisticsGraduationInfoDto;
+import com.xjrsoft.module.student.dto.EnrollmentStatisticsInfoDto;
+import com.xjrsoft.module.student.entity.EnrollmentStatisticsInfo;
+import com.xjrsoft.module.student.mapper.EnrollmentStatisticsInfoMapper;
+import com.xjrsoft.module.student.service.IPbCseFeeobjupdateService;
+import com.xjrsoft.module.student.vo.EnrollmentStatisticsGraduationInfoVo;
+import com.xjrsoft.module.student.vo.EnrollmentStatisticsInfoVo;
+import com.yomahub.liteflow.util.JsonUtil;
+import org.junit.jupiter.api.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * @author dzx
+ * @date 2025/3/17
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = XjrSoftApplication.class)
+class EnrollmentStatisticsInfoTaskTest {
+    @Autowired
+    private IPbCseFeeobjupdateService pbCseFeeobjupdateService;
+
+    @Autowired
+    private EnrollmentStatisticsInfoMapper enrollmentStatisticsInfoMapper;
+
+    @Test
+    public void execute() {
+        doExecute();
+    }
+
+    void doExecute() {
+        LocalDate now = LocalDate.now();
+        EnrollmentStatisticsInfoDto dto = new EnrollmentStatisticsInfoDto();
+//        dto.setDay(now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+        dto.setYear(now.getYear() + "");
+        EnrollmentStatisticsInfoVo info = pbCseFeeobjupdateService.getEnrollmentStatisticsInfo(dto);
+        if(info != null){
+
+            EnrollmentStatisticsInfo infoData = new EnrollmentStatisticsInfo();
+            infoData.setEnabledMark(EnabledMark.ENABLED.getCode());
+            infoData.setDeleteMark(DeleteMark.NODELETE.getCode());
+            infoData.setCreateDate(new Date());
+            infoData.setCreateUserId(1000000000000000000L);
+            infoData.setDataJson(JsonUtil.toJsonString(info));
+            infoData.setDataType(1);
+            enrollmentStatisticsInfoMapper.insert(infoData);
+        }
+
+        String dataDate = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        EnrollmentStatisticsGraduationInfoDto graduationInfoDto = new EnrollmentStatisticsGraduationInfoDto();
+        graduationInfoDto.setDay(dataDate);
+        EnrollmentStatisticsGraduationInfoVo graduationInfo = pbCseFeeobjupdateService.getEnrollmentStatisticsGraduationInfo(graduationInfoDto);
+
+        if(graduationInfo != null){
+            enrollmentStatisticsInfoMapper.deleteGraduationDataByDate(dataDate);
+
+            EnrollmentStatisticsInfo infoData = new EnrollmentStatisticsInfo();
+            infoData.setEnabledMark(EnabledMark.ENABLED.getCode());
+            infoData.setDeleteMark(DeleteMark.NODELETE.getCode());
+            infoData.setCreateDate(new Date());
+            infoData.setCreateUserId(1000000000000000000L);
+            infoData.setDataJson(JsonUtil.toJsonString(graduationInfo));
+            infoData.setDataType(2);
+            infoData.setDataDay(now);
+            enrollmentStatisticsInfoMapper.insert(infoData);
+        }
+    }
+}