| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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.common.utils.RedisUtil;
- import com.xjrsoft.module.student.entity.StudentReportPlan;
- import com.xjrsoft.module.student.entity.StudentReportPlanClassRelation;
- import com.xjrsoft.module.student.service.IBaseStudentService;
- import com.xjrsoft.module.student.service.IStudentReportPlanService;
- import lombok.extern.slf4j.Slf4j;
- import org.hamcrest.core.Is;
- 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 */5 * * * ?")
- public void execute() {
- doExecute();
- }
- public void doExecute(){
- //查询已发布未开始的,自动开始
- LocalDateTime now = LocalDateTime.now();
- List<StudentReportPlan> list = planService.getWillBeginData();
- for (StudentReportPlan studentReportPlan : list) {
- List<StudentReportPlanClassRelation> classRelationList = planService.getStudentReportPlanClassRelationList(studentReportPlan.getId());
- studentReportPlan.setStudentReportPlanClassRelationList(classRelationList);
- 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);
- }
- }
- }
|