| | |
| | | package com.dsh.course.util; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.dsh.course.entity.CoursePackageScheduling; |
| | | import com.dsh.course.entity.CoursePackageStudent; |
| | | import com.dsh.course.entity.TCoursePackagePayment; |
| | | import com.dsh.course.service.CoursePackageStudentService; |
| | | import com.dsh.course.service.ICoursePackageSchedulingService; |
| | | import com.dsh.course.service.TCoursePackagePaymentService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | @Autowired |
| | | private ICoursePackageSchedulingService coursePackageSchedulingService; |
| | | |
| | | @Autowired |
| | | private CoursePackageStudentService coursePackageStudentService; |
| | | |
| | | |
| | | @Autowired |
| | | private RestTemplate internalRestTemplate; |
| | | |
| | | /** |
| | | * 每隔一分钟去处理的定时任务 |
| | | */ |
| | | @Scheduled(fixedRate = 60000) |
| | | public void taskMinute(){ |
| | | public void taskMinute() { |
| | | try { |
| | | //定时修改排课状态 |
| | | coursePackageSchedulingService.taskSetStatus(); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 每隔一分钟去处理的定时任务 预约课时 |
| | | */ |
| | | @Scheduled(cron = "0 0 18 * * ?") |
| | | public void pushOne() { |
| | | try { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE, 1); |
| | | Date time = instance.getTime(); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String format1 = format.format(time); |
| | | // 获取明天排课 |
| | | List<CoursePackageScheduling> list = coursePackageSchedulingService.list(new LambdaQueryWrapper<CoursePackageScheduling>().like(CoursePackageScheduling::getClassDate, format1)); |
| | | for (CoursePackageScheduling coursePackageScheduling : list) { |
| | | CoursePackageStudent one = coursePackageStudentService.getOne(new LambdaQueryWrapper<CoursePackageStudent>().eq(CoursePackageStudent::getCoursePackageSchedulingId, coursePackageScheduling.getId())); |
| | | if (one != null && one.getReservationStatus() == 1) { |
| | | Integer appUserId = one.getAppUserId(); |
| | | |
| | | //调用推送 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | String s1 = appUserId + "_" + "Class"; |
| | | //定时修改排课状态 |
| | | String s = internalRestTemplate.getForObject("http://mb-cloud-gateway/netty/sendMsgToClient?id=" + s1, String.class); |
| | | JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class); |
| | | if (jsonObject1.getIntValue("code") != 200) { |
| | | System.err.println(jsonObject1.getString("msg")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Scheduled(cron = "0 1 0 * * ?") |
| | | public void everyMorningTask() { |
| | | //定时清楚过期的课时 |
| | | coursePackageSchedulingService.taskOverdueClearing(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 零时任务 |
| | | * 每周一执行的定时任务 |
| | | */ |
| | | @Scheduled(cron = "0 0 0 * * *") |
| | | public void zeroTask(){ |
| | | @Scheduled(cron = "0 0 2 * * 2") |
| | | public void weekTask() { |
| | | //定时添加排课数据 |
| | | coursePackageSchedulingService.taskAddData(); |
| | | coursePackageSchedulingService.taskCoursePackageScheduling(); |
| | | } |
| | | } |