fix:token接口,数据获取
This commit is contained in:
@@ -7,4 +7,6 @@ package com.xiang.xservice.application.script.jntyzx.constants;
|
||||
public class RedisKeyConstant {
|
||||
|
||||
public static final String JNTYZX_ORDER_CREATE_KEY = "jntyzx:order:create:orderId:";
|
||||
|
||||
public static final String JNTUZX_ORDER_PEEK_KEY = "jntyzx:order:peek:user:";
|
||||
}
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
package com.xiang.xservice.application.script.jntyzx.schedule;
|
||||
|
||||
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||
import com.xiang.xservice.application.script.jntyzx.constants.RedisKeyConstant;
|
||||
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||
import com.xiang.xservice.application.script.jntyzx.service.DingTalkScriptVenueService;
|
||||
import com.xiang.xservice.application.script.jntyzx.service.IJntyzxHttpService;
|
||||
import com.xiang.xservice.application.script.jntyzx.service.IUserTokenInfoService;
|
||||
import com.xiang.xservice.application.script.jntyzx.service.IVenueService;
|
||||
import com.xiang.xservice.application.script.jntyzx.utils.VenueInfoUtils;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.common.entity.SysConfigDO;
|
||||
import com.xiang.xservice.common.service.ISysConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -24,6 +29,7 @@ import java.util.stream.Collectors;
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 16:12
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class VenuePeekSchedule {
|
||||
@@ -33,9 +39,11 @@ public class VenuePeekSchedule {
|
||||
private final ISysConfigService sysConfigService;
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final DingTalkScriptVenueService dingTalkScriptVenueService;
|
||||
private final IRedisService redisService;
|
||||
|
||||
@Scheduled(cron = "5 1 9-20 * * ?")
|
||||
@Scheduled(cron = "5 0/1 * * * ?")
|
||||
public void peek8210() {
|
||||
log.info("8-10捡漏定时任务启动");
|
||||
SysConfigDO config = sysConfigService.getByName("jntyzx.venue.peek.switch");
|
||||
boolean peekSwitch;
|
||||
if (Objects.isNull(config)) {
|
||||
@@ -52,23 +60,33 @@ public class VenuePeekSchedule {
|
||||
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||
return;
|
||||
}
|
||||
Map<String, List<VenueInfoDO>> map = venueInfoDOS.stream().filter(VenueInfoUtils::get8210VenueInfo).collect(Collectors.groupingBy(VenueInfoDO::getPlaceName));
|
||||
Map<String, List<VenueInfoDO>> map = venueInfoDOS.stream()
|
||||
.filter(VenueInfoUtils::get8210VenueInfo)
|
||||
.collect(Collectors.groupingBy(VenueInfoDO::getPlaceName));
|
||||
String token = userTokenInfoService.getToken("Xiang");
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return;
|
||||
}
|
||||
String key = RedisKeyConstant.JNTUZX_ORDER_PEEK_KEY + "Xiang" + DateUtils.getDateFromDate(LocalDate.now(), "yyyyMMdd");
|
||||
String redisResp = (String) redisService.get(key);
|
||||
if (StringUtils.equals(redisResp, "true")) {
|
||||
log.info("当前已捡漏,勿重复捡漏");
|
||||
return;
|
||||
}
|
||||
map.keySet().parallelStream().forEach(placeName -> {
|
||||
List<VenueInfoDO> venueInfoDOList = map.get(placeName);
|
||||
Boolean order = jntyzxHttpService.createOrder(venueInfoDOList, token);
|
||||
if (order) {
|
||||
dingTalkScriptVenueService.sendScriptMsg("场地:" + placeName + "下单成功,请付款!时间:" + LocalDateTime.now());
|
||||
redisService.set(key, "true");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "5 1 9-20 * * ?")
|
||||
@Scheduled(cron = "5 0/1 * * * ?")
|
||||
public void peek628() {
|
||||
log.info("6-8捡漏定时任务启动");
|
||||
SysConfigDO config = sysConfigService.getByName("jntyzx.venue.peek.switch");
|
||||
boolean peekSwitch;
|
||||
if (Objects.isNull(config)) {
|
||||
@@ -92,11 +110,18 @@ public class VenuePeekSchedule {
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return;
|
||||
}
|
||||
String key = RedisKeyConstant.JNTUZX_ORDER_PEEK_KEY + "Xiang" + DateUtils.getDateFromDate(LocalDate.now(), "yyyyMMdd");
|
||||
String redisResp = (String) redisService.get(key);
|
||||
if (StringUtils.equals(redisResp, "true")) {
|
||||
log.info("当前已捡漏,勿重复捡漏");
|
||||
return;
|
||||
}
|
||||
map.keySet().parallelStream().forEach(placeName -> {
|
||||
List<VenueInfoDO> venueInfoDOList = map.get(placeName);
|
||||
Boolean order = jntyzxHttpService.createOrder(venueInfoDOList, token);
|
||||
if (order) {
|
||||
dingTalkScriptVenueService.sendScriptMsg("场地:" + placeName + "下单成功,请付款!时间:" + LocalDateTime.now());
|
||||
redisService.set(key, "true");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,21 +70,27 @@ public class VenueQuerySchedule {
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0/10 9-15 * * ?")
|
||||
public void venueQueryTask4Free() {
|
||||
log.info("每日空闲时刻拉取江体小程序数据定时任务");
|
||||
@Scheduled(cron = "0 0/1 9-10 * * ?")
|
||||
public void venueQueryTask49210() {
|
||||
log.info("每日9-10点时刻拉取江体小程序数据定时任务");
|
||||
venueService.queryVenueService();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "1 0/5 15-17 * * ?")
|
||||
@Scheduled(cron = "0 0/10 10-12 * * ?")
|
||||
public void venueQueryTask4Free() {
|
||||
log.info("每日空闲时刻10-12点拉取江体小程序数据定时任务");
|
||||
venueService.queryVenueService();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "1 0/5 12-17 * * ?")
|
||||
public void venueQueryTask4Normal() {
|
||||
log.info("每日正常时刻拉取江体小程序数据定时任务");
|
||||
log.info("每日正常时刻12-17点拉取江体小程序数据定时任务");
|
||||
venueService.queryVenueService();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "2 0/2 17-20 * * ?")
|
||||
public void venueQueryTask4Urgency() {
|
||||
log.info("每日紧急时刻时刻拉取江体小程序数据定时任务");
|
||||
log.info("每日紧急时刻17-20点拉取江体小程序数据定时任务");
|
||||
venueService.queryVenueService();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.xiang.xservice.application.script.jntyzx.schedule;
|
||||
|
||||
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||
import com.xiang.xservice.application.script.jntyzx.constants.RedisKeyConstant;
|
||||
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||
import com.xiang.xservice.application.script.jntyzx.service.DingTalkScriptVenueService;
|
||||
@@ -8,12 +10,14 @@ import com.xiang.xservice.application.script.jntyzx.service.IJtOrderService;
|
||||
import com.xiang.xservice.application.script.jntyzx.service.IUserTokenInfoService;
|
||||
import com.xiang.xservice.application.script.jntyzx.service.IVenueService;
|
||||
import com.xiang.xservice.application.script.jntyzx.utils.VenueInfoUtils;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -31,6 +35,7 @@ public class VenueSubscribeSchedule {
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final DingTalkScriptVenueService dingTalkScriptVenueService;
|
||||
private final IJtOrderService orderService;
|
||||
private final IRedisService redisService;
|
||||
@Scheduled(cron = "0 0 9 * * ?")
|
||||
public void subscribe() {
|
||||
List<VenueInfoDO> venueInfoDOS = venueService.queryCanBuyVenue();
|
||||
@@ -42,11 +47,13 @@ public class VenueSubscribeSchedule {
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return;
|
||||
}
|
||||
String key = RedisKeyConstant.JNTUZX_ORDER_PEEK_KEY + "Xiang" + DateUtils.getDateFromDate(LocalDate.now(), "yyyyMMdd");
|
||||
map.keySet().parallelStream().forEach(placeName -> {
|
||||
List<VenueInfoDO> venueInfoDOList = map.get(placeName);
|
||||
Boolean order = jntyzxHttpService.createOrder(venueInfoDOList, token);
|
||||
if (order) {
|
||||
dingTalkScriptVenueService.sendScriptMsg("场地:" + placeName + "下单成功,请付款!时间:" + LocalDateTime.now());
|
||||
redisService.set(key, "true");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,43 +80,54 @@ public class VenueServiceImpl implements IVenueService {
|
||||
venueInfoDOS.addAll(venueInfoManage.queryByDate(LocalDate.now().plusDays(1)));
|
||||
}
|
||||
|
||||
Map<Long, VenueInfoDO> map = Maps.newHashMap();
|
||||
Map<Integer, List<VenueInfoDO>> map = Maps.newHashMap();
|
||||
if (CollectionUtils.isNotEmpty(venueInfoDOS)) {
|
||||
map.putAll(venueInfoDOS.stream().filter(Objects::nonNull)
|
||||
.collect(Collectors.toMap(item -> Long.parseLong(String.valueOf(item.getPlaceId())), Function.identity(), (a, b) -> a)));
|
||||
.collect(Collectors.groupingBy(VenueInfoDO::getPlaceId)));
|
||||
}
|
||||
List<VenueInfoDO> insertList = Lists.newArrayList();
|
||||
for (SitePositionList sitePositionList : list) {
|
||||
if (map.containsKey(sitePositionList.getId())) {
|
||||
VenueInfoDO venueInfoDO = map.get(sitePositionList.getId());
|
||||
if (!StringUtils.equals(venueInfoDO.getContacts(), sitePositionList.getContacts())
|
||||
|| !Objects.equals(venueInfoDO.getType(), sitePositionList.getType())) {
|
||||
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||
venueInfoDO.setType(sitePositionList.getType());
|
||||
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||
venueInfoManage.updateById(venueInfoDO);
|
||||
if (map.containsKey(sitePositionList.getPlaceId())) {
|
||||
List<VenueInfoDO> venueInfoDOList = map.get(sitePositionList.getPlaceId());
|
||||
Map<String, VenueInfoDO> sjMap = venueInfoDOList.stream().collect(Collectors.toMap(VenueInfoDO::getSjName, Function.identity(), (a, b) -> a));
|
||||
if (sjMap.containsKey(sitePositionList.getSjName())) {
|
||||
VenueInfoDO venueInfoDO = sjMap.get(sitePositionList.getSjName());
|
||||
if (!StringUtils.equals(venueInfoDO.getContacts(), sitePositionList.getContacts())
|
||||
|| !Objects.equals(venueInfoDO.getType(), sitePositionList.getType())
|
||||
|| !Objects.equals(venueInfoDO.getPlaceMainId(), sitePositionList.getId())) {
|
||||
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||
venueInfoDO.setType(sitePositionList.getType());
|
||||
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||
venueInfoManage.updateById(venueInfoDO);
|
||||
}
|
||||
} else {
|
||||
addIntoInsert(sitePositionList, insertList);
|
||||
}
|
||||
} else {
|
||||
VenueInfoDO venueInfoDO = new VenueInfoDO();
|
||||
venueInfoDO.setPlaceName(sitePositionList.getPlaceName());
|
||||
venueInfoDO.setDate(DateUtils.getDateFromStr(sitePositionList.getAppointments()));
|
||||
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||
venueInfoDO.setPlaceId(sitePositionList.getPlaceId());
|
||||
venueInfoDO.setScheduleId(Integer.valueOf(sitePositionList.getScheduleId()));
|
||||
venueInfoDO.setSjName(sitePositionList.getSjName());
|
||||
venueInfoDO.setCreateTime(LocalDateTime.now());
|
||||
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||
venueInfoDO.setType(sitePositionList.getType());
|
||||
venueInfoDO.setMoney(sitePositionList.getMoney());
|
||||
venueInfoDO.setClassName(sitePositionList.getClassName());
|
||||
venueInfoDO.setClassCode(sitePositionList.getClassCode());
|
||||
venueInfoDO.setAppointments(sitePositionList.getAppointments());
|
||||
venueInfoDO.setCTypeCode(sitePositionList.getCtypeCode());
|
||||
insertList.add(venueInfoDO);
|
||||
addIntoInsert(sitePositionList, insertList);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(insertList)) {
|
||||
venueInfoManage.saveBatch(insertList);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addIntoInsert(SitePositionList sitePositionList, List<VenueInfoDO> insertList) {
|
||||
VenueInfoDO venueInfoDO = new VenueInfoDO();
|
||||
venueInfoDO.setPlaceName(sitePositionList.getPlaceName());
|
||||
venueInfoDO.setDate(DateUtils.getDateFromStr(sitePositionList.getAppointments()));
|
||||
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||
venueInfoDO.setPlaceId(sitePositionList.getPlaceId());
|
||||
venueInfoDO.setScheduleId(Integer.valueOf(sitePositionList.getScheduleId()));
|
||||
venueInfoDO.setSjName(sitePositionList.getSjName());
|
||||
venueInfoDO.setCreateTime(LocalDateTime.now());
|
||||
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||
venueInfoDO.setType(sitePositionList.getType());
|
||||
venueInfoDO.setMoney(sitePositionList.getMoney());
|
||||
venueInfoDO.setClassName(sitePositionList.getClassName());
|
||||
venueInfoDO.setClassCode(sitePositionList.getClassCode());
|
||||
venueInfoDO.setAppointments(sitePositionList.getAppointments());
|
||||
venueInfoDO.setCTypeCode(sitePositionList.getCtypeCode());
|
||||
insertList.add(venueInfoDO);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user