Compare commits
22 Commits
fd30c72a73
...
feat/jntyz
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b9ac21ecf | ||
|
|
f3637a80f2 | ||
|
|
4bc549eebe | ||
|
|
237fcc7139 | ||
|
|
4277106d00 | ||
|
|
7932222f8e | ||
|
|
6d19b1a021 | ||
|
|
57a28b4049 | ||
|
|
a3c9e2eb51 | ||
|
|
93969624c1 | ||
|
|
4904be16da | ||
|
|
c4915b17c8 | ||
|
|
7fce8c91f2 | ||
|
|
d942b31c8b | ||
|
|
d7b49281c1 | ||
|
|
c6817b23fc | ||
|
|
69257b5c80 | ||
|
|
1cd24c78e7 | ||
|
|
12c4ccdd5d | ||
|
|
d5c096e7a5 | ||
|
|
b7ecbdfa7a | ||
|
|
454d93b5cc |
@@ -17,6 +17,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||||||
"com.xiang.xservice.application.script.glados.repository",
|
"com.xiang.xservice.application.script.glados.repository",
|
||||||
"com.xiang.xservice.application.script.xb.repository",
|
"com.xiang.xservice.application.script.xb.repository",
|
||||||
"com.xiang.xservice.common.mapper",
|
"com.xiang.xservice.common.mapper",
|
||||||
|
"com.xiang.xservice.application.script.jntyzx.mapper"
|
||||||
})
|
})
|
||||||
@ConfigurationPropertiesScan(basePackages = {
|
@ConfigurationPropertiesScan(basePackages = {
|
||||||
"com.xiang.xservice.config"
|
"com.xiang.xservice.config"
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 10:43
|
||||||
|
*/
|
||||||
|
public class RedisKeyConstant {
|
||||||
|
|
||||||
|
public static final String JNTYZX_ORDER_CREATE_KEY = "jntyzx:order:create:orderId:";
|
||||||
|
|
||||||
|
public static final String JNTUZX_ORDER_PEEK_KEY = "jntyzx:order:peek:user:";
|
||||||
|
|
||||||
|
public static final String JNTYZX_VENUE_MSG_628_KEY = "jntyzx:venue:msg:628";
|
||||||
|
public static final String JNTYZX_VENUE_MSG_8210_KEY = "jntyzx:venue:msg:8210";
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.constants;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 13:46
|
||||||
|
*/
|
||||||
|
public class UrlConstant {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 江南体育中心基础URL
|
||||||
|
*/
|
||||||
|
private final static String GNTYZX_BASE_URL = "https://jntyzx.cn:8443";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询当天的场地信息
|
||||||
|
*/
|
||||||
|
public final static String QUERY_TODAY_SUBSCRIBE_URL = GNTYZX_BASE_URL + "/GYM-JN/multi/Subscribe/getSubscribeByToday";
|
||||||
|
public final static String QUERY_TOMORROW_SUBSCRIBE_URL = GNTYZX_BASE_URL + "/GYM-JN/multi/Subscribe/getSubscribeByTomorrow";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订阅场地
|
||||||
|
*/
|
||||||
|
public final static String ADD_SUBSCRIBE = GNTYZX_BASE_URL + "/GYM-JN/multi/Subscribe/addSubscribe";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单信息
|
||||||
|
*/
|
||||||
|
public final static String ORDER_INFO = GNTYZX_BASE_URL + "/GYM-JN/multi/busiOrder/queryOrderInfo";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 心跳监测接口
|
||||||
|
*/
|
||||||
|
public final static String HEALTH_DECLARATION = GNTYZX_BASE_URL + "/GYM-JN//busi/healthDeclaration/addUserPrivacy";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.controller;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.DingTalkScriptVenueService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IUserTokenInfoService;
|
||||||
|
import com.xiang.xservice.basic.common.resp.Result;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-18 09:08
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/open/jntyzx/token/")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class TokenFreshController {
|
||||||
|
|
||||||
|
private final IUserTokenInfoService userTokenInfoService;
|
||||||
|
private final DingTalkScriptVenueService dingTalkScriptVenueService;
|
||||||
|
|
||||||
|
@GetMapping("/freshToken")
|
||||||
|
public Result<Void> freshToken() {
|
||||||
|
boolean token = userTokenInfoService.flushToken();
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/freshTokenOnline")
|
||||||
|
public Result<Void> freshTokenOnline(@RequestParam("token") String token, @RequestParam("name") String name) {
|
||||||
|
if (userTokenInfoService.updateTokenByName(name, token)) {
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg(name + "token更新成功");
|
||||||
|
}
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.controller;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.DingTalkScriptVenueService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IJntyzxHttpService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IUserTokenInfoService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IVenueService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.utils.VenueInfoUtils;
|
||||||
|
import com.xiang.xservice.basic.common.resp.Result;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 14:28
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class VenueController {
|
||||||
|
|
||||||
|
private final IVenueService venueService;
|
||||||
|
private final IJntyzxHttpService jntyzxHttpService;
|
||||||
|
private final IUserTokenInfoService userTokenInfoService;
|
||||||
|
private final DingTalkScriptVenueService dingTalkScriptVenueService;
|
||||||
|
|
||||||
|
private final static String STATIC_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NjU3ODQ1NjMsInVzZXJuYW1lIjoid3hfb3Blbl9pZF9vMjFNWDR5N3doWENHanZVVEdQNkNUejJIYkQ4In0.QBzNQNvJZQPZZnzmbU8K5Liz0piHwercrDIq3kirUJk";
|
||||||
|
|
||||||
|
@PostMapping("/queryVenue")
|
||||||
|
public Result<Void> queryVenue() {
|
||||||
|
venueService.queryVenueService();
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/getTomorrowVenue")
|
||||||
|
public Result<SitePositionList> getTomorrowVenue() {
|
||||||
|
List<SitePositionList> sitePositionLists = venueService.queryTomorrowVenue();
|
||||||
|
return Result.success(sitePositionLists);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/addSubscribe")
|
||||||
|
public Result<Void> addSubscribe() {
|
||||||
|
List<VenueInfoDO> venueInfoDOS = venueService.queryCanBuyVenue();
|
||||||
|
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||||
|
return Result.error("暂无可订购的数据");
|
||||||
|
}
|
||||||
|
Map<String, List<VenueInfoDO>> map = venueInfoDOS.stream().filter(VenueInfoUtils::get1221VenueInfo4Mor).collect(Collectors.groupingBy(VenueInfoDO::getPlaceName));
|
||||||
|
String token = userTokenInfoService.getToken("Xiang");
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
return Result.error("暂无可订购的用户");
|
||||||
|
}
|
||||||
|
map.keySet().parallelStream().forEach(placeName -> {
|
||||||
|
List<VenueInfoDO> venueInfoDOList = map.get(placeName);
|
||||||
|
Boolean order = jntyzxHttpService.createOrder(venueInfoDOList, token);
|
||||||
|
if (order) {
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg("场地:" + placeName + "下单成功,请付款!时间:" + LocalDateTime.now());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.entity.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 13:55
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class VenueListDTO {
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间
|
||||||
|
*/
|
||||||
|
private String sjName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场地名称
|
||||||
|
*/
|
||||||
|
private String placeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系人
|
||||||
|
*/
|
||||||
|
private String contacts;
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.entity.pojo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 10:57
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("jntyzx_order_create_info")
|
||||||
|
public class OrderInfoDO {
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 订单id
|
||||||
|
*/
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数
|
||||||
|
*/
|
||||||
|
private String params;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单创建人
|
||||||
|
*/
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场地号
|
||||||
|
*/
|
||||||
|
private String placeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属日期
|
||||||
|
*/
|
||||||
|
private LocalDate date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单状态 (0:待付款,1:已付款)
|
||||||
|
*/
|
||||||
|
private Integer orderStatus;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.entity.pojo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 09:18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("jntyzx_user_token_info")
|
||||||
|
public class UserTokenInfoDO {
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* token
|
||||||
|
*/
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* wx openid
|
||||||
|
*/
|
||||||
|
private String openId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态(0:禁用 1:启用)
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.entity.pojo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 15:48
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("jntyzx_venue_info")
|
||||||
|
public class VenueInfoDO {
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 场地名称
|
||||||
|
*/
|
||||||
|
private String placeName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属日期
|
||||||
|
*/
|
||||||
|
private LocalDate date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场地信息三方主键
|
||||||
|
*/
|
||||||
|
private Long placeMainId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 场地id
|
||||||
|
*/
|
||||||
|
private Integer placeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private Integer scheduleId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 时间范围
|
||||||
|
*/
|
||||||
|
private String sjName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 联系人
|
||||||
|
*/
|
||||||
|
private String contacts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
private BigDecimal money;
|
||||||
|
private String className;
|
||||||
|
private String classCode;
|
||||||
|
private String appointments;
|
||||||
|
private String cTypeCode;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.entity.req;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 16:34
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SubscribeRequest {
|
||||||
|
private JSONObject jsonObject;
|
||||||
|
private List<SubscribeVo> subscribeVos;
|
||||||
|
private String bookTime;
|
||||||
|
private Integer paymentMethod;
|
||||||
|
private String svCiphertext;
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.entity.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 16:35
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class SubscribeVo {
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private String ballCourtId;
|
||||||
|
|
||||||
|
private String sjName;
|
||||||
|
|
||||||
|
private String scheduleId;
|
||||||
|
|
||||||
|
private String placeName;
|
||||||
|
|
||||||
|
private int placeId;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
private String className;
|
||||||
|
|
||||||
|
private String classCode;
|
||||||
|
|
||||||
|
private BigDecimal money;
|
||||||
|
|
||||||
|
private String contacts;
|
||||||
|
|
||||||
|
private String contactNumber;
|
||||||
|
|
||||||
|
private String memberNumber;
|
||||||
|
|
||||||
|
private String appointments;
|
||||||
|
|
||||||
|
private String operator;
|
||||||
|
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
private String beginTime;
|
||||||
|
|
||||||
|
private int specOneTimes;
|
||||||
|
|
||||||
|
private String ctypeCode;
|
||||||
|
|
||||||
|
private int isWhole;
|
||||||
|
|
||||||
|
private String orderId;
|
||||||
|
|
||||||
|
private int votesnum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.entity.resp;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 10:36
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class OrderCreateResp {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String countDownNum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.manage;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 10:59
|
||||||
|
*/
|
||||||
|
public interface IOrderCreateInfoManage extends IService<OrderInfoDO> {
|
||||||
|
|
||||||
|
|
||||||
|
List<OrderInfoDO> queryNoPayOrder();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.manage;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.UserTokenInfoDO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 09:19
|
||||||
|
*/
|
||||||
|
public interface IUserTokenInfoManage extends IService<UserTokenInfoDO> {
|
||||||
|
|
||||||
|
List<UserTokenInfoDO> listUser();
|
||||||
|
UserTokenInfoDO getByName(String name);
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.manage;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 15:50
|
||||||
|
*/
|
||||||
|
public interface IVenueInfoManage extends IService<VenueInfoDO> {
|
||||||
|
|
||||||
|
List<VenueInfoDO> queryByDate(LocalDate date);
|
||||||
|
|
||||||
|
List<VenueInfoDO> queryByType(LocalDate date, Integer type);
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.manage;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.mapper.JntyzxOrderCreateInfoMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 10:59
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class OrderCreateInfoManageImpl extends ServiceImpl<JntyzxOrderCreateInfoMapper, OrderInfoDO> implements IOrderCreateInfoManage {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderInfoDO> queryNoPayOrder() {
|
||||||
|
LambdaQueryWrapper<OrderInfoDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
lambdaQueryWrapper.eq(OrderInfoDO::getOrderStatus, 0);
|
||||||
|
return baseMapper.selectList(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.manage;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.UserTokenInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.mapper.JntyzxUserTokenInfoMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 09:19
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UserTokenInfoManageImpl extends ServiceImpl<JntyzxUserTokenInfoMapper, UserTokenInfoDO> implements IUserTokenInfoManage {
|
||||||
|
@Override
|
||||||
|
public List<UserTokenInfoDO> listUser() {
|
||||||
|
LambdaQueryWrapper<UserTokenInfoDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
lambdaQueryWrapper.eq(UserTokenInfoDO::getStatus, 1);
|
||||||
|
return baseMapper.selectList(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserTokenInfoDO getByName(String name) {
|
||||||
|
LambdaQueryWrapper<UserTokenInfoDO> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
lambdaQueryWrapper.eq(UserTokenInfoDO::getStatus, 1);
|
||||||
|
lambdaQueryWrapper.eq(UserTokenInfoDO::getName, name);
|
||||||
|
return baseMapper.selectOne(lambdaQueryWrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.manage;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.mapper.JntyzxVenueInfoMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 15:51
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class VenueInfoManageImpl extends ServiceImpl<JntyzxVenueInfoMapper, VenueInfoDO> implements IVenueInfoManage {
|
||||||
|
|
||||||
|
public List<VenueInfoDO> queryByDate(LocalDate date) {
|
||||||
|
LambdaQueryWrapper<VenueInfoDO> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(VenueInfoDO::getDate, date);
|
||||||
|
return baseMapper.selectList(lqw);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<VenueInfoDO> queryByType(LocalDate date, Integer type) {
|
||||||
|
LambdaQueryWrapper<VenueInfoDO> lqw = Wrappers.lambdaQuery();
|
||||||
|
lqw.eq(VenueInfoDO::getDate, date);
|
||||||
|
lqw.eq(VenueInfoDO::getType, type);
|
||||||
|
return baseMapper.selectList(lqw);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 10:58
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface JntyzxOrderCreateInfoMapper extends BaseMapper<OrderInfoDO> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.UserTokenInfoDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 09:18
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface JntyzxUserTokenInfoMapper extends BaseMapper<UserTokenInfoDO> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 15:48
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Repository
|
||||||
|
public interface JntyzxVenueInfoMapper extends BaseMapper<VenueInfoDO> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.schedule;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IUserTokenInfoService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 09:15
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class JtTokenHealthSchedule {
|
||||||
|
|
||||||
|
private final IUserTokenInfoService userTokenInfoService;
|
||||||
|
@Scheduled(cron = "0 30 0/2 * * ?")
|
||||||
|
public void flushToken() {
|
||||||
|
userTokenInfoService.flushToken();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.schedule;
|
||||||
|
|
||||||
|
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.constants.RedisKeyConstant;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.DingTalkScriptVenueService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IJntyzxHttpService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IUserTokenInfoService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IVenueService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.utils.VenueInfoUtils;
|
||||||
|
import com.xiang.xservice.basic.utils.DateUtils;
|
||||||
|
import com.xiang.xservice.common.entity.SysConfigDO;
|
||||||
|
import com.xiang.xservice.common.service.ISysConfigService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 16:12
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class VenuePeekSchedule {
|
||||||
|
|
||||||
|
private final IVenueService venueService;
|
||||||
|
private final IJntyzxHttpService jntyzxHttpService;
|
||||||
|
private final ISysConfigService sysConfigService;
|
||||||
|
private final IUserTokenInfoService userTokenInfoService;
|
||||||
|
private final DingTalkScriptVenueService dingTalkScriptVenueService;
|
||||||
|
private final IRedisService redisService;
|
||||||
|
|
||||||
|
@Scheduled(cron = "5 0/1 * * * ?")
|
||||||
|
public void peek8210() {
|
||||||
|
log.info("8-10捡漏定时任务启动");
|
||||||
|
SysConfigDO config = sysConfigService.getByName("jntyzx.venue.peek.switch");
|
||||||
|
boolean peekSwitch;
|
||||||
|
if (Objects.isNull(config)) {
|
||||||
|
peekSwitch = false;
|
||||||
|
} else {
|
||||||
|
if (StringUtils.equals(config.getValue(), "true")) {
|
||||||
|
peekSwitch = true;
|
||||||
|
} else {
|
||||||
|
peekSwitch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (peekSwitch) {
|
||||||
|
List<VenueInfoDO> venueInfoDOS = venueService.queryCanBuyVenue();
|
||||||
|
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, List<VenueInfoDO>> map = venueInfoDOS.stream()
|
||||||
|
.filter(VenueInfoUtils::get8210VenueInfo)
|
||||||
|
.collect(Collectors.groupingBy(VenueInfoDO::getPlaceName));
|
||||||
|
String token = userTokenInfoService.getToken("Xiang");
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String key = RedisKeyConstant.JNTUZX_ORDER_PEEK_KEY + "Xiang" + DateUtils.getDateFromDate(LocalDate.now(), "yyyyMMdd");
|
||||||
|
String redisResp = (String) redisService.get(key);
|
||||||
|
if (StringUtils.equals(redisResp, "true")) {
|
||||||
|
log.info("当前已捡漏,勿重复捡漏");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
map.keySet().parallelStream().forEach(placeName -> {
|
||||||
|
List<VenueInfoDO> venueInfoDOList = map.get(placeName);
|
||||||
|
Boolean order = jntyzxHttpService.createOrder(venueInfoDOList, token);
|
||||||
|
if (order) {
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg("场地:" + placeName + "下单成功,请付款!时间:" + LocalDateTime.now());
|
||||||
|
redisService.set(key, "true");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "5 0/1 * * * ?")
|
||||||
|
public void peek628() {
|
||||||
|
log.info("6-8捡漏定时任务启动");
|
||||||
|
SysConfigDO config = sysConfigService.getByName("jntyzx.venue.peek.switch");
|
||||||
|
boolean peekSwitch;
|
||||||
|
if (Objects.isNull(config)) {
|
||||||
|
peekSwitch = false;
|
||||||
|
} else {
|
||||||
|
if (StringUtils.equals(config.getValue(), "true")) {
|
||||||
|
peekSwitch = true;
|
||||||
|
} else {
|
||||||
|
peekSwitch = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (peekSwitch) {
|
||||||
|
List<VenueInfoDO> venueInfoDOS = venueService.queryCanBuyVenue();
|
||||||
|
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, List<VenueInfoDO>> map = venueInfoDOS.stream()
|
||||||
|
.filter(VenueInfoUtils::get628VenueInfo)
|
||||||
|
.collect(Collectors.groupingBy(VenueInfoDO::getPlaceName));
|
||||||
|
String token = userTokenInfoService.getToken("Xiang");
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String key = RedisKeyConstant.JNTUZX_ORDER_PEEK_KEY + "Xiang" + DateUtils.getDateFromDate(LocalDate.now(), "yyyyMMdd");
|
||||||
|
String redisResp = (String) redisService.get(key);
|
||||||
|
if (StringUtils.equals(redisResp, "true")) {
|
||||||
|
log.info("当前已捡漏,勿重复捡漏");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
map.keySet().parallelStream().forEach(placeName -> {
|
||||||
|
List<VenueInfoDO> venueInfoDOList = map.get(placeName);
|
||||||
|
Boolean order = jntyzxHttpService.createOrder(venueInfoDOList, token);
|
||||||
|
if (order) {
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg("场地:" + placeName + "下单成功,请付款!时间:" + LocalDateTime.now());
|
||||||
|
redisService.set(key, "true");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,237 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.schedule;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.constants.RedisKeyConstant;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.DingTalkScriptVenueService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IVenueService;
|
||||||
|
import com.xiang.xservice.common.entity.SysConfigDO;
|
||||||
|
import com.xiang.xservice.common.service.ISysConfigService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 15:02
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class VenueQuerySchedule {
|
||||||
|
|
||||||
|
private final IVenueService venueService;
|
||||||
|
private final DingTalkScriptVenueService dingTalkScriptVenueService;
|
||||||
|
private final ISysConfigService sysConfigService;
|
||||||
|
private final IRedisService redisService;
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 30 8 * * ?")
|
||||||
|
public void venueQueryTask() {
|
||||||
|
log.info("每日8:30拉取江体小程序数据定时任务");
|
||||||
|
List<SitePositionList> sitePositionLists = venueService.queryTomorrowVenue();
|
||||||
|
// 6-8场地
|
||||||
|
Map<String, List<SitePositionList>> map1 = Maps.newLinkedHashMap();
|
||||||
|
// 8-10场地
|
||||||
|
Map<String, List<SitePositionList>> map2 = Maps.newLinkedHashMap();
|
||||||
|
sitePositionLists.stream()
|
||||||
|
.filter(item -> StringUtils.equals(item.getSjName(), "18:00-19:00") || StringUtils.equals(item.getSjName(), "19:00-20:00")
|
||||||
|
|| StringUtils.equals(item.getSjName(), "20:00-21:00") || StringUtils.equals(item.getSjName(), "21:00-22:00"))
|
||||||
|
.forEach(item -> {
|
||||||
|
if (StringUtils.equals(item.getSjName(), "18:00-19:00")) {
|
||||||
|
putIntoMap(item, map1);
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(item.getSjName(), "19:00-20:00")) {
|
||||||
|
putIntoMap(item, map1);
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(item.getSjName(), "20:00-21:00")) {
|
||||||
|
putIntoMap(item, map2);
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(item.getSjName(), "21:00-22:00")) {
|
||||||
|
putIntoMap(item, map2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (MapUtils.isNotEmpty(map1)) {
|
||||||
|
StringBuffer sb1 = new StringBuffer("查询江体小程序场地信息【18:00-20:00】\n");
|
||||||
|
buildMsg2(map1, sb1);
|
||||||
|
String s = (String) redisService.get(RedisKeyConstant.JNTYZX_VENUE_MSG_628_KEY);
|
||||||
|
if (StringUtils.isBlank(s)) {
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg(sb1.toString());
|
||||||
|
redisService.set(RedisKeyConstant.JNTYZX_VENUE_MSG_628_KEY, "true", 30, TimeUnit.MINUTES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (MapUtils.isNotEmpty(map2)) {
|
||||||
|
StringBuffer sb2 = new StringBuffer("查询江体小程序场地信息【20:00-22:00】\n");
|
||||||
|
buildMsg2(map2, sb2);
|
||||||
|
String s = (String) redisService.get(RedisKeyConstant.JNTYZX_VENUE_MSG_8210_KEY);
|
||||||
|
if (StringUtils.isBlank(s)) {
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg(sb2.toString());
|
||||||
|
redisService.set(RedisKeyConstant.JNTYZX_VENUE_MSG_8210_KEY, "true", 30, TimeUnit.MINUTES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0/1 9-10 * * ?")
|
||||||
|
public void venueQueryTask49210() {
|
||||||
|
log.info("每日9-10点时刻拉取江体小程序数据定时任务");
|
||||||
|
venueService.queryVenueService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0/10 10-12 * * ?")
|
||||||
|
public void venueQueryTask4Free() {
|
||||||
|
log.info("每日空闲时刻10-12点拉取江体小程序数据定时任务");
|
||||||
|
venueService.queryVenueService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "1 0/5 12-17 * * ?")
|
||||||
|
public void venueQueryTask4Normal() {
|
||||||
|
log.info("每日正常时刻12-17点拉取江体小程序数据定时任务");
|
||||||
|
venueService.queryVenueService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "2 0/2 17-20 * * ?")
|
||||||
|
public void venueQueryTask4Urgency() {
|
||||||
|
log.info("每日紧急时刻17-20点拉取江体小程序数据定时任务");
|
||||||
|
venueService.queryVenueService();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 17 * * ?")
|
||||||
|
public void todayVenueInfo() {
|
||||||
|
log.info("每日拉取江体小程序数据定时任务");
|
||||||
|
List<VenueInfoDO> venueInfoDOS = venueService.queryToday6210VenueInfo();
|
||||||
|
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 6-8场地
|
||||||
|
Map<String, List<VenueInfoDO>> map1 = Maps.newLinkedHashMap();
|
||||||
|
// 8-10场地
|
||||||
|
Map<String, List<VenueInfoDO>> map2 = Maps.newLinkedHashMap();
|
||||||
|
venueInfoDOS.forEach(item -> {
|
||||||
|
if (StringUtils.equals(item.getSjName(), "18:00-19:00")) {
|
||||||
|
putIntoMap(item, map1);
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(item.getSjName(), "19:00-20:00")) {
|
||||||
|
putIntoMap(item, map1);
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(item.getSjName(), "20:00-21:00")) {
|
||||||
|
putIntoMap(item, map2);
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(item.getSjName(), "21:00-22:00")) {
|
||||||
|
putIntoMap(item, map2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (MapUtils.isNotEmpty(map1)) {
|
||||||
|
StringBuffer sb1 = new StringBuffer("查询江体小程序场地信息【18:00-20:00】\n");
|
||||||
|
buildMsg(map1, sb1);
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg(sb1.toString());
|
||||||
|
}
|
||||||
|
if (MapUtils.isNotEmpty(map1)) {
|
||||||
|
StringBuffer sb2 = new StringBuffer("查询江体小程序场地信息【20:00-22:00】\n");
|
||||||
|
buildMsg(map2, sb2);
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg(sb2.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0/1 9-20 * * ?")
|
||||||
|
public void venueCanBuyMsg() {
|
||||||
|
List<VenueInfoDO> venueInfoDOS = venueService.queryCanBuyVenue();
|
||||||
|
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SysConfigDO config = sysConfigService.getByName("jntyzx.order.create.xiaoguan.switch");
|
||||||
|
boolean orderSwitch;
|
||||||
|
if (Objects.nonNull(config)) {
|
||||||
|
String value = config.getValue();
|
||||||
|
if (StringUtils.equals(value, "true")) {
|
||||||
|
orderSwitch = true;
|
||||||
|
} else {
|
||||||
|
orderSwitch = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
orderSwitch = false;
|
||||||
|
}
|
||||||
|
// 6-8场地
|
||||||
|
Map<String, List<VenueInfoDO>> map1 = Maps.newLinkedHashMap();
|
||||||
|
// 8-10场地
|
||||||
|
Map<String, List<VenueInfoDO>> map2 = Maps.newLinkedHashMap();
|
||||||
|
venueInfoDOS.stream()
|
||||||
|
.filter(item -> StringUtils.equals(item.getSjName(), "18:00-19:00") || StringUtils.equals(item.getSjName(), "19:00-20:00")
|
||||||
|
|| StringUtils.equals(item.getSjName(), "20:00-21:00") || StringUtils.equals(item.getSjName(), "21:00-22:00"))
|
||||||
|
.filter(item -> {
|
||||||
|
if (!orderSwitch) {
|
||||||
|
return !item.getPlaceName().contains("小馆");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.forEach(item -> {
|
||||||
|
if (StringUtils.equals(item.getSjName(), "18:00-19:00")) {
|
||||||
|
putIntoMap(item, map1);
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(item.getSjName(), "19:00-20:00")) {
|
||||||
|
putIntoMap(item, map1);
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(item.getSjName(), "20:00-21:00")) {
|
||||||
|
putIntoMap(item, map2);
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(item.getSjName(), "21:00-22:00")) {
|
||||||
|
putIntoMap(item, map2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (MapUtils.isNotEmpty(map1) && LocalTime.now().isBefore(LocalTime.of(18, 0, 0))) {
|
||||||
|
StringBuffer sb1 = new StringBuffer("查询江体小程序场地信息【18:00-20:00】\n");
|
||||||
|
buildMsg(map1, sb1);
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg(sb1.toString());
|
||||||
|
}
|
||||||
|
if (MapUtils.isNotEmpty(map2) && LocalTime.now().isBefore(LocalTime.of(20, 0, 0))) {
|
||||||
|
StringBuffer sb2 = new StringBuffer("查询江体小程序场地信息【20:00-22:00】\n");
|
||||||
|
buildMsg(map2, sb2);
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg(sb2.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void buildMsg(Map<String, List<VenueInfoDO>> map1, StringBuffer sb1) {
|
||||||
|
map1.forEach((k, v) -> {
|
||||||
|
VenueInfoDO sitePositionList1 = v.get(0);
|
||||||
|
VenueInfoDO sitePositionList2 = v.get(1);
|
||||||
|
String contacts = sitePositionList1.getContacts();
|
||||||
|
if (!StringUtils.equals(sitePositionList1.getContacts(), sitePositionList2.getContacts())) {
|
||||||
|
contacts = sitePositionList1.getContacts() + "," + sitePositionList2.getContacts();
|
||||||
|
}
|
||||||
|
sb1.append(k).append("场地,订购人:").append(contacts).append("\n");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
private static void buildMsg2(Map<String, List<SitePositionList>> map1, StringBuffer sb1) {
|
||||||
|
map1.forEach((k, v) -> {
|
||||||
|
SitePositionList sitePositionList1 = v.get(0);
|
||||||
|
SitePositionList sitePositionList2 = v.get(1);
|
||||||
|
String contacts = sitePositionList1.getContacts();
|
||||||
|
if (!StringUtils.equals(sitePositionList1.getContacts(), sitePositionList2.getContacts())) {
|
||||||
|
contacts = sitePositionList1.getContacts() + "," + sitePositionList2.getContacts();
|
||||||
|
}
|
||||||
|
sb1.append(k).append("场地,订购人:").append(contacts).append("\n");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void putIntoMap(VenueInfoDO item, Map<String, List<VenueInfoDO>> map1) {
|
||||||
|
map1.computeIfAbsent(item.getPlaceName(),
|
||||||
|
k -> new ArrayList<>()
|
||||||
|
).add(item);
|
||||||
|
}
|
||||||
|
private static void putIntoMap(SitePositionList item, Map<String, List<SitePositionList>> map1) {
|
||||||
|
map1.computeIfAbsent(item.getPlaceName(),
|
||||||
|
k -> new ArrayList<>()
|
||||||
|
).add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.schedule;
|
||||||
|
|
||||||
|
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.constants.RedisKeyConstant;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.DingTalkScriptVenueService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IJntyzxHttpService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IJtOrderService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IUserTokenInfoService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.service.IVenueService;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.utils.VenueInfoUtils;
|
||||||
|
import com.xiang.xservice.basic.utils.DateUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 14:26
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class VenueSubscribeSchedule {
|
||||||
|
private final IVenueService venueService;
|
||||||
|
private final IJntyzxHttpService jntyzxHttpService;
|
||||||
|
private final IUserTokenInfoService userTokenInfoService;
|
||||||
|
private final DingTalkScriptVenueService dingTalkScriptVenueService;
|
||||||
|
private final IJtOrderService orderService;
|
||||||
|
private final IRedisService redisService;
|
||||||
|
@Scheduled(cron = "0 0 9 * * ?")
|
||||||
|
public void subscribe() {
|
||||||
|
List<VenueInfoDO> venueInfoDOS = venueService.queryCanBuyVenue();
|
||||||
|
if (CollectionUtils.isEmpty(venueInfoDOS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, List<VenueInfoDO>> map = venueInfoDOS.stream().filter(VenueInfoUtils::get1221VenueInfo4Mor).collect(Collectors.groupingBy(VenueInfoDO::getPlaceName));
|
||||||
|
String token = userTokenInfoService.getToken("Xiang");
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String key = RedisKeyConstant.JNTUZX_ORDER_PEEK_KEY + "Xiang" + DateUtils.getDateFromDate(LocalDate.now(), "yyyyMMdd");
|
||||||
|
map.keySet().parallelStream().forEach(placeName -> {
|
||||||
|
List<VenueInfoDO> venueInfoDOList = map.get(placeName);
|
||||||
|
Boolean order = jntyzxHttpService.createOrder(venueInfoDOList, token);
|
||||||
|
if (order) {
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg("场地:" + placeName + "下单成功,请付款!时间:" + LocalDateTime.now());
|
||||||
|
redisService.set(key, "true");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0/2 * * * ?")
|
||||||
|
public void checkPay() {
|
||||||
|
List<OrderInfoDO> orderInfoDOS = orderService.queryNoPayOrder();
|
||||||
|
if (CollectionUtils.isEmpty(orderInfoDOS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
import com.xiang.xmc.service.message.dingTalk.service.DingTalkService;
|
||||||
|
import com.xiang.xservice.config.DingTalkRobotVenueConfig;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-08-07 10:30
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class DingTalkScriptVenueService {
|
||||||
|
|
||||||
|
private final DingTalkService dingTalkService;
|
||||||
|
private final DingTalkRobotVenueConfig dingTalkRobotVenueConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送脚本消息
|
||||||
|
* @param msg 消息
|
||||||
|
*/
|
||||||
|
public void sendScriptMsg(String msg) {
|
||||||
|
try {
|
||||||
|
dingTalkService.sendRobotMessage(dingTalkRobotVenueConfig.getSecret(), dingTalkRobotVenueConfig.getToken(),
|
||||||
|
dingTalkRobotVenueConfig.getUsers(), msg);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("信息发送异常, 信息:{}", msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.JntyzxResponse;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 14:47
|
||||||
|
*/
|
||||||
|
public interface IJntyzxHttpService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询今日可用场地
|
||||||
|
*/
|
||||||
|
List<SitePositionList> queryAvailable(String isWeekend, String token);
|
||||||
|
List<SitePositionList> queryAvailableTomorrow(String isWeekend, String token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单创建
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Boolean createOrder(List<VenueInfoDO> venueInfos, String token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 心跳监测
|
||||||
|
* @param token token
|
||||||
|
* @param openId openid
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
JntyzxResponse healthDeclaration(String token, String openId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 16:17
|
||||||
|
*/
|
||||||
|
public interface IJtOrderService {
|
||||||
|
|
||||||
|
List<OrderInfoDO> queryNoPayOrder();
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 09:22
|
||||||
|
*/
|
||||||
|
public interface IUserTokenInfoService {
|
||||||
|
|
||||||
|
String getToken(String name);
|
||||||
|
boolean flushSingleToken(String name);
|
||||||
|
boolean flushToken();
|
||||||
|
|
||||||
|
boolean updateTokenByName(String name, String token);
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 16:07
|
||||||
|
*/
|
||||||
|
public interface IVenueService {
|
||||||
|
|
||||||
|
List<SitePositionList> queryVenueService();
|
||||||
|
List<SitePositionList> queryTomorrowVenue();
|
||||||
|
List<VenueInfoDO> queryCanBuyVenue();
|
||||||
|
List<VenueInfoDO> queryToday6210VenueInfo();
|
||||||
|
}
|
||||||
@@ -0,0 +1,242 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.alibaba.fastjson2.TypeReference;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||||
|
import com.xiang.xmc.service.http.helper.HttpHelper;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.constants.RedisKeyConstant;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.constants.UrlConstant;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.req.SubscribeRequest;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.req.SubscribeVo;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.JntyzxResponse;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.OrderCreateResp;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.VenueList;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.manage.IOrderCreateInfoManage;
|
||||||
|
import com.xiang.xservice.basic.utils.Base64;
|
||||||
|
import com.xiang.xservice.basic.utils.JsonUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-05-14 14:07
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class JntyzxHttpServiceImpl implements IJntyzxHttpService {
|
||||||
|
|
||||||
|
private final IRedisService redisService;
|
||||||
|
private final IOrderCreateInfoManage orderCreateInfoManage;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SitePositionList> queryAvailable(String isWeekend, String token) {
|
||||||
|
String url = UrlConstant.QUERY_TODAY_SUBSCRIBE_URL;
|
||||||
|
return querySitePositionInfo(isWeekend, token, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static List<SitePositionList> querySitePositionInfo(String isWeekend, String token, String url) {
|
||||||
|
Map<String, String> header = Maps.newHashMap();
|
||||||
|
header.put("X-Access-Token", token);
|
||||||
|
String resp = null;
|
||||||
|
Map<String, String> params = Maps.newHashMap();
|
||||||
|
params.put("gid", "03");
|
||||||
|
params.put("isWeekend", isWeekend);
|
||||||
|
try {
|
||||||
|
resp = HttpHelper.doGet(url, header, params);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[doGet] 江南体育中心查询当天场地 请求失败, url:{}", url);
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(resp)) {
|
||||||
|
log.warn("[查询场地] 江南体育中心查询当天场地 请求结果为空, url:{}, resp:{}", url, resp);
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
JSONObject jsonObject = JSON.parseObject(resp);
|
||||||
|
if (Objects.isNull(jsonObject)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
String resultStr = JSON.toJSONString(jsonObject.get("result"));
|
||||||
|
if (StringUtils.isBlank(resultStr)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
JSONObject result = JSON.parseObject(resultStr);
|
||||||
|
if (Objects.isNull(result)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
String venueStr = JSON.toJSONString(result.get("venue"));
|
||||||
|
if (StringUtils.isBlank(venueStr)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
List<VenueList> venueLists = JSON.parseArray(venueStr, VenueList.class);
|
||||||
|
if (CollectionUtils.isEmpty(venueLists)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
List<SitePositionList> res = Lists.newArrayList();
|
||||||
|
for (VenueList venueList : venueLists) {
|
||||||
|
List<SitePositionList> sitePositionList = venueList.getSitePosition();
|
||||||
|
if (CollectionUtils.isEmpty(sitePositionList)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
res.addAll(sitePositionList);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SitePositionList> queryAvailableTomorrow(String isWeekend, String token) {
|
||||||
|
String url = UrlConstant.QUERY_TOMORROW_SUBSCRIBE_URL;
|
||||||
|
return querySitePositionInfo(isWeekend, token, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean createOrder(List<VenueInfoDO> venueInfos, String token) {
|
||||||
|
|
||||||
|
List<SubscribeVo> vos = Lists.newArrayList();
|
||||||
|
for (VenueInfoDO venueInfo : venueInfos) {
|
||||||
|
SubscribeVo subscribeVo = new SubscribeVo();
|
||||||
|
subscribeVo.setId(0);
|
||||||
|
subscribeVo.setBallCourtId("03");
|
||||||
|
subscribeVo.setSjName(venueInfo.getSjName());
|
||||||
|
subscribeVo.setScheduleId(String.valueOf(venueInfo.getScheduleId()));
|
||||||
|
subscribeVo.setPlaceName(venueInfo.getPlaceName());
|
||||||
|
subscribeVo.setPlaceId(venueInfo.getPlaceId());
|
||||||
|
subscribeVo.setType("0");
|
||||||
|
subscribeVo.setClassName(venueInfo.getClassName());
|
||||||
|
subscribeVo.setClassCode(venueInfo.getClassCode());
|
||||||
|
subscribeVo.setMoney(venueInfo.getMoney().setScale(0));
|
||||||
|
subscribeVo.setContacts("0");
|
||||||
|
subscribeVo.setContactNumber(null);
|
||||||
|
subscribeVo.setMemberNumber(null);
|
||||||
|
subscribeVo.setAppointments(venueInfo.getAppointments());
|
||||||
|
subscribeVo.setOperator(null);
|
||||||
|
subscribeVo.setEndTime(null);
|
||||||
|
subscribeVo.setBeginTime(null);
|
||||||
|
subscribeVo.setSpecOneTimes(3);
|
||||||
|
subscribeVo.setCtypeCode(venueInfo.getCTypeCode());
|
||||||
|
subscribeVo.setIsWhole(0);
|
||||||
|
subscribeVo.setOrderId(null);
|
||||||
|
subscribeVo.setVotesnum(1);
|
||||||
|
vos.add(subscribeVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject jsonObject = buildParamJsonObj();
|
||||||
|
SubscribeRequest subscribeRequest = new SubscribeRequest();
|
||||||
|
|
||||||
|
subscribeRequest.setSubscribeVos(vos);
|
||||||
|
subscribeRequest.setBookTime(venueInfos.get(0).getAppointments());
|
||||||
|
subscribeRequest.setPaymentMethod(1);
|
||||||
|
subscribeRequest.setSvCiphertext(sonAddSalt(JsonUtils.toJsonString(vos)));
|
||||||
|
subscribeRequest.setJsonObject(jsonObject);
|
||||||
|
|
||||||
|
Map<String, String> params = Maps.newHashMap();
|
||||||
|
params.put("X-Access-Token", token);
|
||||||
|
String resp = HttpHelper.doPost(UrlConstant.ADD_SUBSCRIBE, params, JsonUtils.toJsonString(subscribeRequest));
|
||||||
|
if (StringUtils.isBlank(resp)) {
|
||||||
|
log.info("请求结果为空");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JntyzxResponse<OrderCreateResp> response = JSON.parseObject(resp, new TypeReference<JntyzxResponse<OrderCreateResp>>() {
|
||||||
|
});
|
||||||
|
if (Objects.isNull(response)) {
|
||||||
|
log.info("请求结果为空");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public JntyzxResponse healthDeclaration(String token, String openId) {
|
||||||
|
Map<String, String> headers = Maps.newHashMap();
|
||||||
|
headers.put("X-Access-Token", token);
|
||||||
|
Map<String, String> params = Maps.newHashMap();
|
||||||
|
params.put("openId", openId);
|
||||||
|
|
||||||
|
String respStr = HttpHelper.doGet(UrlConstant.HEALTH_DECLARATION, headers, params);
|
||||||
|
if (StringUtils.isBlank(respStr)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return JSON.parseObject(respStr, JntyzxResponse.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static JSONObject buildParamJsonObj() {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("id", "1702581215097257986");
|
||||||
|
jsonObject.put("createBy", null);
|
||||||
|
jsonObject.put("createTime", "2023-09-15 15:12:48");
|
||||||
|
jsonObject.put("updateBy", null);
|
||||||
|
jsonObject.put("updateTime", null);
|
||||||
|
jsonObject.put("sysOrgCode", null);
|
||||||
|
jsonObject.put("openId", "o21MX4y7whXCGjvUTGP6CTz2HbD8");
|
||||||
|
jsonObject.put("nickName", "1");
|
||||||
|
jsonObject.put("unionId", null);
|
||||||
|
jsonObject.put("avatarUrl", "https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132");
|
||||||
|
jsonObject.put("remarks", null);
|
||||||
|
jsonObject.put("default01", null);
|
||||||
|
jsonObject.put("default02", null);
|
||||||
|
jsonObject.put("default03", null);
|
||||||
|
jsonObject.put("default04", null);
|
||||||
|
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,13 +0,0 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: xiang
|
|
||||||
* @Date: 2025-05-14 14:06
|
|
||||||
*/
|
|
||||||
public interface JntyzxService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询可用场地
|
|
||||||
*/
|
|
||||||
void queryAvailable() throws Exception;
|
|
||||||
}
|
|
||||||
@@ -1,99 +0,0 @@
|
|||||||
package com.xiang.xservice.application.script.jntyzx.service;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.xiang.xmc.service.message.dingTalk.service.DingTalkService;
|
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.JntyzxResponse;
|
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.QueryVenueResponse;
|
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
|
|
||||||
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.VenueList;
|
|
||||||
import com.xiang.xservice.application.script.xb.common.URLConstants;
|
|
||||||
import com.xiang.xservice.basic.utils.HttpUtils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: xiang
|
|
||||||
* @Date: 2025-05-14 14:07
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Slf4j
|
|
||||||
public class JntyzxServiceImpl implements JntyzxService{
|
|
||||||
|
|
||||||
|
|
||||||
private final DingTalkService dingTalkService;
|
|
||||||
|
|
||||||
@Value("${dingtalk.chatId}")
|
|
||||||
private String chatId;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void queryAvailable() throws Exception {
|
|
||||||
String url = URLConstants.JNTYZX_QUERY_TODAY_VENUE;
|
|
||||||
Map<String, String> header = Maps.newHashMap();
|
|
||||||
header.put("X-Access-Token", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NDcyMTAwNzQsInVzZXJuYW1lIjoid3hfb3Blbl9pZF9vMjFNWDR5N3doWENHanZVVEdQNkNUejJIYkQ4In0.0h_cAH_e5cCXDQlQN40jZDBgtfrzQWAmgl3YPQf0d-M");
|
|
||||||
String resp = null;
|
|
||||||
try {
|
|
||||||
resp = HttpUtils.doGet(url, header, null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("[doGet] 江南体育中心查询当天场地 请求失败, url:{}", url);
|
|
||||||
}
|
|
||||||
if (StringUtils.isEmpty(resp)) {
|
|
||||||
log.warn("[查询场地] 江南体育中心查询当天场地 请求结果为空, url:{}, resp:{}", url, resp);
|
|
||||||
}
|
|
||||||
JntyzxResponse response = JSONObject.parseObject(resp, JntyzxResponse.class);
|
|
||||||
String message = "";
|
|
||||||
if (Objects.nonNull(response)) {
|
|
||||||
if (response.getSuccess()) {
|
|
||||||
log.info("[查询场地] 江南体育中心查询当天场地 请求地址:{}, 请求结果:{}", url, resp);
|
|
||||||
JSONObject object = (JSONObject) response.getResult();
|
|
||||||
if (Objects.nonNull(object)) {
|
|
||||||
QueryVenueResponse result = object.toJavaObject(QueryVenueResponse.class);
|
|
||||||
if (Objects.nonNull(result)) {
|
|
||||||
List<VenueList> venueLists = result.getVenue();
|
|
||||||
if (!CollectionUtils.isEmpty(venueLists)) {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (VenueList venue : venueLists) {
|
|
||||||
List<SitePositionList> positionList = venue.getSitePosition();
|
|
||||||
positionList = positionList.stream().filter(this::filterTime).collect(Collectors.toList());
|
|
||||||
for (SitePositionList sitePositionList : positionList) {
|
|
||||||
sb.append(venue.getPlaceName()).append(":").append(sitePositionList.getSjName()).append(":预定人:").append(sitePositionList.getContacts()).append(",电话:").append(sitePositionList.getContactNumber()).append("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
message = sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (StringUtils.isNotBlank(message)) {
|
|
||||||
dingTalkService.sendChatMessage(chatId, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Boolean filterTime(SitePositionList sitePositionList) {
|
|
||||||
if (StringUtils.equals("18:00-19:00", sitePositionList.getSjName())) {
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
if (StringUtils.equals("19:00-20:00", sitePositionList.getSjName())) {
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
if (StringUtils.equals("20:00-21:00", sitePositionList.getSjName())) {
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
if (StringUtils.equals("21:00-22:00", sitePositionList.getSjName())) {
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.OrderInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.manage.IOrderCreateInfoManage;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 16:17
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class OrderInfoServiceImpl implements IJtOrderService {
|
||||||
|
|
||||||
|
private final IOrderCreateInfoManage orderCreateInfoManage;
|
||||||
|
@Override
|
||||||
|
public List<OrderInfoDO> queryNoPayOrder() {
|
||||||
|
return orderCreateInfoManage.queryNoPayOrder();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.UserTokenInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.JntyzxResponse;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.manage.IUserTokenInfoManage;
|
||||||
|
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.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 09:22
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class UserTokenInfoServiceImpl implements IUserTokenInfoService {
|
||||||
|
|
||||||
|
private final IUserTokenInfoManage userTokenInfoManage;
|
||||||
|
private final IJntyzxHttpService jntyzxHttpService;
|
||||||
|
private final DingTalkScriptVenueService dingTalkScriptVenueService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getToken(String name) {
|
||||||
|
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(name);
|
||||||
|
if (Objects.isNull(userTokenInfoDO)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return userTokenInfoDO.getToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean flushSingleToken(String name) {
|
||||||
|
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(name);
|
||||||
|
if (Objects.isNull(userTokenInfoDO)) {
|
||||||
|
log.info("用户信息不存在,无需进行监测!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return healthDeclaration(userTokenInfoDO);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean flushToken() {
|
||||||
|
List<UserTokenInfoDO> userTokenInfoDOS = userTokenInfoManage.listUser();
|
||||||
|
if (CollectionUtils.isEmpty(userTokenInfoDOS)) {
|
||||||
|
log.info("【心跳监测】查询用户信息为空,无需操作");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
userTokenInfoDOS.parallelStream().forEach(this::healthDeclaration);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateTokenByName(String name, String token) {
|
||||||
|
UserTokenInfoDO userTokenInfoDO = userTokenInfoManage.getByName(name);
|
||||||
|
if (Objects.isNull(userTokenInfoDO)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
userTokenInfoDO.setToken(token);
|
||||||
|
return userTokenInfoManage.updateById(userTokenInfoDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean healthDeclaration(UserTokenInfoDO userTokenInfoDO) {
|
||||||
|
JntyzxResponse jntyzxResponse = jntyzxHttpService.healthDeclaration(userTokenInfoDO.getToken(), userTokenInfoDO.getOpenId());
|
||||||
|
if (Objects.isNull(jntyzxResponse)) {
|
||||||
|
log.info("用户名:{}心跳监测失败!", userTokenInfoDO.getName());
|
||||||
|
}
|
||||||
|
boolean flag = StringUtils.contains(jntyzxResponse.getMessage(), "已存在");
|
||||||
|
if (flag) {
|
||||||
|
log.info("用户名:{}心跳成功✅✅✅✅✅✅", userTokenInfoDO.getName());
|
||||||
|
} else {
|
||||||
|
dingTalkScriptVenueService.sendScriptMsg("用户名:" + userTokenInfoDO.getName() + "心跳失败,消息:" + jntyzxResponse.getMessage());
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.service;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.resp.query.SitePositionList;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.manage.IVenueInfoManage;
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.utils.VenueInfoUtils;
|
||||||
|
import com.xiang.xservice.basic.utils.DateUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
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.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 16:08
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class VenueServiceImpl implements IVenueService {
|
||||||
|
|
||||||
|
// private final static String STATIC_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3NjU4NTI4MjYsInVzZXJuYW1lIjoid3hfb3Blbl9pZF9vMjFNWDR5N3doWENHanZVVEdQNkNUejJIYkQ4In0.pI1tK1imZdKZWXdHRxseqq87_IarHhiRt-hUdBq8hkg";
|
||||||
|
private final IJntyzxHttpService jntyzxHttpService;
|
||||||
|
private final IVenueInfoManage venueInfoManage;
|
||||||
|
private final IUserTokenInfoService userTokenInfoService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SitePositionList> queryVenueService() {
|
||||||
|
String token = userTokenInfoService.getToken("Xiang");
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailable("1", token);
|
||||||
|
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
updateDatabase(sitePositionLists, true);
|
||||||
|
return sitePositionLists;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SitePositionList> queryTomorrowVenue() {
|
||||||
|
String token = userTokenInfoService.getToken("Xiang");
|
||||||
|
if (StringUtils.isBlank(token)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
List<SitePositionList> sitePositionLists = jntyzxHttpService.queryAvailableTomorrow("1", token);
|
||||||
|
if (CollectionUtils.isEmpty(sitePositionLists)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
updateDatabase(sitePositionLists, false);
|
||||||
|
return sitePositionLists;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<VenueInfoDO> queryCanBuyVenue() {
|
||||||
|
return venueInfoManage.queryByType(LocalDate.now(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<VenueInfoDO> queryToday6210VenueInfo() {
|
||||||
|
List<VenueInfoDO> venueInfoDOS = venueInfoManage.queryByDate(LocalDate.now());
|
||||||
|
return venueInfoDOS.stream().filter(item -> VenueInfoUtils.get628VenueInfo(item) || VenueInfoUtils.get8210VenueInfo(item)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDatabase(List<SitePositionList> list, boolean isToday) {
|
||||||
|
List<VenueInfoDO> venueInfoDOS = Lists.newArrayList();
|
||||||
|
if (isToday) {
|
||||||
|
venueInfoDOS.addAll(venueInfoManage.queryByDate(LocalDate.now()));
|
||||||
|
} else {
|
||||||
|
venueInfoDOS.addAll(venueInfoManage.queryByDate(LocalDate.now().plusDays(1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, List<VenueInfoDO>> map = Maps.newHashMap();
|
||||||
|
if (CollectionUtils.isNotEmpty(venueInfoDOS)) {
|
||||||
|
map.putAll(venueInfoDOS.stream().filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.groupingBy(VenueInfoDO::getPlaceId)));
|
||||||
|
}
|
||||||
|
List<VenueInfoDO> insertList = Lists.newArrayList();
|
||||||
|
for (SitePositionList sitePositionList : list) {
|
||||||
|
if (map.containsKey(sitePositionList.getPlaceId())) {
|
||||||
|
List<VenueInfoDO> venueInfoDOList = map.get(sitePositionList.getPlaceId());
|
||||||
|
Map<String, VenueInfoDO> sjMap = venueInfoDOList.stream().collect(Collectors.toMap(VenueInfoDO::getSjName, Function.identity(), (a, b) -> a));
|
||||||
|
if (sjMap.containsKey(sitePositionList.getSjName())) {
|
||||||
|
VenueInfoDO venueInfoDO = sjMap.get(sitePositionList.getSjName());
|
||||||
|
if (!StringUtils.equals(venueInfoDO.getContacts(), sitePositionList.getContacts())
|
||||||
|
|| !Objects.equals(venueInfoDO.getType(), sitePositionList.getType())
|
||||||
|
|| !Objects.equals(venueInfoDO.getPlaceMainId(), sitePositionList.getId())) {
|
||||||
|
venueInfoDO.setContacts(sitePositionList.getContacts());
|
||||||
|
venueInfoDO.setType(sitePositionList.getType());
|
||||||
|
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||||
|
venueInfoManage.updateById(venueInfoDO);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addIntoInsert(sitePositionList, insertList);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
addIntoInsert(sitePositionList, insertList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(insertList)) {
|
||||||
|
venueInfoManage.saveBatch(insertList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addIntoInsert(SitePositionList sitePositionList, List<VenueInfoDO> insertList) {
|
||||||
|
VenueInfoDO venueInfoDO = new VenueInfoDO();
|
||||||
|
venueInfoDO.setPlaceName(sitePositionList.getPlaceName());
|
||||||
|
venueInfoDO.setDate(DateUtils.getDateFromStr(sitePositionList.getAppointments()));
|
||||||
|
venueInfoDO.setPlaceMainId(sitePositionList.getId());
|
||||||
|
venueInfoDO.setPlaceId(sitePositionList.getPlaceId());
|
||||||
|
venueInfoDO.setScheduleId(Integer.valueOf(sitePositionList.getScheduleId()));
|
||||||
|
venueInfoDO.setSjName(sitePositionList.getSjName());
|
||||||
|
venueInfoDO.setCreateTime(LocalDateTime.now());
|
||||||
|
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());
|
||||||
|
insertList.add(venueInfoDO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.xiang.xservice.application.script.jntyzx.utils;
|
||||||
|
|
||||||
|
import com.xiang.xservice.application.script.jntyzx.entity.pojo.VenueInfoDO;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 09:55
|
||||||
|
*/
|
||||||
|
public class VenueInfoUtils {
|
||||||
|
|
||||||
|
public static boolean get123VenueInfo4Mor(VenueInfoDO venueInfoDO) {
|
||||||
|
return StringUtils.equals(venueInfoDO.getSjName(), "13:00-14:00") || StringUtils.equals(venueInfoDO.getSjName(), "14:00-15:00");
|
||||||
|
}
|
||||||
|
public static boolean get1221VenueInfo4Mor(VenueInfoDO venueInfoDO) {
|
||||||
|
return StringUtils.equals(venueInfoDO.getSjName(), "12:00-13:00") || StringUtils.equals(venueInfoDO.getSjName(), "13:00-14:00");
|
||||||
|
}
|
||||||
|
|
||||||
|
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 get8210VenueInfo(VenueInfoDO venueInfoDO) {
|
||||||
|
return StringUtils.equals(venueInfoDO.getSjName(), "20:00-21:00") || StringUtils.equals(venueInfoDO.getSjName(), "21:00-22:00");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.xiang.xservice.common.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.common.entity.SysConfigDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 11:19
|
||||||
|
*/
|
||||||
|
public interface ISysConfigService {
|
||||||
|
|
||||||
|
SysConfigDO getByName(String name);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.xiang.xservice.common.service;
|
||||||
|
|
||||||
|
import com.xiang.xservice.common.entity.SysConfigDO;
|
||||||
|
import com.xiang.xservice.common.mapper.SysConfigMapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-16 11:20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class SysConfigServiceImpl implements ISysConfigService {
|
||||||
|
private final SysConfigMapper sysConfigMapper;
|
||||||
|
@Override
|
||||||
|
public SysConfigDO getByName(String name) {
|
||||||
|
return sysConfigMapper.getByName(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.xiang.xservice.config;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: xiang
|
||||||
|
* @Date: 2025-12-15 15:20
|
||||||
|
*/
|
||||||
|
@ConfigurationProperties(prefix = "dingtalk.robot.venue")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DingTalkRobotVenueConfig {
|
||||||
|
private String token;
|
||||||
|
private String secret;
|
||||||
|
private List<String> users;
|
||||||
|
}
|
||||||
@@ -49,5 +49,10 @@ dingtalk:
|
|||||||
xb:
|
xb:
|
||||||
token: ad21ead99f0fdc63aa00d6732b7b0888c17590f7612c68297edfcb71844d1437
|
token: ad21ead99f0fdc63aa00d6732b7b0888c17590f7612c68297edfcb71844d1437
|
||||||
secret: SECc09d8aad6635f1a4cbadb7c0ab365523c46299f138438cd885e445e0f5f4d730
|
secret: SECc09d8aad6635f1a4cbadb7c0ab365523c46299f138438cd885e445e0f5f4d730
|
||||||
|
users:
|
||||||
|
- 450841600726084717
|
||||||
|
venue:
|
||||||
|
token: 6a218646972c684c75832b0229ea93a234778af537d7469ce96bef290faf530e
|
||||||
|
secret: SEC9018755ba86d3e5c1ed2fbfa1d6953d84bb2a6c8ebe7ed4e318457bfed5e0465
|
||||||
users:
|
users:
|
||||||
- 450841600726084717
|
- 450841600726084717
|
||||||
@@ -51,5 +51,10 @@ dingtalk:
|
|||||||
xb:
|
xb:
|
||||||
token: 340a9d39a5b0b6a52ba2262f9c27179cf50e3c8cfe6883ca082649d306038f41
|
token: 340a9d39a5b0b6a52ba2262f9c27179cf50e3c8cfe6883ca082649d306038f41
|
||||||
secret: SECe10ade3058880b84df5c6f46ab072c11f4ac2a5ef9f134d684705c2a3b004de2
|
secret: SECe10ade3058880b84df5c6f46ab072c11f4ac2a5ef9f134d684705c2a3b004de2
|
||||||
|
users:
|
||||||
|
- 450841600726084717
|
||||||
|
venue:
|
||||||
|
token: 6a218646972c684c75832b0229ea93a234778af537d7469ce96bef290faf530e
|
||||||
|
secret: SEC9018755ba86d3e5c1ed2fbfa1d6953d84bb2a6c8ebe7ed4e318457bfed5e0465
|
||||||
users:
|
users:
|
||||||
- 450841600726084717
|
- 450841600726084717
|
||||||
Reference in New Issue
Block a user