Compare commits
6 Commits
e43af1fe94
...
feat/jntyz
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14f64e94ad | ||
|
|
286190ff0b | ||
|
|
ec8826508a | ||
|
|
906a1d84fa | ||
|
|
ed59385672 | ||
|
|
d295cbd04c |
@@ -10,7 +10,6 @@ import java.util.List;
|
|||||||
* @Date: 2025-12-16 09:19
|
* @Date: 2025-12-16 09:19
|
||||||
*/
|
*/
|
||||||
public interface IUserTokenInfoManage extends IService<UserTokenInfoDO> {
|
public interface IUserTokenInfoManage extends IService<UserTokenInfoDO> {
|
||||||
|
|
||||||
List<UserTokenInfoDO> listUser();
|
List<UserTokenInfoDO> listUser();
|
||||||
UserTokenInfoDO getByName(String name);
|
UserTokenInfoDO getByName(String name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.pojo.VenueInfoDO;
|
||||||
import com.xiang.app.modules.jntyzx.entity.resp.JntyzxResponse;
|
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 com.xiang.app.modules.jntyzx.entity.resp.query.SitePositionList;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,7 +31,7 @@ public interface IJntyzxHttpService {
|
|||||||
* 订单创建
|
* 订单创建
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean createOrder(List<VenueInfoDO> venueInfos, String token);
|
JntyzxResponse<OrderCreateResp> createOrder(List<VenueInfoDO> venueInfos, String token, String openId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 心跳监测
|
* 心跳监测
|
||||||
|
|||||||
@@ -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.OrderInfoDO;
|
||||||
|
import com.xiang.app.modules.jntyzx.entity.pojo.UserTokenInfoDO;
|
||||||
|
import com.xiang.app.modules.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -11,5 +13,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface IJtOrderService {
|
public interface IJtOrderService {
|
||||||
|
|
||||||
|
boolean createOrder(List<VenueInfoDO> venueInfoDOS, UserTokenInfoDO userTokenInfoDO);
|
||||||
|
|
||||||
List<OrderInfoDO> queryNoPayOrder();
|
List<OrderInfoDO> queryNoPayOrder();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public interface IVenueService {
|
|||||||
List<SitePositionList> queryVenueService();
|
List<SitePositionList> queryVenueService();
|
||||||
List<SitePositionList> queryTomorrowVenue();
|
List<SitePositionList> queryTomorrowVenue();
|
||||||
List<VenueInfoDO> queryCanBuyVenue();
|
List<VenueInfoDO> queryCanBuyVenue();
|
||||||
|
List<VenueInfoDO> queryTomorrowCanBuyVenue();
|
||||||
List<VenueInfoDO> queryToday6210VenueInfo();
|
List<VenueInfoDO> queryToday6210VenueInfo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,4 +24,11 @@ public interface IVenueService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
boolean saveOrUpdateTodayVenueInfo(List<SitePositionList> sitePositionLists);
|
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.entity.resp.query.VenueList;
|
||||||
import com.xiang.app.modules.jntyzx.manage.IOrderCreateInfoManage;
|
import com.xiang.app.modules.jntyzx.manage.IOrderCreateInfoManage;
|
||||||
import com.xiang.app.modules.jntyzx.service.IJntyzxHttpService;
|
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.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.HttpHelper;
|
||||||
|
import com.xiang.xmc.service.http.helper.HttpHelperFactory;
|
||||||
import com.xiang.xservice.basic.utils.Base64;
|
import com.xiang.xservice.basic.utils.Base64;
|
||||||
import com.xiang.xservice.basic.utils.JsonUtils;
|
import com.xiang.xservice.basic.utils.JsonUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -109,8 +112,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean createOrder(List<VenueInfoDO> venueInfos, String token) {
|
public JntyzxResponse<OrderCreateResp> createOrder(List<VenueInfoDO> venueInfos, String token, String openId) {
|
||||||
|
|
||||||
List<SubscribeVo> vos = Lists.newArrayList();
|
List<SubscribeVo> vos = Lists.newArrayList();
|
||||||
for (VenueInfoDO venueInfo : venueInfos) {
|
for (VenueInfoDO venueInfo : venueInfos) {
|
||||||
SubscribeVo subscribeVo = new SubscribeVo();
|
SubscribeVo subscribeVo = new SubscribeVo();
|
||||||
@@ -139,13 +141,13 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
|||||||
vos.add(subscribeVo);
|
vos.add(subscribeVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject jsonObject = buildParamJsonObj();
|
JSONObject jsonObject = buildParamJsonObj(openId);
|
||||||
SubscribeRequest subscribeRequest = new SubscribeRequest();
|
SubscribeRequest subscribeRequest = new SubscribeRequest();
|
||||||
|
|
||||||
subscribeRequest.setSubscribeVos(vos);
|
subscribeRequest.setSubscribeVos(vos);
|
||||||
subscribeRequest.setBookTime(venueInfos.get(0).getAppointments());
|
subscribeRequest.setBookTime(venueInfos.get(0).getAppointments());
|
||||||
subscribeRequest.setPaymentMethod(1);
|
subscribeRequest.setPaymentMethod(1);
|
||||||
subscribeRequest.setSvCiphertext(sonAddSalt(JsonUtils.toJsonString(vos)));
|
subscribeRequest.setSvCiphertext(JntyzxSaltEncodeUtils.sonAddSalt(JsonUtils.toJsonString(vos)));
|
||||||
subscribeRequest.setJsonObject(jsonObject);
|
subscribeRequest.setJsonObject(jsonObject);
|
||||||
|
|
||||||
Map<String, String> params = Maps.newHashMap();
|
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));
|
String resp = HttpHelper.doPost(UrlConstant.ADD_SUBSCRIBE, params, JsonUtils.toJsonString(subscribeRequest));
|
||||||
if (StringUtils.isBlank(resp)) {
|
if (StringUtils.isBlank(resp)) {
|
||||||
log.info("请求结果为空");
|
log.info("请求结果为空");
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
JntyzxResponse<OrderCreateResp> response = JSON.parseObject(resp, new TypeReference<JntyzxResponse<OrderCreateResp>>() {
|
JntyzxResponse<OrderCreateResp> response = JSON.parseObject(resp, new TypeReference<JntyzxResponse<OrderCreateResp>>() {
|
||||||
});
|
});
|
||||||
if (Objects.isNull(response)) {
|
if (Objects.isNull(response)) {
|
||||||
log.info("请求结果为空");
|
log.info("请求结果为空");
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
if (response.getSuccess()) {
|
return response;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public JntyzxResponse healthDeclaration(String token, String openId) {
|
public JntyzxResponse healthDeclaration(String token, String openId) {
|
||||||
@@ -194,7 +179,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
|||||||
return JSON.parseObject(respStr, JntyzxResponse.class);
|
return JSON.parseObject(respStr, JntyzxResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JSONObject buildParamJsonObj() {
|
private static JSONObject buildParamJsonObj(String openId) {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("id", "1702581215097257986");
|
jsonObject.put("id", "1702581215097257986");
|
||||||
jsonObject.put("createBy", null);
|
jsonObject.put("createBy", null);
|
||||||
@@ -202,7 +187,7 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
|||||||
jsonObject.put("updateBy", null);
|
jsonObject.put("updateBy", null);
|
||||||
jsonObject.put("updateTime", null);
|
jsonObject.put("updateTime", null);
|
||||||
jsonObject.put("sysOrgCode", null);
|
jsonObject.put("sysOrgCode", null);
|
||||||
jsonObject.put("openId", "o21MX4y7whXCGjvUTGP6CTz2HbD8");
|
jsonObject.put("openId", openId);
|
||||||
jsonObject.put("nickName", "1");
|
jsonObject.put("nickName", "1");
|
||||||
jsonObject.put("unionId", null);
|
jsonObject.put("unionId", null);
|
||||||
jsonObject.put("avatarUrl", "https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132");
|
jsonObject.put("avatarUrl", "https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132");
|
||||||
@@ -214,30 +199,4 @@ public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
|||||||
jsonObject.put("default05", null);
|
jsonObject.put("default05", null);
|
||||||
return jsonObject;
|
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,85 @@
|
|||||||
package com.xiang.app.modules.jntyzx.service.impl;
|
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.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.manage.IOrderCreateInfoManage;
|
||||||
|
import com.xiang.app.modules.jntyzx.service.IJntyzxHttpService;
|
||||||
import com.xiang.app.modules.jntyzx.service.IJtOrderService;
|
import com.xiang.app.modules.jntyzx.service.IJtOrderService;
|
||||||
|
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: xiang
|
* @Author: xiang
|
||||||
* @Date: 2025-12-16 16:17
|
* @Date: 2025-12-16 16:17
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class OrderInfoServiceImpl implements IJtOrderService {
|
public class OrderInfoServiceImpl implements IJtOrderService {
|
||||||
|
|
||||||
private final IOrderCreateInfoManage orderCreateInfoManage;
|
private final IOrderCreateInfoManage orderCreateInfoManage;
|
||||||
|
private final IJntyzxHttpService jntyzxHttpService;
|
||||||
|
private final IRedisService redisService;
|
||||||
|
private final JtDingTalkFactory dingTalkFactory;
|
||||||
@Override
|
@Override
|
||||||
public List<OrderInfoDO> queryNoPayOrder() {
|
public List<OrderInfoDO> queryNoPayOrder() {
|
||||||
return orderCreateInfoManage.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() + LocalDate.now());
|
||||||
|
if (StringUtils.isNotBlank(order)) {
|
||||||
|
log.info("用户:{}已经有成功预订了场地", userTokenInfoDO.getName());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
JntyzxResponse<OrderCreateResp> orderResp = jntyzxHttpService.createOrder(venueInfoDOS, userTokenInfoDO.getToken(), userTokenInfoDO.getOpenId());
|
||||||
|
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() + LocalDate.now(), 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;
|
||||||
|
} else {
|
||||||
|
dingTalkFactory.sendMsg("用户" + userTokenInfoDO.getName() + "预订场地号:" + venueInfoDOS.get(0).getPlaceName() + "结果返回:" + JSON.toJSONString(orderResp));
|
||||||
|
if (orderResp.getMessage().contains("锁卡")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (orderResp.getMessage().contains("限制")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean flushToken() {
|
public boolean flushToken() {
|
||||||
List<UserTokenInfoDO> userTokenInfoDOS = userTokenInfoManage.listUser();
|
List<UserTokenInfoDO> userTokenInfoDOS = userTokenInfoManage.list();
|
||||||
if (CollectionUtils.isEmpty(userTokenInfoDOS)) {
|
if (CollectionUtils.isEmpty(userTokenInfoDOS)) {
|
||||||
log.info("【心跳监测】查询用户信息为空,无需操作");
|
log.info("【心跳监测】查询用户信息为空,无需操作");
|
||||||
return true;
|
return true;
|
||||||
@@ -72,7 +72,9 @@ public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
userTokenInfoDO.setToken(token);
|
userTokenInfoDO.setToken(token);
|
||||||
return userTokenInfoManage.updateById(userTokenInfoDO);
|
boolean flag = userTokenInfoManage.updateById(userTokenInfoDO);
|
||||||
|
jtDingTalkFactory.sendMsg("用户:" + name + ",token更新成功!");
|
||||||
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean healthDeclaration(UserTokenInfoDO userTokenInfoDO) {
|
private boolean healthDeclaration(UserTokenInfoDO userTokenInfoDO) {
|
||||||
@@ -83,8 +85,12 @@ public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
|
|||||||
boolean flag = StringUtils.contains(jntyzxResponse.getMessage(), "已存在");
|
boolean flag = StringUtils.contains(jntyzxResponse.getMessage(), "已存在");
|
||||||
if (flag) {
|
if (flag) {
|
||||||
log.info("用户名:{}心跳成功✅✅✅✅✅✅", userTokenInfoDO.getName());
|
log.info("用户名:{}心跳成功✅✅✅✅✅✅", userTokenInfoDO.getName());
|
||||||
|
userTokenInfoDO.setStatus(1);
|
||||||
|
userTokenInfoManage.updateById(userTokenInfoDO);
|
||||||
} else {
|
} else {
|
||||||
jtDingTalkFactory.sendMsg("用户名:" + userTokenInfoDO.getName() + "心跳失败,消息:" + jntyzxResponse.getMessage());
|
jtDingTalkFactory.sendMsg("用户名:" + userTokenInfoDO.getName() + "心跳失败,消息:" + jntyzxResponse.getMessage());
|
||||||
|
userTokenInfoDO.setStatus(0);
|
||||||
|
userTokenInfoManage.updateById(userTokenInfoDO);
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,11 @@ public class VenueServiceImpl implements IVenueService {
|
|||||||
return venueInfoManage.queryByType(LocalDate.now(), 0);
|
return venueInfoManage.queryByType(LocalDate.now(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<VenueInfoDO> queryTomorrowCanBuyVenue() {
|
||||||
|
return venueInfoManage.queryByType(LocalDate.now().plusDays(1), 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VenueInfoDO> queryToday6210VenueInfo() {
|
public List<VenueInfoDO> queryToday6210VenueInfo() {
|
||||||
List<VenueInfoDO> venueInfoDOS = venueInfoManage.queryByDate(LocalDate.now());
|
List<VenueInfoDO> venueInfoDOS = venueInfoManage.queryByDate(LocalDate.now());
|
||||||
@@ -127,6 +132,29 @@ public class VenueServiceImpl implements IVenueService {
|
|||||||
return true;
|
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) {
|
private void updateDatabase(List<SitePositionList> list, boolean isToday) {
|
||||||
List<VenueInfoDO> venueInfoDOS = Lists.newArrayList();
|
List<VenueInfoDO> venueInfoDOS = Lists.newArrayList();
|
||||||
if (isToday) {
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,4 +25,27 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>2.3.0.RELEASE</version>
|
||||||
|
<configuration>
|
||||||
|
<classifier>exec</classifier>
|
||||||
|
<!-- 指定该Main Class为全局的唯一入口 -->
|
||||||
|
<mainClass>com.xiang.app.Application</mainClass>
|
||||||
|
<layout>ZIP</layout>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -17,7 +17,6 @@ import org.springframework.context.annotation.ComponentScan;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@ConfigurationPropertiesScan(basePackages = {
|
@ConfigurationPropertiesScan(basePackages = {
|
||||||
"com.xiang.xservice.logger",
|
"com.xiang.xservice.logger",
|
||||||
"com.xiang.app.common.config",
|
|
||||||
})
|
})
|
||||||
@MapperScan(basePackages = {
|
@MapperScan(basePackages = {
|
||||||
"com.xiang.app.modules.*.mapper"
|
"com.xiang.app.modules.*.mapper"
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import com.xiang.core.quartz.annotation.XxzJob;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: xiang
|
* @Author: xiang
|
||||||
@@ -13,11 +15,13 @@ import org.springframework.stereotype.Component;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
public class JtTokenRefreshTask {
|
public class JtTokenRefreshTask {
|
||||||
|
|
||||||
private final IUserTokenInfoService userTokenInfoService;
|
private final IUserTokenInfoService userTokenInfoService;
|
||||||
|
|
||||||
@XxzJob(name = "jtTokenRefreshHandler")
|
@XxzJob(name = "jtTokenRefreshHandler")
|
||||||
|
@GetMapping("/jtTokenRefreshHandler")
|
||||||
public void handle() {
|
public void handle() {
|
||||||
log.info("【Token】江南体育中心token续期定时任务启动!!!time:{}", System.currentTimeMillis());
|
log.info("【Token】江南体育中心token续期定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||||
userTokenInfoService.flushToken();
|
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.IUserTokenInfoService;
|
||||||
import com.xiang.app.modules.jntyzx.service.IVenueService;
|
import com.xiang.app.modules.jntyzx.service.IVenueService;
|
||||||
import com.xiang.app.modules.jntyzx.utils.VenueInfoUtils;
|
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.core.quartz.annotation.XxzJob;
|
||||||
import com.xiang.xservice.basic.utils.DateUtils;
|
import com.xiang.xservice.basic.utils.DateUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -14,14 +15,21 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Component;
|
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.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每日9:00-19:00场地更新信息查询
|
||||||
|
*/
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
public class JtVenuePullTask {
|
public class JtVenuePullTask {
|
||||||
|
|
||||||
private final IUserTokenInfoService userTokenInfoService;
|
private final IUserTokenInfoService userTokenInfoService;
|
||||||
@@ -30,6 +38,7 @@ public class JtVenuePullTask {
|
|||||||
private final IVenueService venueService;
|
private final IVenueService venueService;
|
||||||
|
|
||||||
@XxzJob(name = "jtVenueInfoPullTask")
|
@XxzJob(name = "jtVenueInfoPullTask")
|
||||||
|
@GetMapping("/jtVenueInfoPullTask")
|
||||||
public void handler() {
|
public void handler() {
|
||||||
log.info("【Venue】江体小程序场地数据拉取定时任务启动!!!time:{}", System.currentTimeMillis());
|
log.info("【Venue】江体小程序场地数据拉取定时任务启动!!!time:{}", System.currentTimeMillis());
|
||||||
List<UserTokenInfoDO> availableUser = userTokenInfoService.getAvailableUser();
|
List<UserTokenInfoDO> availableUser = userTokenInfoService.getAvailableUser();
|
||||||
@@ -38,6 +47,9 @@ public class JtVenuePullTask {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String token;
|
String token;
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
int dayOfWeek = now.getDayOfWeek().getValue();
|
||||||
|
|
||||||
for (UserTokenInfoDO userTokenInfoDO : availableUser) {
|
for (UserTokenInfoDO userTokenInfoDO : availableUser) {
|
||||||
if (Objects.isNull(userTokenInfoDO)) {
|
if (Objects.isNull(userTokenInfoDO)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -46,25 +58,36 @@ public class JtVenuePullTask {
|
|||||||
if (StringUtils.isBlank(token)) {
|
if (StringUtils.isBlank(token)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable("1", token);
|
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable(WeekendUtils.isWeekend(), token);
|
||||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
venueService.saveOrUpdateTodayVenueInfo(sitePositionLists);
|
venueService.saveOrUpdateTodayVenueInfo(sitePositionLists);
|
||||||
|
|
||||||
sitePositionLists = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
|
sitePositionLists = handleMsgSendList(sitePositionLists, dayOfWeek);
|
||||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sitePositionLists = sitePositionLists.stream().filter(item -> StringUtils.equals(item.getContacts(), "0")).toList();
|
|
||||||
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
StringBuffer msg = new StringBuffer("查询到20:00-22:00空闲场地信息===>\n时间:" + DateUtils.getDateFromDate(LocalDate.now()));
|
||||||
return;
|
|
||||||
}
|
|
||||||
StringBuffer msg = new StringBuffer("查询到20:00-22:00空闲场地信息===>时间:" + DateUtils.getDateFromDate(LocalDate.now()) + "\n");
|
|
||||||
sitePositionLists.forEach(item -> {
|
sitePositionLists.forEach(item -> {
|
||||||
msg.append(item.getPlaceName()).append("\n");
|
msg.append(item.getPlaceName()).append("\n");
|
||||||
});
|
});
|
||||||
jtDingTalkFactory.sendMsg(msg.toString());
|
jtDingTalkFactory.sendMsg(msg.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<SitePositionList> handleMsgSendList(List<SitePositionList> sitePositionLists, int dayOfWeek) {
|
||||||
|
// 过滤出来8-10的未订购的场地信息
|
||||||
|
sitePositionLists = sitePositionLists.stream()
|
||||||
|
.filter(VenueInfoUtils::get8210VenueInfo)
|
||||||
|
.filter(item -> StringUtils.equals(item.getContacts(), "0")).toList();
|
||||||
|
// 周六周日过滤小馆,不查询当天小馆信息
|
||||||
|
if (dayOfWeek == 6 || dayOfWeek == 7) {
|
||||||
|
return sitePositionLists.stream()
|
||||||
|
.filter(item -> !item.getPlaceName().contains("小馆"))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
return sitePositionLists;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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::get8210VenueInfo).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,61 @@
|
|||||||
|
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.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.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 java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2026-01-19 14:00
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class JtVenueTodaySubscribeTask {
|
||||||
|
|
||||||
|
private final IJntyzxHttpService jntyzxHttpService;
|
||||||
|
private final IUserTokenInfoService userTokenInfoService;
|
||||||
|
private final JtDingTalkFactory jtDingTalkFactory;
|
||||||
|
|
||||||
|
@XxzJob(name = "jtVenueTodaySubscribeTask")
|
||||||
|
@GetMapping("/jtVenueTodaySubscribeTask")
|
||||||
|
public void handle() {
|
||||||
|
String token = userTokenInfoService.getToken("Xiang");
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable(WeekendUtils.isWeekend(), token);
|
||||||
|
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sitePositionLists = sitePositionLists.stream().filter(VenueInfoUtils::get8210VenueInfo).toList();
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
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.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@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().plusDays(1)) + " 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);
|
userTokenInfoService.updateTokenByName(username, token);
|
||||||
return Result.success();
|
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
|
password: cornucopia@123
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
sshConnect: false
|
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:
|
redis:
|
||||||
host: r-bp1wt59a6nfyt4e3ltpd.redis.rds.aliyuncs.com
|
host: r-bp1wt59a6nfyt4e3ltpd.redis.rds.aliyuncs.com
|
||||||
port: 6379
|
port: 6379
|
||||||
@@ -37,7 +31,7 @@ spring:
|
|||||||
max-wait: 1000
|
max-wait: 1000
|
||||||
xxz-job:
|
xxz-job:
|
||||||
app-name: xservice-cornucopia
|
app-name: xservice-cornucopia
|
||||||
admin-address: http://127.0.0.1:30030
|
admin-address: http://192.168.1.10:10001
|
||||||
namespace: 1
|
namespace: 1
|
||||||
|
|
||||||
dingtalk:
|
dingtalk:
|
||||||
|
|||||||
Reference in New Issue
Block a user