From eb6b6dbb35a9f029e0b7d269773685c19fd40976 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 11 七月 2024 10:47:51 +0800
Subject: [PATCH] 玩湃微信商户认证代码
---
cloud-server-course/src/main/java/com/dsh/course/util/TaskUtil.java | 78 ++++++++++++++++++++++++++++++++++++--
1 files changed, 73 insertions(+), 5 deletions(-)
diff --git a/cloud-server-course/src/main/java/com/dsh/course/util/TaskUtil.java b/cloud-server-course/src/main/java/com/dsh/course/util/TaskUtil.java
index fb26c90..63f1251 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/util/TaskUtil.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/util/TaskUtil.java
@@ -1,9 +1,26 @@
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
@@ -15,11 +32,18 @@
@Autowired
private ICoursePackageSchedulingService coursePackageSchedulingService;
+ @Autowired
+ private CoursePackageStudentService coursePackageStudentService;
+
+
+ @Autowired
+ private RestTemplate internalRestTemplate;
+
/**
* 每隔一分钟去处理的定时任务
*/
@Scheduled(fixedRate = 60000)
- public void taskMinute(){
+ public void taskMinute() {
try {
//定时修改排课状态
coursePackageSchedulingService.taskSetStatus();
@@ -28,14 +52,58 @@
}
}
+ /**
+ * 每隔一分钟去处理的定时任务 预约课时
+ */
+ @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();
}
}
--
Gitblit v1.7.1