Merge remote-tracking branch 'origin/perf/script_app_perf_1208'
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -27,6 +27,11 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.xiang.pom</groupId>
|
||||
<artifactId>xmc-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xiang</groupId>
|
||||
<artifactId>xservice-common</artifactId>
|
||||
|
||||
@@ -16,8 +16,7 @@ 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",
|
||||
})
|
||||
@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 {
|
||||
|
||||
@@ -23,6 +23,8 @@ 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.common.entity.SysConfigDO;
|
||||
import com.xiang.xservice.common.mapper.SysConfigMapper;
|
||||
import com.xiang.xservice.schedule.core.DynamicTaskScheduler;
|
||||
import com.xiang.xservice.schedule.entity.ScheduledTaskEntity;
|
||||
import com.xiang.xservice.schedule.entity.TaskConfig;
|
||||
@@ -33,6 +35,7 @@ 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());
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,32 +0,0 @@
|
||||
package com.xiang.xservice.application.script.stock.data.service;
|
||||
|
||||
import com.xiang.xservice.basic.xservice.dingTalk.service.DingTalkService;
|
||||
import com.xiang.xservice.config.DingTalkRobotXbConfig;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author: xiang
|
||||
* @Date: 2025-08-07 10:30
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DingTalkScriptStockService {
|
||||
|
||||
private final DingTalkService dingTalkService;
|
||||
private final DingTalkRobotXbConfig dingTalkRobotXbConfig;
|
||||
|
||||
/**
|
||||
* 发送脚本消息
|
||||
* @param msg 消息
|
||||
*/
|
||||
public void sendScriptMsg(String msg) {
|
||||
try {
|
||||
dingTalkService.sendRobotMessage(dingTalkRobotXbConfig.getSecret(), dingTalkRobotXbConfig.getToken(), dingTalkRobotXbConfig.getUsers(), msg);
|
||||
} catch (Exception e) {
|
||||
log.error("信息发送异常, 信息:{}", msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -1,16 +1,44 @@
|
||||
package com.xiang.xservice.common.utils;
|
||||
|
||||
|
||||
import com.xiang.xservice.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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
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