feat:江体小程序定时任务
This commit is contained in:
@@ -17,7 +17,6 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
@SpringBootApplication
|
||||
@ConfigurationPropertiesScan(basePackages = {
|
||||
"com.xiang.xservice.logger",
|
||||
"com.xiang.app.common.config",
|
||||
})
|
||||
@MapperScan(basePackages = {
|
||||
"com.xiang.app.modules.*.mapper"
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.xiang.core.quartz.annotation.XxzJob;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
@@ -13,11 +15,13 @@ import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class JtTokenRefreshTask {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
|
||||
@XxzJob(name = "jtTokenRefreshHandler")
|
||||
@GetMapping("/jtTokenRefreshHandler")
|
||||
public void handle() {
|
||||
log.info("【Token】江南体育中心token续期定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||
userTokenInfoService.flushToken();
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.xiang.app.modules.jntyzx.service.IJntyzxHttpService;
|
||||
import com.xiang.app.modules.jntyzx.service.IUserTokenInfoService;
|
||||
import com.xiang.app.modules.jntyzx.service.IVenueService;
|
||||
import com.xiang.app.modules.jntyzx.utils.VenueInfoUtils;
|
||||
import com.xiang.app.modules.jntyzx.utils.WeekendUtils;
|
||||
import com.xiang.core.quartz.annotation.XxzJob;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -14,14 +15,21 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 每日9:00-19:00场地更新信息查询
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class JtVenuePullTask {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
@@ -30,6 +38,7 @@ public class JtVenuePullTask {
|
||||
private final IVenueService venueService;
|
||||
|
||||
@XxzJob(name = "jtVenueInfoPullTask")
|
||||
@GetMapping("/jtVenueInfoPullTask")
|
||||
public void handler() {
|
||||
log.info("【Venue】江体小程序场地数据拉取定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||
List<UserTokenInfoDO> availableUser = userTokenInfoService.getAvailableUser();
|
||||
@@ -38,6 +47,7 @@ public class JtVenuePullTask {
|
||||
return;
|
||||
}
|
||||
String token;
|
||||
|
||||
for (UserTokenInfoDO userTokenInfoDO : availableUser) {
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
continue;
|
||||
@@ -46,7 +56,7 @@ public class JtVenuePullTask {
|
||||
if (StringUtils.isBlank(token)) {
|
||||
continue;
|
||||
}
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable("1", token);
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable(WeekendUtils.isWeekend(), token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.xiang.app.schedule.jntyzx;
|
||||
|
||||
import com.xiang.app.modules.jntyzx.entity.pojo.UserTokenInfoDO;
|
||||
import com.xiang.app.modules.jntyzx.entity.pojo.VenueInfoDO;
|
||||
import com.xiang.app.modules.jntyzx.service.IJtOrderService;
|
||||
import com.xiang.app.modules.jntyzx.service.IUserTokenInfoService;
|
||||
import com.xiang.app.modules.jntyzx.service.IVenueService;
|
||||
import com.xiang.app.modules.jntyzx.utils.VenueInfoUtils;
|
||||
import com.xiang.core.quartz.annotation.XxzJob;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Component
|
||||
@RestController
|
||||
public class JtVenueSubscribeTask {
|
||||
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final IJtOrderService jtOrderService;
|
||||
private final IVenueService venueService;
|
||||
|
||||
@XxzJob(name = "jtVenueSubscribeTask")
|
||||
@GetMapping("/jtVenueSubscribeTask")
|
||||
public void handle() {
|
||||
log.info("【Subscribe】 江体场地预定定时任务启动!!! time:{}", System.currentTimeMillis());
|
||||
|
||||
List<UserTokenInfoDO> users = userTokenInfoService.getAvailableUser();
|
||||
List<VenueInfoDO> venueInfoDOS = venueService.queryTomorrowCanBuyVenue();
|
||||
|
||||
Map<String, List<VenueInfoDO>> venueInfoMap = venueInfoDOS.stream().filter(VenueInfoUtils::get123VenueInfo4Mor).collect(Collectors.groupingByConcurrent(VenueInfoDO::getPlaceName));
|
||||
|
||||
venueInfoMap.keySet().parallelStream().forEach(placeName -> {
|
||||
List<VenueInfoDO> venueInfoDOList = venueInfoMap.get(placeName);
|
||||
users.forEach(user -> {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
boolean order = jtOrderService.createOrder(venueInfoDOList, user);
|
||||
if (order) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.xiang.app.schedule.jntyzx;
|
||||
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.app.common.service.dingtalk.JtDingTalkFactory;
|
||||
import com.xiang.app.modules.jntyzx.entity.pojo.UserTokenInfoDO;
|
||||
import com.xiang.app.modules.jntyzx.entity.resp.query.SitePositionList;
|
||||
import com.xiang.app.modules.jntyzx.service.IJntyzxHttpService;
|
||||
import com.xiang.app.modules.jntyzx.service.IUserTokenInfoService;
|
||||
import com.xiang.app.modules.jntyzx.service.IVenueService;
|
||||
import com.xiang.app.modules.jntyzx.utils.VenueInfoUtils;
|
||||
import com.xiang.app.modules.jntyzx.utils.WeekendUtils;
|
||||
import com.xiang.core.quartz.annotation.XxzJob;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class JtVenueTomorrowPullTask {
|
||||
private final IUserTokenInfoService userTokenInfoService;
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final JtDingTalkFactory jtDingTalkFactory;
|
||||
private final IVenueService venueService;
|
||||
|
||||
@XxzJob(name = "jtVenueTomorrowPullTask")
|
||||
@GetMapping("/jtVenueTomorrowPullTask")
|
||||
public void handle() {
|
||||
log.info("【Venue】江体小程序场地拉取定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||
List<UserTokenInfoDO> availableUser = userTokenInfoService.getAvailableUser();
|
||||
if (CollectionUtils.isEmpty(availableUser)) {
|
||||
log.info("当前无可用用户查询场地信息!");
|
||||
return;
|
||||
}
|
||||
String token;
|
||||
for (UserTokenInfoDO userTokenInfoDO : availableUser) {
|
||||
if (Objects.isNull(userTokenInfoDO)) {
|
||||
continue;
|
||||
}
|
||||
token = userTokenInfoDO.getToken();
|
||||
if (StringUtils.isBlank(token)) {
|
||||
continue;
|
||||
}
|
||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow(WeekendUtils.isWeekend(), token);
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
continue;
|
||||
}
|
||||
venueService.saveTomorrowVenueInfo(sitePositionLists);
|
||||
|
||||
sitePositionLists = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
|
||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||
return;
|
||||
}
|
||||
Map<String, SitePositionList> map = Maps.newLinkedHashMap();
|
||||
for (SitePositionList sitePositionList : sitePositionLists) {
|
||||
if (map.containsKey(sitePositionList.getPlaceName())) {
|
||||
continue;
|
||||
}
|
||||
map.put(sitePositionList.getPlaceName(), sitePositionList);
|
||||
}
|
||||
StringBuffer msg = new StringBuffer("查询场地信息===>时间:\n" + DateUtils.getDateFromDate(LocalDate.now()) + " 20:00-22:00\n");
|
||||
map.forEach((placeName, sitePositionList) -> {
|
||||
msg.append(placeName).append("订购人:").append(sitePositionList.getContacts()).append("\n");
|
||||
});
|
||||
jtDingTalkFactory.sendMsg(msg.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,5 +24,4 @@ public class JtTokenServer {
|
||||
userTokenInfoService.updateTokenByName(username, token);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
group: DEFAULT_GROUP
|
||||
namespace: 6f603892-e9f7-4ca4-acbc-538fa09ebec0
|
||||
server-addr: general.xiangtech.xyz:8848
|
||||
username: nacos
|
||||
password: nacos
|
||||
datasource:
|
||||
dynamic:
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://rm-bp15t34gqx62jm069ro.mysql.rds.aliyuncs.com:3306/xservice_cornucopia?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: cornucopia
|
||||
password: cornucopia@123
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
sshConnect: false
|
||||
redis:
|
||||
host: r-bp1wt59a6nfyt4e3ltpd.redis.rds.aliyuncs.com
|
||||
port: 6379
|
||||
password: Xiang0000 # 如果无密码可以省略
|
||||
database: 0
|
||||
timeout: 5000
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 8
|
||||
max-idle: 8
|
||||
min-idle: 0
|
||||
max-wait: 1000
|
||||
xxz-job:
|
||||
app-name: xservice-cornucopia
|
||||
admin-address: http://192.168.1.10:10001
|
||||
namespace: 17029199820391402
|
||||
|
||||
dingtalk:
|
||||
robot:
|
||||
properties:
|
||||
venue:
|
||||
name: 江南体育中心通知群
|
||||
token: 6a218646972c684c75832b0229ea93a234778af537d7469ce96bef290faf530e
|
||||
secret: SEC9018755ba86d3e5c1ed2fbfa1d6953d84bb2a6c8ebe7ed4e318457bfed5e0465
|
||||
users:
|
||||
- 450841600726084717
|
||||
@@ -17,12 +17,6 @@ spring:
|
||||
password: cornucopia@123
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
sshConnect: false
|
||||
xxz-job:
|
||||
url: jdbc:mysql://120.27.153.87:3306/xservice_quartz?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: quartz
|
||||
password: quartz@123
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
sshConnect: false
|
||||
redis:
|
||||
host: r-bp1wt59a6nfyt4e3ltpd.redis.rds.aliyuncs.com
|
||||
port: 6379
|
||||
@@ -37,7 +31,7 @@ spring:
|
||||
max-wait: 1000
|
||||
xxz-job:
|
||||
app-name: xservice-cornucopia
|
||||
admin-address: http://127.0.0.1:30030
|
||||
admin-address: http://192.168.1.10:10001
|
||||
namespace: 1
|
||||
|
||||
dingtalk:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
spring:
|
||||
profiles:
|
||||
active: test
|
||||
active: prod
|
||||
application:
|
||||
name: xservice-cornucopia
|
||||
main:
|
||||
|
||||
Reference in New Issue
Block a user