Merge remote-tracking branch 'origin/retifive' into retifive

This commit is contained in:
Achilles
2024-04-22 15:18:40 +08:00
4 changed files with 33 additions and 20 deletions

View File

@@ -30,12 +30,12 @@ public class RetifiveStockInfo {
private String stockType;
@ApiModelProperty("当前价格")
private String currentPrice;
private String lastPrice;
@ApiModelProperty("变动百分比")
private String changePercent;
private String perchg;
@ApiModelProperty("变动值")
private String changeValue;
private String change;
@ApiModelProperty("开盘价格")
private String openPrice;

View File

@@ -127,10 +127,10 @@ public class RefinitivUtil {
}
return RetifiveStockInfo.builder()
.stockCode(stockCode).stockName(stockName).symbol(name).status(status)
.openPrice(openPrice).currentPrice(price).highPrice(high).lowPrice(low)
.previousPrice(previousPrice).changePercent(percentChange).volume(volume)
.openPrice(openPrice).lastPrice(price).highPrice(high).lowPrice(low)
.previousPrice(previousPrice).perchg(percentChange).volume(volume)
.week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType)
.changeValue(changeValue)
.change(changeValue)
.build();
}
@@ -257,8 +257,8 @@ public class RefinitivUtil {
}
}
RetifiveStockInfo retifiveStockInfo = RetifiveStockInfo.builder().stockCode(stockCode).stockName(stockName).symbol(name).status(status)
.openPrice(openPrice).currentPrice(price).highPrice(high).lowPrice(low).previousPrice(previousPrice).changePercent(percentChange)
.volume(volume).week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType).changeValue(changeValue)
.openPrice(openPrice).lastPrice(price).highPrice(high).lowPrice(low).previousPrice(previousPrice).perchg(percentChange)
.volume(volume).week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType).change(changeValue)
.build();
return retifiveStockInfo;

View File

@@ -3,19 +3,15 @@ package cn.stock.market.web;
import cn.stock.market.domain.basic.entity.RetifiveStock;
import cn.stock.market.domain.basic.service.RetifiveStockService;
import cn.stock.market.dto.RetifiveStockInfo;
import cn.stock.market.infrastructure.db.po.RetifiveStockPO;
import cn.stock.market.listener.AppClient;
import cn.stock.market.listener.ConcurrentAppClient;
import cn.stock.market.listener.StockInfoRefinitiv;
import cn.stock.market.listener.SymbolRefinitiv;
import cn.stock.market.utils.ServerResponse;
import com.google.common.collect.Lists;
import com.thomsonreuters.ema.access.Data;
import com.thomsonreuters.ema.access.DataType;
import com.thomsonreuters.ema.access.FieldEntry;
import com.thomsonreuters.ema.access.FieldList;
import com.thomsonreuters.ema.access.Map;
import com.thomsonreuters.ema.access.MapEntry;
import com.thomsonreuters.ema.access.RefreshMsg;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -27,14 +23,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -661,8 +652,8 @@ public class MessageRetifiveController {
}
}
RetifiveStockInfo retifiveStockInfo = RetifiveStockInfo.builder().stockCode(stockCode).stockName(stockName).symbol(name).status(status)
.openPrice(openPrice).currentPrice(price).highPrice(high).lowPrice(low).previousPrice(previousPrice).changePercent(percentChange)
.volume(volume).week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType).changeValue(changeValue)
.openPrice(openPrice).lastPrice(price).highPrice(high).lowPrice(low).previousPrice(previousPrice).perchg(percentChange)
.volume(volume).week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType).change(changeValue)
.build();
return retifiveStockInfo;

View File

@@ -1,5 +1,8 @@
package cn.stock.market.web;
import cn.hutool.core.util.StrUtil;
import cn.stock.market.domain.basic.entity.RetifiveStock;
import cn.stock.market.domain.basic.service.RetifiveStockService;
import cn.stock.market.dto.RetifiveStockInfo;
import cn.stock.market.listener.AppClient;
import cn.stock.market.utils.RefinitivUtil;
@@ -13,12 +16,14 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -34,19 +39,25 @@ public class RefinitivApiController {
@Resource
private AppClient appClient;
@Autowired
private RetifiveStockService retifiveStockService;
@ApiOperation(value = "股票详情信息", httpMethod = "GET", response = RetifiveStockInfo.class)
@ApiImplicitParams({@ApiImplicitParam(name = "symbol", value = "symbol值")})
@GetMapping("/getStockDetail")
@EncryptFilter(decryptRequest = false)
public ServerResponse<?> getStockDetail(String symbol) {
// 计算每个线程应处理的元素数量
try {
appClient.subscribe(symbol);
// 等待消息, 设置超时时间例如10秒
RefreshMsg refreshMsg = appClient.getMessageFuture().get(10, TimeUnit.SECONDS);
if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()) {
RetifiveStockInfo retifiveStockInfo = RefinitivUtil.decodeData(refreshMsg.payload().fieldList(), refreshMsg.name());
//获取股票id
RetifiveStock stock = retifiveStockService.repository().findBtStockByCoCode(symbol);
if(stock != null){
retifiveStockInfo.setId(stock.getId());
}
return ServerResponse.createBySuccess("操作成功", retifiveStockInfo);
}
} catch (Exception e) {
@@ -85,6 +96,10 @@ public class RefinitivApiController {
@GetMapping("/getTopActives")
@EncryptFilter(decryptRequest = false)
public ServerResponse<?> getTopActives(@RequestParam String stockType) {
if (StrUtil.equalsIgnoreCase(stockType, "nse")) {
return ServerResponse.createBySuccess("操作成功", new ArrayList<>());
}
String name = ".AV.BO";
List<RetifiveStockInfo> list = Lists.newArrayList();
try {
@@ -111,6 +126,9 @@ public class RefinitivApiController {
@GetMapping("/getTopGainers")
@EncryptFilter(decryptRequest = false)
public ServerResponse<?> getTopGainers(@RequestParam String stockType) {
if (StrUtil.equalsIgnoreCase(stockType, "nse")) {
return ServerResponse.createBySuccess("操作成功", new ArrayList<>());
}
String name = ".PG.BO";
List<RetifiveStockInfo> list = Lists.newArrayList();
try {
@@ -137,6 +155,10 @@ public class RefinitivApiController {
@GetMapping("/getTopLosers")
@EncryptFilter(decryptRequest = false)
public ServerResponse<?> getTopLosers(@RequestParam String stockType) {
if (StrUtil.equalsIgnoreCase(stockType, "nse")) {
return ServerResponse.createBySuccess("操作成功", new ArrayList<>());
}
String name = ".PL.BO";
List<RetifiveStockInfo> list = Lists.newArrayList();
try {