feat:江体小程序定时任务
This commit is contained in:
@@ -3,6 +3,7 @@ package com.xiang.app.modules.jntyzx.service;
|
||||
|
||||
import com.xiang.app.modules.jntyzx.entity.pojo.VenueInfoDO;
|
||||
import com.xiang.app.modules.jntyzx.entity.resp.JntyzxResponse;
|
||||
import com.xiang.app.modules.jntyzx.entity.resp.OrderCreateResp;
|
||||
import com.xiang.app.modules.jntyzx.entity.resp.query.SitePositionList;
|
||||
|
||||
import java.util.List;
|
||||
@@ -30,7 +31,7 @@ public interface IJntyzxHttpService {
|
||||
* 订单创建
|
||||
* @return
|
||||
*/
|
||||
Boolean createOrder(List<VenueInfoDO> venueInfos, String token);
|
||||
JntyzxResponse<OrderCreateResp> createOrder(List<VenueInfoDO> venueInfos, String token);
|
||||
|
||||
/**
|
||||
* 心跳监测
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.xiang.app.modules.jntyzx.service;
|
||||
|
||||
|
||||
import com.xiang.app.modules.jntyzx.entity.pojo.OrderInfoDO;
|
||||
import com.xiang.app.modules.jntyzx.entity.pojo.UserTokenInfoDO;
|
||||
import com.xiang.app.modules.jntyzx.entity.pojo.VenueInfoDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -11,5 +13,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface IJtOrderService {
|
||||
|
||||
boolean createOrder(List<VenueInfoDO> venueInfoDOS, UserTokenInfoDO userTokenInfoDO);
|
||||
|
||||
List<OrderInfoDO> queryNoPayOrder();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public interface IVenueService {
|
||||
List<SitePositionList> queryVenueService();
|
||||
List<SitePositionList> queryTomorrowVenue();
|
||||
List<VenueInfoDO> queryCanBuyVenue();
|
||||
List<VenueInfoDO> queryTomorrowCanBuyVenue();
|
||||
List<VenueInfoDO> queryToday6210VenueInfo();
|
||||
|
||||
/**
|
||||
@@ -23,4 +24,11 @@ public interface IVenueService {
|
||||
* @return
|
||||
*/
|
||||
boolean saveOrUpdateTodayVenueInfo(List<SitePositionList> sitePositionLists);
|
||||
|
||||
/**
|
||||
* 更新第二天的场地信息
|
||||
* @param sitePositionLists
|
||||
* @return
|
||||
*/
|
||||
boolean saveTomorrowVenueInfo(List<SitePositionList> sitePositionLists);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,11 @@ import com.xiang.app.modules.jntyzx.entity.resp.query.SitePositionList;
|
||||
import com.xiang.app.modules.jntyzx.entity.resp.query.VenueList;
|
||||
import com.xiang.app.modules.jntyzx.manage.IOrderCreateInfoManage;
|
||||
import com.xiang.app.modules.jntyzx.service.IJntyzxHttpService;
|
||||
import com.xiang.app.modules.jntyzx.utils.JntyzxSaltEncodeUtils;
|
||||
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||
import com.xiang.xmc.service.http.helper.BaseHttpHelp;
|
||||
import com.xiang.xmc.service.http.helper.HttpHelper;
|
||||
import com.xiang.xmc.service.http.helper.HttpHelperFactory;
|
||||
import com.xiang.xservice.basic.utils.Base64;
|
||||
import com.xiang.xservice.basic.utils.JsonUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -109,8 +112,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean createOrder(List<VenueInfoDO> venueInfos, String token) {
|
||||
|
||||
public JntyzxResponse<OrderCreateResp> createOrder(List<VenueInfoDO> venueInfos, String token) {
|
||||
List<SubscribeVo> vos = Lists.newArrayList();
|
||||
for (VenueInfoDO venueInfo : venueInfos) {
|
||||
SubscribeVo subscribeVo = new SubscribeVo();
|
||||
@@ -145,7 +147,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
subscribeRequest.setSubscribeVos(vos);
|
||||
subscribeRequest.setBookTime(venueInfos.get(0).getAppointments());
|
||||
subscribeRequest.setPaymentMethod(1);
|
||||
subscribeRequest.setSvCiphertext(sonAddSalt(JsonUtils.toJsonString(vos)));
|
||||
subscribeRequest.setSvCiphertext(JntyzxSaltEncodeUtils.sonAddSalt(JsonUtils.toJsonString(vos)));
|
||||
subscribeRequest.setJsonObject(jsonObject);
|
||||
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
@@ -153,32 +155,15 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
String resp = HttpHelper.doPost(UrlConstant.ADD_SUBSCRIBE, params, JsonUtils.toJsonString(subscribeRequest));
|
||||
if (StringUtils.isBlank(resp)) {
|
||||
log.info("请求结果为空");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
JntyzxResponse<OrderCreateResp> response = JSON.parseObject(resp, new TypeReference<JntyzxResponse<OrderCreateResp>>() {
|
||||
});
|
||||
if (Objects.isNull(response)) {
|
||||
log.info("请求结果为空");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
if (response.getSuccess()) {
|
||||
OrderCreateResp createResp = response.getResult();
|
||||
if (Objects.nonNull(createResp)) {
|
||||
String orderId = createResp.getId();
|
||||
redisService.set(RedisKeyConstant.JNTYZX_ORDER_CREATE_KEY + orderId, String.valueOf(System.currentTimeMillis()));
|
||||
OrderInfoDO orderInfoDO = new OrderInfoDO();
|
||||
orderInfoDO.setOrderId(orderId);
|
||||
orderInfoDO.setParams(JsonUtils.toJsonString(subscribeRequest));
|
||||
orderInfoDO.setCreateTime(LocalDateTime.now());
|
||||
orderInfoDO.setUsername(token);
|
||||
orderInfoDO.setPlaceName(vos.get(0).getPlaceName());
|
||||
orderInfoDO.setDate(LocalDate.now());
|
||||
orderInfoDO.setOrderStatus(0);
|
||||
orderCreateInfoManage.save(orderInfoDO);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return response;
|
||||
}
|
||||
@Override
|
||||
public JntyzxResponse healthDeclaration(String token, String openId) {
|
||||
@@ -214,30 +199,4 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||
jsonObject.put("default05", null);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
private static int[] getMonthAndDay() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
int month = currentDate.getMonthValue();
|
||||
int day = currentDate.getDayOfMonth();
|
||||
return new int[]{month, day};
|
||||
}
|
||||
|
||||
private String sonAddSalt(String json) {
|
||||
String svCiphertext = "";
|
||||
String suiji = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
String token1 = String.valueOf(suiji.charAt((int) (Math.random() * (double) suiji.length())));
|
||||
String token2 = String.valueOf(suiji.charAt((int) (Math.random() * (double) suiji.length())));
|
||||
svCiphertext = Base64.encode(json.getBytes(StandardCharsets.UTF_8));
|
||||
int[] monthAndDay = getMonthAndDay();
|
||||
int month = monthAndDay[0];
|
||||
int day = monthAndDay[1];
|
||||
if (month == 1) {
|
||||
svCiphertext = (svCiphertext = token1 + svCiphertext).substring(0, day - 1) + token2 + svCiphertext.substring(day - 1);
|
||||
} else if (day == 1) {
|
||||
svCiphertext = token2 + svCiphertext.substring(0, month - 1) + token1 + svCiphertext.substring(month - 1);
|
||||
} else {
|
||||
svCiphertext = (svCiphertext = svCiphertext.substring(0, month - 1) + token1 + svCiphertext.substring(month - 1)).substring(0, day - 1) + token2 + svCiphertext.substring(day - 1);
|
||||
}
|
||||
return svCiphertext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,78 @@
|
||||
package com.xiang.app.modules.jntyzx.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.xiang.app.common.service.dingtalk.JtDingTalkFactory;
|
||||
import com.xiang.app.modules.jntyzx.constants.RedisKeyConstant;
|
||||
import com.xiang.app.modules.jntyzx.entity.pojo.OrderInfoDO;
|
||||
import com.xiang.app.modules.jntyzx.entity.pojo.UserTokenInfoDO;
|
||||
import com.xiang.app.modules.jntyzx.entity.pojo.VenueInfoDO;
|
||||
import com.xiang.app.modules.jntyzx.entity.resp.JntyzxResponse;
|
||||
import com.xiang.app.modules.jntyzx.entity.resp.OrderCreateResp;
|
||||
import com.xiang.app.modules.jntyzx.manage.IOrderCreateInfoManage;
|
||||
import com.xiang.app.modules.jntyzx.service.IJntyzxHttpService;
|
||||
import com.xiang.app.modules.jntyzx.service.IJtOrderService;
|
||||
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||
import com.xiang.xservice.basic.utils.JsonUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-16 16:17
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class OrderInfoServiceImpl implements IJtOrderService {
|
||||
|
||||
private final IOrderCreateInfoManage orderCreateInfoManage;
|
||||
private final IJntyzxHttpService jntyzxHttpService;
|
||||
private final IRedisService redisService;
|
||||
private final JtDingTalkFactory dingTalkFactory;
|
||||
@Override
|
||||
public List<OrderInfoDO> queryNoPayOrder() {
|
||||
return orderCreateInfoManage.queryNoPayOrder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createOrder(List<VenueInfoDO> venueInfoDOS, UserTokenInfoDO userTokenInfoDO) {
|
||||
|
||||
String order = (String) redisService.get(RedisKeyConstant.JNTYZX_ORDER_CREATE_KEY + userTokenInfoDO.getName());
|
||||
if (StringUtils.isNotBlank(order)) {
|
||||
log.info("用户:{}已经有成功预订了场地", userTokenInfoDO.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
JntyzxResponse<OrderCreateResp> orderResp = jntyzxHttpService.createOrder(venueInfoDOS, userTokenInfoDO.getToken());
|
||||
if (Objects.isNull(orderResp)) {
|
||||
return false;
|
||||
}
|
||||
if (orderResp.getSuccess()) {
|
||||
OrderCreateResp result = orderResp.getResult();
|
||||
if (Objects.nonNull(result)) {
|
||||
String orderId = result.getId();
|
||||
if (StringUtils.isNotBlank(orderId)) {
|
||||
redisService.set(RedisKeyConstant.JNTYZX_ORDER_CREATE_KEY + userTokenInfoDO.getName(), orderId);
|
||||
OrderInfoDO orderInfoDO = new OrderInfoDO();
|
||||
orderInfoDO.setOrderId(orderId);
|
||||
orderInfoDO.setCreateTime(LocalDateTime.now());
|
||||
orderInfoDO.setUsername(userTokenInfoDO.getName());
|
||||
orderInfoDO.setPlaceName(venueInfoDOS.get(0).getPlaceName());
|
||||
orderInfoDO.setDate(LocalDate.now());
|
||||
orderInfoDO.setOrderStatus(0);
|
||||
orderCreateInfoManage.save(orderInfoDO);
|
||||
}
|
||||
}
|
||||
}
|
||||
dingTalkFactory.sendMsg("用户" + userTokenInfoDO.getName() + "预订场地号:" + venueInfoDOS.get(0).getPlaceName() + "结果返回:" + JSON.toJSONString(orderResp));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,11 @@ public class VenueServiceImpl implements IVenueService {
|
||||
return venueInfoManage.queryByType(LocalDate.now(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VenueInfoDO> queryTomorrowCanBuyVenue() {
|
||||
return venueInfoManage.queryByType(LocalDate.now().plusDays(1), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VenueInfoDO> queryToday6210VenueInfo() {
|
||||
List<VenueInfoDO> venueInfoDOS = venueInfoManage.queryByDate(LocalDate.now());
|
||||
@@ -127,6 +132,29 @@ public class VenueServiceImpl implements IVenueService {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveTomorrowVenueInfo(List<SitePositionList> sitePositionLists) {
|
||||
for (SitePositionList sitePositionList : sitePositionLists) {
|
||||
VenueInfoDO venueInfoDO = new VenueInfoDO();
|
||||
venueInfoDO.setDate(LocalDate.now().plusDays(1));
|
||||
venueInfoDO.setCreateTime(LocalDateTime.now());
|
||||
venueInfoDO.setPlaceName(sitePositionList.getPlaceName());
|
||||
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||
venueInfoDO.setPlaceId(sitePositionList.getPlaceId());
|
||||
venueInfoDO.setScheduleId(Integer.valueOf(sitePositionList.getScheduleId()));
|
||||
venueInfoDO.setSjName(sitePositionList.getSjName());
|
||||
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||
venueInfoDO.setType(sitePositionList.getType());
|
||||
venueInfoDO.setMoney(sitePositionList.getMoney());
|
||||
venueInfoDO.setClassName(sitePositionList.getClassName());
|
||||
venueInfoDO.setClassCode(sitePositionList.getClassCode());
|
||||
venueInfoDO.setAppointments(sitePositionList.getAppointments());
|
||||
venueInfoDO.setCTypeCode(sitePositionList.getCtypeCode());
|
||||
venueInfoManage.save(venueInfoDO);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateDatabase(List<SitePositionList> list, boolean isToday) {
|
||||
List<VenueInfoDO> venueInfoDOS = Lists.newArrayList();
|
||||
if (isToday) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xiang.app.modules.jntyzx.utils;
|
||||
|
||||
import com.xiang.xservice.basic.utils.Base64;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class JntyzxSaltEncodeUtils {
|
||||
|
||||
private static int[] getMonthAndDay() {
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
int month = currentDate.getMonthValue();
|
||||
int day = currentDate.getDayOfMonth();
|
||||
return new int[]{month, day};
|
||||
}
|
||||
|
||||
public static String sonAddSalt(String json) {
|
||||
String svCiphertext = "";
|
||||
String suiji = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
String token1 = String.valueOf(suiji.charAt((int) (Math.random() * (double) suiji.length())));
|
||||
String token2 = String.valueOf(suiji.charAt((int) (Math.random() * (double) suiji.length())));
|
||||
svCiphertext = Base64.encode(json.getBytes(StandardCharsets.UTF_8));
|
||||
int[] monthAndDay = getMonthAndDay();
|
||||
int month = monthAndDay[0];
|
||||
int day = monthAndDay[1];
|
||||
if (month == 1) {
|
||||
svCiphertext = (svCiphertext = token1 + svCiphertext).substring(0, day - 1) + token2 + svCiphertext.substring(day - 1);
|
||||
} else if (day == 1) {
|
||||
svCiphertext = token2 + svCiphertext.substring(0, month - 1) + token1 + svCiphertext.substring(month - 1);
|
||||
} else {
|
||||
svCiphertext = (svCiphertext = svCiphertext.substring(0, month - 1) + token1 + svCiphertext.substring(month - 1)).substring(0, day - 1) + token2 + svCiphertext.substring(day - 1);
|
||||
}
|
||||
return svCiphertext;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xiang.app.modules.jntyzx.utils;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class WeekendUtils {
|
||||
|
||||
public static String isWeekend() {
|
||||
LocalDate tomorrow = LocalDate.now().plusDays(1);
|
||||
DayOfWeek dayOfWeek = tomorrow.getDayOfWeek();
|
||||
String isWeekend = "0";
|
||||
if (dayOfWeek.getValue() == 6 || dayOfWeek.getValue() == 7 ) {
|
||||
isWeekend = "1";
|
||||
}
|
||||
return isWeekend;
|
||||
}
|
||||
}
|
||||
@@ -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