|
|
@@ -0,0 +1,57 @@
|
|
|
+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.IStudentReportPlanService;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author dzx
|
|
|
+ * @date 2025/2/10
|
|
|
+ */
|
|
|
+
|
|
|
+@SpringBootTest
|
|
|
+class StudentReportPlanTaskTest {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IStudentReportPlanService planService;
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void execute() {
|
|
|
+ doExecute();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void doExecute(){
|
|
|
+ //查询已发布未开始的,自动开始
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ List<StudentReportPlan> list = planService.getWillBeginData();
|
|
|
+
|
|
|
+ for (StudentReportPlan studentReportPlan : list) {
|
|
|
+ planService.release(planService.getByIdDeep(studentReportPlan.getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询已发布已结束的,自动结束
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|