Compare commits
32 Commits
54afcf47fc
...
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 | ||
|
|
fd30c72a73 | ||
|
|
48590d5d26 | ||
|
|
56df38d7c5 | ||
|
|
8fbc83bf06 | ||
|
|
d3920fe6c2 | ||
|
|
1b6b48e8df | ||
|
|
2e2e69f139 | ||
|
|
174b7a269c | ||
|
|
dd99d2609b | ||
|
|
b2b1921c32 |
29
pom.xml
29
pom.xml
@@ -29,33 +29,38 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.xiang</groupId>
|
||||
<artifactId>xservice-common</artifactId>
|
||||
<version>2.0</version>
|
||||
<artifactId>xmc-mysql-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xiang</groupId>
|
||||
<artifactId>xservice-message-starter</artifactId>
|
||||
<version>2.0</version>
|
||||
<artifactId>xmc-cache-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xiang</groupId>
|
||||
<artifactId>xservice-schedule-starter</artifactId>
|
||||
<version>2.0</version>
|
||||
<artifactId>xmc-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xiang</groupId>
|
||||
<artifactId>xservice-cache-starter</artifactId>
|
||||
<version>2.0</version>
|
||||
<artifactId>xmc-message-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xiang</groupId>
|
||||
<artifactId>xservice-http-starter</artifactId>
|
||||
<version>2.0</version>
|
||||
<artifactId>xmc-http-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xiang</groupId>
|
||||
<artifactId>xservice-mysql-starter</artifactId>
|
||||
<version>2.0</version>
|
||||
<artifactId>xmc-logger-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xiang</groupId>
|
||||
<artifactId>xmc-schedule-starter</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -16,8 +16,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
"com.xiang.xservice.application.script.fwd.mapper",
|
||||
"com.xiang.xservice.application.script.glados.repository",
|
||||
"com.xiang.xservice.application.script.xb.repository",
|
||||
"com.xiang.xservice.application.script.stock.gnshyx.mapper",
|
||||
"com.xiang.xservice.application.script.stock.data.mapper",
|
||||
"com.xiang.xservice.common.mapper",
|
||||
"com.xiang.xservice.application.script.jntyzx.mapper"
|
||||
})
|
||||
@ConfigurationPropertiesScan(basePackages = {
|
||||
"com.xiang.xservice.config"
|
||||
|
||||
@@ -19,7 +19,7 @@ public class DynamicDomainSchedule {
|
||||
|
||||
private final IDomainService IDomainService;
|
||||
|
||||
@Scheduled(cron = "0 0/5 * * * ? ")
|
||||
@Scheduled(cron = "0 0/30 * * * ? ")
|
||||
public void dynamicDomainSchedule() {
|
||||
String publicIp = "";
|
||||
try {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xiang.xservice.application.script.domain.service;
|
||||
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xmc.service.message.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.config.DingTalkRobotScriptConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -3,13 +3,17 @@ package com.xiang.xservice.application.script.fwd.schedule;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FUserConfig;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.basic.utils.PrimaryKeyUtils;
|
||||
import com.xiang.xmc.service.schedule.core.DynamicTaskScheduler;
|
||||
import com.xiang.xmc.service.schedule.entity.ScheduledTaskEntity;
|
||||
import com.xiang.xmc.service.schedule.entity.TaskConfig;
|
||||
import com.xiang.xmc.service.schedule.enums.TaskGroupEnum;
|
||||
import com.xiang.xmc.service.schedule.enums.TaskStatusEnum;
|
||||
import com.xiang.xmc.service.schedule.service.IDynamicTaskSchedulerService;
|
||||
import com.xiang.xservice.application.script.fwd.entity.param.FwdOrderTaskParam;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FPerformConfig;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FPerformProjectInfo;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FPerformSeatInfo;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FUserConfig;
|
||||
import com.xiang.xservice.application.script.fwd.entity.resp.http.perform.Perform;
|
||||
import com.xiang.xservice.application.script.fwd.entity.resp.http.perform.PerformDetail;
|
||||
import com.xiang.xservice.application.script.fwd.entity.resp.http.perform.PerformInfo;
|
||||
@@ -23,16 +27,15 @@ import com.xiang.xservice.application.script.fwd.service.DingTalkScriptFWDServic
|
||||
import com.xiang.xservice.application.script.fwd.service.IPerformService;
|
||||
import com.xiang.xservice.application.script.fwd.service.IPerformServiceHttp;
|
||||
import com.xiang.xservice.application.script.fwd.utils.TimeSyncUtils;
|
||||
import com.xiang.xservice.schedule.core.DynamicTaskScheduler;
|
||||
import com.xiang.xservice.schedule.entity.ScheduledTaskEntity;
|
||||
import com.xiang.xservice.schedule.entity.TaskConfig;
|
||||
import com.xiang.xservice.schedule.enums.TaskGroupEnum;
|
||||
import com.xiang.xservice.schedule.enums.TaskStatusEnum;
|
||||
import com.xiang.xservice.schedule.service.IDynamicTaskSchedulerService;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.basic.utils.PrimaryKeyUtils;
|
||||
import com.xiang.xservice.common.entity.SysConfigDO;
|
||||
import com.xiang.xservice.common.mapper.SysConfigMapper;
|
||||
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 org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -69,6 +72,7 @@ public class FwdImportantMsgJob {
|
||||
private final IPerformService iPerformService;
|
||||
private final IDynamicTaskSchedulerService dynamicTaskSchedulerService;
|
||||
private final IPerformServiceHttp iPerformServiceHttp;
|
||||
private final SysConfigMapper sysConfigMapper;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
@@ -116,6 +120,17 @@ public class FwdImportantMsgJob {
|
||||
performConfigMapper.insertPerforms(addList);
|
||||
}
|
||||
|
||||
// 是否下单开关
|
||||
boolean flag = false;
|
||||
SysConfigDO config = sysConfigMapper.getByName("fwd.order.create.switch");
|
||||
if (Objects.nonNull(config)) {
|
||||
if (StringUtils.isNotBlank(config.getValue())) {
|
||||
if (StringUtils.equals(config.getValue(), "true")) {
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder msg = new StringBuilder("今日" + now + "演唱会门票预售信息:\n");
|
||||
for (FPerformProjectInfo data : saleTodayData) {
|
||||
msg.append("演唱会名称:").append(data.getProjectName()).append("预售时间:").append(DateUtils.getDateTimeFromDateTime(data.getPreSaleTime())).append("\n");
|
||||
@@ -123,13 +138,15 @@ public class FwdImportantMsgJob {
|
||||
Map<String, Object> params = Maps.newHashMap();
|
||||
params.put("projectId", data.getProjectId());
|
||||
LocalDateTime runTime = data.getPreSaleTime().isBefore(LocalDateTime.now()) ? LocalDateTime.now().plusMinutes(1) : data.getPreSaleTime();
|
||||
dynamicTaskScheduler.schedule(
|
||||
new TaskConfig(taskId, "芬玩岛演唱会抢票-【" + data.getProjectName() + "】", TaskGroupEnum.SERVICE_FWD_SCHEDULE.getCode(),
|
||||
runTime, params),
|
||||
new TicketGrabTask(fwdUserConfigMapper, fwdAudienceConfigMapper, iPerformService,
|
||||
new FwdOrderTaskParam(data.getProjectId(), taskId), dynamicTaskSchedulerService),
|
||||
TimeSyncUtils.now());
|
||||
savaTask(data, taskId, params);
|
||||
if (flag) {
|
||||
dynamicTaskScheduler.schedule(
|
||||
new TaskConfig(taskId, "芬玩岛演唱会抢票-【" + data.getProjectName() + "】", TaskGroupEnum.SERVICE_FWD_SCHEDULE.getCode(),
|
||||
runTime, params),
|
||||
new TicketGrabTask(fwdUserConfigMapper, fwdAudienceConfigMapper, iPerformService,
|
||||
new FwdOrderTaskParam(data.getProjectId(), taskId), dynamicTaskSchedulerService),
|
||||
TimeSyncUtils.now());
|
||||
savaTask(data, taskId, params);
|
||||
}
|
||||
}
|
||||
msg.append("请注意进行数据库配置的更改!");
|
||||
dingTalkScriptFWDService.sendScriptMsg(msg.toString());
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.xiang.xservice.application.script.fwd.schedule;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.xiang.xmc.service.http.helper.HttpRequestHelper;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FAudienceConfig;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FPerformProjectInfo;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FPerformSeatInfo;
|
||||
@@ -24,7 +25,6 @@ import com.xiang.xservice.basic.common.req.BaseRequest;
|
||||
import com.xiang.xservice.basic.config.MyThreadFactory;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.basic.utils.RandomCodeUtils;
|
||||
import com.xiang.xservice.http.helper.HttpRequestHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.xiang.xservice.application.script.fwd.schedule;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xiang.xmc.service.schedule.service.IDynamicTaskSchedulerService;
|
||||
import com.xiang.xservice.application.script.fwd.entity.param.FwdOrderTaskParam;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FAudienceConfig;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FUserConfig;
|
||||
import com.xiang.xservice.application.script.fwd.mapper.FwdAudienceConfigMapper;
|
||||
import com.xiang.xservice.application.script.fwd.mapper.FwdUserConfigMapper;
|
||||
import com.xiang.xservice.application.script.fwd.service.IPerformService;
|
||||
import com.xiang.xservice.schedule.service.IDynamicTaskSchedulerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xiang.xservice.application.script.fwd.service;
|
||||
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xmc.service.message.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.config.DingTalkRobotScriptConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.xiang.xservice.application.script.fwd.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xiang.xmc.service.http.helper.HttpRequestHelper;
|
||||
import com.xiang.xservice.application.script.fwd.constants.PriceRange;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FPerformConfig;
|
||||
import com.xiang.xservice.application.script.fwd.entity.pojo.FPerformProjectInfo;
|
||||
@@ -16,7 +17,6 @@ import com.xiang.xservice.application.script.fwd.service.DingTalkScriptFWDServic
|
||||
import com.xiang.xservice.application.script.fwd.service.IPerformService;
|
||||
import com.xiang.xservice.application.script.fwd.service.IPerformServiceHttp;
|
||||
import com.xiang.xservice.basic.config.MyThreadFactory;
|
||||
import com.xiang.xservice.http.helper.HttpRequestHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -87,6 +87,8 @@ public class PerformServiceImpl implements IPerformService {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
Map<Long, List<FPerformSeatInfo>> performMap = seatInfoByProjectId.stream().filter(item -> 0 == item.getSoldOut()).collect(Collectors.groupingBy(FPerformSeatInfo::getPerformId));
|
||||
// todo 场次座位排序 优先 场次先后顺序 周六>周日>周五>工作日 根据场次分组进行
|
||||
// todo 座位价格排序 优先 600-900 > 900-1300 > 1300-1600 > 1600~* > 0-600
|
||||
for (Long performId : performMap.keySet()) {
|
||||
List<FPerformSeatInfo> fPerformSeatInfos = performMap.get(performId);
|
||||
AtomicReference<BigDecimal> atomicPrice = new AtomicReference<>();
|
||||
@@ -128,28 +130,6 @@ public class PerformServiceImpl implements IPerformService {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static ProjectOrderCreateReq buildReq(Long projectId, List<Long> frequentIds, FPerformSeatInfo fPerformSeatInfo) {
|
||||
ProjectOrderCreateReq projectOrderCreateReq = new ProjectOrderCreateReq();
|
||||
projectOrderCreateReq.setDeliveryType(1);
|
||||
projectOrderCreateReq.setContactName("朱吉祥");
|
||||
projectOrderCreateReq.setContactPhone("15858717571");
|
||||
projectOrderCreateReq.setPayment(fPerformSeatInfo.getPrice().multiply(BigDecimal.valueOf(frequentIds.size())).setScale(2));
|
||||
projectOrderCreateReq.setTotalPrice(fPerformSeatInfo.getPrice().multiply(BigDecimal.valueOf(frequentIds.size())).setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
projectOrderCreateReq.setPerformId(fPerformSeatInfo.getPerformId());
|
||||
projectOrderCreateReq.setProjectId(projectId.toString());
|
||||
projectOrderCreateReq.setPrivilegeCodeList(new ArrayList<>());
|
||||
projectOrderCreateReq.setAudienceCount(frequentIds.size());
|
||||
projectOrderCreateReq.setFrequentIds(frequentIds);
|
||||
projectOrderCreateReq.setSeatPlanIds(Collections.singletonList(fPerformSeatInfo.getSeatPlanId()));
|
||||
projectOrderCreateReq.setBlackBox(":0");
|
||||
projectOrderCreateReq.setCombineTicketVos(null);
|
||||
projectOrderCreateReq.setOrdinaryTicketVos(null);
|
||||
projectOrderCreateReq.setActivityId(Strings.EMPTY);
|
||||
projectOrderCreateReq.setActivityType(0);
|
||||
return projectOrderCreateReq;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static ProjectOrderCreateReq buildReqV2(Long projectId, List<Long> frequentIds, List<Long> seatPlanIds, Long perfomrId, BigDecimal price) {
|
||||
ProjectOrderCreateReq projectOrderCreateReq = new ProjectOrderCreateReq();
|
||||
|
||||
@@ -19,7 +19,7 @@ public class GladosCheckInJob {
|
||||
|
||||
private final GLaDOSService glaDOSService;
|
||||
|
||||
@Scheduled(cron = "0 0 8,16 1/1 * ?")
|
||||
@Scheduled(cron = "0 0 7 1/1 * ?")
|
||||
public void checkInJon() {
|
||||
log.info("[job] Glados Check In Job start, time:{}", LocalDateTime.now());
|
||||
glaDOSService.checkIn();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xiang.xservice.application.script.glados.service;
|
||||
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xmc.service.message.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.config.DingTalkRobotScriptConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -2,13 +2,13 @@ package com.xiang.xservice.application.script.glados.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.xservice.basic.utils.HttpUtils;
|
||||
import com.xiang.xservice.application.script.glados.common.GladosConstants;
|
||||
import com.xiang.xservice.application.script.glados.common.URLConstants;
|
||||
import com.xiang.xservice.application.script.glados.entity.GladosRunLog;
|
||||
import com.xiang.xservice.application.script.glados.entity.resp.GLaDOSResponse;
|
||||
import com.xiang.xservice.application.script.glados.repository.GladosMapper;
|
||||
import com.xiang.xservice.application.script.xb.entity.pojo.User;
|
||||
import com.xiang.xservice.basic.utils.HttpUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -46,7 +46,16 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
users.parallelStream().forEach(user -> {
|
||||
try {
|
||||
checkIn(user, sb);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
if (checkIn(user, sb)) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
log.error("线程暂停10s失败");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("签到失败,", e);
|
||||
}
|
||||
@@ -54,7 +63,7 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void checkIn(User user, StringBuffer sb) {
|
||||
private boolean checkIn(User user, StringBuffer sb) {
|
||||
|
||||
Map<String, String> header = Maps.newHashMap();
|
||||
header.put("Cookie", user.getCookie());
|
||||
@@ -72,6 +81,8 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
||||
GLaDOSResponse gLaDOSResponse =JSONObject.parseObject(response, GLaDOSResponse.class);
|
||||
if (Objects.nonNull(gLaDOSResponse)) {
|
||||
log.info("http do post success, response:{}", response);
|
||||
|
||||
// 成功签到记录
|
||||
if (0 == gLaDOSResponse.getCode() && Objects.nonNull(gLaDOSResponse.getPoints())) {
|
||||
log.info("签到成功, 签到积分:{}, 签到消息:{}", gLaDOSResponse.getPoints(), gLaDOSResponse.getMessage());
|
||||
sb.append(user.getEmail()).append("签到成功,获得积分:").append(gLaDOSResponse.getPoints()).append("\n");
|
||||
@@ -81,11 +92,27 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
||||
} catch (Exception e) {
|
||||
log.error("发送钉钉消息失败", e);
|
||||
}
|
||||
GladosRunLog build = GladosRunLog.builder().time(LocalDateTime.now()).status(1).code(Integer.valueOf(gLaDOSResponse.getCode().toString())).response(response).user(user.getEmail()).userId(user.getId()).build();
|
||||
gladosMapper.insertScriptRunLog(build);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
// 重复签到,表示当日签到成功
|
||||
if (1 == gLaDOSResponse.getCode()) {
|
||||
log.warn("签到失败,重复签到,用户:{}, 签到消息:{}", user.getEmail(), gLaDOSResponse.getMessage());
|
||||
sb.append(user).append("签到失败,重复签到,用户:").append(user).append(",签到消息:").append(gLaDOSResponse.getMessage());
|
||||
try {
|
||||
dingTalkService.sendScriptMsg("[时间:" + LocalDateTime.now() + "] 用户: " +
|
||||
user.getEmail() + "当天已经签到成功!获得积分" + gLaDOSResponse.getList().get(0));
|
||||
} catch (Exception e) {
|
||||
log.error("发送钉钉消息失败", e);
|
||||
}
|
||||
GladosRunLog build = GladosRunLog.builder().time(LocalDateTime.now()).status(1).code(Integer.valueOf(gLaDOSResponse.getCode().toString())).response(response).user(user.getEmail()).userId(user.getId()).build();
|
||||
gladosMapper.insertScriptRunLog(build);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
// cookie过期
|
||||
if (-2 == gLaDOSResponse.getCode()) {
|
||||
log.warn("签到失败,用户:{}, cookie过期:{}", user.getEmail(), gLaDOSResponse.getMessage());
|
||||
String message = "[时间:" + LocalDateTime.now() + "] 用户: " + user.getEmail() + ",签到消息: " + gLaDOSResponse.getMessage();
|
||||
@@ -95,15 +122,25 @@ public class GLaDOSServiceImpl implements GLaDOSService{
|
||||
log.error("发送钉钉消息失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 其余的异常情况
|
||||
if (gLaDOSResponse.getCode() != 1) {
|
||||
log.warn("签到异常,返回的消息:{}", gLaDOSResponse.getMessage());
|
||||
sb.append(user.getEmail()).append("签到异常,返回的消息:").append(gLaDOSResponse.getMessage()).append("\n");
|
||||
}
|
||||
GladosRunLog build = GladosRunLog.builder().time(LocalDateTime.now()).status(1).code(Integer.valueOf(gLaDOSResponse.getCode().toString())).response(response).user(user.getEmail()).userId(user.getId()).build();
|
||||
GladosRunLog build = GladosRunLog.builder().time(LocalDateTime.now()).status(0).code(Integer.valueOf(gLaDOSResponse.getCode().toString())).response(response).user(user.getEmail()).userId(user.getId()).build();
|
||||
gladosMapper.insertScriptRunLog(build);
|
||||
return;
|
||||
return Boolean.FALSE;
|
||||
} else {
|
||||
try {
|
||||
String mes = "[时间:" + LocalDateTime.now() + "] 用户: " + user.getEmail() + ",签到异常,请求结果为空。";
|
||||
dingTalkService.sendScriptMsg(mes);
|
||||
} catch (Exception e) {
|
||||
log.error("发送钉钉消息失败", e);
|
||||
}
|
||||
}
|
||||
GladosRunLog build = GladosRunLog.builder().time(LocalDateTime.now()).status(0).response(response).user(user.getEmail()).userId(user.getId()).build();
|
||||
gladosMapper.insertScriptRunLog(build);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.xiang.xservice.application.script.stock.data.service;
|
||||
package com.xiang.xservice.application.script.jntyzx.service;
|
||||
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.config.DingTalkRobotXbConfig;
|
||||
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;
|
||||
@@ -13,10 +13,10 @@ import org.springframework.stereotype.Service;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DingTalkScriptStockService {
|
||||
public class DingTalkScriptVenueService {
|
||||
|
||||
private final DingTalkService dingTalkService;
|
||||
private final DingTalkRobotXbConfig dingTalkRobotXbConfig;
|
||||
private final DingTalkRobotVenueConfig dingTalkRobotVenueConfig;
|
||||
|
||||
/**
|
||||
* 发送脚本消息
|
||||
@@ -24,7 +24,8 @@ public class DingTalkScriptStockService {
|
||||
*/
|
||||
public void sendScriptMsg(String msg) {
|
||||
try {
|
||||
dingTalkService.sendRobotMessage(dingTalkRobotXbConfig.getSecret(), dingTalkRobotXbConfig.getToken(), dingTalkRobotXbConfig.getUsers(), msg);
|
||||
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.xservice.basic.utils.HttpUtils;
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.application.script.xb.common.URLConstants;
|
||||
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 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");
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.data.common.constants;
|
||||
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
public class RedisConstants {
|
||||
|
||||
public static final String MSG_SEND_REDIS_KEY = "stock:msg:send:";
|
||||
|
||||
|
||||
public static String getDate4Key() {
|
||||
return DateUtils.getDateFromDate(LocalDate.now(), "yyyyMMdd");
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.data.common.constants;
|
||||
|
||||
public class UrlConstants {
|
||||
|
||||
/**
|
||||
* 新浪财经 股票数据拉取
|
||||
*/
|
||||
public static final String SINA_STOCK_DATA_PULL_URL = "https://hq.sinajs.cn/list=";
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.data.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class StockSinaDataRecordDO {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 股票名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 今开价格
|
||||
*/
|
||||
private BigDecimal jkPrice;
|
||||
|
||||
/**
|
||||
* 昨收价格
|
||||
*/
|
||||
private BigDecimal zsPrice;
|
||||
|
||||
/**
|
||||
* 现在价格
|
||||
*/
|
||||
private BigDecimal xjPrice;
|
||||
|
||||
/**
|
||||
* 最高价格
|
||||
*/
|
||||
private BigDecimal zgPrice;
|
||||
|
||||
/**
|
||||
* 最低价格
|
||||
*/
|
||||
private BigDecimal zdPrice;
|
||||
|
||||
/**
|
||||
* 总手数量
|
||||
*/
|
||||
private String zsNum;
|
||||
|
||||
/**
|
||||
* 总交易金额
|
||||
*/
|
||||
private BigDecimal price;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.data.mapper;
|
||||
|
||||
import com.xiang.xservice.application.script.stock.data.entity.StockSinaDataRecordDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface StockSinaDataRecordPullMapper {
|
||||
|
||||
int batchInsert(@Param("list") List<StockSinaDataRecordDO> list);
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.data.schedule;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xiang.xservice.application.script.stock.data.common.constants.RedisConstants;
|
||||
import com.xiang.xservice.application.script.stock.data.entity.StockSinaDataRecordDO;
|
||||
import com.xiang.xservice.application.script.stock.data.service.DingTalkScriptStockService;
|
||||
import com.xiang.xservice.application.script.stock.data.service.IStockDataService;
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.entity.StockGnshyxRecordDataDO;
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.service.ICloudRecordDataService;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.cache.service.IRedisService;
|
||||
import com.xiang.xservice.common.entity.DayResult;
|
||||
import com.xiang.xservice.common.enums.RedisConstant;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.DayOfWeek;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class DataMsgSendJob {
|
||||
|
||||
private final ICloudRecordDataService cloudRecordDataService;
|
||||
private final IStockDataService stockDataService;
|
||||
private final DingTalkScriptStockService dingTalkScriptStockService;
|
||||
private final IRedisService redisService;
|
||||
|
||||
@Scheduled(cron = "0 27 9 1/1 * ?")
|
||||
public void stockDataGetMsgSendJob() {
|
||||
if (DateUtils.validWeekTime()) return;
|
||||
LocalDate now = LocalDate.now();
|
||||
JSONObject dayResult = (JSONObject) redisService.hGet(RedisConstant.DAY_INFO_PREFIX_KEY + RedisConstant.getDate4Key(), DateUtils.getDateFromDate(now));
|
||||
if (com.xiang.xservice.common.utils.DateUtils.validHoliday(JSON.toJavaObject(dayResult, DayResult.class)))
|
||||
return;
|
||||
|
||||
StringBuffer msg = new StringBuffer();
|
||||
List<StockGnshyxRecordDataDO> list = cloudRecordDataService.getList();
|
||||
list.parallelStream().forEach(item -> {
|
||||
String stockCode = item.getStockCode();
|
||||
String[] values = stockCode.split("\\.");
|
||||
String c1 = values[1].toLowerCase();
|
||||
String c2 = values[0];
|
||||
String code = c1 + c2;
|
||||
|
||||
String resp = stockDataService.getStockDataFromHttp(code);
|
||||
|
||||
StockSinaDataRecordDO recordDO = stockDataService.buildRecordDO(resp);
|
||||
if (Objects.nonNull(recordDO)) {
|
||||
|
||||
if (recordDO.getXjPrice().compareTo(item.getAttentionPrice()) > 0) {
|
||||
msg.append("股票代码:").append(item.getStockCode()).append(",名称:").append(item.getStockName())
|
||||
.append(",现在价格:").append(recordDO.getXjPrice()).append(",目标价格:").append(item.getAttentionPrice()).append("\n");
|
||||
}
|
||||
if (recordDO.getXjPrice().compareTo(item.getStopPrice()) < 0) {
|
||||
msg.append("股票代码:").append(item.getStockCode()).append(",名称:").append(item.getStockName())
|
||||
.append(",现在价格:").append(recordDO.getXjPrice()).append(",止损价格:").append(item.getStopPrice()).append("\n");
|
||||
}
|
||||
}
|
||||
});
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
dingTalkScriptStockService.sendScriptMsg(msg.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0/10 * * * * ?")
|
||||
public void stockGetTargetMsgSendJob() {
|
||||
if (DateUtils.validWeekTime()) return;
|
||||
LocalDate now = LocalDate.now();
|
||||
JSONObject dayResult = (JSONObject) redisService.hGet(RedisConstant.DAY_INFO_PREFIX_KEY + RedisConstant.getDate4Key(), DateUtils.getDateFromDate(now));
|
||||
if (com.xiang.xservice.common.utils.DateUtils.validHoliday(JSON.toJavaObject(dayResult, DayResult.class))) return;
|
||||
StringBuilder msg = new StringBuilder();
|
||||
List<StockGnshyxRecordDataDO> list = cloudRecordDataService.getList();
|
||||
for (StockGnshyxRecordDataDO stockGnshyxRecordDataDO : list) {
|
||||
String stockCode = stockGnshyxRecordDataDO.getStockCode();
|
||||
String[] values = stockCode.split("\\.");
|
||||
String c1 = values[1].toLowerCase();
|
||||
String c2 = values[0];
|
||||
String code = c1 + c2;
|
||||
String resp = stockDataService.getStockDataFromHttp(code);
|
||||
StockSinaDataRecordDO recordDO = stockDataService.buildRecordDO(resp);
|
||||
if (Objects.nonNull(recordDO)) {
|
||||
Object o = redisService.hGet(RedisConstants.MSG_SEND_REDIS_KEY + RedisConstants.getDate4Key(), stockGnshyxRecordDataDO.getStockCode());
|
||||
if (Objects.isNull(o)) {
|
||||
if (recordDO.getXjPrice().compareTo(stockGnshyxRecordDataDO.getAttentionPrice()) > 0) {
|
||||
msg.append("股票代码:")
|
||||
.append(stockGnshyxRecordDataDO.getStockCode())
|
||||
.append(",名称:")
|
||||
.append(stockGnshyxRecordDataDO.getStockName())
|
||||
.append(",达到预期的价格:")
|
||||
.append(stockGnshyxRecordDataDO.getAttentionPrice())
|
||||
.append(",现在价格:").append(recordDO.getXjPrice())
|
||||
.append("\n");
|
||||
}
|
||||
if (recordDO.getXjPrice().compareTo(stockGnshyxRecordDataDO.getStopPrice()) < 0) {
|
||||
msg.append("股票代码:")
|
||||
.append(stockGnshyxRecordDataDO.getStockCode())
|
||||
.append(",名称:")
|
||||
.append(stockGnshyxRecordDataDO.getStockName())
|
||||
.append("达到止损的价格:")
|
||||
.append(stockGnshyxRecordDataDO.getStopPrice())
|
||||
.append(",现在价格:").append(recordDO.getXjPrice())
|
||||
.append("\n");
|
||||
}
|
||||
redisService.hSet(RedisConstants.MSG_SEND_REDIS_KEY + RedisConstants.getDate4Key(), stockGnshyxRecordDataDO.getStockCode(), "true");
|
||||
redisService.expire("xservice-script-center", RedisConstants.MSG_SEND_REDIS_KEY + RedisConstants.getDate4Key(), 10, TimeUnit.DAYS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
log.info("发送钉钉消息:{}", msg);
|
||||
dingTalkScriptStockService.sendScriptMsg(msg.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean validTime() {
|
||||
if (Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SATURDAY) ||
|
||||
Objects.equals(LocalDateTime.now().getDayOfWeek(), DayOfWeek.SUNDAY)) {
|
||||
log.info("当前时间为:{}", LocalDateTime.now());
|
||||
return false;
|
||||
}
|
||||
LocalTime now = LocalTime.now();
|
||||
|
||||
boolean inMorning = now.isAfter(LocalTime.of(9, 29)) && now.isBefore(LocalTime.of(11, 31));
|
||||
boolean inAfternoon = now.isAfter(LocalTime.of(12, 59)) && now.isBefore(LocalTime.of(15, 1));
|
||||
if (!inAfternoon && !inMorning) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.data.schedule;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.cache.service.IRedisService;
|
||||
import com.xiang.xservice.common.entity.DayResult;
|
||||
import com.xiang.xservice.common.enums.RedisConstant;
|
||||
import com.xiang.xservice.application.script.stock.data.entity.StockSinaDataRecordDO;
|
||||
import com.xiang.xservice.application.script.stock.data.service.IStockDataService;
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.entity.StockGnshyxRecordDataDO;
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.service.ICloudRecordDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class StockDataPullJob {
|
||||
|
||||
private final ICloudRecordDataService cloudRecordDataService;
|
||||
private final IStockDataService stockDataService;
|
||||
private final IRedisService redisService;
|
||||
private static final Integer BATCH_SIZE = 500;
|
||||
|
||||
@Scheduled(cron = "*/1 * * * * ?")
|
||||
public void sinaDataPullJob() {
|
||||
if (DateUtils.validWeekTime()) return;
|
||||
LocalDate now = LocalDate.now();
|
||||
JSONObject dayResult = (JSONObject) redisService.hGet(RedisConstant.DAY_INFO_PREFIX_KEY + RedisConstant.getDate4Key(), DateUtils.getDateFromDate(now));
|
||||
if (com.xiang.xservice.common.utils.DateUtils.validHoliday(JSON.toJavaObject(dayResult, DayResult.class))) return;
|
||||
log.info(">>>>>>>>>>>>>>>>>新浪财经数据拉取开始>>>>>>>>>>>>>>>>>");
|
||||
List<StockGnshyxRecordDataDO> dataList = cloudRecordDataService.getList();
|
||||
List<StockSinaDataRecordDO> result = Lists.newArrayList();
|
||||
for (StockGnshyxRecordDataDO stockGnshyxRecordDataDO : dataList) {
|
||||
String stockCode = stockGnshyxRecordDataDO.getStockCode();
|
||||
String[] values = stockCode.split("\\.");
|
||||
String c1 = values[1].toLowerCase();
|
||||
String c2 = values[0];
|
||||
String code = c1 + c2;
|
||||
String resp = stockDataService.getStockDataFromHttp(code);
|
||||
StockSinaDataRecordDO stockSinaDataRecordDO = stockDataService.buildRecordDO(resp);
|
||||
if (Objects.nonNull(stockSinaDataRecordDO)) {
|
||||
result.add(stockSinaDataRecordDO);
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(result)) {
|
||||
if (BATCH_SIZE > result.size()) {
|
||||
Lists.partition(result, BATCH_SIZE).forEach(stockDataService::insertData2DB);
|
||||
} else {
|
||||
stockDataService.insertData2DB(result);
|
||||
}
|
||||
}
|
||||
log.info(">>>>>>>>>>>>>>>>>新浪财经数据拉取结束>>>>>>>>>>>>>>>>>");
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.data.service;
|
||||
|
||||
import com.xiang.xservice.application.script.stock.data.entity.StockSinaDataRecordDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IStockDataService {
|
||||
|
||||
String getStockDataFromHttp(String stockCode);
|
||||
|
||||
boolean insertData2DB(List<StockSinaDataRecordDO> stockSinaDataRecordDOs);
|
||||
|
||||
StockSinaDataRecordDO buildRecordDO(String resp);
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.data.service;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.xservice.basic.exception.BusinessException;
|
||||
import com.xiang.xservice.basic.utils.HttpUtils;
|
||||
import com.xiang.xservice.application.script.stock.data.common.constants.UrlConstants;
|
||||
import com.xiang.xservice.application.script.stock.data.entity.StockSinaDataRecordDO;
|
||||
import com.xiang.xservice.application.script.stock.data.mapper.StockSinaDataRecordPullMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class StockDataServiceImpl implements IStockDataService{
|
||||
|
||||
private final StockSinaDataRecordPullMapper stockSinaDataRecordPullMapper;
|
||||
|
||||
//文灿股份,22.210,22.240,22.070,22.310,21.960,22.070,22.080,5173623, 114323642.000, 2900, 22.070,7600, 22.060,4600, 22.050,2700, 22.040,4700, 22.030,600, 22.080,29800,22.090,3800, 22.100,3000, 22.120,800, 22.130,2025-09-19,15:00:02,00
|
||||
//浦发银行,12.690,12.750,12.810,12.900,12.560,12.800,12.810,79638295,1015780801.000,78500, 12.800,88400, 12.790,151900,12.780,42900,12.770,71700,12.760,841170, 12.810,1100, 12.830,48100,12.860,128600,12.870,116600,12.880,2025-09-19,15:00:03,00,
|
||||
//平安银行,11.410,11.410,11.450,11.510,11.370,11.450,11.460,83465123,955004096.910, 103813,11.450,321000,11.440,198700,11.430,216100,11.420,553000,11.410,15300,11.460,27500,11.470,28400,11.480,175335,11.490,893111,11.500,2025-09-19,15:00:00,00
|
||||
|
||||
@Override
|
||||
public String getStockDataFromHttp(String stockCode) {
|
||||
String url = UrlConstants.SINA_STOCK_DATA_PULL_URL + stockCode;
|
||||
|
||||
Map<String, String> headers = Maps.newHashMap();
|
||||
headers.put("Referer", "https://finance.sina.com.cn");
|
||||
headers.put("User-Agent", "Mozilla/5.0");
|
||||
String resp = HttpUtils.doGet(url, headers, null);
|
||||
if (StringUtils.isBlank(resp)) {
|
||||
log.error("http请求拉取新浪财经股票数据失败, 股票代码:{}, 响应结果:{}", stockCode, resp);
|
||||
throw new BusinessException("拉取数据失败");
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean insertData2DB(List<StockSinaDataRecordDO> stockSinaDataRecordDOs) {
|
||||
return stockSinaDataRecordPullMapper.batchInsert(stockSinaDataRecordDOs) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockSinaDataRecordDO buildRecordDO(String resp) {
|
||||
if (resp.contains("=")) {
|
||||
resp = resp.split("=")[1].replace("\"", "").replace(";", "");
|
||||
if (StringUtils.equals(resp, "FAILED")) {
|
||||
return null;
|
||||
}
|
||||
String[] values = resp.split(",");
|
||||
|
||||
// 股票名称
|
||||
String mc = values[0];
|
||||
// 今开价格
|
||||
String jk = values[1];
|
||||
// 昨收价格
|
||||
String zs = values[2];
|
||||
// 现在价格
|
||||
String xj = values[3];
|
||||
// 最高价格
|
||||
String zg = values[4];
|
||||
// 最低价格
|
||||
String zd = values[5];
|
||||
// 总手
|
||||
String zongshou = values[8];
|
||||
// 金额
|
||||
String je = values[9];
|
||||
// 时间
|
||||
String sj = values[values.length - 3];
|
||||
// 日期
|
||||
String rq = values[values.length - 4];
|
||||
|
||||
BigDecimal change = (new BigDecimal(xj).subtract(new BigDecimal(zs))).divide(new BigDecimal(zs), 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
|
||||
log.info("股票名称:{}, 当前价格:{}, 昨收价格:{}, 涨跌幅:{}%", mc, xj, zs, change);
|
||||
|
||||
StockSinaDataRecordDO stockSinaDataRecordDO = new StockSinaDataRecordDO();
|
||||
stockSinaDataRecordDO.setName(mc);
|
||||
stockSinaDataRecordDO.setJkPrice(new BigDecimal(jk));
|
||||
stockSinaDataRecordDO.setZsPrice(new BigDecimal(zs));
|
||||
stockSinaDataRecordDO.setXjPrice(new BigDecimal(xj));
|
||||
stockSinaDataRecordDO.setZgPrice(new BigDecimal(zg));
|
||||
stockSinaDataRecordDO.setZdPrice(new BigDecimal(zd));
|
||||
stockSinaDataRecordDO.setZsNum(zs);
|
||||
stockSinaDataRecordDO.setPrice(new BigDecimal(je));
|
||||
stockSinaDataRecordDO.setUpdateTime(LocalDateTime.now());
|
||||
return stockSinaDataRecordDO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.gnshyx.common.constants;
|
||||
|
||||
public class UrlConstant {
|
||||
|
||||
public final static String BASE_URL = "https://gnshyx.cloudgn.com";
|
||||
|
||||
public final static String URL_PREFIX = "/prod-api";
|
||||
|
||||
public final static String LAST_PRICE = BASE_URL + "/price/lastprice";
|
||||
|
||||
public final static String LAST_LIST = BASE_URL + URL_PREFIX + "/public/stockDailySelection/listLast";
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.gnshyx.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class StockGnshyxRecordDataDO {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String symbolName;
|
||||
|
||||
/**
|
||||
* 股票名称
|
||||
*/
|
||||
private String stockName;
|
||||
|
||||
/**
|
||||
* 目标价格
|
||||
*/
|
||||
private BigDecimal attentionPrice;
|
||||
|
||||
/**
|
||||
* 关注价格低位
|
||||
*/
|
||||
private BigDecimal targetPriceLow;
|
||||
|
||||
/**
|
||||
* 关注价格高位
|
||||
*/
|
||||
private BigDecimal targetPriceHigh;
|
||||
|
||||
/**
|
||||
* 止损价位
|
||||
*/
|
||||
private BigDecimal stopPrice;
|
||||
|
||||
/**
|
||||
* 系统每日选择id
|
||||
*/
|
||||
private Long stockDailySelectionId;
|
||||
|
||||
/**
|
||||
* 股票代码
|
||||
*/
|
||||
private String stockCode;
|
||||
|
||||
/**
|
||||
* 生成时间
|
||||
*/
|
||||
private LocalDateTime selectionTime;
|
||||
|
||||
/**
|
||||
* maximum_increase
|
||||
*/
|
||||
private String maximumIncrease;
|
||||
|
||||
/**
|
||||
* maximum_increase_seven
|
||||
*/
|
||||
private String maximumIncreaseSeven;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.gnshyx.entity.resp;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GnshyxBaseResp {
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String msg;
|
||||
|
||||
@JSONField(name = "server_time")
|
||||
private Long serverTime;
|
||||
|
||||
private String data;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.gnshyx.entity.resp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ListLastDataResp {
|
||||
|
||||
/**
|
||||
* 选择id
|
||||
*/
|
||||
private Long stockDailySelectionId;
|
||||
|
||||
/**
|
||||
* 股票代码
|
||||
*/
|
||||
private String stockCode;
|
||||
|
||||
/**
|
||||
* 股票名称
|
||||
*/
|
||||
private String stockName;
|
||||
|
||||
/**
|
||||
* 标识名称
|
||||
*/
|
||||
private String symbolName;
|
||||
|
||||
/**
|
||||
* 目标价格
|
||||
*/
|
||||
private BigDecimal attentionPrice;
|
||||
|
||||
/**
|
||||
* 关注价格低位
|
||||
*/
|
||||
private BigDecimal targetPriceLow;
|
||||
|
||||
/**
|
||||
* 关注价格高位
|
||||
*/
|
||||
private BigDecimal targetPriceHigh;
|
||||
|
||||
/**
|
||||
* 止损价格
|
||||
*/
|
||||
private BigDecimal stopPrice;
|
||||
|
||||
|
||||
private String maximumIncrease;
|
||||
|
||||
private String maximumIncreaseSeven;
|
||||
|
||||
/**
|
||||
* 生成时间
|
||||
*/
|
||||
private String selectionTime;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.gnshyx.enums;
|
||||
|
||||
public enum GnshyxUrlEnum {
|
||||
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.gnshyx.mapper;
|
||||
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.entity.StockGnshyxRecordDataDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface StockGnshyxRecordDataMapper {
|
||||
|
||||
/**
|
||||
* 批量新增
|
||||
* @param entities
|
||||
* @return
|
||||
*/
|
||||
int batchInsertRecord(@Param("list") List<StockGnshyxRecordDataDO> entities);
|
||||
|
||||
List<StockGnshyxRecordDataDO> getList();
|
||||
|
||||
|
||||
int insert(StockGnshyxRecordDataDO entity);
|
||||
|
||||
StockGnshyxRecordDataDO getByStockCode(@Param("stockCode") String stockCode);
|
||||
|
||||
int update(StockGnshyxRecordDataDO entity);
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.gnshyx.schedule;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.basic.utils.HttpUtils;
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.common.constants.UrlConstant;
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.entity.StockGnshyxRecordDataDO;
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.entity.resp.ListLastDataResp;
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.service.ICloudRecordDataService;
|
||||
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.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Component
|
||||
public class CloudRecordDataJob {
|
||||
|
||||
private final ICloudRecordDataService cloudRecordDataService;
|
||||
|
||||
@Scheduled(cron = "0 30 9,14 * * ?")
|
||||
public void gnshyxRecordDataPullJob() {
|
||||
log.info("<<<<<gnshyx数据拉取定时任务开始>>>>>, 时间戳:{}", System.currentTimeMillis());
|
||||
|
||||
String resp = HttpUtils.doGet(UrlConstant.LAST_LIST, null, null);
|
||||
if (StringUtils.isBlank(resp)) {
|
||||
log.error("{}请求失败,响应结果为空, time:{}", UrlConstant.LAST_LIST, System.currentTimeMillis());
|
||||
return;
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(resp);
|
||||
Integer code = (Integer) jsonObject.get("code");
|
||||
if (200 == code) {
|
||||
String data = JSON.toJSONString(jsonObject.get("data"));
|
||||
log.info("查询到的数据结果:{}", data);
|
||||
List<ListLastDataResp> dataRespList = JSON.parseArray(data, ListLastDataResp.class);
|
||||
if (CollectionUtils.isNotEmpty(dataRespList)) {
|
||||
for (ListLastDataResp listLastDataResp : dataRespList) {
|
||||
StockGnshyxRecordDataDO stock = cloudRecordDataService.getByStockCode(listLastDataResp.getStockCode());
|
||||
if (Objects.nonNull(stock)) {
|
||||
stock.setSymbolName(listLastDataResp.getSymbolName());
|
||||
stock.setStockName(listLastDataResp.getStockName());
|
||||
stock.setAttentionPrice(listLastDataResp.getAttentionPrice());
|
||||
stock.setTargetPriceLow(listLastDataResp.getTargetPriceLow());
|
||||
stock.setTargetPriceHigh(listLastDataResp.getTargetPriceHigh());
|
||||
stock.setStopPrice(listLastDataResp.getStopPrice());
|
||||
stock.setStockDailySelectionId(listLastDataResp.getStockDailySelectionId());
|
||||
stock.setStockCode(listLastDataResp.getStockCode());
|
||||
stock.setSelectionTime(DateUtils.getDateTimeFromStr(listLastDataResp.getSelectionTime()));
|
||||
stock.setMaximumIncrease(listLastDataResp.getMaximumIncrease());
|
||||
stock.setMaximumIncreaseSeven(listLastDataResp.getMaximumIncreaseSeven());
|
||||
stock.setCreateTime(LocalDateTime.now());
|
||||
cloudRecordDataService.updateRecord(stock);
|
||||
} else {
|
||||
StockGnshyxRecordDataDO stockGnshyxRecordDataDO = new StockGnshyxRecordDataDO();
|
||||
stockGnshyxRecordDataDO.setSymbolName(listLastDataResp.getSymbolName());
|
||||
stockGnshyxRecordDataDO.setStockName(listLastDataResp.getStockName());
|
||||
stockGnshyxRecordDataDO.setAttentionPrice(listLastDataResp.getAttentionPrice());
|
||||
stockGnshyxRecordDataDO.setTargetPriceLow(listLastDataResp.getTargetPriceLow());
|
||||
stockGnshyxRecordDataDO.setTargetPriceHigh(listLastDataResp.getTargetPriceHigh());
|
||||
stockGnshyxRecordDataDO.setStopPrice(listLastDataResp.getStopPrice());
|
||||
stockGnshyxRecordDataDO.setStockDailySelectionId(listLastDataResp.getStockDailySelectionId());
|
||||
stockGnshyxRecordDataDO.setStockCode(listLastDataResp.getStockCode());
|
||||
stockGnshyxRecordDataDO.setSelectionTime(DateUtils.getDateTimeFromStr(listLastDataResp.getSelectionTime()));
|
||||
stockGnshyxRecordDataDO.setMaximumIncrease(listLastDataResp.getMaximumIncrease());
|
||||
stockGnshyxRecordDataDO.setMaximumIncreaseSeven(listLastDataResp.getMaximumIncreaseSeven());
|
||||
stockGnshyxRecordDataDO.setCreateTime(LocalDateTime.now());
|
||||
cloudRecordDataService.insertRecord(stockGnshyxRecordDataDO);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.gnshyx.service;
|
||||
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.entity.StockGnshyxRecordDataDO;
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.mapper.StockGnshyxRecordDataMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CloudRecordDataServiceImpl implements ICloudRecordDataService {
|
||||
private final StockGnshyxRecordDataMapper stockGnshyxRecordDataMapper;
|
||||
|
||||
@Override
|
||||
public Boolean insertRecord(StockGnshyxRecordDataDO entity) {
|
||||
return stockGnshyxRecordDataMapper.insert(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean batchInsertRecord(List<StockGnshyxRecordDataDO> list) {
|
||||
return stockGnshyxRecordDataMapper.batchInsertRecord(list) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StockGnshyxRecordDataDO> getList() {
|
||||
return stockGnshyxRecordDataMapper.getList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateRecord(StockGnshyxRecordDataDO entity) {
|
||||
return stockGnshyxRecordDataMapper.update(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StockGnshyxRecordDataDO getByStockCode(String stockCode) {
|
||||
return stockGnshyxRecordDataMapper.getByStockCode(stockCode);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.gnshyx.service;
|
||||
|
||||
import com.xiang.xservice.application.script.stock.gnshyx.entity.StockGnshyxRecordDataDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ICloudRecordDataService {
|
||||
|
||||
Boolean insertRecord(StockGnshyxRecordDataDO entity);
|
||||
|
||||
Boolean batchInsertRecord(List<StockGnshyxRecordDataDO> list);
|
||||
|
||||
List<StockGnshyxRecordDataDO> getList();
|
||||
|
||||
Boolean updateRecord(StockGnshyxRecordDataDO entity);
|
||||
|
||||
StockGnshyxRecordDataDO getByStockCode(String stockCode);
|
||||
}
|
||||
@@ -3,18 +3,18 @@ package com.xiang.xservice.application.script.xb.schedule.xb;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.xiang.xservice.basic.config.MyThreadFactory;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.cache.service.IRedisService;
|
||||
import com.xiang.xservice.common.entity.DayResult;
|
||||
import com.xiang.xservice.common.enums.RedisConstant;
|
||||
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||
import com.xiang.xmc.service.message.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.application.script.xb.entity.pojo.xb.FundMessage;
|
||||
import com.xiang.xservice.application.script.xb.entity.pojo.xb.XbFundList;
|
||||
import com.xiang.xservice.application.script.xb.entity.response.xbyj.fund.FundInfo;
|
||||
import com.xiang.xservice.application.script.xb.entity.response.xbyj.fund.FundList;
|
||||
import com.xiang.xservice.application.script.xb.repository.XBFundMapper;
|
||||
import com.xiang.xservice.application.script.xb.service.FundService;
|
||||
import com.xiang.xservice.basic.config.MyThreadFactory;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.common.entity.DayResult;
|
||||
import com.xiang.xservice.common.enums.RedisConstant;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -76,7 +76,8 @@ public class FundInfoQueryJob {
|
||||
if (DateUtils.validWeekTime()) return;
|
||||
LocalDate now = LocalDate.now();
|
||||
com.alibaba.fastjson.JSONObject dayResult = (com.alibaba.fastjson.JSONObject) redisService.hGet(RedisConstant.DAY_INFO_PREFIX_KEY + RedisConstant.getDate4Key(), DateUtils.getDateFromDate(now));
|
||||
if (com.xiang.xservice.common.utils.DateUtils.validHoliday(JSON.toJavaObject(dayResult, DayResult.class))) return;
|
||||
com.xiang.xservice.common.utils.DateUtils dateUtils = new com.xiang.xservice.common.utils.DateUtils(redisService);
|
||||
if (dateUtils.validHoliday(JSON.toJavaObject(dayResult, DayResult.class))) return;
|
||||
|
||||
List<com.xiang.xservice.application.script.xb.entity.pojo.xb.FundInfo> fundInfos = xbFundMapper.queryListIn2Min();
|
||||
if (CollectionUtils.isEmpty(fundInfos)) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.xiang.xservice.application.script.xb.service;
|
||||
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xmc.service.message.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.config.DingTalkRobotXbConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xiang.xservice.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-08 16:39
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SysConfigDO{
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private String value;
|
||||
private Integer status;
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiang.xservice.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.xiang.xservice.common.entity.SysConfigDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-12-08 17:01
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface SysConfigMapper extends BaseMapper<SysConfigDO> {
|
||||
|
||||
SysConfigDO getByName(@Param("name") String name);
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package com.xiang.xservice.common.schedule;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||
import com.xiang.xservice.basic.utils.DateUtils;
|
||||
import com.xiang.xservice.basic.utils.HttpUtils;
|
||||
import com.xiang.xservice.cache.service.IRedisService;
|
||||
import com.xiang.xservice.common.entity.DayResult;
|
||||
import com.xiang.xservice.common.enums.RedisConstant;
|
||||
import com.xiang.xservice.common.enums.UrlConstant;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,44 @@
|
||||
package com.xiang.xservice.common.utils;
|
||||
|
||||
|
||||
import com.xiang.xmc.service.cache.service.IRedisService;
|
||||
import com.xiang.xservice.common.entity.DayResult;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-10-04 10:34
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DateUtils {
|
||||
|
||||
public static Boolean validHoliday(DayResult result) {
|
||||
return com.xiang.xservice.basic.utils.DateUtils.validHolidayTime(
|
||||
result.getDate(), result.getStatusDesc(), result.getWeek(), result.getStatus());
|
||||
private IRedisService redisService;
|
||||
public Boolean validHoliday(DayResult result) {
|
||||
if (validHolidayTime(result.getDate(), result.getStatusDesc(), result.getWeek(), result.getStatus()))
|
||||
return Boolean.TRUE;
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
private Boolean validHolidayTime(String date, String statusDesc, String week, String status) {
|
||||
if (StringUtils.equals(status, "1")) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if (StringUtils.equals(status, "2")) {
|
||||
log.info("当前日期:{}, {}, 是工作日", date, week);
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
if (StringUtils.isEmpty(status)) {
|
||||
if (StringUtils.equals(week, "周六") || StringUtils.equals(week, "周日")) {
|
||||
log.info("当前日期:{}, {}, 是周末", date, week);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.xiang.xservice.config;
|
||||
|
||||
import org.apache.log4j.MDC;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-11-12 17:03
|
||||
*/
|
||||
@Component
|
||||
public class TraceIdFilter implements Filter {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
try {
|
||||
// 从请求头中获取 traceId,如果没有则新建一个
|
||||
String traceId = ((HttpServletRequest) request).getHeader("traceId");
|
||||
if (traceId == null || traceId.isEmpty()) {
|
||||
traceId = UUID.randomUUID().toString().replace("-", "");
|
||||
}
|
||||
|
||||
MDC.put("traceId", traceId);
|
||||
chain.doFilter(request, response);
|
||||
} finally {
|
||||
MDC.remove("traceId");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,16 +12,16 @@ spring:
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://rm-bp15t34gqx62jm069ro.mysql.rds.aliyuncs.com:3306/xservice-script-test?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
url: jdbc:mysql://120.27.153.87:3306/xservice-script-test?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: root
|
||||
password: xb#UWqnhH24&XpX
|
||||
password: sdkljfikdfn@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
|
||||
database: 10
|
||||
timeout: 5000
|
||||
lettuce:
|
||||
pool:
|
||||
@@ -51,3 +51,8 @@ dingtalk:
|
||||
secret: SECc09d8aad6635f1a4cbadb7c0ab365523c46299f138438cd885e445e0f5f4d730
|
||||
users:
|
||||
- 450841600726084717
|
||||
venue:
|
||||
token: 6a218646972c684c75832b0229ea93a234778af537d7469ce96bef290faf530e
|
||||
secret: SEC9018755ba86d3e5c1ed2fbfa1d6953d84bb2a6c8ebe7ed4e318457bfed5e0465
|
||||
users:
|
||||
- 450841600726084717
|
||||
@@ -12,15 +12,15 @@ spring:
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://192.168.2.10:3306/xservice-script?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: root
|
||||
password: Admin@123
|
||||
url: jdbc:mysql://rm-bp15t34gqx62jm069ro.mysql.rds.aliyuncs.com:3306/xservice-script?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: xservice
|
||||
password: xb#UWqnhH24&XpX
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
sshConnect: false
|
||||
redis:
|
||||
host: 192.168.2.10
|
||||
host: r-bp1wt59a6nfyt4e3ltpd.redis.rds.aliyuncs.com
|
||||
port: 6379
|
||||
password: Admin@123 # 如果无密码可以省略
|
||||
password: Xiang0000 # 如果无密码可以省略
|
||||
database: 0
|
||||
timeout: 5000
|
||||
lettuce:
|
||||
@@ -53,3 +53,8 @@ dingtalk:
|
||||
secret: SECe10ade3058880b84df5c6f46ab072c11f4ac2a5ef9f134d684705c2a3b004de2
|
||||
users:
|
||||
- 450841600726084717
|
||||
venue:
|
||||
token: 6a218646972c684c75832b0229ea93a234778af537d7469ce96bef290faf530e
|
||||
secret: SEC9018755ba86d3e5c1ed2fbfa1d6953d84bb2a6c8ebe7ed4e318457bfed5e0465
|
||||
users:
|
||||
- 450841600726084717
|
||||
@@ -12,16 +12,16 @@ spring:
|
||||
primary: master
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://rm-bp15t34gqx62jm069ro.mysql.rds.aliyuncs.com:3306/xservice-script-test?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
url: jdbc:mysql://120.27.153.87:3306/xservice-script-test?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true
|
||||
username: root
|
||||
password: xb#UWqnhH24&XpX
|
||||
password: sdkljfikdfn@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
|
||||
database: 10
|
||||
timeout: 5000
|
||||
lettuce:
|
||||
pool:
|
||||
|
||||
@@ -16,7 +16,7 @@ server:
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
active: test
|
||||
active: local
|
||||
application:
|
||||
name: xservice-script-center
|
||||
main:
|
||||
|
||||
29
script/src/main/resources/mapper/SysConfigMapper.xml
Normal file
29
script/src/main/resources/mapper/SysConfigMapper.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xiang.xservice.common.mapper.SysConfigMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.xiang.xservice.common.entity.SysConfigDO" >
|
||||
<result column="id" property="id"/>
|
||||
<result column="name" property="name" />
|
||||
<result column="value" property="value" />
|
||||
<result column="status" property="status" />
|
||||
<result column="create_time" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_sql">
|
||||
id,
|
||||
name,
|
||||
value,
|
||||
status,
|
||||
create_time
|
||||
</sql>
|
||||
|
||||
<select id="getByName" resultMap="BaseResultMap" parameterType="String">
|
||||
select <include refid="Base_sql"/>
|
||||
from sys_config
|
||||
where name = #{name} and status = 1
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,183 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xiang.xservice.application.script.stock.gnshyx.mapper.StockGnshyxRecordDataMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.xiang.xservice.application.script.stock.gnshyx.entity.StockGnshyxRecordDataDO" >
|
||||
<result column="id" property="id" />
|
||||
<result column="symbol_name" property="symbolName" />
|
||||
<result column="stock_name" property="stockName" />
|
||||
<result column="attention_price" property="attentionPrice" />
|
||||
<result column="target_price_low" property="targetPriceLow" />
|
||||
<result column="target_price_high" property="targetPriceHigh" />
|
||||
<result column="stop_price" property="stopPrice" />
|
||||
<result column="stock_daily_selection_id" property="stockDailySelectionId" />
|
||||
<result column="stock_code" property="stockCode" />
|
||||
<result column="selection_time" property="selectionTime" />
|
||||
<result column="maximum_increase" property="maximumIncrease" />
|
||||
<result column="maximum_increase_seven" property="maximumIncreaseSeven" />
|
||||
<result column="create_time" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,
|
||||
symbol_name,
|
||||
stock_name,
|
||||
attention_price,
|
||||
target_price_low,
|
||||
target_price_high,
|
||||
stop_price,
|
||||
stock_daily_selection_id,
|
||||
stock_code,
|
||||
selection_time,
|
||||
maximum_increase,
|
||||
maximum_increase_seven,
|
||||
create_time
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.xiang.xservice.application.script.stock.gnshyx.entity.StockGnshyxRecordDataDO">
|
||||
INSERT INTO stock_gnshyx_record_data
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="null != symbolName and '' != symbolName">
|
||||
symbol_name,
|
||||
</if>
|
||||
<if test="null != stockName and '' != stockName">
|
||||
stock_name,
|
||||
</if>
|
||||
<if test="null != attentionPrice ">
|
||||
attention_price,
|
||||
</if>
|
||||
<if test="null != targetPriceLow ">
|
||||
target_price_low,
|
||||
</if>
|
||||
<if test="null != targetPriceHigh ">
|
||||
target_price_high,
|
||||
</if>
|
||||
<if test="null != stopPrice ">
|
||||
stop_price,
|
||||
</if>
|
||||
<if test="null != stockDailySelectionId ">
|
||||
stock_daily_selection_id,
|
||||
</if>
|
||||
<if test="null != stockCode and '' != stockCode">
|
||||
stock_code,
|
||||
</if>
|
||||
<if test="null != selectionTime ">
|
||||
selection_time,
|
||||
</if>
|
||||
<if test="null != maximumIncrease and '' != maximumIncrease">
|
||||
maximum_increase,
|
||||
</if>
|
||||
<if test="null != maximumIncreaseSeven and '' != maximumIncreaseSeven">
|
||||
maximum_increase_seven,
|
||||
</if>
|
||||
<if test="null != createTime ">
|
||||
create_time
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="null != symbolName and '' != symbolName">
|
||||
#{symbolName},
|
||||
</if>
|
||||
<if test="null != stockName and '' != stockName">
|
||||
#{stockName},
|
||||
</if>
|
||||
<if test="null != attentionPrice ">
|
||||
#{attentionPrice},
|
||||
</if>
|
||||
<if test="null != targetPriceLow ">
|
||||
#{targetPriceLow},
|
||||
</if>
|
||||
<if test="null != targetPriceHigh ">
|
||||
#{targetPriceHigh},
|
||||
</if>
|
||||
<if test="null != stopPrice ">
|
||||
#{stopPrice},
|
||||
</if>
|
||||
<if test="null != stockDailySelectionId ">
|
||||
#{stockDailySelectionId},
|
||||
</if>
|
||||
<if test="null != stockCode and '' != stockCode">
|
||||
#{stockCode},
|
||||
</if>
|
||||
<if test="null != selectionTime ">
|
||||
#{selectionTime},
|
||||
</if>
|
||||
<if test="null != maximumIncrease and '' != maximumIncrease">
|
||||
#{maximumIncrease},
|
||||
</if>
|
||||
<if test="null != maximumIncreaseSeven and '' != maximumIncreaseSeven">
|
||||
#{maximumIncreaseSeven},
|
||||
</if>
|
||||
<if test="null != createTime ">
|
||||
#{createTime}
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="batchInsertRecord">
|
||||
insert into stock_gnshyx_record_data(symbol_name,
|
||||
stock_name,
|
||||
attention_price,
|
||||
target_price_low,
|
||||
target_price_high,
|
||||
stop_price,
|
||||
stock_daily_selection_id,
|
||||
stock_code,
|
||||
selection_time,
|
||||
maximum_increase,
|
||||
maximum_increase_seven,
|
||||
create_time)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.symbolName},
|
||||
#{item.stockName},
|
||||
#{item.attentionPrice},
|
||||
#{item.targetPriceLow},
|
||||
#{item.targetPriceHigh},
|
||||
#{item.stopPrice},
|
||||
#{item.stockDailySelectionId},
|
||||
#{item.stockCode},
|
||||
#{item.selectionTime},
|
||||
#{item.maximumIncrease},
|
||||
#{item.maximumIncreaseSeven},
|
||||
#{item.createTime}
|
||||
)
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
|
||||
<delete id="delete" >
|
||||
DELETE FROM stock_gnshyx_record_data
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
<select id="getList" resultMap="BaseResultMap">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from stock_gnshyx_record_data where 1=1
|
||||
</select>
|
||||
<select id="getByStockCode" resultMap="BaseResultMap">
|
||||
select <include refid="Base_Column_List"/>
|
||||
from stock_gnshyx_record_data where stock_code = #{stockCode}
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="com.xiang.xservice.application.script.stock.gnshyx.entity.StockGnshyxRecordDataDO">
|
||||
UPDATE stock_gnshyx_record_data
|
||||
<set>
|
||||
<if test="null != symbolName and '' != symbolName">symbol_name = #{symbolName},</if>
|
||||
<if test="null != stockName and '' != stockName">stock_name = #{stockName},</if>
|
||||
<if test="null != attentionPrice ">attention_price = #{attentionPrice},</if>
|
||||
<if test="null != targetPriceLow ">target_price_low = #{targetPriceLow},</if>
|
||||
<if test="null != targetPriceHigh ">target_price_high = #{targetPriceHigh},</if>
|
||||
<if test="null != stopPrice ">stop_price = #{stopPrice},</if>
|
||||
<if test="null != stockDailySelectionId ">stock_daily_selection_id = #{stockDailySelectionId},</if>
|
||||
<if test="null != stockCode and '' != stockCode">stock_code = #{stockCode},</if>
|
||||
<if test="null != selectionTime ">selection_time = #{selectionTime},</if>
|
||||
<if test="null != maximumIncrease and '' != maximumIncrease">maximum_increase = #{maximumIncrease},</if>
|
||||
<if test="null != maximumIncreaseSeven and '' != maximumIncreaseSeven">maximum_increase_seven = #{maximumIncreaseSeven},</if>
|
||||
<if test="null != createTime ">create_time = #{createTime}</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -1,126 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xiang.xservice.application.script.stock.data.mapper.StockSinaDataRecordPullMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.xiang.xservice.application.script.stock.data.entity.StockSinaDataRecordDO" >
|
||||
<result column="id" property="id" />
|
||||
<result column="name" property="name" />
|
||||
<result column="jk_price" property="jkPrice" />
|
||||
<result column="zs_price" property="zsPrice" />
|
||||
<result column="xj_price" property="xjPrice" />
|
||||
<result column="zg_price" property="zgPrice" />
|
||||
<result column="zd_price" property="zdPrice" />
|
||||
<result column="zs_num" property="zsNum" />
|
||||
<result column="price" property="price" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,
|
||||
name,
|
||||
jk_price,
|
||||
zs_price,
|
||||
xj_price,
|
||||
zg_price,
|
||||
zd_price,
|
||||
zs_num,
|
||||
price,
|
||||
update_time
|
||||
</sql>
|
||||
|
||||
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.xiang.xservice.application.script.stock.data.entity.StockSinaDataRecordDO">
|
||||
INSERT INTO stock_sina_record_data
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="null != name and '' != name">
|
||||
name,
|
||||
</if>
|
||||
<if test="null != jkPrice ">
|
||||
jk_price,
|
||||
</if>
|
||||
<if test="null != zsPrice ">
|
||||
zs_price,
|
||||
</if>
|
||||
<if test="null != xjPrice ">
|
||||
xj_price,
|
||||
</if>
|
||||
<if test="null != zgPrice ">
|
||||
zg_price,
|
||||
</if>
|
||||
<if test="null != zdPrice ">
|
||||
zd_price,
|
||||
</if>
|
||||
<if test="null != zsNum and '' != zsNum">
|
||||
zs_num,
|
||||
</if>
|
||||
<if test="null != price ">
|
||||
price,
|
||||
</if>
|
||||
<if test="null != updateTime ">
|
||||
update_time
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="null != name and '' != name">
|
||||
#{name},
|
||||
</if>
|
||||
<if test="null != jkPrice ">
|
||||
#{jkPrice},
|
||||
</if>
|
||||
<if test="null != zsPrice ">
|
||||
#{zsPrice},
|
||||
</if>
|
||||
<if test="null != xjPrice ">
|
||||
#{xjPrice},
|
||||
</if>
|
||||
<if test="null != zgPrice ">
|
||||
#{zgPrice},
|
||||
</if>
|
||||
<if test="null != zdPrice ">
|
||||
#{zdPrice},
|
||||
</if>
|
||||
<if test="null != zsNum and '' != zsNum">
|
||||
#{zsNum},
|
||||
</if>
|
||||
<if test="null != price ">
|
||||
#{price},
|
||||
</if>
|
||||
<if test="null != updateTime ">
|
||||
#{updateTime}
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="batchInsert">
|
||||
INSERT INTO stock_sina_record_data
|
||||
(name, jk_price, zs_price, xj_price, zg_price, zd_price, zs_num, price, update_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.name}, #{item.jkPrice}, #{item.zsPrice}, #{item.xjPrice},
|
||||
#{item.zgPrice}, #{item.zdPrice}, #{item.zsNum}, #{item.price}, #{item.updateTime})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="delete" >
|
||||
DELETE FROM stock_sina_record_data
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="update" parameterType="com.xiang.xservice.application.script.stock.data.entity.StockSinaDataRecordDO">
|
||||
UPDATE stock_sina_record_data
|
||||
<set>
|
||||
<if test="null != name and '' != name">name = #{name},</if>
|
||||
<if test="null != jkPrice ">jk_price = #{jkPrice},</if>
|
||||
<if test="null != zsPrice ">zs_price = #{zsPrice},</if>
|
||||
<if test="null != xjPrice ">xj_price = #{xjPrice},</if>
|
||||
<if test="null != zgPrice ">zg_price = #{zgPrice},</if>
|
||||
<if test="null != zdPrice ">zd_price = #{zdPrice},</if>
|
||||
<if test="null != zsNum and '' != zsNum">zs_num = #{zsNum},</if>
|
||||
<if test="null != price ">price = #{price},</if>
|
||||
<if test="null != updateTime ">update_time = #{updateTime}</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user