|
@@ -7,6 +7,7 @@ import org.jeecg.modules.app.vo.weixin.NotificationRequest;
|
|
|
import org.jeecg.modules.app.weixinService.WechatNotificationService;
|
|
import org.jeecg.modules.app.weixinService.WechatNotificationService;
|
|
|
import org.jeecg.modules.quartz.vo.JobClassNoticeVo;
|
|
import org.jeecg.modules.quartz.vo.JobClassNoticeVo;
|
|
|
import org.jeecg.modules.quartz.vo.JobExtendedClassNoticeVo;
|
|
import org.jeecg.modules.quartz.vo.JobExtendedClassNoticeVo;
|
|
|
|
|
+import org.jeecg.modules.quartz.vo.JobReservationSiteVo;
|
|
|
import org.jeecg.modules.system.app.entity.AppOrder;
|
|
import org.jeecg.modules.system.app.entity.AppOrder;
|
|
|
import org.jeecg.modules.system.app.service.IAppOrderService;
|
|
import org.jeecg.modules.system.app.service.IAppOrderService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -14,6 +15,12 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.LocalTime;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -87,9 +94,25 @@ public class WxNotificationService {
|
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
|
log.info("Start checking orders for notification at {}", now);
|
|
log.info("Start checking orders for notification at {}", now);
|
|
|
|
|
|
|
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
|
|
+ LocalTime localTime = LocalTime.now().truncatedTo(ChronoUnit.SECONDS);
|
|
|
|
|
+
|
|
|
//查询预约过学校场地的用户并通知他
|
|
//查询预约过学校场地的用户并通知他
|
|
|
-// iAppOrderService.findBySite();
|
|
|
|
|
|
|
+ List<JobReservationSiteVo> jobReservationSiteVos = iAppOrderService.findBySite(currentDate,localTime);
|
|
|
|
|
|
|
|
|
|
+ ArrayList<NotificationRequest> notificationRequests = new ArrayList<>();
|
|
|
|
|
+ for (JobReservationSiteVo jobReservationSiteVo : jobReservationSiteVos) {
|
|
|
|
|
+ NotificationRequest notificationRequest = new NotificationRequest();
|
|
|
|
|
+ notificationRequest.setOpenid(jobReservationSiteVo.getUserOpenId());
|
|
|
|
|
+ notificationRequest.setTemplateId("WSJjc9I24ijtr3EyNVXjEvTQm0gIECW9ABYVFcegOwM");
|
|
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
|
|
+ // 根据模板内容设置数据项
|
|
|
|
|
+ data.put("thing5", new JSONObject().fluentPut("value",jobReservationSiteVo.getSiteName() ));
|
|
|
|
|
+ data.put("thing3", new JSONObject().fluentPut("value", "空闲:" +getDate(currentDate,jobReservationSiteVo.getStartTime(),jobReservationSiteVo.getEndTime()) ));
|
|
|
|
|
+ notificationRequest.setData(data);
|
|
|
|
|
+ notificationRequests.add(notificationRequest);
|
|
|
|
|
+ }
|
|
|
|
|
+ notificationService.batchSendSubscribeMessages(notificationRequests);
|
|
|
log.info("Finished checking orders for notification");
|
|
log.info("Finished checking orders for notification");
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
log.error("Error occurred while checking orders for notification", e);
|
|
log.error("Error occurred while checking orders for notification", e);
|
|
@@ -115,7 +138,7 @@ public class WxNotificationService {
|
|
|
}
|
|
}
|
|
|
Date now = new Date();
|
|
Date now = new Date();
|
|
|
log.info("Start checking orders for notification at {}", now);
|
|
log.info("Start checking orders for notification at {}", now);
|
|
|
- ExecutorService executor = Executors.newFixedThreadPool(10);
|
|
|
|
|
|
|
+ ArrayList<NotificationRequest> notificationRequests = new ArrayList<>();
|
|
|
for (JobExtendedClassNoticeVo jobExtendedClassNoticeVo : jobExtendedClassNoticeVos) {
|
|
for (JobExtendedClassNoticeVo jobExtendedClassNoticeVo : jobExtendedClassNoticeVos) {
|
|
|
NotificationRequest notificationRequest = new NotificationRequest();
|
|
NotificationRequest notificationRequest = new NotificationRequest();
|
|
|
notificationRequest.setOpenid(jobExtendedClassNoticeVo.getUserOpenId());
|
|
notificationRequest.setOpenid(jobExtendedClassNoticeVo.getUserOpenId());
|
|
@@ -125,15 +148,10 @@ public class WxNotificationService {
|
|
|
data.put("thing2", new JSONObject().fluentPut("value", jobExtendedClassNoticeVo.getLassHourTime()));
|
|
data.put("thing2", new JSONObject().fluentPut("value", jobExtendedClassNoticeVo.getLassHourTime()));
|
|
|
data.put("thing1", new JSONObject().fluentPut("value", jobExtendedClassNoticeVo.getSiteName()));
|
|
data.put("thing1", new JSONObject().fluentPut("value", jobExtendedClassNoticeVo.getSiteName()));
|
|
|
data.put("thing3", new JSONObject().fluentPut("value", jobExtendedClassNoticeVo.getReasonClassExtension()));
|
|
data.put("thing3", new JSONObject().fluentPut("value", jobExtendedClassNoticeVo.getReasonClassExtension()));
|
|
|
- executor.submit(() -> {
|
|
|
|
|
- try {
|
|
|
|
|
- notificationService.sendSubscribeMessage(notificationRequest);
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- log.error("延课批量发送小程序订阅消息异常", e);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
|
|
+ notificationRequest.setData(data);
|
|
|
|
|
+ notificationRequests.add(notificationRequest);
|
|
|
}
|
|
}
|
|
|
|
|
+ notificationService.batchSendSubscribeMessages(notificationRequests);
|
|
|
//查询被延课的数据通知他
|
|
//查询被延课的数据通知他
|
|
|
// iAppOrderService.findBySite();
|
|
// iAppOrderService.findBySite();
|
|
|
|
|
|
|
@@ -183,6 +201,7 @@ public class WxNotificationService {
|
|
|
data.put("time3", new JSONObject().fluentPut("value", date));
|
|
data.put("time3", new JSONObject().fluentPut("value", date));
|
|
|
data.put("thing4", new JSONObject().fluentPut("value", siteName));
|
|
data.put("thing4", new JSONObject().fluentPut("value", siteName));
|
|
|
data.put("thing11", new JSONObject().fluentPut("value", "如有特殊情况不能上课,记得沟通延课"));
|
|
data.put("thing11", new JSONObject().fluentPut("value", "如有特殊情况不能上课,记得沟通延课"));
|
|
|
|
|
+ notificationRequest.setData(data);
|
|
|
executor.submit(() -> {
|
|
executor.submit(() -> {
|
|
|
AppOrder appOrder = iAppOrderService.getById(jobClassNoticeVo.getOrderId());
|
|
AppOrder appOrder = iAppOrderService.getById(jobClassNoticeVo.getOrderId());
|
|
|
if (appOrder==null){
|
|
if (appOrder==null){
|
|
@@ -218,4 +237,19 @@ public class WxNotificationService {
|
|
|
return sdf.format(date);
|
|
return sdf.format(date);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private String getDate(LocalDate currentDate ,Date startTime,Date endTime){
|
|
|
|
|
+
|
|
|
|
|
+ if (startTime==null|| endTime==null){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 将 Date 转换为 LocalDateTime
|
|
|
|
|
+ LocalDateTime startLdt = LocalDateTime.ofInstant(startTime.toInstant(), java.time.ZoneId.systemDefault());
|
|
|
|
|
+ LocalDateTime endLdt = LocalDateTime.ofInstant(endTime.toInstant(), java.time.ZoneId.systemDefault());
|
|
|
|
|
+ DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("MM.dd");
|
|
|
|
|
+ DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm");
|
|
|
|
|
+ String formattedDate = currentDate.format(dateFormatter);
|
|
|
|
|
+ String formattedStartTime = startLdt.format(timeFormatter);
|
|
|
|
|
+ String formattedEndTime = endLdt.format(timeFormatter);
|
|
|
|
|
+ return formattedDate + " " + formattedStartTime + "-" + formattedEndTime;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|