Compare commits
9 Commits
76ec2c8b3c
...
feat/scrip
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f7af30789 | ||
|
|
b4ed93171c | ||
|
|
6902a16cfa | ||
|
|
60992dc4f6 | ||
|
|
cb21b38287 | ||
|
|
268b63e607 | ||
|
|
d1584184ae | ||
|
|
fea069d795 | ||
|
|
b30af008e0 |
@@ -2,9 +2,11 @@ package com.xiang;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.pojo.schedule.ScheduleOpeningConfigDO;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -28,6 +30,7 @@ import java.util.stream.Collectors;
|
||||
public class ApplicationInit implements ApplicationRunner {
|
||||
|
||||
private final IScheduleOpeningConfigService scheduleOpeningConfigService;
|
||||
private final RedisService redisService;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
@@ -35,6 +38,10 @@ public class ApplicationInit implements ApplicationRunner {
|
||||
log.info("开始加载任务配置!");
|
||||
loadScheduleTask();
|
||||
log.info("任务配置加载完成!");
|
||||
|
||||
log.info("redis key 加载开始!");
|
||||
loadRedisKey();
|
||||
log.info("redis key 加载结束!");
|
||||
}
|
||||
|
||||
private void loadScheduleTask() {
|
||||
@@ -54,7 +61,7 @@ public class ApplicationInit implements ApplicationRunner {
|
||||
continue;
|
||||
}
|
||||
ScheduleOpeningConfigDO scheduleOpeningConfigDO = new ScheduleOpeningConfigDO();
|
||||
scheduleOpeningConfigDO.setModule(scheduleEnum.getModeleCode());
|
||||
scheduleOpeningConfigDO.setModule(scheduleEnum.getModuleCode());
|
||||
scheduleOpeningConfigDO.setBeanName(scheduleEnum.getTaskName());
|
||||
scheduleOpeningConfigDO.setStatus(1);
|
||||
list.add(scheduleOpeningConfigDO);
|
||||
@@ -63,4 +70,8 @@ public class ApplicationInit implements ApplicationRunner {
|
||||
scheduleOpeningConfigService.saveBatch(list);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadRedisKey() {
|
||||
redisService.set(RedisKeyConstant.JNTYZX_SUBSCRIBE_TIME_KEY, "18:00");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,17 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisPassword;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
@Bean
|
||||
@@ -35,7 +41,6 @@ public class RedisConfig {
|
||||
|
||||
template.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
template.setHashValueSerializer(jackson2JsonRedisSerializer);
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
@@ -44,4 +49,18 @@ public class RedisConfig {
|
||||
public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) {
|
||||
return new StringRedisTemplate(factory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisConnectionFactory redisConnectionFactory(RedisProperties props) {
|
||||
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
|
||||
config.setHostName(props.getHost());
|
||||
config.setPort(Integer.parseInt(props.getPort()));
|
||||
config.setPassword(RedisPassword.of(props.getPassword()));
|
||||
config.setDatabase(props.getDatabase());
|
||||
|
||||
LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
|
||||
.commandTimeout(Duration.ofSeconds(3))
|
||||
.build();
|
||||
return new LettuceConnectionFactory(config, clientConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class RedisProperties {
|
||||
private String host;
|
||||
private String port;
|
||||
private String password;
|
||||
private Integer database = 0;
|
||||
private Integer database;
|
||||
|
||||
public String getAddress() {
|
||||
return "redis://" + host + ":" + port;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.constants;
|
||||
package com.xiang.common.enums;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-15 13:46
|
||||
*/
|
||||
public class UrlConstant {
|
||||
public class JntyzxUrlConstant {
|
||||
|
||||
/**
|
||||
* 江南体育中心基础URL
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.constants;
|
||||
package com.xiang.common.enums;
|
||||
|
||||
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
@@ -27,6 +29,8 @@ public class RedisKeyConstant {
|
||||
return JNTYZX_VENUE_SUBSCRIBE_KEY + placeName + ":" + getDate();
|
||||
}
|
||||
|
||||
public static final String JNTYZX_SUBSCRIBE_TIME_KEY = "jntyzx:subscribe:time";
|
||||
|
||||
public static String getDate() {
|
||||
LocalDate now = LocalDate.now();
|
||||
return ":" + DateUtils.getDateFromDate(now);
|
||||
@@ -31,9 +31,19 @@ public enum ScheduleEnums {
|
||||
ZLB_ORDER_CREATE_TASK(3, "zlb", "zlbOrderCreateTask"),
|
||||
ZLB_USER_CONFIG_TASK(3, "zlb", "zlbUserConfigTask"),
|
||||
|
||||
|
||||
JNTYZX_TOKEN_REFRESH_TASK(4, "jt-miniApp", "jntyzxTokenRefreshTask"),
|
||||
JNTYZX_VENUE_INFO_PULL_TASK(4, "jt-miniApp", "jntyzxVenuePullTask"),
|
||||
JNTYZX_ORDER_SUBSCRIBE_TASK(4, "jt-miniApp", "jntyzxOrderSubscribeTask"),
|
||||
JNTYZX_VENUE_TODAY_SUBSCRIBE_TASK(4, "jt-miniApp", "jntyzxVenueTodaySubscribeTask"),
|
||||
JNTYZX_VENUE_TOMORROW_PULL_TASK(4, "jt-miniApp", "jntyzxVenueTodayPullTask"),
|
||||
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 modeleCode;
|
||||
private final Integer moduleCode;
|
||||
private final String module;
|
||||
private final String taskName;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.OrderInfoDO;
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 10:17
|
||||
*/
|
||||
public interface IUserInfoManage extends IService<UserInfoDO> {
|
||||
boolean delAll();
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserRestrictionInfo;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.VenueInfoQueryRequest;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
@@ -17,6 +15,4 @@ public interface IVenueInfoManage extends IService<VenueInfoDO> {
|
||||
List<VenueInfoDO> queryByDate(LocalDate date);
|
||||
|
||||
List<VenueInfoDO> queryByType(LocalDate date, Integer type);
|
||||
|
||||
Page<VenueInfoDO> page(VenueInfoQueryRequest request);
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
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.common.pojo.jntyzx.miniapp.pojo.OrderInfoDO;
|
||||
import com.xiang.service.module.jntyzx.miniapp.mapper.JntyzxOrderCreateInfoMapper;
|
||||
import com.xiang.common.mapper.JntyzxOrderCreateInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.JntyzxUserInfoMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 10:17
|
||||
*/
|
||||
@Service
|
||||
public class UserInfoManageImpl extends ServiceImpl<JntyzxUserInfoMapper, UserInfoDO> implements IUserInfoManage {
|
||||
@Override
|
||||
public boolean delAll() {
|
||||
return baseMapper.delAll() > 0;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
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.common.pojo.jntyzx.miniapp.pojo.UserRestrictionInfo;
|
||||
import com.xiang.service.module.jntyzx.miniapp.mapper.JntyzxUserRestrictionInfoMapper;
|
||||
import com.xiang.common.mapper.JntyzxUserRestrictionInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.UserQueryReq;
|
||||
import com.xiang.service.module.jntyzx.miniapp.mapper.JntyzxUserTokenInfoMapper;
|
||||
import com.xiang.common.mapper.JntyzxUserTokenInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -1,13 +1,10 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.manage;
|
||||
package com.xiang.common.manage.jntyzx.miniapp;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.VenueInfoQueryRequest;
|
||||
import com.xiang.service.module.jntyzx.miniapp.mapper.JntyzxVenueInfoMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.xiang.common.mapper.JntyzxVenueInfoMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@@ -33,18 +30,4 @@ public class VenueInfoManageImpl extends ServiceImpl<JntyzxVenueInfoMapper, Venu
|
||||
lqw.eq(VenueInfoDO::getType, type);
|
||||
return baseMapper.selectList(lqw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VenueInfoDO> page(VenueInfoQueryRequest request) {
|
||||
Page<VenueInfoDO> page = new Page<>(request.getCurrent(), request.getPageSize());
|
||||
LambdaQueryWrapper<VenueInfoDO> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(VenueInfoDO::getDate, request.getDate());
|
||||
if (StringUtils.isNotBlank(request.getSj())) {
|
||||
lqw.eq(VenueInfoDO::getSjName, request.getSj());
|
||||
}
|
||||
if (StringUtils.isNotBlank(request.getPlaceName())) {
|
||||
lqw.like(VenueInfoDO::getPlaceName, request.getPlaceName());
|
||||
}
|
||||
return baseMapper.selectPage(page, lqw);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbPayOrder;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 15:11
|
||||
*/
|
||||
public interface IZlbOrderInfoManage extends IService<ZlbPayOrder> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.ZlbOrderInfoMapper;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbPayOrder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 15:11
|
||||
*/
|
||||
@Service
|
||||
public class ZlbOrderInfoManageImpl extends ServiceImpl<ZlbOrderInfoMapper, ZlbPayOrder> implements IZlbOrderInfoManage {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbSiteInfo;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.ZlbSiteInfoMapper;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.service;
|
||||
package com.xiang.common.manage.jntyzx.zlb;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiang.common.mapper.ZlbUserInfoMapper;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.mapper;
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.OrderInfoDO;
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 10:16
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface JntyzxUserInfoMapper extends BaseMapper<UserInfoDO> {
|
||||
|
||||
@Delete("delete from jntyzx_user_info where 1=1")
|
||||
int delAll();
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.mapper;
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserRestrictionInfo;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.mapper;
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.mapper;
|
||||
package com.xiang.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 09:54
|
||||
*/
|
||||
@Data
|
||||
@TableName("jntyzx_user_info")
|
||||
public class UserInfoDO {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer loginInfoId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 星期几
|
||||
*/
|
||||
private String week;
|
||||
|
||||
/**
|
||||
* 分配的任务参数
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 场地信息
|
||||
*/
|
||||
private String placeName;
|
||||
|
||||
/**
|
||||
* 时间id111
|
||||
*/
|
||||
private String siteTimeName;
|
||||
|
||||
/**
|
||||
* 是否开抢0-抢,1-不抢
|
||||
*/
|
||||
private Integer isBook;
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
@NoArgsConstructor
|
||||
public class SubscribeRequest {
|
||||
private JSONObject jsonObject;
|
||||
private List<com.xiang.service.module.jntyzx.miniapp.entity.req.SubscribeVo> subscribeVos;
|
||||
private List<SubscribeVo> subscribeVos;
|
||||
private String bookTime;
|
||||
private Integer paymentMethod;
|
||||
private String svCiphertext;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
package com.xiang.common.pojo.jntyzx.miniapp.resp.query;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@@ -26,75 +26,20 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class DateUtils {
|
||||
|
||||
private static final String defaultDateFormatter = "yyyy-MM-dd";
|
||||
private static final String defaultDateTimeFormatter = "yyyy-MM-dd HH:mm:ss";
|
||||
private static final Logger logger = LoggerFactory.getLogger(DateUtils.class);
|
||||
|
||||
|
||||
/**
|
||||
* 构造函数.
|
||||
*/
|
||||
public void DateUtil() {
|
||||
throw new RuntimeException("this is a util class,can not instance!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT = "yyyy-MM-dd HH:mm:ss";
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ASCM_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_YMD = "yyyy-MM-dd";
|
||||
public static final String ENUM_FORMAT_YMD_1 = "yyyyMMdd";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_YMDS = "yyyy-MM-dd HH:mm:ss.S";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_SLASH = "yyyy/MM/dd HH:mm:ss";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String ENUM_FORMAT_YMDS_SLASH = "yyyy/MM/dd HH:mm:ss.S";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_DAY = "day"; // 粒度级别
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_HOUR = "hour";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_MINUTE = "minute";
|
||||
|
||||
/**
|
||||
* 添加字段注释.
|
||||
*/
|
||||
public static final String LEVEL_SECOND = "second";
|
||||
|
||||
/**
|
||||
* 日期特殊字符对应.
|
||||
*/
|
||||
private static Map<String, String> mapSign = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 使用ThreadLocal保证SimpleDateFormat线程安全.
|
||||
*/
|
||||
private static ThreadLocal<Map<String, SimpleDateFormat>> threadLocalDateFormat = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
@@ -141,6 +86,11 @@ public class DateUtils {
|
||||
return convertToChinese(dayOfWeek);
|
||||
}
|
||||
|
||||
public static String getWeekDay(LocalDate date) {
|
||||
DayOfWeek dayOfWeek = date.getDayOfWeek();
|
||||
return convertToChinese(dayOfWeek);
|
||||
}
|
||||
|
||||
private static String convertToChinese(DayOfWeek dayOfWeek) {
|
||||
switch (dayOfWeek) {
|
||||
case MONDAY:
|
||||
@@ -658,7 +608,7 @@ public class DateUtils {
|
||||
boolean inAfternoon = now.isAfter(LocalTime.of(12, 59)) && now.isBefore(LocalTime.of(15, 1));
|
||||
return !inAfternoon && !inMorning ? true : false;
|
||||
} else {
|
||||
log.info("当前时间为:{}", LocalDateTime.now());
|
||||
logger.info("当前时间为:{}", LocalDateTime.now());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class HttpService {
|
||||
CloseableHttpResponse response = null;
|
||||
String result = "";
|
||||
try {
|
||||
log.info("HTTP请求,请求地址===>{}, 请求头===>{}, 请求参数===>{}", url, JSON.toJSONString(header), jsonParams);
|
||||
log.debug("HTTP请求,请求地址===>{}, 请求头===>{}, 请求参数===>{}", url, JSON.toJSONString(header), jsonParams);
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
httpPost.addHeader("Content-Type", "application/json");
|
||||
// 创建请求内容
|
||||
@@ -88,7 +88,7 @@ public class HttpService {
|
||||
}
|
||||
response = httpClient.execute(httpPost);
|
||||
result = EntityUtils.toString(response.getEntity(), "utf-8");
|
||||
log.info("【POST请求】 请求地址===>{}, 响应结果==={}", url, result);
|
||||
log.debug("【POST请求】 请求地址===>{}, 响应结果==={}", url, result);
|
||||
} catch (Exception e) {
|
||||
log.error("doPost异常", e);
|
||||
} finally {
|
||||
@@ -117,10 +117,10 @@ public class HttpService {
|
||||
httpGet.setHeader(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
log.info("doGet请求:请求头:{},请求地址:{}", header, url + request);
|
||||
log.debug("doGet请求:请求头:{},请求地址:{}", header, url + request);
|
||||
response = httpClient.execute(httpGet);
|
||||
result = EntityUtils.toString(response.getEntity(), "utf-8");
|
||||
log.info("【GET请求】, 请求地址===>{}, 响应结果===>{}", url + request, result);
|
||||
log.debug("【GET请求】, 请求地址===>{}, 响应结果===>{}", url + request, result);
|
||||
} catch (Exception e) {
|
||||
log.error("doGet异常:", e);
|
||||
} finally {
|
||||
|
||||
18
src/main/java/com/xiang/common/utils/JsonUtils.java
Normal file
18
src/main/java/com/xiang/common/utils/JsonUtils.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.xiang.common.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-07-25 15:58
|
||||
*/
|
||||
public class JsonUtils {
|
||||
public static String toJsonString(Object obj) {
|
||||
return JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue);
|
||||
}
|
||||
|
||||
public static <T> T parse(String json, Class<T> clazz) {
|
||||
return JSON.parseObject(json, clazz);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class DomainDynamicAnalysisTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.DOMAIN_DYNAMIC_ANALYSIS_TASK.getModeleCode();
|
||||
return ScheduleEnums.DOMAIN_DYNAMIC_ANALYSIS_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -31,7 +31,7 @@ public class GladosCheckInTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.GLADOS_CHECK_IN_TASK.getModeleCode();
|
||||
return ScheduleEnums.GLADOS_CHECK_IN_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.converts;
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JtUserVo;
|
||||
import com.xiang.service.module.jntyzx.miniapp.entity.pojo.UserTokenInfoDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Named;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface UserConverter {
|
||||
|
||||
UserConverter INSTANCE = Mappers.getMapper(UserConverter.class);
|
||||
@Mapping(source = "id", target = "userId")
|
||||
@Mapping(source = "isOrder", target = "isOrder", qualifiedByName = "isOrder")
|
||||
@Mapping(source = "isRestriction", target = "isRestriction", qualifiedByName = "isRestrict")
|
||||
JtUserVo convert(UserTokenInfoDO userTokenInfoDO);
|
||||
List<JtUserVo> convert(List<UserTokenInfoDO> userTokenInfoDOs);
|
||||
|
||||
@Named("isOrder")
|
||||
default Boolean isOrder(Integer value) {
|
||||
return Objects.nonNull(value) && Objects.equals(value, 1);
|
||||
}
|
||||
|
||||
@Named("isRestrict")
|
||||
default Boolean isRestrict(Integer value) {
|
||||
return Objects.nonNull(value) && Objects.equals(value, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.converts;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.VenueInfoQueryResp;
|
||||
import com.xiang.service.module.jntyzx.miniapp.entity.pojo.VenueInfoDO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-04-09 09:54
|
||||
*/
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface VenueInfoConverter {
|
||||
|
||||
Page<VenueInfoQueryResp> toPage(Page<VenueInfoDO> page);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 定时任务配置器
|
||||
*
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 08:56
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class JntyzxMiniappScheduleConfig {
|
||||
|
||||
private final JtTokenRefreshTask jtTokenRefreshTask;
|
||||
private final JtVenuePullTask jtVenuePullTask;
|
||||
private final JtVenueSubscribeTask jtVenueSubscribeTask;
|
||||
private final JtVenueTomorrowPullTask jtVenueTomorrowPullTask;
|
||||
private final JntyzxUserInfoConfigTask jntyzxUserInfoConfigTask;
|
||||
private final JtVenueInfoTodayResultTask jtVenueInfoTodayResultTask;
|
||||
private final JtVenueInfoTomorrowResultTask jtVenueInfoTomorrowResultTask;
|
||||
|
||||
/**
|
||||
* token刷新
|
||||
*/
|
||||
@Scheduled(cron = "0 20,50 * * * ?")
|
||||
@GetMapping("/jtTokenRefreshTask")
|
||||
public void jtTokenRefreshTask() {
|
||||
jtTokenRefreshTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每分钟场地信息更新
|
||||
*/
|
||||
@Scheduled(cron = "0 0/1 10-18 * * ?")
|
||||
@GetMapping("/jtVenuePullTask")
|
||||
public void jtVenuePullTask() {
|
||||
jtVenuePullTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取第二天场地信息
|
||||
*/
|
||||
@Scheduled(cron = "0 30 8 * * ?")
|
||||
@GetMapping("/jtVenueTomorrowPullTask")
|
||||
public void jtVenueTomorrowPullTask() {
|
||||
jtVenueTomorrowPullTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置下单用户场地数据
|
||||
*/
|
||||
@Scheduled(cron = "0 40 8 * * ?")
|
||||
@GetMapping("/jtUserInfoConfig")
|
||||
public void jtUserInfoConfig() {
|
||||
jntyzxUserInfoConfigTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下单定时任务
|
||||
*/
|
||||
@Scheduled(cron = "0 0 9 * * ?")
|
||||
@GetMapping("/jtVenueSubscribeTask")
|
||||
public void jtVenueSubscribeTask() {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
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.pojo.UserInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
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.common.utils.RedisService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserInfoService;
|
||||
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.utils.VenueInfoUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户场地配置任务 每日8:40运行
|
||||
*
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 09:58
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class JntyzxUserInfoConfigTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final IVenueService venueService;
|
||||
private final IUserInfoService userInfoService;
|
||||
private final JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||
private final RedisService redisService;
|
||||
|
||||
public JntyzxUserInfoConfigTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IUserTokenInfoService userTokenInfoService,
|
||||
IVenueService venueService,
|
||||
IUserInfoService userInfoService,
|
||||
JntyzxDingTalkFactory jntyzxDingTalkFactory,
|
||||
RedisService redisService) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.userTokenInfoService = userTokenInfoService;
|
||||
this.venueService = venueService;
|
||||
this.userInfoService = userInfoService;
|
||||
this.jntyzxDingTalkFactory = jntyzxDingTalkFactory;
|
||||
this.redisService = redisService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_USER_INFO_CONFIG.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_USER_INFO_CONFIG.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_USER_INFO_CONFIG.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
TaskResult taskResult = new TaskResult();
|
||||
taskResult.setSuccess(false);
|
||||
List<VenueInfoDO> venueInfoDOS = venueService.queryTomorrowCanBuyVenue();
|
||||
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||
taskResult.setSummary("无可用场地");
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
String time = (String) redisService.get(RedisKeyConstant.JNTYZX_SUBSCRIBE_TIME_KEY);
|
||||
if (StringUtils.isBlank(time)) {
|
||||
time = "18:00";
|
||||
}
|
||||
String finalTime = time;
|
||||
venueInfoDOS = VenueInfoUtils.filterVenueList(finalTime, venueInfoDOS);
|
||||
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||
taskResult.setSummary("无可用场地");
|
||||
return taskResult;
|
||||
}
|
||||
venueInfoDOS = venueInfoDOS.stream()
|
||||
.filter(item -> !item.getPlaceName().contains("小馆"))
|
||||
.sorted(Comparator.comparing(item -> VenueInfoUtils.sortVenueInfo(item.getPlaceName())))
|
||||
.toList();
|
||||
|
||||
List<UserTokenInfoDO> users = userTokenInfoService.getCanOrderUser();
|
||||
if (CollectionUtils.isEmpty(users)) {
|
||||
taskResult.setSummary("无可用用户");
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
List<UserInfoDO> list = Lists.newArrayList();
|
||||
int i = 0;
|
||||
userInfoService.delAll();
|
||||
for (UserTokenInfoDO user : users) {
|
||||
VenueInfoDO venueInfoDO = venueInfoDOS.get(i);
|
||||
UserInfoDO userInfoDO = new UserInfoDO();
|
||||
userInfoDO.setName(user.getName());
|
||||
userInfoDO.setWeek(DateUtils.getWeekDay(venueInfoDO.getDate()));
|
||||
userInfoDO.setType("1");
|
||||
userInfoDO.setPlaceName(venueInfoDO.getPlaceName());
|
||||
userInfoDO.setSiteTimeName(venueInfoDO.getSjName().split("-")[0]);
|
||||
userInfoDO.setIsBook(0);
|
||||
list.add(userInfoDO);
|
||||
i++;
|
||||
if (i == venueInfoDOS.size()) {
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
userInfoService.batchSave(list);
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (UserInfoDO user : list) {
|
||||
stringBuilder.append(user.getName()).append("配置预约:").append(user.getPlaceName()).append("\n");
|
||||
}
|
||||
jntyzxDingTalkFactory.sendMsg(stringBuilder.toString());
|
||||
taskResult.setSuccess(Boolean.TRUE);
|
||||
taskResult.setSummary(stringBuilder.toString());
|
||||
}
|
||||
return taskResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserTokenInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 用户token刷新定时任务 每半个小时运行一次 在每个小时的20和50分
|
||||
*
|
||||
* @Author: xiang
|
||||
* @Date: 2026-01-15 17:29
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RestController
|
||||
public class JtTokenRefreshTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
|
||||
public JtTokenRefreshTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IUserTokenInfoService userTokenInfoService) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.userTokenInfoService = userTokenInfoService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_TOKEN_REFRESH_TASK.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_TOKEN_REFRESH_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_TOKEN_REFRESH_TASK.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
TaskResult taskResult = new TaskResult();
|
||||
|
||||
log.info("【Token】江南体育中心token续期定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||
userTokenInfoService.flushToken();
|
||||
|
||||
taskResult.setSuccess(true);
|
||||
taskResult.setSummary("江体小程序token刷新成功");
|
||||
return taskResult;
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
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.IJntyzxHttpService;
|
||||
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.utils.MsgSendUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.WeekendUtils;
|
||||
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.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 每日9:00-19:00场地更新信息查询
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class JtVenuePullTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final IVenueService venueService;
|
||||
private final MsgSendUtils msgSendUtils;
|
||||
|
||||
public JtVenuePullTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IUserTokenInfoService userTokenInfoService,
|
||||
IJntyzxHttpService jntyzxHttpService,
|
||||
IVenueService venueService,
|
||||
MsgSendUtils msgSendUtils) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.userTokenInfoService = userTokenInfoService;
|
||||
this.jntyzxHttpService = jntyzxHttpService;
|
||||
this.venueService = venueService;
|
||||
this.msgSendUtils = msgSendUtils;
|
||||
}
|
||||
|
||||
private List<SitePositionList> handleMsgSendList(List<SitePositionList> sitePositionLists, Integer type) {
|
||||
if (type == 1) {
|
||||
sitePositionLists = sitePositionLists.stream()
|
||||
.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();
|
||||
}
|
||||
Map<String, SitePositionList> mapByName = Maps.newLinkedHashMap();
|
||||
for (SitePositionList sitePositionList : sitePositionLists) {
|
||||
if (!mapByName.containsKey(sitePositionList.getPlaceName())) {
|
||||
mapByName.put(sitePositionList.getPlaceName(), sitePositionList);
|
||||
}
|
||||
}
|
||||
return mapByName.values().stream().toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_PULL_TASK.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_PULL_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_INFO_PULL_TASK.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
TaskResult taskResult = new TaskResult();
|
||||
taskResult.setSuccess(false);
|
||||
log.info("【Venue】江体小程序场地数据拉取定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||
List<UserTokenInfoDO> availableUser = userTokenInfoService.getAvailableUser();
|
||||
if (CollectionUtils.isEmpty(availableUser)) {
|
||||
log.info("当前无可用用户查询场地信息!");
|
||||
taskResult.setSuccess(true);
|
||||
taskResult.setSummary("当前无可用用户查询场地信息!");
|
||||
return taskResult;
|
||||
}
|
||||
String token;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
for (UserTokenInfoDO userTokenInfoDO : availableUser) {
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
continue;
|
||||
}
|
||||
token = userTokenInfoDO.getToken();
|
||||
if (StringUtils.isBlank(token)) {
|
||||
continue;
|
||||
}
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable(WeekendUtils.isWeekend(), token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
continue;
|
||||
}
|
||||
venueService.saveOrUpdateTodayVenueInfo(sitePositionLists);
|
||||
|
||||
StringBuffer msg = new StringBuffer();
|
||||
|
||||
List<SitePositionList> sitePositionLists6_8 = handleMsgSendList(sitePositionLists, 1);
|
||||
if (CollectionUtils.isNotEmpty(sitePositionLists6_8)) {
|
||||
msg.append("查询到18:00-20:00空闲场地信息=====>\n时间:").append(DateUtils.getDateFromDate(LocalDate.now())).append("\n");
|
||||
sitePositionLists6_8.forEach(item -> msg.append(item.getPlaceName()).append("\n"));
|
||||
}
|
||||
List<SitePositionList> sitePositionLists8_10 = handleMsgSendList(sitePositionLists, 2);
|
||||
if (CollectionUtils.isNotEmpty(sitePositionLists8_10)) {
|
||||
msg.append("查询到20:00-22:00空闲场地信息=====>\n时间:").append(DateUtils.getDateFromDate(LocalDate.now())).append("\n");
|
||||
sitePositionLists8_10.forEach(item -> msg.append(item.getPlaceName()).append("\n"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
String key = RedisKeyConstant.JNTYZX_VENUE_MSG_SEND_KEY + RedisKeyConstant.getDate();
|
||||
msgSendUtils.sendMsgRestrict1Hours(key, msg.toString());
|
||||
}
|
||||
taskResult.setSuccess(true);
|
||||
taskResult.setSummary("查询场地信息成功!时间:" + now);
|
||||
return taskResult;
|
||||
}
|
||||
return taskResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.schedule;
|
||||
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
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.pojo.UserInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJtOrderService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserInfoService;
|
||||
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.utils.VenueInfoUtils;
|
||||
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.RestController;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 场地订阅定时任务 每日9:00:00
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RestController
|
||||
public class JtVenueSubscribeTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final IJtOrderService jtOrderService;
|
||||
private final IVenueService venueService;
|
||||
private final JntyzxDingTalkFactory jtDingTalkFactory;
|
||||
private final RedisService redisService;
|
||||
private final IUserInfoService userInfoService;
|
||||
|
||||
public JtVenueSubscribeTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IUserTokenInfoService userTokenInfoService,
|
||||
IJtOrderService jtOrderService,
|
||||
IVenueService venueService,
|
||||
JntyzxDingTalkFactory jtDingTalkFactory,
|
||||
RedisService redisService,
|
||||
IUserInfoService userInfoService) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.userTokenInfoService = userTokenInfoService;
|
||||
this.jtOrderService = jtOrderService;
|
||||
this.venueService = venueService;
|
||||
this.jtDingTalkFactory = jtDingTalkFactory;
|
||||
this.redisService = redisService;
|
||||
this.userInfoService = userInfoService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_ORDER_SUBSCRIBE_TASK.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_ORDER_SUBSCRIBE_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_ORDER_SUBSCRIBE_TASK.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
TaskResult taskResult = new TaskResult();
|
||||
taskResult.setSuccess(false);
|
||||
|
||||
log.info("【Subscribe】 江体场地预定定时任务启动!!! time:{}", System.currentTimeMillis());
|
||||
List<UserTokenInfoDO> users = userTokenInfoService.getCanOrderUser();
|
||||
if (CollectionUtils.isEmpty(users)) {
|
||||
log.info("暂无可下单用户, time:{}", System.currentTimeMillis());
|
||||
jtDingTalkFactory.sendMsg("暂无可下单用户, time:" + System.currentTimeMillis());
|
||||
taskResult.setSummary("无可下单用户");
|
||||
return taskResult;
|
||||
}
|
||||
Map<String, UserTokenInfoDO> userMap = users.stream().collect(Collectors.toMap(UserTokenInfoDO::getName, Function.identity(), (a, b) -> a));
|
||||
|
||||
List<VenueInfoDO> venueInfoDOS = venueService.queryTomorrowCanBuyVenue();
|
||||
Map<String, List<VenueInfoDO>> venueInfoMap = venueInfoDOS.stream()
|
||||
.collect(Collectors.groupingByConcurrent(VenueInfoDO::getPlaceName));
|
||||
|
||||
List<UserInfoDO> userInfoDOS = userInfoService.selectAll();
|
||||
if (CollectionUtils.isEmpty(userInfoDOS)) {
|
||||
log.info("暂无可下单用户, time:{}", System.currentTimeMillis());
|
||||
jtDingTalkFactory.sendMsg("暂无可下单用户配置信息, time:" + System.currentTimeMillis());
|
||||
taskResult.setSummary("无可下单用户配置信息");
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
|
||||
for (UserInfoDO userInfoDO : userInfoDOS) {
|
||||
if (venueInfoMap.containsKey(userInfoDO.getPlaceName()) && userMap.containsKey(userInfoDO.getName())) {
|
||||
UserTokenInfoDO userTokenInfoDO = userMap.get(userInfoDO.getName());
|
||||
List<VenueInfoDO> venueInfoDOList = venueInfoMap.get(userInfoDO.getPlaceName());
|
||||
if (CollectionUtils.isEmpty(venueInfoDOList)) {
|
||||
logger.info("用户:{}查询不到场地信息:{}", userInfoDO.getName(), userInfoDO.getPlaceName());
|
||||
continue;
|
||||
}
|
||||
venueInfoDOList = VenueInfoUtils.filterVenueList(userInfoDO.getSiteTimeName(), venueInfoDOList);
|
||||
if (CollectionUtils.isEmpty(venueInfoDOList)) {
|
||||
logger.info("用户:{}无场地信息:{},时间:{}", userInfoDO.getName(), userInfoDO.getPlaceName(), userInfoDO.getSiteTimeName());
|
||||
continue;
|
||||
}
|
||||
|
||||
String placeName = userInfoDO.getPlaceName();
|
||||
|
||||
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
|
||||
//计算9点到现在的时间差
|
||||
//获取江体当前时间
|
||||
LocalTime currentTime = LocalTime.now();
|
||||
LocalTime targetTime = LocalTime.parse("09:00:10");
|
||||
Duration duration = Duration.between(currentTime, targetTime);
|
||||
long milliseconds = duration.toMillis();
|
||||
if (milliseconds <= 0) {
|
||||
milliseconds = 0;
|
||||
}
|
||||
List<VenueInfoDO> finalVenueInfoDOList = venueInfoDOList;
|
||||
executorService.schedule(() -> {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
String valid = (String) redisService.get(RedisKeyConstant.getVenueSubscribeKey(placeName));
|
||||
if (StringUtils.isNotBlank(valid)) {
|
||||
break;
|
||||
}
|
||||
boolean order = jtOrderService.createOrder(finalVenueInfoDOList, userTokenInfoDO);
|
||||
if (order) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("睡眠失败~~~");
|
||||
}
|
||||
}
|
||||
}, milliseconds, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
taskResult.setSuccess(true);
|
||||
taskResult.setSummary("下单执行成功!");
|
||||
return taskResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
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.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JntyzxResponse;
|
||||
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.IJntyzxHttpService;
|
||||
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.utils.VenueInfoUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.WeekendUtils;
|
||||
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;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 场地信息获取定时任务 每日8:30拉取第二天的场地信息
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class JtVenueTomorrowPullTask extends BaseScheduleTaskTemplate {
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final JntyzxDingTalkFactory jtDingTalkFactory;
|
||||
private final IVenueService venueService;
|
||||
|
||||
public JtVenueTomorrowPullTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
IUserTokenInfoService userTokenInfoService,
|
||||
IJntyzxHttpService jntyzxHttpService,
|
||||
JntyzxDingTalkFactory jtDingTalkFactory,
|
||||
IVenueService venueService) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.userTokenInfoService = userTokenInfoService;
|
||||
this.jntyzxHttpService = jntyzxHttpService;
|
||||
this.jtDingTalkFactory = jtDingTalkFactory;
|
||||
this.venueService = venueService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTaskName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_TOMORROW_PULL_TASK.getTaskName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_TOMORROW_PULL_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getModuleName() {
|
||||
return ScheduleEnums.JNTYZX_VENUE_TOMORROW_PULL_TASK.getModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TaskResult doExecute(Object validatedParams) throws Exception {
|
||||
TaskResult taskResult = new TaskResult();
|
||||
taskResult.setSuccess(Boolean.FALSE);
|
||||
log.info("【Venue】江体小程序场地拉取定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||
List<UserTokenInfoDO> availableUser = userTokenInfoService.getAvailableUser();
|
||||
if (CollectionUtils.isEmpty(availableUser)) {
|
||||
log.info("当前无可用用户查询场地信息!");
|
||||
taskResult.setSummary("当前无可用用户查询场地信息");
|
||||
return taskResult;
|
||||
}
|
||||
// 用户信息
|
||||
StringBuffer userMsg = new StringBuffer();
|
||||
availableUser.forEach(item -> {
|
||||
JntyzxResponse jntyzxResponse = jntyzxHttpService.checkDefaultNums(item.getToken(), item.getMemberCardNo());
|
||||
if (Objects.nonNull(jntyzxResponse)) {
|
||||
if (jntyzxResponse.getSuccess()) {
|
||||
userMsg.append("订购人:").append(item.getName()).append("正常下单\n");
|
||||
} else {
|
||||
userMsg.append("订购人:").append(item.getName()).append(jntyzxResponse.getMessage()).append("\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
jtDingTalkFactory.sendMsg(userMsg.toString());
|
||||
|
||||
// 场地信息
|
||||
UserTokenInfoDO userTokenInfoDO = availableUser.get(0);
|
||||
String token = userTokenInfoDO.getToken();
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow(WeekendUtils.isWeekend(), token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
taskResult.setSummary("当前无可用场地信息");
|
||||
return taskResult;
|
||||
}
|
||||
venueService.saveTomorrowVenueInfo(sitePositionLists);
|
||||
List<SitePositionList> sitePositionLists6_8 = sitePositionLists.stream().filter(VenueInfoUtils::get628VenueInfo).toList();
|
||||
if (CollectionUtils.isEmpty(sitePositionLists6_8)) {
|
||||
taskResult.setSummary("当前无可用场地信息");
|
||||
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();
|
||||
for (SitePositionList sitePositionList : sitePositionLists) {
|
||||
if (map.containsKey(sitePositionList.getPlaceName())) {
|
||||
continue;
|
||||
}
|
||||
map.put(sitePositionList.getPlaceName(), sitePositionList);
|
||||
}
|
||||
StringBuffer msg = new StringBuffer("查询江体场地信息=====>\n时间:" + DateUtils.getDateFromDate(LocalDate.now().plusDays(1)) + " " + time + "\n");
|
||||
map.forEach((placeName, sitePositionList) -> {
|
||||
msg.append(placeName).append("订购人:").append(sitePositionList.getContacts()).append("\n");
|
||||
});
|
||||
jtDingTalkFactory.sendMsg(msg.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service;
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 10:00
|
||||
*/
|
||||
public interface IUserInfoService {
|
||||
|
||||
boolean delAll();
|
||||
|
||||
boolean batchSave(List<UserInfoDO> list);
|
||||
|
||||
List<UserInfoDO> selectAll();
|
||||
}
|
||||
@@ -2,9 +2,6 @@ package com.xiang.service.module.jntyzx.miniapp.service;
|
||||
|
||||
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.UserAddReq;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.UserQueryReq;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JtUserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,14 +17,4 @@ public interface IUserTokenInfoService {
|
||||
boolean flushSingleToken(String name);
|
||||
boolean flushToken();
|
||||
boolean updateTokenByName(String name, String token);
|
||||
|
||||
List<JtUserVo> list(UserQueryReq req);
|
||||
|
||||
Boolean updateStatusByUserName(String username, Integer status);
|
||||
|
||||
Boolean refreshToken(String username);
|
||||
|
||||
Boolean save(UserAddReq req);
|
||||
|
||||
JtUserVo info(Long userId);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.VenueInfoQueryRequest;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.VenueInfoQueryResp;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
|
||||
import java.util.List;
|
||||
@@ -34,11 +31,4 @@ public interface IVenueService {
|
||||
* @return
|
||||
*/
|
||||
boolean saveTomorrowVenueInfo(List<SitePositionList> sitePositionLists);
|
||||
|
||||
/**
|
||||
* 查询场地列表信息
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
Page<VenueInfoQueryResp> list(VenueInfoQueryRequest request);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,11 @@ import com.xiang.common.pojo.jntyzx.miniapp.resp.OrderCreateResp;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.UserInfoResponse;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.VenueList;
|
||||
import com.xiang.common.utils.HttpService;
|
||||
import com.xiang.common.utils.JsonUtils;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.constants.UrlConstant;
|
||||
import com.xiang.service.module.jntyzx.miniapp.manage.IOrderCreateInfoManage;
|
||||
import com.xiang.common.enums.JntyzxUrlConstant;
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IOrderCreateInfoManage;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJntyzxHttpService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.JntyzxSaltEncodeUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -43,7 +45,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
|
||||
@Override
|
||||
public List<SitePositionList> queryAvailable(String isWeekend, String token) {
|
||||
String url = UrlConstant.QUERY_TODAY_SUBSCRIBE_URL;
|
||||
String url = JntyzxUrlConstant.QUERY_TODAY_SUBSCRIBE_URL;
|
||||
return querySitePositionInfo(isWeekend, token, url);
|
||||
}
|
||||
|
||||
@@ -56,7 +58,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
params.put("gid", "03");
|
||||
params.put("isWeekend", isWeekend);
|
||||
try {
|
||||
resp = HttpHelper.doGet(url, header, params);
|
||||
resp = HttpService.doGet(url, header, params);
|
||||
} catch (Exception e) {
|
||||
log.error("[doGet] 江南体育中心查询当天场地 请求失败, url:{}", url);
|
||||
return Lists.newArrayList();
|
||||
@@ -98,7 +100,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
|
||||
@Override
|
||||
public List<SitePositionList> queryAvailableTomorrow(String isWeekend, String token) {
|
||||
String url = UrlConstant.QUERY_TOMORROW_SUBSCRIBE_URL;
|
||||
String url = JntyzxUrlConstant.QUERY_TOMORROW_SUBSCRIBE_URL;
|
||||
return querySitePositionInfo(isWeekend, token, url);
|
||||
}
|
||||
|
||||
@@ -143,7 +145,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("X-Access-Token", token);
|
||||
String resp = HttpHelper.doPost(UrlConstant.ADD_SUBSCRIBE, params, JsonUtils.toJsonString(subscribeRequest));
|
||||
String resp = HttpService.doPost(JntyzxUrlConstant.ADD_SUBSCRIBE, params, JsonUtils.toJsonString(subscribeRequest));
|
||||
log.info("[江体小程序] 羽毛球场地下单响应结果:{}", resp);
|
||||
if (StringUtils.isBlank(resp)) {
|
||||
log.info("[resp] 请求结果为空");
|
||||
@@ -164,7 +166,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("openId", openId);
|
||||
|
||||
String respStr = HttpHelper.doGet(UrlConstant.HEALTH_DECLARATION, headers, params);
|
||||
String respStr = HttpService.doGet(JntyzxUrlConstant.HEALTH_DECLARATION, headers, params);
|
||||
if (StringUtils.isBlank(respStr)) {
|
||||
return null;
|
||||
}
|
||||
@@ -178,7 +180,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
Map<String, String> headers = Maps.newHashMap();
|
||||
headers.put("X-Access-Token", token);
|
||||
|
||||
String resp = HttpHelper.doGet(UrlConstant.QUERY_BY_OPEN_ID, headers, params);
|
||||
String resp = HttpService.doGet(JntyzxUrlConstant.QUERY_BY_OPEN_ID, headers, params);
|
||||
JntyzxResponse<UserInfoResponse> response = JSON.parseObject(resp, new TypeReference<JntyzxResponse<UserInfoResponse>>() {
|
||||
});
|
||||
if (Objects.isNull(response)) {
|
||||
@@ -195,7 +197,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
Map<String, String> headers = Maps.newHashMap();
|
||||
headers.put("X-Access-Token", token);
|
||||
|
||||
String resp = HttpHelper.doGet(UrlConstant.CHECK_NUM, headers, params);
|
||||
String resp = HttpService.doGet(JntyzxUrlConstant.CHECK_NUM, headers, params);
|
||||
if (StringUtils.isBlank(resp)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,14 +2,15 @@ package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.xiang.common.exception.BusinessException;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.OrderInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JntyzxResponse;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.OrderCreateResp;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.constants.RedisKeyConstant;
|
||||
import com.xiang.service.module.jntyzx.miniapp.manage.IOrderCreateInfoManage;
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IOrderCreateInfoManage;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJntyzxHttpService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJtOrderService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -34,7 +35,7 @@ public class OrderInfoServiceImpl implements IJtOrderService {
|
||||
private final IOrderCreateInfoManage orderCreateInfoManage;
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final RedisService redisService;
|
||||
private final JntyzxHttpServiceImpl dingTalkFactory;
|
||||
private final JntyzxDingTalkFactory dingTalkFactory;
|
||||
@Override
|
||||
public List<OrderInfoDO> queryNoPayOrder() {
|
||||
return orderCreateInfoManage.queryNoPayOrder();
|
||||
@@ -75,10 +76,10 @@ public class OrderInfoServiceImpl implements IJtOrderService {
|
||||
orderCreateInfoManage.save(orderInfoDO);
|
||||
}
|
||||
}
|
||||
dingTalkFactory.sendMsg("用户" + userTokenInfoDO.getName() + "预订场地号:" + venueInfoDOS.get(0).getPlaceName() + "结果返回:" + JSON.toJSONString(orderResp));
|
||||
dingTalkFactory.sendMsg("用户" + userTokenInfoDO.getName() + "小程序预订场地号:" + venueInfoDOS.get(0).getPlaceName() + "结果返回:" + JSON.toJSONString(orderResp));
|
||||
return true;
|
||||
} else {
|
||||
dingTalkFactory.sendMsg("用户" + userTokenInfoDO.getName() + "预订场地号:" + venueInfoDOS.get(0).getPlaceName() + "结果返回:" + JSON.toJSONString(orderResp));
|
||||
dingTalkFactory.sendMsg("用户" + userTokenInfoDO.getName() + "小程序预订场地号:" + venueInfoDOS.get(0).getPlaceName() + "结果返回:" + JSON.toJSONString(orderResp));
|
||||
if (orderResp.getMessage().contains("锁卡")) {
|
||||
log.info("有锁卡风险,不在请求,用户:{}", userTokenInfoDO.getName());
|
||||
throw new BusinessException("即将锁卡,不再请求");
|
||||
@@ -92,6 +93,10 @@ public class OrderInfoServiceImpl implements IJtOrderService {
|
||||
log.info("该场地已被人预定,更换场地, 用户:{}", userTokenInfoDO.getName());
|
||||
redisService.set(RedisKeyConstant.getVenueSubscribeKey(venueInfoDOS.get(0).getPlaceName()), "true");
|
||||
}
|
||||
if (orderResp.getMessage().contains("预约场地不能超过2个")) {
|
||||
log.info("用户:{}已经预约场地", userTokenInfoDO.getName());
|
||||
throw new BusinessException("用户已经预约场地");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IUserInfoManage;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserInfoDO;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserInfoService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2026-05-09 10:18
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class UserInfoServiceImpl implements IUserInfoService {
|
||||
|
||||
private final IUserInfoManage userInfoManage;
|
||||
|
||||
@Override
|
||||
public boolean delAll() {
|
||||
return userInfoManage.delAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean batchSave(List<UserInfoDO> list) {
|
||||
return userInfoManage.saveBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserInfoDO> selectAll() {
|
||||
return userInfoManage.list();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,15 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xiang.common.exception.BusinessException;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IUserRestrictionManage;
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IUserTokenInfoManage;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserRestrictionInfo;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.UserTokenInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.UserAddReq;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.UserQueryReq;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JntyzxResponse;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.JtUserVo;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.UserInfoResponse;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.converts.UserConverter;
|
||||
import com.xiang.service.module.jntyzx.miniapp.manage.IUserRestrictionManage;
|
||||
import com.xiang.service.module.jntyzx.miniapp.manage.IUserTokenInfoManage;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IJntyzxHttpService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.service.IUserTokenInfoService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -23,12 +18,8 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
@@ -43,7 +34,6 @@ public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final JntyzxDingTalkFactory jtDingTalkFactory;
|
||||
private final IUserRestrictionManage userRestrictionManage;
|
||||
private final UserConverter userConverter;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -103,6 +93,10 @@ public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
|
||||
}
|
||||
|
||||
private boolean healthDeclaration(UserTokenInfoDO userTokenInfoDO) {
|
||||
if (StringUtils.isBlank(userTokenInfoDO.getToken()) || StringUtils.isBlank(userTokenInfoDO.getOpenId())) {
|
||||
log.info("用户信息异常:{}", JSONObject.toJSONString(userTokenInfoDO));
|
||||
return false;
|
||||
}
|
||||
JntyzxResponse jntyzxResponse = jntyzxHttpService.healthDeclaration(userTokenInfoDO.getToken(), userTokenInfoDO.getOpenId());
|
||||
if (Objects.isNull(jntyzxResponse)) {
|
||||
log.info("用户名:{}心跳监测失败!", userTokenInfoDO.getName());
|
||||
@@ -120,97 +114,6 @@ public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JtUserVo> list(UserQueryReq req) {
|
||||
List<UserTokenInfoDO> userTokenInfoDOS = userTokenInfoManage.queryByList(req);
|
||||
if (CollectionUtils.isEmpty(userTokenInfoDOS)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<Long> idList = userTokenInfoDOS.stream().map(UserTokenInfoDO::getId).toList();
|
||||
List<UserRestrictionInfo> userRestrictionInfos = userRestrictionManage.queryByIdList(idList);
|
||||
Map<Long, UserRestrictionInfo> userRestrictionInfoMap = Maps.newHashMap();
|
||||
if (CollectionUtils.isNotEmpty(userRestrictionInfos)) {
|
||||
userRestrictionInfoMap.putAll(
|
||||
userRestrictionInfos.stream().collect(Collectors.toMap(
|
||||
UserRestrictionInfo::getUserId, Function.identity(), (a, b) -> a)));
|
||||
}
|
||||
List<JtUserVo> jtUserVoList = userConverter.convert(userTokenInfoDOS);
|
||||
jtUserVoList.forEach(item -> {
|
||||
if (userRestrictionInfoMap.containsKey(item.getUserId())) {
|
||||
UserRestrictionInfo userRestrictionInfo = userRestrictionInfoMap.get(item.getUserId());
|
||||
if (Objects.nonNull(userRestrictionInfo)) {
|
||||
if (userRestrictionInfo.getRestrictionDeadline().isAfter(LocalDateTime.now())) {
|
||||
item.setRestrictionDeadline(userRestrictionInfo.getRestrictionDeadline());
|
||||
item.setRestrictionDesc(userRestrictionInfo.getRestrictionDesc());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return jtUserVoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateStatusByUserName(String username, Integer status) {
|
||||
if (StringUtils.isEmpty(username)) {
|
||||
log.error("用户名为空");
|
||||
return false;
|
||||
}
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(username);
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
throw new BusinessException("用户不存在!");
|
||||
}
|
||||
userTokenInfoDO.setStatus(status);
|
||||
return userTokenInfoManage.updateById(userTokenInfoDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean refreshToken(String username) {
|
||||
if (StringUtils.isEmpty(username)) {
|
||||
log.error("用户名为空");
|
||||
return false;
|
||||
}
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(username);
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
throw new BusinessException("用户不存在!");
|
||||
}
|
||||
return healthDeclaration(userTokenInfoDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean save(UserAddReq req) {
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(req.getName());
|
||||
if (Objects.nonNull(userTokenInfoDO)) {
|
||||
throw new BusinessException("用户名已存在!");
|
||||
}
|
||||
userTokenInfoDO = new UserTokenInfoDO();
|
||||
userTokenInfoDO.setName(req.getName());
|
||||
userTokenInfoDO.setToken(req.getToken());
|
||||
userTokenInfoDO.setOpenId(req.getOpenId());
|
||||
userTokenInfoDO.setStatus(req.getStatus());
|
||||
userTokenInfoDO.setIsOrder(1);
|
||||
userTokenInfoDO.setMemberCardNo(req.getMemberCardNo());
|
||||
userTokenInfoDO.setIsRestriction(0);
|
||||
userTokenInfoDO.setUpdateTime(LocalDateTime.now());
|
||||
return userTokenInfoManage.save(userTokenInfoDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JtUserVo info(Long userId) {
|
||||
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getById(userId);
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
throw new BusinessException("用户不存在!");
|
||||
}
|
||||
JtUserVo jtUserVo = userConverter.convert(userTokenInfoDO);
|
||||
UserRestrictionInfo userRestrictionInfo = userRestrictionManage.queryByUserId(userId);
|
||||
if (Objects.nonNull(userRestrictionInfo)) {
|
||||
if (userRestrictionInfo.getRestrictionDeadline().isAfter(LocalDateTime.now())) {
|
||||
jtUserVo.setRestrictionDeadline(userRestrictionInfo.getRestrictionDeadline());
|
||||
jtUserVo.setRestrictionDesc(userRestrictionInfo.getRestrictionDesc());
|
||||
}
|
||||
}
|
||||
return jtUserVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户信息
|
||||
*
|
||||
@@ -219,6 +122,10 @@ public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
|
||||
* @return
|
||||
*/
|
||||
private void queryMemberCardInfo(UserTokenInfoDO userTokenInfoDO) {
|
||||
if (StringUtils.isBlank(userTokenInfoDO.getToken()) || StringUtils.isBlank(userTokenInfoDO.getOpenId())) {
|
||||
log.info("用户信息异常:{}", JSONObject.toJSONString(userTokenInfoDO));
|
||||
return;
|
||||
}
|
||||
JntyzxResponse<UserInfoResponse> response = jntyzxHttpService.queryByOpenId(userTokenInfoDO.getToken(), userTokenInfoDO.getOpenId());
|
||||
if (Objects.isNull(response)) {
|
||||
return;
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
package com.xiang.service.module.jntyzx.miniapp.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.req.VenueInfoQueryRequest;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.VenueInfoQueryResp;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.converts.VenueInfoConverter;
|
||||
import com.xiang.service.module.jntyzx.miniapp.manage.IVenueInfoManage;
|
||||
import com.xiang.common.manage.jntyzx.miniapp.IVenueInfoManage;
|
||||
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.IVenueService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.VenueInfoUtils;
|
||||
import com.xiang.service.module.jntyzx.miniapp.utils.WeekendUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -38,15 +35,14 @@ public class VenueServiceImpl implements IVenueService {
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final IVenueInfoManage venueInfoManage;
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final VenueInfoConverter venueInfoConverter;
|
||||
|
||||
@Override
|
||||
public List<SitePositionList> queryVenueService() {
|
||||
String token = userTokenInfoService.getToken("Xiang");
|
||||
String token = userTokenInfoService.getToken("xiang");
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable("1", token);
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable(WeekendUtils.isWeekend(), token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
@@ -56,11 +52,11 @@ public class VenueServiceImpl implements IVenueService {
|
||||
|
||||
@Override
|
||||
public List<SitePositionList> queryTomorrowVenue() {
|
||||
String token = userTokenInfoService.getToken("Xiang");
|
||||
String token = userTokenInfoService.getToken("xiang");
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow("1", token);
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow(WeekendUtils.isWeekend(), token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
@@ -160,12 +156,6 @@ public class VenueServiceImpl implements IVenueService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VenueInfoQueryResp> list(VenueInfoQueryRequest request) {
|
||||
Page<VenueInfoDO> page = venueInfoManage.page(request);
|
||||
return venueInfoConverter.toPage(page);
|
||||
}
|
||||
|
||||
private void updateDatabase(List<SitePositionList> list, boolean isToday) {
|
||||
List<VenueInfoDO> venueInfoDOS = Lists.newArrayList();
|
||||
if (isToday) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.xiang.service.module.jntyzx.miniapp.utils;
|
||||
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
import com.xiang.service.module.jntyzx.miniapp.constants.RedisKeyConstant;
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -30,7 +30,7 @@ public class MsgSendUtils {
|
||||
String cache = (String) redisService.get(redisKey);
|
||||
if (StringUtils.isNotBlank(cache)) {
|
||||
int sendNum = Integer.parseInt(cache);
|
||||
if (sendNum >= 0 && sendNum <= 5) {
|
||||
if (sendNum >= 0 && sendNum < 5) {
|
||||
jtDingTalkFactory.sendMsg(msgContent);
|
||||
redisService.set(key, String.valueOf(++sendNum), 1, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,20 @@ import com.xiang.common.pojo.jntyzx.miniapp.pojo.VenueInfoDO;
|
||||
import com.xiang.common.pojo.jntyzx.miniapp.resp.query.SitePositionList;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 09:55
|
||||
*/
|
||||
public class VenueInfoUtils {
|
||||
|
||||
public static boolean get11213VenueInfo4Mor(VenueInfoDO venueInfoDO) {
|
||||
return StringUtils.equals(venueInfoDO.getSjName(), "11:00-12:00") || StringUtils.equals(venueInfoDO.getSjName(), "12:00-13:00");
|
||||
}
|
||||
|
||||
public static boolean get123VenueInfo4Mor(VenueInfoDO venueInfoDO) {
|
||||
return StringUtils.equals(venueInfoDO.getSjName(), "13:00-14:00") || StringUtils.equals(venueInfoDO.getSjName(), "14:00-15:00");
|
||||
}
|
||||
@@ -19,6 +27,9 @@ public class VenueInfoUtils {
|
||||
public static boolean get628VenueInfo(VenueInfoDO venueInfoDO) {
|
||||
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) {
|
||||
return StringUtils.equals(venueInfoDO.getSjName(), "20:00-21:00") || StringUtils.equals(venueInfoDO.getSjName(), "21:00-22:00");
|
||||
}
|
||||
@@ -30,12 +41,65 @@ public class VenueInfoUtils {
|
||||
if (placeName.contains("十号")) {
|
||||
return 0;
|
||||
}
|
||||
if (placeName.contains("二号")) {
|
||||
if (placeName.contains("九号")) {
|
||||
return 1;
|
||||
}
|
||||
if (placeName.contains("九号")) {
|
||||
if (placeName.contains("二号")) {
|
||||
return 2;
|
||||
}
|
||||
return 3;
|
||||
if (placeName.contains("八号")) {
|
||||
return 3;
|
||||
}
|
||||
if (placeName.contains("七号")) {
|
||||
return 4;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
public static int sortVenueInfo4Zlb(String placeName) {
|
||||
if (placeName.contains("10号")) {
|
||||
return 0;
|
||||
}
|
||||
if (placeName.contains("9号")) {
|
||||
return 1;
|
||||
}
|
||||
if (placeName.contains("2号")) {
|
||||
return 2;
|
||||
}
|
||||
if (placeName.contains("8号")) {
|
||||
return 3;
|
||||
}
|
||||
if (placeName.contains("7号")) {
|
||||
return 4;
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
public static List<VenueInfoDO> filterVenueList(String siteTimeName, List<VenueInfoDO> venueInfoDOS) {
|
||||
if (StringUtils.equals(siteTimeName, "18:00")) {
|
||||
return venueInfoDOS.stream().filter(VenueInfoUtils::get628VenueInfo).collect(Collectors.toList());
|
||||
}
|
||||
if (StringUtils.equals(siteTimeName, "20:00")) {
|
||||
return venueInfoDOS.stream().filter(VenueInfoUtils::get8210VenueInfo).collect(Collectors.toList());
|
||||
}
|
||||
if (StringUtils.equals(siteTimeName, "12:00")) {
|
||||
return venueInfoDOS.stream().filter(item -> Objects.equals(item.getSjName(), "12:00-13:00")).collect(Collectors.toList());
|
||||
}
|
||||
if (StringUtils.equals(siteTimeName, "13:00")) {
|
||||
return venueInfoDOS.stream().filter(item -> Objects.equals(item.getSjName(), "13:00-14:00")).collect(Collectors.toList());
|
||||
}
|
||||
if (StringUtils.equals(siteTimeName, "14:00")) {
|
||||
return venueInfoDOS.stream().filter(item -> Objects.equals(item.getSjName(), "14:00-15:00")).collect(Collectors.toList());
|
||||
}
|
||||
if (StringUtils.equals(siteTimeName, "15:00")) {
|
||||
return venueInfoDOS.stream().filter(item -> Objects.equals(item.getSjName(), "15:00-16:00")).collect(Collectors.toList());
|
||||
}
|
||||
if (StringUtils.equals(siteTimeName, "16:00")) {
|
||||
return venueInfoDOS.stream().filter(item -> Objects.equals(item.getSjName(), "16:00-17:00")).collect(Collectors.toList());
|
||||
}
|
||||
if (StringUtils.equals(siteTimeName, "17:00")) {
|
||||
return venueInfoDOS.stream().filter(item -> Objects.equals(item.getSjName(), "17:00-18:00")).collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.service.module.jntyzx.zlb.service.ZlbTokenInfoService;
|
||||
import com.xiang.common.manage.jntyzx.zlb.ZlbTokenInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
@@ -53,7 +53,7 @@ public class ZlbLoginTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.ZLB_LOGIN_TASK.getModeleCode();
|
||||
return ScheduleEnums.ZLB_LOGIN_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.exception.BusinessException;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.manage.jntyzx.zlb.IZlbOrderInfoManage;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbPayOrder;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
@@ -17,13 +19,14 @@ import com.xiang.common.utils.DateUtils;
|
||||
import com.xiang.common.utils.OkHttpUtil;
|
||||
import com.xiang.service.module.jntyzx.zlb.constants.ZlbUrlConstants;
|
||||
import com.xiang.service.module.jntyzx.zlb.service.ZlbService;
|
||||
import com.xiang.service.module.jntyzx.zlb.service.ZlbTokenInfoService;
|
||||
import com.xiang.service.module.jntyzx.zlb.service.ZlbUserInfoService;
|
||||
import com.xiang.common.manage.jntyzx.zlb.ZlbTokenInfoService;
|
||||
import com.xiang.common.manage.jntyzx.zlb.ZlbUserInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
@@ -40,6 +43,7 @@ public class ZlbOrderTask extends BaseScheduleTaskTemplate {
|
||||
private final ZlbTokenInfoService zlbTokenInfoService;
|
||||
private final JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||
private final RedisTemplate redisTemplate;
|
||||
private final IZlbOrderInfoManage zlbOrderInfoManage;
|
||||
|
||||
public ZlbOrderTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
@@ -47,13 +51,15 @@ public class ZlbOrderTask extends BaseScheduleTaskTemplate {
|
||||
ZlbService zlbService,
|
||||
ZlbTokenInfoService zlbTokenInfoService,
|
||||
JntyzxDingTalkFactory jntyzxDingTalkFactory,
|
||||
RedisTemplate redisTemplate) {
|
||||
RedisTemplate redisTemplate,
|
||||
IZlbOrderInfoManage zlbOrderInfoManage) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.zlbUserInfoService = zlbUserInfoService;
|
||||
this.zlbService = zlbService;
|
||||
this.zlbTokenInfoService = zlbTokenInfoService;
|
||||
this.jntyzxDingTalkFactory = jntyzxDingTalkFactory;
|
||||
this.redisTemplate = redisTemplate;
|
||||
this.zlbOrderInfoManage = zlbOrderInfoManage;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +69,7 @@ public class ZlbOrderTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.ZLB_ORDER_CREATE_TASK.getModeleCode();
|
||||
return ScheduleEnums.ZLB_ORDER_CREATE_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,43 +104,73 @@ public class ZlbOrderTask extends BaseScheduleTaskTemplate {
|
||||
String tokenId = zlbTokenInfo.getTokenId();
|
||||
String secretKey = zlbService.getKey(tokenId, client);
|
||||
String siteOrderDetailsStr = zlbService.buildSiteOrder(zlbUserInfo, secretKey, day);
|
||||
if (StringUtils.isEmpty(siteOrderDetailsStr)) {
|
||||
log.info("构建订单参数异常:{}", siteOrderDetailsStr);
|
||||
throw new BusinessException("构建订单参数异常");
|
||||
}
|
||||
Map<String, String> headers = zlbService.getHeaders(zlbTokenInfo.getTokenId());
|
||||
String newOrderJson = zlbService.buildNewOrder(siteOrderDetailsStr, client);
|
||||
if (StringUtils.isBlank(newOrderJson)) {
|
||||
log.info("构建订单参数异常:{}", siteOrderDetailsStr);
|
||||
throw new BusinessException("");
|
||||
throw new BusinessException("构建订单参数异常");
|
||||
}
|
||||
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
|
||||
//计算9点到现在的时间差
|
||||
//获取江体当前时间
|
||||
LocalTime currentTime = LocalTime.now();
|
||||
LocalTime targetTime = LocalTime.parse("09:00:11.800");
|
||||
LocalTime targetTime = LocalTime.parse("09:00:12.500");
|
||||
Duration duration = Duration.between(currentTime, targetTime);
|
||||
long milliseconds = duration.toMillis();
|
||||
executorService.schedule(() -> {
|
||||
String response = null;
|
||||
try {
|
||||
response = client.postJson(ZlbUrlConstants.newOrderUrl, headers, newOrderJson);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
String response = null;
|
||||
try {
|
||||
response = client.postJson(ZlbUrlConstants.newOrderUrl, headers, newOrderJson);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
boolean b = buildOrder(name, response, placeName, siteTimeName);
|
||||
if (b) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1250);
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("线程暂停异常");
|
||||
}
|
||||
}
|
||||
buildOrder(name, response, placeName, siteTimeName);
|
||||
}, milliseconds, TimeUnit.MILLISECONDS);
|
||||
|
||||
return taskResult;
|
||||
}
|
||||
|
||||
private void buildOrder(String name, String response, String placeName, String siteTimeName) {
|
||||
private boolean buildOrder(String name, String response, String placeName, String siteTimeName) {
|
||||
log.info("订单接口返回结果==> \n {}", response);
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
if (jsonObject.getInteger("code") == 200) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + "订单接口下单返回成功请2分钟内付款√√√√√√场地号:" + placeName + "时间:" + siteTimeName);
|
||||
jntyzxDingTalkFactory.sendMsg(name + ":zlb订单接口下单返回成功请2分钟内付款√√√√√√场地号:" + placeName + "时间:" + siteTimeName);
|
||||
JSONObject data = jsonObject.getJSONObject("data");
|
||||
String orderId = data.getString("orderId");
|
||||
log.info("{}订单{}创建成功", name, orderId);
|
||||
String redisKey = ZlbUrlConstants.REDIS_PREFIX + "_" + orderId + "_" + name;
|
||||
redisTemplate.opsForValue().set(redisKey, name);
|
||||
redisTemplate.expire(redisKey, 120, TimeUnit.SECONDS);
|
||||
ZlbPayOrder zlbPayOrder = new ZlbPayOrder();
|
||||
zlbPayOrder.setName(name);
|
||||
zlbPayOrder.setDay(DateUtils.getDateFromDate(LocalDate.now().plusDays(1)));
|
||||
zlbPayOrder.setVenues("江体");
|
||||
zlbPayOrder.setPlaceName(placeName);
|
||||
zlbPayOrder.setTime(siteTimeName);
|
||||
zlbPayOrder.setIsPay(0);
|
||||
zlbOrderInfoManage.save(zlbPayOrder);
|
||||
return true;
|
||||
}
|
||||
if (jsonObject.getInteger("code") == 500) {
|
||||
if (jsonObject.getString("message").contains("已被售出")) {
|
||||
jntyzxDingTalkFactory.sendMsg(name + ":zlb订单接口下单返回失败❌❌❌场地号:" + placeName + "已被售出");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.xiang.common.utils.DateUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -40,7 +39,7 @@ public class ZlbSiteDayTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.ZLB_SITE_DAY_TASK.getModeleCode();
|
||||
return ScheduleEnums.ZLB_SITE_DAY_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,7 @@ public class ZlbSiteTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.ZLB_SITE_QUERY_TASK.getModeleCode();
|
||||
return ScheduleEnums.ZLB_SITE_QUERY_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,41 +18,57 @@ public class ZlbTaskConfig {
|
||||
private final ZlbOrderTask zlbOrderTask;
|
||||
private final ZlbUserConfigTask zlbUserConfigTask;
|
||||
|
||||
/**
|
||||
* token续期
|
||||
*/
|
||||
@Scheduled(cron = "0 0/30 * * * ?")
|
||||
@GetMapping("/zlbLoginTask")
|
||||
public void zlbLoginTask() {
|
||||
zlbLoginTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* token校验
|
||||
*/
|
||||
@Scheduled(cron = "0 0 8 * * *")
|
||||
@GetMapping("/zlbTokenRefresh")
|
||||
public void zlbTokenRefresh() {
|
||||
zlbTokenRefreshTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 场地信息拉取 拉取后天的场地信息
|
||||
*/
|
||||
@GetMapping("/zlbSiteTask")
|
||||
@Scheduled(cron = "30 30 16 * * ?")
|
||||
public void zlbSiteTask() {
|
||||
zlbSiteTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 当天场地订阅信息--数据库数据
|
||||
*/
|
||||
@GetMapping("/zlbSiteDayTask")
|
||||
@Scheduled(cron = "0 00 17 * * ?")
|
||||
public void zlbSiteDayTask() {
|
||||
zlbSiteDayTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下单
|
||||
*/
|
||||
@GetMapping("/zlbOrderCreateTask")
|
||||
@Scheduled(cron = "55 59 8 * * ?")
|
||||
@Scheduled(cron = "2 0 9 * * ?")
|
||||
public void zlbOrderCreateTask() {
|
||||
zlbOrderTask.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下单用户场地配置信息
|
||||
*/
|
||||
@Scheduled(cron = "30 35 16 * * ?")
|
||||
@GetMapping("/zlbUserConfig")
|
||||
public void zlbUserConfig() {
|
||||
zlbUserConfigTask.run();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,12 +9,11 @@ import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
import com.xiang.common.pojo.schedule.TaskResult;
|
||||
import com.xiang.common.service.IScheduleOpeningConfigService;
|
||||
import com.xiang.common.service.IScheduleRunLogService;
|
||||
import com.xiang.service.module.jntyzx.zlb.service.ZlbTokenInfoService;
|
||||
import com.xiang.common.manage.jntyzx.zlb.ZlbTokenInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -41,7 +40,7 @@ public class ZlbTokenRefreshTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.ZLB_TOKEN_CHECK_TASK.getModeleCode();
|
||||
return ScheduleEnums.ZLB_TOKEN_CHECK_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package com.xiang.service.module.jntyzx.zlb.schedule;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.xiang.common.enums.RedisKeyConstant;
|
||||
import com.xiang.common.enums.ScheduleEnums;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.factory.schedule.BaseScheduleTaskTemplate;
|
||||
import com.xiang.common.manage.jntyzx.zlb.ZlbSiteInfoService;
|
||||
import com.xiang.common.manage.jntyzx.zlb.ZlbTokenInfoService;
|
||||
import com.xiang.common.manage.jntyzx.zlb.ZlbUserInfoService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbSiteInfo;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbTokenInfo;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbUserInfo;
|
||||
@@ -13,9 +18,8 @@ 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.zlb.service.ZlbSiteInfoService;
|
||||
import com.xiang.service.module.jntyzx.zlb.service.ZlbTokenInfoService;
|
||||
import com.xiang.service.module.jntyzx.zlb.service.ZlbUserInfoService;
|
||||
import com.xiang.common.utils.RedisService;
|
||||
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;
|
||||
@@ -38,18 +42,21 @@ public class ZlbUserConfigTask extends BaseScheduleTaskTemplate {
|
||||
private final ZlbUserInfoService zlbUserInfoService;
|
||||
private final JntyzxDingTalkFactory jntyzxDingTalkFactory;
|
||||
private final ZlbTokenInfoService zlbTokenInfoService;
|
||||
private final RedisService redisService;
|
||||
|
||||
public ZlbUserConfigTask(IScheduleOpeningConfigService scheduleOpeningConfigService,
|
||||
IScheduleRunLogService scheduleRunLogService,
|
||||
ZlbSiteInfoService zlbSiteInfoService,
|
||||
ZlbUserInfoService zlbUserInfoService,
|
||||
ZlbTokenInfoService zlbTokenInfoService,
|
||||
JntyzxDingTalkFactory jntyzxDingTalkFactory) {
|
||||
JntyzxDingTalkFactory jntyzxDingTalkFactory,
|
||||
RedisService redisService) {
|
||||
super(scheduleOpeningConfigService, scheduleRunLogService);
|
||||
this.zlbSiteInfoService = zlbSiteInfoService;
|
||||
this.zlbUserInfoService = zlbUserInfoService;
|
||||
this.jntyzxDingTalkFactory = jntyzxDingTalkFactory;
|
||||
this.zlbTokenInfoService = zlbTokenInfoService;
|
||||
this.redisService = redisService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +66,7 @@ public class ZlbUserConfigTask extends BaseScheduleTaskTemplate {
|
||||
|
||||
@Override
|
||||
protected Integer getModule() {
|
||||
return ScheduleEnums.ZLB_USER_CONFIG_TASK.getModeleCode();
|
||||
return ScheduleEnums.ZLB_USER_CONFIG_TASK.getModuleCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,33 +133,18 @@ public class ZlbUserConfigTask extends BaseScheduleTaskTemplate {
|
||||
}
|
||||
|
||||
private List<ZlbSiteInfo> filterSiteInfo(List<ZlbSiteInfo> siteInfoList) {
|
||||
return siteInfoList.stream().filter(item -> Objects.equals(item.getDayEffectiveTimes(), "20:00")).toList();
|
||||
String time = (String) redisService.get(RedisKeyConstant.JNTYZX_SUBSCRIBE_TIME_KEY);
|
||||
if (StringUtils.isBlank(time)) {
|
||||
time = "18:00";
|
||||
}
|
||||
String finalTime = time;
|
||||
return siteInfoList.stream().filter(item -> Objects.equals(item.getDayEffectiveTimes(), finalTime)).toList();
|
||||
}
|
||||
|
||||
private List<ZlbSiteInfo> sortSiteInfo(List<ZlbSiteInfo> siteInfoList) {
|
||||
if (CollectionUtils.isEmpty(siteInfoList)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
return siteInfoList.stream().sorted(Comparator.comparing(this::sort)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private int sort(ZlbSiteInfo siteInfo) {
|
||||
String placeName = siteInfo.getPlaceName();
|
||||
if (placeName.contains("十号")) {
|
||||
return 0;
|
||||
}
|
||||
if (placeName.contains("九号")) {
|
||||
return 1;
|
||||
}
|
||||
if (placeName.contains("二号")) {
|
||||
return 2;
|
||||
}
|
||||
if (placeName.contains("八号")) {
|
||||
return 3;
|
||||
}
|
||||
if (placeName.contains("七号")) {
|
||||
return 4;
|
||||
}
|
||||
return 5;
|
||||
return siteInfoList.stream().sorted(Comparator.comparing(item -> VenueInfoUtils.sortVenueInfo4Zlb(item.getPlaceName()))).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.xiang.common.factory.JntyzxDingTalkFactory;
|
||||
import com.xiang.common.manage.jntyzx.zlb.ZlbSiteInfoService;
|
||||
import com.xiang.common.manage.jntyzx.zlb.ZlbTokenInfoService;
|
||||
import com.xiang.common.manage.jntyzx.zlb.ZlbUserInfoService;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbCaptchaResp;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbOrderInfo;
|
||||
import com.xiang.common.pojo.jntyzx.zlb.ZlbOrderJson;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<configuration scan="true">
|
||||
|
||||
<!-- 应用名称:和统一配置中的项目代码保持一致(小写) -->
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name" defaultValue="X_APP" />
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name" defaultValue="APP" />
|
||||
<contextName>${APP_NAME}</contextName>
|
||||
|
||||
<!--日志文件保留天数 -->
|
||||
@@ -65,6 +65,23 @@
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="APP_WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<FileNamePattern>${LOG_HOME}/warn-%d{yyyy-MM-dd}.log</FileNamePattern>
|
||||
<MaxHistory>${LOG_MAX_HISTORY}</MaxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%contextName: %d{yyyy-MM-dd HH:mm:ss.SSS} [%c][%t][%L][%p] [traceId:%X{traceId:-},spanId:%X{spanId:-},localIp:%X{localIp:-}] - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>warn</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
|
||||
<!-- 按照每天生成日志文件:主项目日志 -->
|
||||
<appender name="APP_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
@@ -90,12 +107,12 @@
|
||||
<root level="INFO">
|
||||
<appender-ref ref="APP_DEBUG"/>
|
||||
<appender-ref ref="APP_INFO"/>
|
||||
<appender-ref ref="APP_WARN"/>
|
||||
<appender-ref ref="APP_ERROR"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
|
||||
<!-- mybatis 日志级别 -->
|
||||
<logger name="com.xiang" level="INFO"/>
|
||||
<logger name="com.xiang" level="DEBUG"/>
|
||||
<!-- Spring 框架 -->
|
||||
<logger name="org.springframework" level="INFO"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user