diff --git a/script/src/main/java/com/xiang/xservice/application/script/stock/data/schedule/DataMsgSendJob.java b/script/src/main/java/com/xiang/xservice/application/script/stock/data/schedule/DataMsgSendJob.java index 065683a..5f9aa94 100644 --- a/script/src/main/java/com/xiang/xservice/application/script/stock/data/schedule/DataMsgSendJob.java +++ b/script/src/main/java/com/xiang/xservice/application/script/stock/data/schedule/DataMsgSendJob.java @@ -2,14 +2,14 @@ package com.xiang.xservice.application.script.stock.data.schedule; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.xiang.xservice.basic.utils.DateUtils; -import com.xiang.xservice.cache.service.IRedisService; 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; @@ -36,8 +36,45 @@ public class DataMsgSendJob { 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 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 stockGetTargetMsgSend() { + 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));