StudentReportPlanTask.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package com.xjrsoft.module.job;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.xjrsoft.common.enums.DeleteMark;
  4. import com.xjrsoft.common.enums.EnabledMark;
  5. import com.xjrsoft.common.utils.RedisUtil;
  6. import com.xjrsoft.module.student.entity.StudentReportPlan;
  7. import com.xjrsoft.module.student.entity.StudentReportPlanClassRelation;
  8. import com.xjrsoft.module.student.service.IBaseStudentService;
  9. import com.xjrsoft.module.student.service.IStudentReportPlanService;
  10. import lombok.extern.slf4j.Slf4j;
  11. import org.hamcrest.core.Is;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.scheduling.annotation.Scheduled;
  14. import org.springframework.stereotype.Component;
  15. import java.time.LocalDateTime;
  16. import java.util.List;
  17. /**
  18. * 学生报到相关计划调整
  19. * @author dzx
  20. * @date 2025年2月10日
  21. */
  22. @Component
  23. @Slf4j
  24. public class StudentReportPlanTask {
  25. @Autowired
  26. private IStudentReportPlanService planService;
  27. @Scheduled(cron = "0 */5 * * * ?")
  28. public void execute() {
  29. doExecute();
  30. }
  31. public void doExecute(){
  32. //查询已发布未开始的,自动开始
  33. LocalDateTime now = LocalDateTime.now();
  34. List<StudentReportPlan> list = planService.getWillBeginData();
  35. for (StudentReportPlan studentReportPlan : list) {
  36. List<StudentReportPlanClassRelation> classRelationList = planService.getStudentReportPlanClassRelationList(studentReportPlan.getId());
  37. studentReportPlan.setStudentReportPlanClassRelationList(classRelationList);
  38. planService.release(studentReportPlan);
  39. }
  40. //查询已发布已结束的,自动结束
  41. List<StudentReportPlan> endList = planService.list(
  42. new QueryWrapper<StudentReportPlan>().lambda()
  43. .eq(StudentReportPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
  44. .eq(StudentReportPlan::getStatus, 1)
  45. .eq(StudentReportPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
  46. .eq(StudentReportPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
  47. .le(StudentReportPlan::getEndTime, now)
  48. );
  49. for (StudentReportPlan studentReportPlan : endList) {
  50. studentReportPlan.setStatus(2);
  51. planService.updateById(studentReportPlan);
  52. }
  53. }
  54. }