Selaa lähdekoodia

开学报到导出调整

dzx 9 kuukautta sitten
vanhempi
commit
c6efe51e57

+ 68 - 0
src/main/java/com/xjrsoft/module/job/StudentReportPlanTask.java

@@ -0,0 +1,68 @@
+package com.xjrsoft.module.job;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.module.student.entity.StudentReportPlan;
+import com.xjrsoft.module.student.service.IBaseStudentService;
+import com.xjrsoft.module.student.service.IStudentReportPlanService;
+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.LocalDateTime;
+import java.util.List;
+
+/**
+ * 学生报到相关计划调整
+ * @author dzx
+ * @date 2025年2月10日
+ */
+@Component
+@Slf4j
+public class StudentReportPlanTask {
+
+    @Autowired
+    private IStudentReportPlanService planService;
+
+
+    @Scheduled(cron = "0 */15 * * * ?")
+    public void execute() {
+        doExecute();
+    }
+
+    public void doExecute(){
+        //查询已发布未开始的,自动开始
+        LocalDateTime now = LocalDateTime.now();
+        List<StudentReportPlan> list = planService.list(
+                new QueryWrapper<StudentReportPlan>().lambda()
+                        .eq(StudentReportPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .eq(StudentReportPlan::getStatus, 1)
+                        .eq(StudentReportPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
+                        .eq(StudentReportPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .le(StudentReportPlan::getStartTime, now)
+                        .ge(StudentReportPlan::getEndTime, now)
+        );
+
+        for (StudentReportPlan studentReportPlan : list) {
+            planService.release(studentReportPlan);
+        }
+
+        //查询已发布已结束的,自动结束
+        List<StudentReportPlan> endList = planService.list(
+                new QueryWrapper<StudentReportPlan>().lambda()
+                        .eq(StudentReportPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .eq(StudentReportPlan::getStatus, 1)
+                        .eq(StudentReportPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
+                        .eq(StudentReportPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .le(StudentReportPlan::getEndTime, now)
+        );
+        for (StudentReportPlan studentReportPlan : endList) {
+            studentReportPlan.setStatus(2);
+            planService.updateById(studentReportPlan);
+        }
+    }
+
+}
+

+ 4 - 1
src/main/java/com/xjrsoft/module/student/controller/StudentReportRecordController.java

@@ -463,7 +463,10 @@ public class StudentReportRecordController {
         List<StudentReportRecordExcelVo> dataList = new ArrayList<>();
         for (StudentReportRecordPlanPageVo pageVo : planPageList) {
             StudentReportRecordExcelVo excelVo = BeanUtil.toBean(pageVo, StudentReportRecordExcelVo.class);
-            excelVo.setReportTime(sdf.format(pageVo.getReportTime()));
+            if(pageVo.getReportTime() != null){
+                excelVo.setReportTime(sdf.format(pageVo.getReportTime()));
+            }
+
             dataList.add(excelVo);
         }
         ByteArrayOutputStream bot = new ByteArrayOutputStream();