From dfe52245f20a8177a0db0bc2841909fb3eab0f13 Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期三, 08 十一月 2023 09:07:05 +0800
Subject: [PATCH] 后台bug修改
---
cloud-server-course/src/main/java/com/dsh/course/util/TaskUtil.java | 62 ++++++++++++++++++++++++++++++
1 files changed, 61 insertions(+), 1 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..1af557f 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
@@ -14,6 +31,13 @@
@Autowired
private ICoursePackageSchedulingService coursePackageSchedulingService;
+
+ @Autowired
+ private CoursePackageStudentService coursePackageStudentService;
+
+
+ @Autowired
+ private RestTemplate internalRestTemplate;
/**
* 每隔一分钟去处理的定时任务
@@ -27,13 +51,49 @@
e.printStackTrace();
}
}
+ /**
+ * 每隔一分钟去处理的定时任务 预约课时
+ */
+ @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 0 0 * * *")
+// @Scheduled(cron = "0 0 0 * * *")
public void zeroTask(){
//定时添加排课数据
coursePackageSchedulingService.taskAddData();
--
Gitblit v1.7.1