3 Commits

Author SHA1 Message Date
Xiang
14f64e94ad feat:新增当天场地信息拉取 2026-01-19 14:12:41 +08:00
Xiang
286190ff0b perf:周六周日过滤小馆,不查询当天小馆信息 2026-01-19 11:22:15 +08:00
Xiang
ec8826508a perf:周六周日过滤小馆,不查询当天小馆信息 2026-01-19 11:22:03 +08:00
6 changed files with 90 additions and 15 deletions

View File

@@ -10,7 +10,6 @@ import java.util.List;
* @Date: 2025-12-16 09:19 * @Date: 2025-12-16 09:19
*/ */
public interface IUserTokenInfoManage extends IService<UserTokenInfoDO> { public interface IUserTokenInfoManage extends IService<UserTokenInfoDO> {
List<UserTokenInfoDO> listUser(); List<UserTokenInfoDO> listUser();
UserTokenInfoDO getByName(String name); UserTokenInfoDO getByName(String name);
} }

View File

@@ -12,10 +12,8 @@ import com.xiang.app.modules.jntyzx.manage.IOrderCreateInfoManage;
import com.xiang.app.modules.jntyzx.service.IJntyzxHttpService; import com.xiang.app.modules.jntyzx.service.IJntyzxHttpService;
import com.xiang.app.modules.jntyzx.service.IJtOrderService; import com.xiang.app.modules.jntyzx.service.IJtOrderService;
import com.xiang.xmc.service.cache.service.IRedisService; import com.xiang.xmc.service.cache.service.IRedisService;
import com.xiang.xservice.basic.utils.JsonUtils;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -78,6 +76,9 @@ public class OrderInfoServiceImpl implements IJtOrderService {
if (orderResp.getMessage().contains("锁卡")) { if (orderResp.getMessage().contains("锁卡")) {
return true; return true;
} }
if (orderResp.getMessage().contains("限制")) {
return true;
}
return false; return false;
} }
} }

View File

@@ -56,7 +56,7 @@ public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
@Override @Override
public boolean flushToken() { public boolean flushToken() {
List<UserTokenInfoDO> userTokenInfoDOS = userTokenInfoManage.listUser(); List<UserTokenInfoDO> userTokenInfoDOS = userTokenInfoManage.list();
if (CollectionUtils.isEmpty(userTokenInfoDOS)) { if (CollectionUtils.isEmpty(userTokenInfoDOS)) {
log.info("【心跳监测】查询用户信息为空,无需操作"); log.info("【心跳监测】查询用户信息为空,无需操作");
return true; return true;
@@ -85,8 +85,12 @@ public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
boolean flag = StringUtils.contains(jntyzxResponse.getMessage(), "已存在"); boolean flag = StringUtils.contains(jntyzxResponse.getMessage(), "已存在");
if (flag) { if (flag) {
log.info("用户名:{}心跳成功✅✅✅✅✅✅", userTokenInfoDO.getName()); log.info("用户名:{}心跳成功✅✅✅✅✅✅", userTokenInfoDO.getName());
userTokenInfoDO.setStatus(1);
userTokenInfoManage.updateById(userTokenInfoDO);
} else { } else {
jtDingTalkFactory.sendMsg("用户名:" + userTokenInfoDO.getName() + "心跳失败,消息:" + jntyzxResponse.getMessage()); jtDingTalkFactory.sendMsg("用户名:" + userTokenInfoDO.getName() + "心跳失败,消息:" + jntyzxResponse.getMessage());
userTokenInfoDO.setStatus(0);
userTokenInfoManage.updateById(userTokenInfoDO);
} }
return flag; return flag;
} }

View File

@@ -18,8 +18,8 @@ import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.time.DayOfWeek;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -47,6 +47,8 @@ public class JtVenuePullTask {
return; return;
} }
String token; String token;
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)) {
@@ -62,19 +64,30 @@ public class JtVenuePullTask {
} }
venueService.saveOrUpdateTodayVenueInfo(sitePositionLists); venueService.saveOrUpdateTodayVenueInfo(sitePositionLists);
sitePositionLists = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList(); sitePositionLists = handleMsgSendList(sitePositionLists, dayOfWeek);
if (CollectionUtils.isEmpty(sitePositionLists)) { if (CollectionUtils.isEmpty(sitePositionLists)) {
return; return;
} }
sitePositionLists = sitePositionLists.stream().filter(item -> StringUtils.equals(item.getContacts(), "0")).toList();
if (CollectionUtils.isEmpty(sitePositionLists)) { StringBuffer msg = new StringBuffer("查询到20:00-22:00空闲场地信息===>\n时间:" + DateUtils.getDateFromDate(LocalDate.now()));
return;
}
StringBuffer msg = new StringBuffer("查询到20:00-22:00空闲场地信息===>时间:" + DateUtils.getDateFromDate(LocalDate.now()) + "\n");
sitePositionLists.forEach(item -> { sitePositionLists.forEach(item -> {
msg.append(item.getPlaceName()).append("\n"); msg.append(item.getPlaceName()).append("\n");
}); });
jtDingTalkFactory.sendMsg(msg.toString()); jtDingTalkFactory.sendMsg(msg.toString());
} }
} }
private List<SitePositionList> handleMsgSendList(List<SitePositionList> sitePositionLists, int dayOfWeek) {
// 过滤出来8-10的未订购的场地信息
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("小馆"))
.toList();
}
return sitePositionLists;
}
} }

