Compare commits
10 Commits
4904be16da
...
feat/jntyz
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b9ac21ecf | ||
|
|
f3637a80f2 | ||
|
|
4bc549eebe | ||
|
|
237fcc7139 | ||
|
|
4277106d00 | ||
|
|
7932222f8e | ||
|
|
6d19b1a021 | ||
|
|
57a28b4049 | ||
|
|
a3c9e2eb51 | ||
|
|
93969624c1 |
@@ -7,4 +7,9 @@ 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:";
|
||||
|
||||
public static final String JNTYZX_VENUE_MSG_628_KEY = "jntyzx:venue:msg:628";
|
||||
public static final String JNTYZX_VENUE_MSG_8210_KEY = "jntyzx:venue:msg:8210";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.xiang.xservice.application.script.jntyzx.controller;
|
||||
|
||||
import com.xiang.xservice.application.script.jntyzx.service.DingTalkScriptVenueService;
|
||||
import com.xiang.xservice.application.script.jntyzx.service.IUserTokenInfoService;
|
||||
import com.xiang.xservice.basic.common.resp.Result;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-18 09:08
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/open/jntyzx/token/")
|
||||
@RequiredArgsConstructor
|
||||
public class TokenFreshController {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final DingTalkScriptVenueService dingTalkScriptVenueService;
|
||||
|
||||
@GetMapping("/freshToken")
|
||||
public Result<Void> freshToken() {
|
||||
boolean token = userTokenInfoService.flushToken();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@GetMapping("/freshTokenOnline")
|
||||
public Result<Void> freshTokenOnline(@RequestParam("token") String token, @RequestParam("name") String name) {
|
||||
if (userTokenInfoService.updateTokenByName(name, token)) {
|
||||
dingTalkScriptVenueService.sendScriptMsg(name + "token更新成功");
|
||||
}
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.xiang.xservice.application.script.jntyzx.manage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 10:59
|
||||
@@ -10,4 +12,6 @@ import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||
public interface IOrderCreateInfoManage extends IService<OrderInfoDO> {
|
||||
|
||||
|
||||
List<OrderInfoDO> queryNoPayOrder();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.xiang.xservice.application.script.jntyzx.manage;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||
import com.xiang.xservice.application.script.jntyzx.mapper.JntyzxOrderCreateInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 10:59
|
||||
@@ -13,4 +17,10 @@ import org.springframework.stereotype.Service;
|
||||
public class OrderCreateInfoManageImpl extends ServiceImpl<JntyzxOrderCreateInfoMapper, OrderInfoDO> implements IOrderCreateInfoManage {
|
||||
|
||||
|
||||
@Override
|
||||
public List<OrderInfoDO> queryNoPayOrder() {
|
||||
LambdaQueryWrapper<OrderInfoDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||
lambdaQueryWrapper.eq(OrderInfoDO::getOrderStatus, 0);
|
||||
return baseMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ import java.util.List;
|
||||
@Service
|
||||
public class VenueInfoManageImpl extends ServiceImpl<JntyzxVenueInfoMapper, VenueInfoDO> implements IVenueInfoManage {
|
||||
|
||||
public List<VenueInfoDO> queryByDate(LocalDate now) {
|
||||
public List<VenueInfoDO> queryByDate(LocalDate date) {
|
||||
LambdaQueryWrapper<VenueInfoDO> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(VenueInfoDO::getDate, now);
|
||||
lqw.eq(VenueInfoDO::getDate, date);
|
||||
return baseMapper.selectList(lqw);
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.xiang.xservice.application.script.jntyzx.schedule;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
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.entity.resp.query.SitePositionList;
|
||||
import com.xiang.xservice.application.script.jntyzx.service.DingTalkScriptVenueService;
|
||||
@@ -15,10 +17,12 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
@@ -32,11 +36,12 @@ public class VenueQuerySchedule {
|
||||
private final IVenueService venueService;
|
||||
private final DingTalkScriptVenueService dingTalkScriptVenueService;
|
||||
private final ISysConfigService sysConfigService;
|
||||
private final IRedisService redisService;
|
||||
|
||||
@Scheduled(cron = "0 30 8 * * ?")
|
||||
public void venueQueryTask() {
|
||||
log.info("每日8:30拉取江体小程序数据定时任务");
|
||||
List<SitePositionList> sitePositionLists = venueService.queryVenueService();
|
||||
List<SitePositionList> sitePositionLists = venueService.queryTomorrowVenue();
|
||||
// 6-8场地
|
||||
Map<String, List<SitePositionList>> map1 = Maps.newLinkedHashMap();
|
||||
// 8-10场地
|
||||
@@ -58,32 +63,87 @@ public class VenueQuerySchedule {
|
||||
putIntoMap(item, map2);
|
||||
}
|
||||
});
|
||||
if (MapUtils.isNotEmpty(map1)) {
|
||||
StringBuffer sb1 = new StringBuffer("查询江体小程序场地信息【18:00-20:00】\n");
|
||||
buildMsg2(map1, sb1);
|
||||
String s = (String) redisService.get(RedisKeyConstant.JNTYZX_VENUE_MSG_628_KEY);
|
||||
if (StringUtils.isBlank(s)) {
|
||||
dingTalkScriptVenueService.sendScriptMsg(sb1.toString());
|
||||
redisService.set(RedisKeyConstant.JNTYZX_VENUE_MSG_628_KEY, "true", 30, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
||||
if (MapUtils.isNotEmpty(map2)) {
|
||||
StringBuffer sb2 = new StringBuffer("查询江体小程序场地信息【20:00-22:00】\n");
|
||||
buildMsg2(map2, sb2);
|
||||
dingTalkScriptVenueService.sendScriptMsg(sb1.toString());
|
||||
String s = (String) redisService.get(RedisKeyConstant.JNTYZX_VENUE_MSG_8210_KEY);
|
||||
if (StringUtils.isBlank(s)) {
|
||||
dingTalkScriptVenueService.sendScriptMsg(sb2.toString());
|
||||
redisService.set(RedisKeyConstant.JNTYZX_VENUE_MSG_8210_KEY, "true", 30, TimeUnit.MINUTES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 17 * * ?")
|
||||
public void todayVenueInfo() {
|
||||
log.info("每日拉取江体小程序数据定时任务");
|
||||
List<VenueInfoDO> venueInfoDOS = venueService.queryToday6210VenueInfo();
|
||||
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||
return;
|
||||
}
|
||||
// 6-8场地
|
||||
Map<String, List<VenueInfoDO>> map1 = Maps.newLinkedHashMap();
|
||||
// 8-10场地
|
||||
Map<String, List<VenueInfoDO>> map2 = Maps.newLinkedHashMap();
|
||||
venueInfoDOS.forEach(item -> {
|
||||
if (StringUtils.equals(item.getSjName(), "18:00-19:00")) {
|
||||
putIntoMap(item, map1);
|
||||
}
|
||||
if (StringUtils.equals(item.getSjName(), "19:00-20:00")) {
|
||||
putIntoMap(item, map1);
|
||||
}
|
||||
if (StringUtils.equals(item.getSjName(), "20:00-21:00")) {
|
||||
putIntoMap(item, map2);
|
||||
}
|
||||
if (StringUtils.equals(item.getSjName(), "21:00-22:00")) {
|
||||
putIntoMap(item, map2);
|
||||
}
|
||||
});
|
||||
if (MapUtils.isNotEmpty(map1)) {
|
||||
StringBuffer sb1 = new StringBuffer("查询江体小程序场地信息【18:00-20:00】\n");
|
||||
buildMsg(map1, sb1);
|
||||
dingTalkScriptVenueService.sendScriptMsg(sb1.toString());
|
||||
}
|
||||
if (MapUtils.isNotEmpty(map1)) {
|
||||
StringBuffer sb2 = new StringBuffer("查询江体小程序场地信息【20:00-22:00】\n");
|
||||
buildMsg(map2, sb2);
|
||||
dingTalkScriptVenueService.sendScriptMsg(sb2.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0/1 9-20 * * ?")
|
||||
public void venueCanBuyMsg() {
|
||||
List<VenueInfoDO> venueInfoDOS = venueService.queryCanBuyVenue();
|
||||
@@ -129,12 +189,12 @@ public class VenueQuerySchedule {
|
||||
putIntoMap(item, map2);
|
||||
}
|
||||
});
|
||||
if (MapUtils.isNotEmpty(map1)) {
|
||||
if (MapUtils.isNotEmpty(map1) && LocalTime.now().isBefore(LocalTime.of(18, 0, 0))) {
|
||||
StringBuffer sb1 = new StringBuffer("查询江体小程序场地信息【18:00-20:00】\n");
|
||||
buildMsg(map1, sb1);
|
||||
dingTalkScriptVenueService.sendScriptMsg(sb1.toString());
|
||||
}
|
||||
if (MapUtils.isNotEmpty(map1)) {
|
||||
if (MapUtils.isNotEmpty(map2) && LocalTime.now().isBefore(LocalTime.of(20, 0, 0))) {
|
||||
StringBuffer sb2 = new StringBuffer("查询江体小程序场地信息【20:00-22:00】\n");
|
||||
buildMsg(map2, sb2);
|
||||
dingTalkScriptVenueService.sendScriptMsg(sb2.toString());
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
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;
|
||||
import com.xiang.xservice.application.script.jntyzx.service.IJntyzxHttpService;
|
||||
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;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 14:26
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class VenueSubscribeSchedule {
|
||||
private final IVenueService venueService;
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
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();
|
||||
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||
return;
|
||||
}
|
||||
Map<String, List<VenueInfoDO>> map = venueInfoDOS.stream().filter(VenueInfoUtils::get1221VenueInfo4Mor).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");
|
||||
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 = "0 0/2 * * * ?")
|
||||
public void checkPay() {
|
||||
List<OrderInfoDO> orderInfoDOS = orderService.queryNoPayOrder();
|
||||
if (CollectionUtils.isEmpty(orderInfoDOS)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xiang.xservice.application.script.jntyzx.service;
|
||||
|
||||
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 16:17
|
||||
*/
|
||||
public interface IJtOrderService {
|
||||
|
||||
List<OrderInfoDO> queryNoPayOrder();
|
||||
}
|
||||
@@ -9,4 +9,6 @@ public interface IUserTokenInfoService {
|
||||
String getToken(String name);
|
||||
boolean flushSingleToken(String name);
|
||||
boolean flushToken();
|
||||
|
||||
boolean updateTokenByName(String name, String token);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,6 @@ public interface IVenueService {
|
||||
|
||||
List<SitePositionList> queryVenueService();
|
||||
List<SitePositionList> queryTomorrowVenue();
|
||||
|
||||
List<VenueInfoDO> queryCanBuyVenue();
|
||||
List<VenueInfoDO> queryToday6210VenueInfo();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xiang.xservice.application.script.jntyzx.service;
|
||||
|
||||
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||
import com.xiang.xservice.application.script.jntyzx.manage.IOrderCreateInfoManage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 16:17
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class OrderInfoServiceImpl implements IJtOrderService {
|
||||
|
||||
private final IOrderCreateInfoManage orderCreateInfoManage;
|
||||
@Override
|
||||
public List<OrderInfoDO> queryNoPayOrder() {
|
||||
return orderCreateInfoManage.queryNoPayOrder();
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,16 @@ public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateTokenByName(String name, String token) {
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(name);
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
return false;
|
||||
}
|
||||
userTokenInfoDO.setToken(token);
|
||||
return userTokenInfoManage.updateById(userTokenInfoDO);
|
||||
}
|
||||
|
||||
private boolean healthDeclaration(UserTokenInfoDO userTokenInfoDO) {
|
||||
JntyzxResponse jntyzxResponse = jntyzxHttpService.healthDeclaration(userTokenInfoDO.getToken(), userTokenInfoDO.getOpenId());
|
||||
if (Objects.isNull(jntyzxResponse)) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.common.collect.Maps;
|
||||
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
|
||||
import com.xiang.xservice.application.script.jntyzx.manage.IVenueInfoManage;
|
||||
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;
|
||||
@@ -27,13 +28,18 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class VenueServiceImpl implements IVenueService {
|
||||
|
||||
private final static String STATIC_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NjU4NTI4MjYsInVzZXJuYW1lIjoid3hfb3Blbl9pZF9vMjFNWDR5N3doWENHanZVVEdQNkNUejJIYkQ4In0.pI1tK1imZdKZWXdHRxseqq87_IarHhiRt-hUdBq8hkg";
|
||||
// private final static String STATIC_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NjU4NTI4MjYsInVzZXJuYW1lIjoid3hfb3Blbl9pZF9vMjFNWDR5N3doWENHanZVVEdQNkNUejJIYkQ4In0.pI1tK1imZdKZWXdHRxseqq87_IarHhiRt-hUdBq8hkg";
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final IVenueInfoManage venueInfoManage;
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
|
||||
@Override
|
||||
public List<SitePositionList> queryVenueService() {
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable("1", STATIC_TOKEN);
|
||||
String token = userTokenInfoService.getToken("Xiang");
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable("1", token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
@@ -41,8 +47,13 @@ public class VenueServiceImpl implements IVenueService {
|
||||
return sitePositionLists;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SitePositionList> queryTomorrowVenue() {
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow("1", STATIC_TOKEN);
|
||||
String token = userTokenInfoService.getToken("Xiang");
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow("1", token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
@@ -55,6 +66,12 @@ public class VenueServiceImpl implements IVenueService {
|
||||
return venueInfoManage.queryByType(LocalDate.now(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VenueInfoDO> queryToday6210VenueInfo() {
|
||||
List<VenueInfoDO> venueInfoDOS = venueInfoManage.queryByDate(LocalDate.now());
|
||||
return venueInfoDOS.stream().filter(item -> VenueInfoUtils.get628VenueInfo(item) || VenueInfoUtils.get8210VenueInfo(item)).toList();
|
||||
}
|
||||
|
||||
private void updateDatabase(List<SitePositionList> list, boolean isToday) {
|
||||
List<VenueInfoDO> venueInfoDOS = Lists.newArrayList();
|
||||
if (isToday) {
|
||||
@@ -63,22 +80,39 @@ 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(VenueInfoDO::getPlaceMainId, Function.identity(), (a, b) -> a)));
|
||||
map.putAll(venueInfoDOS.stream().filter(Objects::nonNull)
|
||||
.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 (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.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 {
|
||||
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()));
|
||||
@@ -96,9 +130,4 @@ public class VenueServiceImpl implements IVenueService {
|
||||
venueInfoDO.setCTypeCode(sitePositionList.getCtypeCode());
|
||||
insertList.add(venueInfoDO);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(insertList)) {
|
||||
venueInfoManage.saveBatch(insertList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,3 +53,8 @@ dingtalk:
|
||||
secret: SECe10ade3058880b84df5c6f46ab072c11f4ac2a5ef9f134d684705c2a3b004de2
|
||||
users:
|
||||
- 450841600726084717
|
||||
venue:
|
||||
token: 6a218646972c684c75832b0229ea93a234778af537d7469ce96bef290faf530e
|
||||
secret: SEC9018755ba86d3e5c1ed2fbfa1d6953d84bb2a6c8ebe7ed4e318457bfed5e0465
|
||||
users:
|
||||
- 450841600726084717
|
||||
Reference in New Issue
Block a user