|
|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|