View File

@@ -0,0 +1,61 @@
package com.xiang.app.schedule.jntyzx;
import com.google.common.collect.Maps;
import com.xiang.app.common.service.dingtalk.JtDingTalkFactory;
import com.xiang.app.modules.jntyzx.entity.resp.query.SitePositionList;
import com.xiang.app.modules.jntyzx.service.IJntyzxHttpService;
import com.xiang.app.modules.jntyzx.service.IUserTokenInfoService;
import com.xiang.app.modules.jntyzx.utils.VenueInfoUtils;
import com.xiang.app.modules.jntyzx.utils.WeekendUtils;
import com.xiang.core.quartz.annotation.XxzJob;
import com.xiang.xservice.basic.utils.DateUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
/**
* @Author: xiang
* @Date: 2026-01-19 14:00
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class JtVenueTodaySubscribeTask {
private final IJntyzxHttpService jntyzxHttpService;
private final IUserTokenInfoService userTokenInfoService;
private final JtDingTalkFactory jtDingTalkFactory;
@XxzJob(name = "jtVenueTodaySubscribeTask")
@GetMapping("/jtVenueTodaySubscribeTask")
public void handle() {
String token = userTokenInfoService.getToken("Xiang");
if (StringUtils.isBlank(token)) {
return;
}
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable(WeekendUtils.isWeekend(), token);
if (CollectionUtils.isEmpty(sitePositionLists)) {
return;
}
sitePositionLists = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
Map<String, SitePositionList> map = Maps.newLinkedHashMap();
for (SitePositionList sitePositionList : sitePositionLists) {
if (map.containsKey(sitePositionList.getPlaceName())) {
continue;
}
map.put(sitePositionList.getPlaceName(), sitePositionList);
}
StringBuffer msg = new StringBuffer("查询江体场地信息=====>\n时间:" + DateUtils.getDateFromDate(LocalDate.now()) + " 20:00-22:00\n");
map.forEach((placeName, sitePositionList) -> {
msg.append(placeName).append("订购人:").append(sitePositionList.getContacts()).append("\n");
});
jtDingTalkFactory.sendMsg(msg.toString());
}
}

View File

@@ -21,12 +21,9 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Component @Component
@@ -73,7 +70,7 @@ public class JtVenueTomorrowPullTask {
} }
map.put(sitePositionList.getPlaceName(), sitePositionList); map.put(sitePositionList.getPlaceName(), sitePositionList);
} }
StringBuffer msg = new StringBuffer("查询场地信息===>时间:\n" + DateUtils.getDateFromDate(LocalDate.now()) + " 20:00-22:00\n"); StringBuffer msg = new StringBuffer("查询江体场地信息===>时间:\n" + DateUtils.getDateFromDate(LocalDate.now().plusDays(1)) + " 20:00-22:00\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");
}); });