江体小程序和zlb接口开发 #1
@@ -38,6 +38,9 @@ public enum ScheduleEnums {
|
|||||||
JNTYZX_VENUE_TODAY_SUBSCRIBE_TASK(4, "jt-miniApp", "jntyzxVenueTodaySubscribeTask"),
|
JNTYZX_VENUE_TODAY_SUBSCRIBE_TASK(4, "jt-miniApp", "jntyzxVenueTodaySubscribeTask"),
|
||||||
JNTYZX_VENUE_TOMORROW_PULL_TASK(4, "jt-miniApp", "jntyzxVenueTodayPullTask"),
|
JNTYZX_VENUE_TOMORROW_PULL_TASK(4, "jt-miniApp", "jntyzxVenueTodayPullTask"),
|
||||||
JNTYZX_USER_INFO_CONFIG(4, "jt-miniApp", "jntyzxUserInfoConfigTask"),
|
JNTYZX_USER_INFO_CONFIG(4, "jt-miniApp", "jntyzxUserInfoConfigTask"),
|
||||||
|
JNTYZX_VENUE_INFO_TODAY_RESULT_TASK(4, "jt-miniApp", "jtVenueInfoTodayResultTask"),
|
||||||
|
JNTYZX_VENUE_INFO_TOMORROW_RESULT_TASK(4, "jt-miniApp", "jtVenueInfoTomorrowResultTask"),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private final Integer moduleCode;
|
private final Integer moduleCode;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 定时任务配置器
|
||||||
|
*
|
||||||
* @Author: xiang
|
* @Author: xiang
|
||||||
* @Date: 2026-05-09 08:56
|
* @Date: 2026-05-09 08:56
|
||||||
*/
|
*/
|
||||||
@@ -20,35 +22,69 @@ public class JntyzxMiniappScheduleConfig {
|
|||||||
private final JtVenueSubscribeTask jtVenueSubscribeTask;
|
private final JtVenueSubscribeTask jtVenueSubscribeTask;
|
||||||
private final JtVenueTomorrowPullTask jtVenueTomorrowPullTask;
|
private final JtVenueTomorrowPullTask jtVenueTomorrowPullTask;
|
||||||
private final JntyzxUserInfoConfigTask jntyzxUserInfoConfigTask;
|
private final JntyzxUserInfoConfigTask jntyzxUserInfoConfigTask;
|
||||||
|
private final JtVenueInfoTodayResultTask jtVenueInfoTodayResultTask;
|
||||||
|
private final JtVenueInfoTomorrowResultTask jtVenueInfoTomorrowResultTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* token刷新
|
||||||
|
*/
|
||||||
@Scheduled(cron = "0 20,50 * * * ?")
|
@Scheduled(cron = "0 20,50 * * * ?")
|
||||||
@GetMapping("/jtTokenRefreshTask")
|
@GetMapping("/jtTokenRefreshTask")
|
||||||
public void jtTokenRefreshTask() {
|
public void jtTokenRefreshTask() {
|
||||||
jtTokenRefreshTask.run();
|
jtTokenRefreshTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Scheduled(cron = "0 0/1 10-18 * * ?")
|
/**
|
||||||
|
* 每分钟场地信息更新
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0/1 10-18 * * ?")
|
||||||
@GetMapping("/jtVenuePullTask")
|
@GetMapping("/jtVenuePullTask")
|
||||||
public void jtVenuePullTask() {
|
public void jtVenuePullTask() {
|
||||||
jtVenuePullTask.run();
|
jtVenuePullTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉取第二天场地信息
|
||||||
|
*/
|
||||||
@Scheduled(cron = "0 30 8 * * ?")
|
@Scheduled(cron = "0 30 8 * * ?")
|
||||||
@GetMapping("/jtVenueTomorrowPullTask")
|
@GetMapping("/jtVenueTomorrowPullTask")
|
||||||
public void jtVenueTomorrowPullTask() {
|
public void jtVenueTomorrowPullTask() {
|
||||||
jtVenueTomorrowPullTask.run();
|
jtVenueTomorrowPullTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置下单用户场地数据
|
||||||
|
*/
|
||||||
@Scheduled(cron = "0 40 8 * * ?")
|
@Scheduled(cron = "0 40 8 * * ?")
|
||||||
@GetMapping("/jtUserInfoConfig")
|
@GetMapping("/jtUserInfoConfig")
|
||||||
public void jtUserInfoConfig() {
|
public void jtUserInfoConfig() {
|
||||||
jntyzxUserInfoConfigTask.run();
|
jntyzxUserInfoConfigTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "5 0 9 * * ?")
|
/**
|
||||||
|
* 下单定时任务
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0 9 * * ?")
|
||||||
@GetMapping("/jtVenueSubscribeTask")
|
@GetMapping("/jtVenueSubscribeTask")
|
||||||
public void jtVenueSubscribeTask() {
|
public void jtVenueSubscribeTask() {
|
||||||
jtVenueSubscribeTask.run();
|
jtVenueSubscribeTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当天场地订阅结果
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0 17 * * ?")
|
||||||
|
@GetMapping("/jtVenueInfoTodayResultTask")
|
||||||
|
public void jtVenueInfoTodayResultTask() {
|
||||||
|
jtVenueInfoTodayResultTask.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第二天场地订阅结果
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 10 9 * * ?")
|
||||||
|
@GetMapping("/jtVenueInfoTomorrowResultTask")
|
||||||
|
public void jtVenueInfoTomorrowResultTask() {
|
||||||
|
jtVenueInfoTomorrowResultTask.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 用户场地配置任务 每日8:40运行
|
||||||
|
*
|
||||||
* @Author: xiang
|
* @Author: xiang
|
||||||
* @Date: 2026-05-09 09:58
|
* @Date: 2026-05-09 09:58
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 用户token刷新定时任务 每半个小时运行一次 在每个小时的20和50分
|
||||||
|
*
|
||||||
* @Author: xiang
|
* @Author: xiang
|
||||||
* @Date: 2026-01-15 17:29
|
* @Date: 2026-01-15 17:29
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.xiang.common.enums.ScheduleEnums;
|
||||||
|
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||||
|
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||||
|
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||||
|
import com.xiang.common.pojo.schedule.TaskResult;
|
||||||
|
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||||
|
import com.xiang.common.service.IScheduleRunLogService;
|
||||||
|
import com.xiang.common.utils.DateUtils;
|
||||||
|
import com.xiang.service.module.jntyzx.miniapp.service.IVenueService;
|
||||||
|
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 17:00查询当天的场地预定结果
|
||||||
|
*
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-05-09 14:17
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class JtVenueInfoTodayResultTask extends BaseScheduleTaskTemplate {
|
||||||
|
|
||||||
|
private final IVenueService venueService;
|
||||||
|
private final JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||||
|
|
||||||
|
public JtVenueInfoTodayResultTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||||
|
IScheduleRunLogService scheduleRunLogService,
|
||||||
|
IVenueService venueService,
|
||||||
|
JntyzxDingTalkFactory jntyzxDingTalkFactory) {
|
||||||
|
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||||
|
this.venueService = venueService;
|
||||||
|
this.jntyzxDingTalkFactory = jntyzxDingTalkFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTaskName() {
|
||||||
|
return ScheduleEnums.JNTYZX_VENUE_INFO_TODAY_RESULT_TASK.getTaskName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Integer getModule() {
|
||||||
|
return ScheduleEnums.JNTYZX_VENUE_INFO_TODAY_RESULT_TASK.getModuleCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getModuleName() {
|
||||||
|
return ScheduleEnums.JNTYZX_VENUE_INFO_TODAY_RESULT_TASK.getModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||||
|
|
||||||
|
TaskResult taskResult = new TaskResult();
|
||||||
|
taskResult.setSuccess(false);
|
||||||
|
List<SitePositionList> sitePositionLists = venueService.queryVenueService();
|
||||||
|
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||||
|
taskResult.setSummary("场地信息为空");
|
||||||
|
return taskResult;
|
||||||
|
}
|
||||||
|
List<SitePositionList> positionListList6_8 = sitePositionLists.stream().filter(VenueInfoUtils::get628VenueInfo).toList();
|
||||||
|
sendMsg(positionListList6_8, "18:00-20:00");
|
||||||
|
List<SitePositionList> positionListList8_10 = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
|
||||||
|
sendMsg(positionListList8_10, "20:00-22:00");
|
||||||
|
taskResult.setSuccess(true);
|
||||||
|
taskResult.setSummary("场地信息查询定时任务成功");
|
||||||
|
return taskResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMsg(List<SitePositionList> positionListList, String time) {
|
||||||
|
if (CollectionUtils.isNotEmpty(positionListList)) {
|
||||||
|
Map<String, SitePositionList> map = Maps.newLinkedHashMap();
|
||||||
|
for (SitePositionList sitePositionList : positionListList) {
|
||||||
|
if (map.containsKey(sitePositionList.getPlaceName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
map.put(sitePositionList.getPlaceName(), sitePositionList);
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder(DateUtils.getDateFromDate(LocalDate.now()) + "==>"+ time +"场地信息如下:\n");
|
||||||
|
map.forEach((placeName, sitePositionList) -> {
|
||||||
|
sb.append(placeName).append("订购人:").append(sitePositionList.getContacts()).append("\n");
|
||||||
|
});
|
||||||
|
jntyzxDingTalkFactory.sendMsg(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.xiang.common.enums.ScheduleEnums;
|
||||||
|
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||||
|
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||||
|
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||||
|
import com.xiang.common.pojo.schedule.TaskResult;
|
||||||
|
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||||
|
import com.xiang.common.service.IScheduleRunLogService;
|
||||||
|
import com.xiang.common.utils.DateUtils;
|
||||||
|
import com.xiang.service.module.jntyzx.miniapp.service.IVenueService;
|
||||||
|
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 9:10分查询第二天的场地预定结果
|
||||||
|
*
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-05-09 14:17
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class JtVenueInfoTomorrowResultTask extends BaseScheduleTaskTemplate {
|
||||||
|
|
||||||
|
private final IVenueService venueService;
|
||||||
|
private final JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||||
|
|
||||||
|
public JtVenueInfoTomorrowResultTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||||
|
IScheduleRunLogService scheduleRunLogService,
|
||||||
|
IVenueService venueService,
|
||||||
|
JntyzxDingTalkFactory jntyzxDingTalkFactory) {
|
||||||
|
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||||
|
this.venueService = venueService;
|
||||||
|
this.jntyzxDingTalkFactory = jntyzxDingTalkFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTaskName() {
|
||||||
|
return ScheduleEnums.JNTYZX_VENUE_INFO_TOMORROW_RESULT_TASK.getTaskName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Integer getModule() {
|
||||||
|
return ScheduleEnums.JNTYZX_VENUE_INFO_TOMORROW_RESULT_TASK.getModuleCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getModuleName() {
|
||||||
|
return ScheduleEnums.JNTYZX_VENUE_INFO_TOMORROW_RESULT_TASK.getModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||||
|
|
||||||
|
TaskResult taskResult = new TaskResult();
|
||||||
|
taskResult.setSuccess(false);
|
||||||
|
List<SitePositionList> sitePositionLists = venueService.queryTomorrowVenue();
|
||||||
|
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||||
|
taskResult.setSummary("场地信息为空");
|
||||||
|
return taskResult;
|
||||||
|
}
|
||||||
|
List<SitePositionList> positionListList6_8 = sitePositionLists.stream().filter(VenueInfoUtils::get628VenueInfo).toList();
|
||||||
|
sendMsg(positionListList6_8, "18:00-20:00");
|
||||||
|
List<SitePositionList> positionListList8_10 = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
|
||||||
|
sendMsg(positionListList8_10, "20:00-22:00");
|
||||||
|
taskResult.setSuccess(true);
|
||||||
|
taskResult.setSummary("场地信息查询定时任务成功");
|
||||||
|
return taskResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendMsg(List<SitePositionList> positionListList, String time) {
|
||||||
|
if (CollectionUtils.isNotEmpty(positionListList)) {
|
||||||
|
Map<String, SitePositionList> map = Maps.newLinkedHashMap();
|
||||||
|
for (SitePositionList sitePositionList : positionListList) {
|
||||||
|
if (map.containsKey(sitePositionList.getPlaceName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
map.put(sitePositionList.getPlaceName(), sitePositionList);
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder(DateUtils.getDateFromDate(LocalDate.now().plusDays(1)) + "==>"+ time +"场地信息如下:\n");
|
||||||
|
map.forEach((placeName, sitePositionList) -> {
|
||||||
|
sb.append(placeName).append("订购人:").append(sitePositionList.getContacts()).append("\n");
|
||||||
|
});
|
||||||
|
jntyzxDingTalkFactory.sendMsg(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,15 +54,18 @@ public class JtVenuePullTask extends BaseScheduleTaskTemplate {
|
|||||||
this.msgSendUtils = msgSendUtils;
|
this.msgSendUtils = msgSendUtils;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<SitePositionList> handleMsgSendList(List<SitePositionList> sitePositionLists, int dayOfWeek) {
|
private List<SitePositionList> handleMsgSendList(List<SitePositionList> sitePositionLists, Integer type) {
|
||||||
// 过滤出来8-10的未订购的场地信息
|
if (type == 1) {
|
||||||
sitePositionLists = sitePositionLists.stream()
|
sitePositionLists = sitePositionLists.stream()
|
||||||
.filter(VenueInfoUtils::get8210VenueInfo)
|
|
||||||
.filter(item -> StringUtils.equals(item.getContacts(), "0")).toList();
|
|
||||||
// 周六周日过滤小馆,不查询当天小馆信息
|
|
||||||
if (dayOfWeek == 6 || dayOfWeek == 7) {
|
|
||||||
return sitePositionLists.stream()
|
|
||||||
.filter(item -> !item.getPlaceName().contains("小馆"))
|
.filter(item -> !item.getPlaceName().contains("小馆"))
|
||||||
|
.filter(VenueInfoUtils::get628VenueInfo)
|
||||||
|
.filter(item -> StringUtils.equals(item.getContacts(), "0"))
|
||||||
|
.toList();
|
||||||
|
} else {
|
||||||
|
sitePositionLists = sitePositionLists.stream()
|
||||||
|
.filter(item -> !item.getPlaceName().contains("小馆"))
|
||||||
|
.filter(VenueInfoUtils::get8210VenueInfo)
|
||||||
|
.filter(item -> StringUtils.equals(item.getContacts(), "0"))
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
Map<String, SitePositionList> mapByName = Maps.newLinkedHashMap();
|
Map<String, SitePositionList> mapByName = Maps.newLinkedHashMap();
|
||||||
@@ -91,7 +94,6 @@ public class JtVenuePullTask extends BaseScheduleTaskTemplate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||||
|
|
||||||
TaskResult taskResult = new TaskResult();
|
TaskResult taskResult = new TaskResult();
|
||||||
taskResult.setSuccess(false);
|
taskResult.setSuccess(false);
|
||||||
log.info("【Venue】江体小程序场地数据拉取定时任务启动!!!time:{}", System.currentTimeMillis());
|
log.info("【Venue】江体小程序场地数据拉取定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||||
@@ -104,7 +106,6 @@ public class JtVenuePullTask extends BaseScheduleTaskTemplate {
|
|||||||
}
|
}
|
||||||
String token;
|
String token;
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
int dayOfWeek = now.getDayOfWeek().getValue();
|
|
||||||
|
|
||||||
for (UserTokenInfoDO userTokenInfoDO : availableUser) {
|
for (UserTokenInfoDO userTokenInfoDO : availableUser) {
|
||||||
if (Objects.isNull(userTokenInfoDO)) {
|
if (Objects.isNull(userTokenInfoDO)) {
|
||||||
@@ -120,18 +121,15 @@ public class JtVenuePullTask extends BaseScheduleTaskTemplate {
|
|||||||
}
|
}
|
||||||
venueService.saveOrUpdateTodayVenueInfo(sitePositionLists);
|
venueService.saveOrUpdateTodayVenueInfo(sitePositionLists);
|
||||||
|
|
||||||
sitePositionLists = handleMsgSendList(sitePositionLists, dayOfWeek);
|
List<SitePositionList> sitePositionLists6_8 = handleMsgSendList(sitePositionLists, 1);
|
||||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
|
||||||
taskResult.setSuccess(true);
|
|
||||||
taskResult.setSummary("当前无场地信息!");
|
|
||||||
return taskResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuffer msg = new StringBuffer(
|
StringBuffer msg = new StringBuffer(
|
||||||
"查询到20:00-22:00空闲场地信息=====>\n时间:" + DateUtils.getDateFromDate(LocalDate.now()) + "\n");
|
"查询到18:00-20:00空闲场地信息=====>\n时间:" + DateUtils.getDateFromDate(LocalDate.now()) + "\n");
|
||||||
sitePositionLists.forEach(item -> {
|
sitePositionLists6_8.forEach(item -> {
|
||||||
msg.append(item.getPlaceName()).append("\n");
|
msg.append(item.getPlaceName()).append("\n");
|
||||||
});
|
});
|
||||||
|
List<SitePositionList> sitePositionLists8_10 = handleMsgSendList(sitePositionLists, 2);
|
||||||
|
msg.append("查询到18:00-20:00空闲场地信息=====>\n时间:").append(DateUtils.getDateFromDate(LocalDate.now())).append("\n");
|
||||||
|
sitePositionLists8_10.forEach(item -> msg.append(item.getPlaceName()).append("\n"));
|
||||||
|
|
||||||
String key = RedisKeyConstant.JNTYZX_VENUE_MSG_SEND_KEY + RedisKeyConstant.getDate();
|
String key = RedisKeyConstant.JNTYZX_VENUE_MSG_SEND_KEY + RedisKeyConstant.getDate();
|
||||||
msgSendUtils.sendMsgRestrict1Hours(key, msg.toString());
|
msgSendUtils.sendMsgRestrict1Hours(key, msg.toString());
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场地订阅定时任务 每日9:00:00
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@RestController
|
@RestController
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场地信息获取定时任务 每日8:30拉取第二天的场地信息
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class JtVenueTomorrowPullTask extends BaseScheduleTaskTemplate {
|
public class JtVenueTomorrowPullTask extends BaseScheduleTaskTemplate {
|
||||||
@@ -96,11 +99,25 @@ public class JtVenueTomorrowPullTask extends BaseScheduleTaskTemplate {
|
|||||||
return taskResult;
|
return taskResult;
|
||||||
}
|
}
|
||||||
venueService.saveTomorrowVenueInfo(sitePositionLists);
|
venueService.saveTomorrowVenueInfo(sitePositionLists);
|
||||||
sitePositionLists = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
|
List<SitePositionList> sitePositionLists6_8 = sitePositionLists.stream().filter(VenueInfoUtils::get628VenueInfo).toList();
|
||||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
if (CollectionUtils.isEmpty(sitePositionLists6_8)) {
|
||||||
taskResult.setSummary("当前无可用场地信息");
|
taskResult.setSummary("当前无可用场地信息");
|
||||||
return taskResult;
|
return taskResult;
|
||||||
}
|
}
|
||||||
|
buildMsg(sitePositionLists6_8, "18:00-20:00");
|
||||||
|
List<SitePositionList> sitePositionLists8_10 = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
|
||||||
|
if (CollectionUtils.isEmpty(sitePositionLists8_10)) {
|
||||||
|
taskResult.setSummary("当前无可用场地信息");
|
||||||
|
return taskResult;
|
||||||
|
}
|
||||||
|
buildMsg(sitePositionLists8_10, "20:00-22:00");
|
||||||
|
|
||||||
|
taskResult.setSuccess(Boolean.TRUE);
|
||||||
|
taskResult.setSummary("场地信息获取成功!");
|
||||||
|
return taskResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildMsg(List<SitePositionList> sitePositionLists, String time) {
|
||||||
Map<String, SitePositionList> map = Maps.newLinkedHashMap();
|
Map<String, SitePositionList> map = Maps.newLinkedHashMap();
|
||||||
for (SitePositionList sitePositionList : sitePositionLists) {
|
for (SitePositionList sitePositionList : sitePositionLists) {
|
||||||
if (map.containsKey(sitePositionList.getPlaceName())) {
|
if (map.containsKey(sitePositionList.getPlaceName())) {
|
||||||
@@ -108,14 +125,10 @@ public class JtVenueTomorrowPullTask extends BaseScheduleTaskTemplate {
|
|||||||
}
|
}
|
||||||
map.put(sitePositionList.getPlaceName(), sitePositionList);
|
map.put(sitePositionList.getPlaceName(), sitePositionList);
|
||||||
}
|
}
|
||||||
StringBuffer msg = new StringBuffer("查询江体场地信息=====>\n时间:" + DateUtils.getDateFromDate(LocalDate.now().plusDays(1)) + " 20:00-22:00\n");
|
StringBuffer msg = new StringBuffer("查询江体场地信息=====>\n时间:" + DateUtils.getDateFromDate(LocalDate.now().plusDays(1)) + time + "\n");
|
||||||
map.forEach((placeName, sitePositionList) -> {
|
map.forEach((placeName, sitePositionList) -> {
|
||||||
msg.append(placeName).append("订购人:").append(sitePositionList.getContacts()).append("\n");
|
msg.append(placeName).append("订购人:").append(sitePositionList.getContacts()).append("\n");
|
||||||
});
|
});
|
||||||
jtDingTalkFactory.sendMsg(msg.toString());
|
jtDingTalkFactory.sendMsg(msg.toString());
|
||||||
|
|
||||||
taskResult.setSuccess(Boolean.TRUE);
|
|
||||||
taskResult.setSummary("场地信息获取成功!");
|
|
||||||
return taskResult;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.xiang.service.module.jntyzx.miniapp.service.IJntyzxHttpService;
|
|||||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserTokenInfoService;
|
import com.xiang.service.module.jntyzx.miniapp.service.IUserTokenInfoService;
|
||||||
import com.xiang.service.module.jntyzx.miniapp.service.IVenueService;
|
import com.xiang.service.module.jntyzx.miniapp.service.IVenueService;
|
||||||
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||||
|
import com.xiang.service.module.jntyzx.miniapp.utils.WeekendUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@@ -37,11 +38,11 @@ public class VenueServiceImpl implements IVenueService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SitePositionList> queryVenueService() {
|
public List<SitePositionList> queryVenueService() {
|
||||||
String token = userTokenInfoService.getToken("Xiang");
|
String token = userTokenInfoService.getToken("xiang");
|
||||||
if (StringUtils.isBlank(token)) {
|
if (StringUtils.isBlank(token)) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable("1", token);
|
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable(WeekendUtils.isWeekend(), token);
|
||||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
@@ -51,11 +52,11 @@ public class VenueServiceImpl implements IVenueService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SitePositionList> queryTomorrowVenue() {
|
public List<SitePositionList> queryTomorrowVenue() {
|
||||||
String token = userTokenInfoService.getToken("Xiang");
|
String token = userTokenInfoService.getToken("xiang");
|
||||||
if (StringUtils.isBlank(token)) {
|
if (StringUtils.isBlank(token)) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow("1", token);
|
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow(WeekendUtils.isWeekend(), token);
|
||||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class MsgSendUtils {
|
|||||||
String cache = (String) redisService.get(redisKey);
|
String cache = (String) redisService.get(redisKey);
|
||||||
if (StringUtils.isNotBlank(cache)) {
|
if (StringUtils.isNotBlank(cache)) {
|
||||||
int sendNum = Integer.parseInt(cache);
|
int sendNum = Integer.parseInt(cache);
|
||||||
if (sendNum >= 0 && sendNum <= 5) {
|
if (sendNum >= 0 && sendNum < 5) {
|
||||||
jtDingTalkFactory.sendMsg(msgContent);
|
jtDingTalkFactory.sendMsg(msgContent);
|
||||||
redisService.set(key, String.valueOf(++sendNum), 1, TimeUnit.HOURS);
|
redisService.set(key, String.valueOf(++sendNum), 1, TimeUnit.HOURS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ public class VenueInfoUtils {
|
|||||||
public static boolean get628VenueInfo(VenueInfoDO venueInfoDO) {
|
public static boolean get628VenueInfo(VenueInfoDO venueInfoDO) {
|
||||||
return StringUtils.equals(venueInfoDO.getSjName(), "18:00-19:00") || StringUtils.equals(venueInfoDO.getSjName(), "19:00-20:00");
|
return StringUtils.equals(venueInfoDO.getSjName(), "18:00-19:00") || StringUtils.equals(venueInfoDO.getSjName(), "19:00-20:00");
|
||||||
}
|
}
|
||||||
|
public static boolean get628VenueInfo(SitePositionList sitePositionList) {
|
||||||
|
return StringUtils.equals(sitePositionList.getSjName(), "18:00-19:00") || StringUtils.equals(sitePositionList.getSjName(), "19:00-20:00");
|
||||||
|
}
|
||||||
public static boolean get8210VenueInfo(VenueInfoDO venueInfoDO) {
|
public static boolean get8210VenueInfo(VenueInfoDO venueInfoDO) {
|
||||||
return StringUtils.equals(venueInfoDO.getSjName(), "20:00-21:00") || StringUtils.equals(venueInfoDO.getSjName(), "21:00-22:00");
|
return StringUtils.equals(venueInfoDO.getSjName(), "20:00-21:00") || StringUtils.equals(venueInfoDO.getSjName(), "21:00-22:00");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,41 +18,57 @@ public class ZlbTaskConfig {
|
|||||||
private final ZlbOrderTask zlbOrderTask;
|
private final ZlbOrderTask zlbOrderTask;
|
||||||
private final ZlbUserConfigTask zlbUserConfigTask;
|
private final ZlbUserConfigTask zlbUserConfigTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* token续期
|
||||||
|
*/
|
||||||
@Scheduled(cron = "0 0/30 * * * ?")
|
@Scheduled(cron = "0 0/30 * * * ?")
|
||||||
@GetMapping("/zlbLoginTask")
|
@GetMapping("/zlbLoginTask")
|
||||||
public void zlbLoginTask() {
|
public void zlbLoginTask() {
|
||||||
zlbLoginTask.run();
|
zlbLoginTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* token校验
|
||||||
|
*/
|
||||||
@Scheduled(cron = "0 0 8 * * *")
|
@Scheduled(cron = "0 0 8 * * *")
|
||||||
@GetMapping("/zlbTokenRefresh")
|
@GetMapping("/zlbTokenRefresh")
|
||||||
public void zlbTokenRefresh() {
|
public void zlbTokenRefresh() {
|
||||||
zlbTokenRefreshTask.run();
|
zlbTokenRefreshTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场地信息拉取 拉取后天的场地信息
|
||||||
|
*/
|
||||||
@GetMapping("/zlbSiteTask")
|
@GetMapping("/zlbSiteTask")
|
||||||
@Scheduled(cron = "30 30 16 * * ?")
|
@Scheduled(cron = "30 30 16 * * ?")
|
||||||
public void zlbSiteTask() {
|
public void zlbSiteTask() {
|
||||||
zlbSiteTask.run();
|
zlbSiteTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当天场地订阅信息--数据库数据
|
||||||
|
*/
|
||||||
@GetMapping("/zlbSiteDayTask")
|
@GetMapping("/zlbSiteDayTask")
|
||||||
@Scheduled(cron = "0 00 17 * * ?")
|
@Scheduled(cron = "0 00 17 * * ?")
|
||||||
public void zlbSiteDayTask() {
|
public void zlbSiteDayTask() {
|
||||||
zlbSiteDayTask.run();
|
zlbSiteDayTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下单
|
||||||
|
*/
|
||||||
@GetMapping("/zlbOrderCreateTask")
|
@GetMapping("/zlbOrderCreateTask")
|
||||||
@Scheduled(cron = "2 0 9 * * ?")
|
@Scheduled(cron = "2 0 9 * * ?")
|
||||||
public void zlbOrderCreateTask() {
|
public void zlbOrderCreateTask() {
|
||||||
zlbOrderTask.run();
|
zlbOrderTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下单用户场地配置信息
|
||||||
|
*/
|
||||||
@Scheduled(cron = "30 35 16 * * ?")
|
@Scheduled(cron = "30 35 16 * * ?")
|
||||||
@GetMapping("/zlbUserConfig")
|
@GetMapping("/zlbUserConfig")
|
||||||
public void zlbUserConfig() {
|
public void zlbUserConfig() {
|
||||||
zlbUserConfigTask.run();
|
zlbUserConfigTask.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user