|
|
@@ -0,0 +1,85 @@
|
|
|
+package com.xjrsoft.module.job;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.xjrsoft.common.enums.DeleteMark;
|
|
|
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
+import com.xjrsoft.common.utils.DateUtils;
|
|
|
+import com.xjrsoft.common.utils.LocalDateUtil;
|
|
|
+import com.xjrsoft.common.utils.SqlRunnerAdapterUtil;
|
|
|
+import com.xjrsoft.module.evaluate.entity.EvaluateManage;
|
|
|
+import com.xjrsoft.module.internship.entity.InternshipPlanManage;
|
|
|
+import com.xjrsoft.module.internship.entity.InternshipTeacherCollect;
|
|
|
+import com.xjrsoft.module.internship.service.IInternshipPlanManageService;
|
|
|
+import com.xjrsoft.module.internship.service.IInternshipTeacherCollectService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 实习相关数据处理
|
|
|
+ */
|
|
|
+@Component
|
|
|
+@Slf4j
|
|
|
+public class InternshipTask {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IInternshipPlanManageService internshipPlanManageService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IInternshipTeacherCollectService internshipTeacherCollectService;
|
|
|
+
|
|
|
+ @Async
|
|
|
+ @Scheduled(cron = "0 0 0 * * ?")
|
|
|
+ public void addSubmitRecord() {
|
|
|
+ //查询实习计划,根据开始时间和结束时间来判断并修改状态
|
|
|
+ List<InternshipPlanManage> list = internshipPlanManageService.list(
|
|
|
+ new QueryWrapper<InternshipPlanManage>().lambda()
|
|
|
+ .eq(InternshipPlanManage::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ List<InternshipPlanManage> updateList = new ArrayList<>();
|
|
|
+ for (InternshipPlanManage planManage : list) {
|
|
|
+ if(LocalDateUtil.isDateInRange(now, planManage.getStartTime(), planManage.getEndTime())){
|
|
|
+ planManage.setStatus(1);
|
|
|
+ updateList.add(planManage);
|
|
|
+ }else if(now.isAfter(planManage.getEndTime())){
|
|
|
+ planManage.setStatus(2);
|
|
|
+ updateList.add(planManage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!updateList.isEmpty()){
|
|
|
+ internshipPlanManageService.updateBatchById(updateList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //查询实习计划,根据开始时间和结束时间来判断并修改状态
|
|
|
+ List<InternshipTeacherCollect> collectList = internshipTeacherCollectService.list(
|
|
|
+ new QueryWrapper<InternshipTeacherCollect>().lambda()
|
|
|
+ .eq(InternshipTeacherCollect::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ );
|
|
|
+
|
|
|
+ List<InternshipTeacherCollect> collectUpdateList = new ArrayList<>();
|
|
|
+ for (InternshipTeacherCollect collect : collectList) {
|
|
|
+ if(LocalDateUtil.isDateInRange(now, collect.getStartDate(), collect.getEndDate())){
|
|
|
+ collect.setStatus(1);
|
|
|
+ collectUpdateList.add(collect);
|
|
|
+ }else if(now.isAfter(collect.getEndDate())){
|
|
|
+ collect.setStatus(2);
|
|
|
+ collectUpdateList.add(collect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!collectUpdateList.isEmpty()){
|
|
|
+ internshipTeacherCollectService.updateBatchById(collectUpdateList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|