Compare commits
39 Commits
feature/up
...
us-gold
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67abfba918 | ||
|
|
2b1a07e2b7 | ||
|
|
5055704078 | ||
| 7deabedfa3 | |||
|
|
721317de0a | ||
|
|
88bfdfa7fa | ||
|
|
51bcd72051 | ||
|
|
769b35046e | ||
|
|
368f4f2f9f | ||
|
|
4053683339 | ||
|
|
9fd87aaf89 | ||
|
|
ccda6cba45 | ||
|
|
22303b5460 | ||
|
|
992108c6e4 | ||
|
|
a086f33541 | ||
|
|
d864aee7e1 | ||
|
|
fc74d7c33f | ||
|
|
309516c40b | ||
|
|
20875fbead | ||
|
|
2e6474035b | ||
|
|
4db963b0e5 | ||
|
|
401983255a | ||
|
|
2d36e8264f | ||
|
|
580d4321bb | ||
|
|
6f2c8652e2 | ||
|
|
e423e3fc19 | ||
|
|
d237c51176 | ||
|
|
97bc0ea694 | ||
|
|
8ef7b46038 | ||
|
|
9785a391a2 | ||
|
|
5b3504f32a | ||
|
|
f67af0d3e9 | ||
|
|
af21d583d9 | ||
|
|
cd06493b9c | ||
|
|
3255012fba | ||
|
|
476645109d | ||
|
|
66eccce4cb | ||
|
|
5ab279daa6 | ||
|
|
be24a57d2d |
@@ -4,12 +4,19 @@ stages:
|
|||||||
- dockerize
|
- dockerize
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
|
variables:
|
||||||
|
company_name: juyoutech
|
||||||
|
project_name: germany_stock
|
||||||
|
service_name: market
|
||||||
|
|
||||||
build:
|
build:
|
||||||
image: maven:3.6.3-openjdk-8
|
image: maven:3.6.3-openjdk-8
|
||||||
stage: build
|
stage: build
|
||||||
only:
|
only:
|
||||||
- main
|
- main
|
||||||
- develop
|
- develop
|
||||||
|
- develop_red
|
||||||
|
- us-gold
|
||||||
before_script:
|
before_script:
|
||||||
- echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
- echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
@@ -47,33 +54,37 @@ dockerize:
|
|||||||
only:
|
only:
|
||||||
- main
|
- main
|
||||||
- develop
|
- develop
|
||||||
|
- develop_red
|
||||||
|
- us-gold
|
||||||
script:
|
script:
|
||||||
- echo ">>>>>>Start Building Image<<<<<<"
|
- echo ">>>>>>Start Building Docker Image<<<<<<"
|
||||||
- ls
|
- pwd
|
||||||
- ls target
|
- ls -lah
|
||||||
- echo $DOCKER_PASSWORD
|
- echo $DOCKER_PASSWORD | docker login -u ${company_name} --password-stdin
|
||||||
- echo $CI_PIPELINE_ID
|
- docker build -t ${company_name}/${project_name}_${service_name} .
|
||||||
- docker build -t juyoutech/india_stock_market:latest .
|
|
||||||
- docker tag juyoutech/india_stock_market:latest juyoutech/india_stock_market:$CI_PIPELINE_ID
|
- docker push ${company_name}/${project_name}_${service_name}
|
||||||
- docker tag juyoutech/india_stock_market:latest juyoutech/india_stock_market:$CI_COMMIT_BRANCH
|
|
||||||
- docker login -u juyoutech -p dckr_pat_8rg23IBA2kZMOCX4IJKApb8m5l8
|
- docker tag ${company_name}/${project_name}_${service_name} ${company_name}/${project_name}_${service_name}:$CI_PIPELINE_ID
|
||||||
- docker push juyoutech/india_stock_market:latest
|
- docker push ${company_name}/${project_name}_${service_name}:$CI_PIPELINE_ID
|
||||||
- docker push juyoutech/india_stock_market:$CI_PIPELINE_ID
|
|
||||||
- docker push juyoutech/india_stock_market:$CI_COMMIT_BRANCH
|
- docker tag ${company_name}/${project_name}_${service_name} ${company_name}/${project_name}_${service_name}:$CI_COMMIT_BRANCH
|
||||||
|
- docker push ${company_name}/${project_name}_${service_name}:$CI_COMMIT_BRANCH
|
||||||
|
|
||||||
|
- echo ${company_name}/${project_name}_${service_name}:$CI_COMMIT_BRANCH
|
||||||
|
|
||||||
deploy-dev:
|
deploy-dev:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
only:
|
only:
|
||||||
- develop
|
- develop_red
|
||||||
script:
|
script:
|
||||||
- echo "Deploying application..."
|
- echo "Deploying application..."
|
||||||
- ls
|
- ls
|
||||||
- apk update
|
- apk update
|
||||||
- apk add curl
|
- apk add curl
|
||||||
|
- apk add curl openssh sshpass
|
||||||
- |
|
- |
|
||||||
curl -X POST \
|
sshpass -p "$SSH_PASS" ssh -o StrictHostKeyChecking=no ubuntu@"$SSH_HOST" "./deploy_service.sh market $CI_PIPELINE_ID"
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d '{"namespace":"yddev", "deployment_name":"india-stock-market"}' \
|
|
||||||
https://updater-yddev.moneytj.com/restart-deployment
|
|
||||||
- echo "Application successfully deployed."
|
- echo "Application successfully deployed."
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
11
pom.xml
11
pom.xml
@@ -82,13 +82,22 @@
|
|||||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||||
<version>3.13.3</version>
|
<version>3.13.3</version>
|
||||||
</dependency>-->
|
</dependency>-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
<artifactId>pagehelper</artifactId>
|
<artifactId>pagehelper</artifactId>
|
||||||
<version>4.1.0</version>
|
<version>4.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
<version>20240303</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ public class QMoneyStockPO extends EntityPathBase<MoneyStockPO> {
|
|||||||
|
|
||||||
public final StringPath moneyScId = createString("moneyScId");
|
public final StringPath moneyScId = createString("moneyScId");
|
||||||
|
|
||||||
|
public final StringPath nseIndiaChartId = createString("nseIndiaChartId");
|
||||||
|
|
||||||
|
public final StringPath nseIndiaId = createString("nseIndiaId");
|
||||||
|
|
||||||
public final DateTimePath<java.util.Date> saveTime = createDateTime("saveTime", java.util.Date.class);
|
public final DateTimePath<java.util.Date> saveTime = createDateTime("saveTime", java.util.Date.class);
|
||||||
|
|
||||||
public final StringPath selfDispId = createString("selfDispId");
|
public final StringPath selfDispId = createString("selfDispId");
|
||||||
@@ -39,6 +43,8 @@ public class QMoneyStockPO extends EntityPathBase<MoneyStockPO> {
|
|||||||
|
|
||||||
public final StringPath stockType = createString("stockType");
|
public final StringPath stockType = createString("stockType");
|
||||||
|
|
||||||
|
public final BooleanPath useFromBseindia = createBoolean("useFromBseindia");
|
||||||
|
|
||||||
public QMoneyStockPO(String variable) {
|
public QMoneyStockPO(String variable) {
|
||||||
super(MoneyStockPO.class, forVariable(variable));
|
super(MoneyStockPO.class, forVariable(variable));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public class QStockIpoPO extends EntityPathBase<StockIpoPO> {
|
|||||||
|
|
||||||
public final DateTimePath<java.util.Date> createDate = createDateTime("createDate", java.util.Date.class);
|
public final DateTimePath<java.util.Date> createDate = createDateTime("createDate", java.util.Date.class);
|
||||||
|
|
||||||
|
public final StringPath exchangeType = createString("exchangeType");
|
||||||
|
|
||||||
public final NumberPath<Integer> id = createNumber("id", Integer.class);
|
public final NumberPath<Integer> id = createNumber("id", Integer.class);
|
||||||
|
|
||||||
public final NumberPath<Integer> isList = createNumber("isList", Integer.class);
|
public final NumberPath<Integer> isList = createNumber("isList", Integer.class);
|
||||||
@@ -38,7 +40,6 @@ public class QStockIpoPO extends EntityPathBase<StockIpoPO> {
|
|||||||
public final StringPath stockCode = createString("stockCode");
|
public final StringPath stockCode = createString("stockCode");
|
||||||
|
|
||||||
public final StringPath stockName = createString("stockName");
|
public final StringPath stockName = createString("stockName");
|
||||||
public final StringPath exchangeType = createString("exchangeType");
|
|
||||||
|
|
||||||
public final NumberPath<java.math.BigDecimal> stockPrice = createNumber("stockPrice", java.math.BigDecimal.class);
|
public final NumberPath<java.math.BigDecimal> stockPrice = createNumber("stockPrice", java.math.BigDecimal.class);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package cn.stock.market.infrastructure.db.po;
|
||||||
|
|
||||||
|
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||||
|
|
||||||
|
import com.querydsl.core.types.dsl.*;
|
||||||
|
|
||||||
|
import com.querydsl.core.types.PathMetadata;
|
||||||
|
import javax.annotation.Generated;
|
||||||
|
import com.querydsl.core.types.Path;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QStockTempPO is a Querydsl query type for StockTempPO
|
||||||
|
*/
|
||||||
|
@Generated("com.querydsl.codegen.EntitySerializer")
|
||||||
|
public class QStockTempPO extends EntityPathBase<StockTempPO> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1973569078L;
|
||||||
|
|
||||||
|
public static final QStockTempPO stockTempPO = new QStockTempPO("stockTempPO");
|
||||||
|
|
||||||
|
public final NumberPath<Integer> id = createNumber("id", Integer.class);
|
||||||
|
|
||||||
|
public final StringPath stockGid = createString("stockGid");
|
||||||
|
|
||||||
|
public final StringPath stockLogo = createString("stockLogo");
|
||||||
|
|
||||||
|
public final StringPath stockType = createString("stockType");
|
||||||
|
|
||||||
|
public QStockTempPO(String variable) {
|
||||||
|
super(StockTempPO.class, forVariable(variable));
|
||||||
|
}
|
||||||
|
|
||||||
|
public QStockTempPO(Path<? extends StockTempPO> path) {
|
||||||
|
super(path.getType(), path.getMetadata());
|
||||||
|
}
|
||||||
|
|
||||||
|
public QStockTempPO(PathMetadata metadata) {
|
||||||
|
super(StockTempPO.class, metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package cn.stock.market.domain.basic.convert;
|
||||||
|
|
||||||
|
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
|
||||||
|
import cn.qutaojing.common.utils.SpringUtils;
|
||||||
|
import cn.stock.market.domain.basic.entity.Stock;
|
||||||
|
import cn.stock.market.domain.basic.entity.StockTemp;
|
||||||
|
import cn.stock.market.infrastructure.db.po.StockPO;
|
||||||
|
import cn.stock.market.infrastructure.db.po.StockTempPO;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StockConvert
|
||||||
|
*
|
||||||
|
* @author rplees
|
||||||
|
* @email rplees.i.ly@gmail.com
|
||||||
|
* @created 2023/06/17
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Lazy
|
||||||
|
public class StockTempConvert extends SimpleEntityPOConvert<StockTemp, StockTempPO> {
|
||||||
|
public static StockTempConvert of() {
|
||||||
|
return SpringUtils.getBean(StockTempConvert.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package cn.stock.market.domain.basic.entity;
|
||||||
|
|
||||||
|
import cn.qutaojing.common.utils.Beans;
|
||||||
|
import cn.stock.market.dto.command.StockCreateCommand;
|
||||||
|
import cn.stock.market.infrastructure.db.po.StockPO;
|
||||||
|
import cn.stock.market.infrastructure.db.po.StockTempPO;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stock
|
||||||
|
*
|
||||||
|
* @author rplees
|
||||||
|
* @email rplees.i.ly@gmail.com
|
||||||
|
* @created 2023/06/17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
@EqualsAndHashCode(
|
||||||
|
callSuper = false
|
||||||
|
)
|
||||||
|
public class StockTemp extends StockTempPO {
|
||||||
|
}
|
||||||
@@ -54,6 +54,11 @@ public class StockRepository extends LocalCacheRepository<Stock, StockPO, Intege
|
|||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Stock> cacheGidMap() {
|
||||||
|
Map<String, Stock> map = cacheList().stream().collect(Collectors.toMap(Stock::getStockGid, val -> val, (u, v) -> u));
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, Stock> cacheNameMap() {
|
public Map<String, Stock> cacheNameMap() {
|
||||||
Map<String, Stock> map = cacheList()
|
Map<String, Stock> map = cacheList()
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package cn.stock.market.domain.basic.repository;
|
||||||
|
|
||||||
|
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
|
||||||
|
import cn.qutaojing.common.domain.respostory.LocalCacheBean;
|
||||||
|
import cn.qutaojing.common.domain.respostory.LocalCacheRepository;
|
||||||
|
import cn.qutaojing.common.jpa.ConditionBuilder;
|
||||||
|
import cn.qutaojing.common.utils.SpringUtils;
|
||||||
|
import cn.stock.market.domain.basic.convert.StockConvert;
|
||||||
|
import cn.stock.market.domain.basic.convert.StockTempConvert;
|
||||||
|
import cn.stock.market.domain.basic.entity.Stock;
|
||||||
|
import cn.stock.market.domain.basic.entity.StockTemp;
|
||||||
|
import cn.stock.market.infrastructure.db.po.QStockPO;
|
||||||
|
import cn.stock.market.infrastructure.db.po.QStockTempPO;
|
||||||
|
import cn.stock.market.infrastructure.db.po.StockPO;
|
||||||
|
import cn.stock.market.infrastructure.db.po.StockTempPO;
|
||||||
|
import cn.stock.market.infrastructure.db.repo.StockRepo;
|
||||||
|
import cn.stock.market.infrastructure.db.repo.StockTempRepo;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.rp.spring.jpa.GenericJpaRepository;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StockRepository
|
||||||
|
*
|
||||||
|
* @author rplees
|
||||||
|
* @email rplees.i.ly@gmail.com
|
||||||
|
* @created 2023/06/17
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
|
public class StockTempRepository extends LocalCacheRepository<StockTemp, StockTempPO, Integer> {
|
||||||
|
final StockTempRepo repo;
|
||||||
|
final StockTempConvert convert;
|
||||||
|
final static QStockTempPO q = QStockTempPO.stockTempPO;
|
||||||
|
|
||||||
|
public List<StockTemp> findAllForCheck() {
|
||||||
|
return findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GenericJpaRepository<StockTempPO, Integer> repo() {
|
||||||
|
return repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IEntityPOConvert<StockTemp, StockTempPO> convert() {
|
||||||
|
return convert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StockTempRepository of() {
|
||||||
|
return SpringUtils.getBean(StockTempRepository.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,30 @@
|
|||||||
package cn.stock.market.domain.basic.service;
|
package cn.stock.market.domain.basic.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.time.Duration;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import cn.qutaojing.common.jpa.ConditionBuilder;
|
||||||
|
import cn.stock.market.infrastructure.db.po.QSiteNewsPO;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
@@ -25,7 +44,8 @@ import cn.stock.market.utils.StringUtils;
|
|||||||
import cn.stock.market.utils.Utils;
|
import cn.stock.market.utils.Utils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.json.JSONObject;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SiteNewsService
|
* SiteNewsService
|
||||||
@@ -40,6 +60,8 @@ import net.sf.json.JSONObject;
|
|||||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||||
public class SiteNewsService {
|
public class SiteNewsService {
|
||||||
final SiteNewsRepository repository;
|
final SiteNewsRepository repository;
|
||||||
|
private final RedisTemplate<String, String> redisTemplate;
|
||||||
|
private final RestTemplate restTemplate;
|
||||||
final SiteNewsFactory factory;
|
final SiteNewsFactory factory;
|
||||||
|
|
||||||
/*新闻资讯-查询列表*/
|
/*新闻资讯-查询列表*/
|
||||||
@@ -54,6 +76,92 @@ public class SiteNewsService {
|
|||||||
return ServerResponse.createBySuccess(Utils.toPageHelperInfo(page));
|
return ServerResponse.createBySuccess(Utils.toPageHelperInfo(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServerResponse getLatestStockNews(int pageNum) {
|
||||||
|
int pageSize = 20;
|
||||||
|
String redisKey = "fmp:stock:latest:news:page:" + pageNum;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Step 1: get from cache
|
||||||
|
String cached = redisTemplate.opsForValue().get(redisKey);
|
||||||
|
List<SiteNews> list;
|
||||||
|
if (cached!= null && !cached.isEmpty()) {
|
||||||
|
list = JSON.parseArray(cached, SiteNews.class);
|
||||||
|
} else {
|
||||||
|
// Step 2: call FMP API
|
||||||
|
String url = String.format("https://financialmodelingprep.com/stable/news/stock-latest?page=%d&limit=%d&apikey=57ZI1xeAsqHY7ag0FBuMkwQzt6TQ60dG", pageNum, pageSize);
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("accept", "application/json");
|
||||||
|
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||||
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
|
||||||
|
|
||||||
|
if (response.getStatusCode().value() != 200 || response.getBody() == null) {
|
||||||
|
return ServerResponse.createByErrorMsg("Failed to fetch news");
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONArray newsArray = JSON.parseArray(response.getBody());
|
||||||
|
list = new ArrayList<>();
|
||||||
|
for (int i = 0; i < newsArray.size(); i++) {
|
||||||
|
JSONObject obj = newsArray.getJSONObject(i);
|
||||||
|
String sourceId = obj.getString("url");
|
||||||
|
|
||||||
|
SiteNews news = new SiteNews();
|
||||||
|
news.setSourceId(sourceId);
|
||||||
|
news.setTitle(obj.getString("title"));
|
||||||
|
news.setSourceName(obj.getString("publisher"));
|
||||||
|
news.setDescription(obj.getString("text"));
|
||||||
|
news.setContent(obj.getString("text"));
|
||||||
|
news.setImgurl(obj.getString("image"));
|
||||||
|
news.setStatus(1);
|
||||||
|
news.setType(1);
|
||||||
|
news.setViews(0);
|
||||||
|
news.setAddTime(new Date());
|
||||||
|
|
||||||
|
try {
|
||||||
|
ZonedDateTime ny = ZonedDateTime.of(
|
||||||
|
LocalDateTime.parse(obj.getString("publishedDate"), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
|
||||||
|
ZoneId.of("America/New_York")
|
||||||
|
);
|
||||||
|
news.setShowTime(Date.from(ny.withZoneSameInstant(ZoneId.systemDefault()).toInstant()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
news.setShowTime(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
list.add(news);
|
||||||
|
}
|
||||||
|
|
||||||
|
redisTemplate.opsForValue().set(redisKey, JSON.toJSONString(list), Duration.ofMinutes(10));
|
||||||
|
}
|
||||||
|
int simulatedTotal = 100;
|
||||||
|
|
||||||
|
Page<SiteNews> page = buildPage(list, pageNum, pageSize, simulatedTotal);
|
||||||
|
return ServerResponse.createBySuccess(page);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error getting latest stock news page {}", pageNum, e);
|
||||||
|
try{
|
||||||
|
Page<SiteNews> page = repository.findAll(ConditionBuilder.builder().build(), PageParam.of(pageNum, pageSize), QSiteNewsPO.siteNewsPO.showTime.desc());
|
||||||
|
|
||||||
|
return ServerResponse.createBySuccess(page);
|
||||||
|
}catch (Exception e1) {
|
||||||
|
return ServerResponse.createByErrorMsg("Internal error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Page<SiteNews> buildPage(List<SiteNews> allNews, int pageNum, int pageSize, int totalCount) {
|
||||||
|
int offset = pageNum * pageSize;
|
||||||
|
|
||||||
|
// Defensive bounds check
|
||||||
|
int toIndex = Math.min(offset + pageSize, allNews.size());
|
||||||
|
|
||||||
|
List<SiteNews> pagedList = offset >= allNews.size() ? allNews : allNews.subList(offset, toIndex);
|
||||||
|
|
||||||
|
Pageable pageable = PageRequest.of(pageNum, pageSize);
|
||||||
|
|
||||||
|
// You can pass total = 100 to simulate full dataset
|
||||||
|
return new PageImpl<>(pagedList, pageable, totalCount);
|
||||||
|
}
|
||||||
|
|
||||||
/*新闻资讯-查询详情*/
|
/*新闻资讯-查询详情*/
|
||||||
public ServerResponse getDetail(int id) {
|
public ServerResponse getDetail(int id) {
|
||||||
return ServerResponse.createBySuccess(repository.find(id));
|
return ServerResponse.createBySuccess(repository.find(id));
|
||||||
@@ -76,89 +184,8 @@ public class SiteNewsService {
|
|||||||
return ServerResponse.createBySuccess(pageInfo);
|
return ServerResponse.createBySuccess(pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*新闻资讯-抓取*/
|
|
||||||
public int grabNews() {
|
|
||||||
int ret = 0;
|
|
||||||
//新闻类型:1、财经要闻,2、经济数据,3、全球股市,4、7*24全球,5、商品资讯,6、上市公司,7、全球央行
|
|
||||||
ret = addNews(1, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetImportantNewsList");
|
|
||||||
log.info("财经要闻-抓取条数:" + ret);
|
|
||||||
|
|
||||||
ret = addNews(2, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=125&pageNumber=1&pagesize=20&condition=&r=");
|
|
||||||
log.info("经济数据-抓取条数:" + ret);
|
|
||||||
|
|
||||||
ret = addNews(3, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=105&pageNumber=1&pagesize=20&condition=&r=");
|
|
||||||
log.info("全球股市-抓取条数:" + ret);
|
|
||||||
|
|
||||||
ret = addNews(4, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=100&pageNumber=1&pagesize=20&condition=&r=");
|
|
||||||
log.info("7*24全球-抓取条数:" + ret);
|
|
||||||
|
|
||||||
ret = addNews(5, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=106&pageNumber=1&pagesize=20&condition=&r=");
|
|
||||||
log.info("商品资讯-抓取条数:" + ret);
|
|
||||||
|
|
||||||
ret = addNews(6, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=103&pageNumber=1&pagesize=20&condition=&r=");
|
|
||||||
log.info("上市公司-抓取条数:" + ret);
|
|
||||||
|
|
||||||
ret = addNews(7, PropertiesUtil.getProperty("news.main.url") + "/pc_news/FastNews/GetInfoList?code=118&pageNumber=1&pagesize=20&condition=&r=");
|
|
||||||
log.info("全球央行-抓取条数:" + ret);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*抓取新闻专用
|
|
||||||
* type:新闻类型:1、财经要闻,2、经济数据,3、全球股市,4、7*24全球,5、商品资讯,6、上市公司,7、全球央行
|
|
||||||
* */
|
|
||||||
private int addNews(Integer type, String url){
|
|
||||||
int k = 0;
|
|
||||||
try {
|
|
||||||
String newlist = HttpRequest.doGrabGet(url);
|
|
||||||
JSONObject json = JSONObject.fromObject(newlist);
|
|
||||||
if(json != null && json.getJSONArray("items") != null && json.getJSONArray("items").size() > 0){
|
|
||||||
for (int i = 0; i < json.getJSONArray("items").size(); i++){
|
|
||||||
JSONObject model = JSONObject.fromObject(json.getJSONArray("items").getString(i));
|
|
||||||
String newsId = model.getString("code");
|
|
||||||
String imgUrl = null;
|
|
||||||
if(model.has("imgUrl")){
|
|
||||||
imgUrl = model.getString("imgUrl");
|
|
||||||
}
|
|
||||||
//新闻不存在则添加
|
|
||||||
if(repository.getNewsBySourceIdCount(newsId) == 0){
|
|
||||||
//获取新闻详情
|
|
||||||
String newdata = HttpRequest.doGrabGet(PropertiesUtil.getProperty("news.main.url") + "/PC_News/Detail/GetDetailContent?id="+ newsId +"&type=1");
|
|
||||||
newdata = newdata.substring(1,newdata.length()-1).replace("\\\\\\\"","\"");
|
|
||||||
newdata = newdata.replace("\\\"","\"");
|
|
||||||
newdata = StringUtils.UnicodeToCN(newdata);
|
|
||||||
newdata = StringUtils.delHTMLTag(newdata);
|
|
||||||
|
|
||||||
JSONObject jsonnew = JSONObject.fromObject(newdata);
|
|
||||||
if(jsonnew != null && jsonnew.get("data") != null){
|
|
||||||
JSONObject news = JSONObject.fromObject(jsonnew.get("data"));
|
|
||||||
SiteNews siteNews = new SiteNews();
|
|
||||||
siteNews.setSourceId(newsId);
|
|
||||||
siteNews.setSourceName(news.getString("source"));
|
|
||||||
siteNews.setTitle(news.getString("title"));
|
|
||||||
String showTime = news.getString("showTime");
|
|
||||||
siteNews.setShowTime(DateTimeUtil.strToDate(showTime));
|
|
||||||
siteNews.setImgurl(imgUrl);
|
|
||||||
siteNews.setDescription(news.getString("description"));
|
|
||||||
siteNews.setContent(news.getString("content"));
|
|
||||||
siteNews.setStatus(1);
|
|
||||||
siteNews.setType(type);
|
|
||||||
try {
|
|
||||||
repository.saveAndFlush(siteNews);
|
|
||||||
} catch(Exception e) {
|
|
||||||
log.warn("siteNewsMapper insert error: {}", e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SiteNewsRepository repository() {
|
public SiteNewsRepository repository() {
|
||||||
return repository;
|
return repository;
|
||||||
|
|||||||
@@ -13,11 +13,9 @@ import cn.hutool.core.text.StrFormatter;
|
|||||||
import cn.stock.market.dto.model.*;
|
import cn.stock.market.dto.model.*;
|
||||||
import cn.stock.market.infrastructure.api.EttechchartsApis;
|
import cn.stock.market.infrastructure.api.EttechchartsApis;
|
||||||
import cn.stock.market.infrastructure.api.GrowwInApis;
|
import cn.stock.market.infrastructure.api.GrowwInApis;
|
||||||
|
import cn.stock.market.infrastructure.api.HomeApiIndex;
|
||||||
import cn.stock.market.infrastructure.api.TodayApis;
|
import cn.stock.market.infrastructure.api.TodayApis;
|
||||||
import cn.stock.market.infrastructure.api.investing.IndiaIndexVo;
|
import cn.stock.market.infrastructure.api.investing.*;
|
||||||
import cn.stock.market.infrastructure.api.investing.IndiaStockVO;
|
|
||||||
import cn.stock.market.infrastructure.api.investing.InvestingApis;
|
|
||||||
import cn.stock.market.infrastructure.api.investing.InvestingInvokerApis;
|
|
||||||
import cn.stock.market.infrastructure.api.sina.vo.HotSearchVO;
|
import cn.stock.market.infrastructure.api.sina.vo.HotSearchVO;
|
||||||
import cn.stock.market.utils.*;
|
import cn.stock.market.utils.*;
|
||||||
import com.ag.utils.CollectionUtils;
|
import com.ag.utils.CollectionUtils;
|
||||||
@@ -1048,70 +1046,33 @@ public class StockService {
|
|||||||
return ServerResponse.createBySuccess(indexVoList);
|
return ServerResponse.createBySuccess(indexVoList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerResponse getIndexByBtoday(){
|
public ServerResponse getIndexByBtoday() throws Exception {
|
||||||
List<IndiaIndexVo> indexVoList = new ArrayList<>();
|
List<StockIndex> list = HomeApiIndex.fetchStockIndices();
|
||||||
try {
|
|
||||||
String exchange = "bse";
|
List<IndiaIndexNewVo> indexVoList = new ArrayList<>();
|
||||||
IndiaIndexVo vo1 = new IndiaIndexVo();
|
|
||||||
String coCode = "20558";
|
for (StockIndex stockIndex : list) {
|
||||||
JSONObject object = TodayApis.getStockDetail("in%3BSEN", coCode);
|
IndiaIndexNewVo vo1 = new IndiaIndexNewVo();
|
||||||
IndiaStockVO market = objToVo(object);
|
IndiaStockVO market = new IndiaStockVO();
|
||||||
market.setName("BSESENSEX指数");
|
market.setClose(String.valueOf(stockIndex.getClose()));
|
||||||
|
market.setHigh(String.valueOf(stockIndex.getHigh()));
|
||||||
|
market.setLow(String.valueOf(stockIndex.getLow()));
|
||||||
|
market.setName(stockIndex.getName());
|
||||||
|
market.setNowPrice(String.valueOf(stockIndex.getClose()));
|
||||||
|
market.setOpen(String.valueOf(stockIndex.getOpen()));
|
||||||
|
market.setRate(String.valueOf(stockIndex.getPercentChange()));
|
||||||
vo1.setIndexVo(market);
|
vo1.setIndexVo(market);
|
||||||
|
|
||||||
//获取k线图 1D 当天的数据
|
List<ChartCandle> kLines = HomeApiIndex.fetchChartData(stockIndex.getId(), 419);
|
||||||
String format = "S";
|
// List kline = HomeApiIndex.convertToJsonList(kLines);
|
||||||
String durationType = "D";
|
vo1.setKLine(kLines);
|
||||||
String duration = "1";
|
|
||||||
List kine = TodayApis.getStockKline(exchange,coCode,format,durationType,duration);
|
|
||||||
vo1.setKLine(kine);
|
|
||||||
indexVoList.add(vo1);
|
indexVoList.add(vo1);
|
||||||
}catch (Exception e){
|
|
||||||
log.error("BToday获取BSESENSEX指数数据异常,异常信息。。。。", e);
|
|
||||||
try {
|
|
||||||
GrowwInApis.requestSenSexData(indexVoList);
|
|
||||||
} catch (Exception e1) {
|
|
||||||
log.error("GrowwIn获取BSESENSEX指数数据异常,异常信息。。。。", e1);
|
|
||||||
try{
|
|
||||||
EttechchartsApis.requestSensexData(indexVoList);
|
|
||||||
} catch (Exception e2) {
|
|
||||||
log.error("Ettechcharts获取BSESENSEX指数数据异常,异常信息。。。。", e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
String exchange = "nse";
|
|
||||||
IndiaIndexVo vo1 = new IndiaIndexVo();
|
|
||||||
String coCode = "20559";
|
|
||||||
JSONObject object = TodayApis.getStockDetail("in%3BNSX", coCode);
|
|
||||||
IndiaStockVO market = objToVo(object);
|
|
||||||
market.setName("NIFTY50指数");
|
|
||||||
vo1.setIndexVo(market);
|
|
||||||
|
|
||||||
//获取k线图 1D 当天的数据
|
|
||||||
String format = "S";
|
|
||||||
String durationType = "D";
|
|
||||||
String duration = "1";
|
|
||||||
List kine = TodayApis.getStockKline(exchange,coCode,format,durationType,duration);
|
|
||||||
vo1.setKLine(kine);
|
|
||||||
indexVoList.add(vo1);
|
|
||||||
}catch (Exception e){
|
|
||||||
log.error("BToday获取NIFTY50指数数据异常,异常信息。。。。", e);
|
|
||||||
try {
|
|
||||||
GrowwInApis.requestNifty50Data(indexVoList);
|
|
||||||
} catch (Exception e1) {
|
|
||||||
log.error("GrowwIn获取NIFTY50指数数据异常,异常信息。。。。", e1);
|
|
||||||
try{
|
|
||||||
EttechchartsApis.requestNifty50Data(indexVoList);
|
|
||||||
} catch (Exception e2) {
|
|
||||||
log.error("Ettechcharts获取NIFTY50指数数据异常,异常信息。。。。", e2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ServerResponse.createBySuccess(indexVoList);
|
return ServerResponse.createBySuccess(indexVoList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IndiaStockVO objToVo(JSONObject object){
|
private IndiaStockVO objToVo(JSONObject object){
|
||||||
IndiaStockVO market = new IndiaStockVO();
|
IndiaStockVO market = new IndiaStockVO();
|
||||||
if(object.containsKey("priceprevclose")){
|
if(object.containsKey("priceprevclose")){
|
||||||
|
|||||||
10
src/main/java/cn/stock/market/dto/RawStockApiResponse.java
Normal file
10
src/main/java/cn/stock/market/dto/RawStockApiResponse.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package cn.stock.market.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RawStockApiResponse {
|
||||||
|
private List<StockDataDto> data;
|
||||||
|
}
|
||||||
13
src/main/java/cn/stock/market/dto/StockDataDto.java
Normal file
13
src/main/java/cn/stock/market/dto/StockDataDto.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package cn.stock.market.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class StockDataDto {
|
||||||
|
private long time;
|
||||||
|
private double open;
|
||||||
|
private double close;
|
||||||
|
private double max;
|
||||||
|
private double min;
|
||||||
|
private long volume;
|
||||||
|
}
|
||||||
31
src/main/java/cn/stock/market/dto/StockQuoteData.java
Normal file
31
src/main/java/cn/stock/market/dto/StockQuoteData.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.stock.market.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class StockQuoteData {
|
||||||
|
private String id;
|
||||||
|
private String symbol;
|
||||||
|
private String name;
|
||||||
|
private String exchange;
|
||||||
|
private String mic_code;
|
||||||
|
private String datetime;
|
||||||
|
private long timestamp;
|
||||||
|
private double open;
|
||||||
|
private double high;
|
||||||
|
private double low;
|
||||||
|
private double close;
|
||||||
|
private long volume;
|
||||||
|
private double previous_close;
|
||||||
|
private double change;
|
||||||
|
private double percent_change;
|
||||||
|
private double average_volume;
|
||||||
|
@JsonProperty("is_market_open")
|
||||||
|
private boolean market_open;
|
||||||
|
private Long market_cap;
|
||||||
|
private Object fifty_two_week;
|
||||||
|
private int icon;
|
||||||
|
}
|
||||||
13
src/main/java/cn/stock/market/dto/StockQuoteResponse.java
Normal file
13
src/main/java/cn/stock/market/dto/StockQuoteResponse.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package cn.stock.market.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class StockQuoteResponse {
|
||||||
|
private List<StockQuoteData> data;
|
||||||
|
private boolean success;
|
||||||
|
private String message;
|
||||||
|
private int status;
|
||||||
|
}
|
||||||
13
src/main/java/cn/stock/market/dto/TradingViewData.java
Normal file
13
src/main/java/cn/stock/market/dto/TradingViewData.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package cn.stock.market.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class TradingViewData {
|
||||||
|
private String s; // symbol
|
||||||
|
private List<Object> d; // data array
|
||||||
|
}
|
||||||
13
src/main/java/cn/stock/market/dto/TradingViewResponse.java
Normal file
13
src/main/java/cn/stock/market/dto/TradingViewResponse.java
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package cn.stock.market.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class TradingViewResponse {
|
||||||
|
private int totalCount;
|
||||||
|
private List<TradingViewData> data;
|
||||||
|
}
|
||||||
11
src/main/java/cn/stock/market/dto/model/ChartCandle.java
Normal file
11
src/main/java/cn/stock/market/dto/model/ChartCandle.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.stock.market.dto.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChartCandle {
|
||||||
|
private String upd_date;
|
||||||
|
private Double price;
|
||||||
|
|
||||||
|
// Getters & Setters (hoặc @Data nếu dùng Lombok)
|
||||||
|
}
|
||||||
31
src/main/java/cn/stock/market/dto/model/StockIndex.java
Normal file
31
src/main/java/cn/stock/market/dto/model/StockIndex.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.stock.market.dto.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class StockIndex {
|
||||||
|
private String id;
|
||||||
|
private String symbol;
|
||||||
|
private String name;
|
||||||
|
private String exchange;
|
||||||
|
private String micCode;
|
||||||
|
private String datetime;
|
||||||
|
private long timestamp;
|
||||||
|
private Double open;
|
||||||
|
private Double high;
|
||||||
|
private Double low;
|
||||||
|
private Double close;
|
||||||
|
private Long volume;
|
||||||
|
private Double previousClose;
|
||||||
|
private Double change;
|
||||||
|
private Double percentChange;
|
||||||
|
private Long averageVolume;
|
||||||
|
private Boolean isMarketOpen;
|
||||||
|
private Long marketCap;
|
||||||
|
private String fiftyTwoWeek;
|
||||||
|
private Integer icon;
|
||||||
|
|
||||||
|
// Getters & setters (hoặc dùng @Data nếu có Lombok)
|
||||||
|
}
|
||||||
28
src/main/java/cn/stock/market/dto/model/Symbol.java
Normal file
28
src/main/java/cn/stock/market/dto/model/Symbol.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package cn.stock.market.dto.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Symbol {
|
||||||
|
private String symbol;
|
||||||
|
private String description;
|
||||||
|
private String stockGid;
|
||||||
|
private String type;
|
||||||
|
private String exchange;
|
||||||
|
private String currencyCode;
|
||||||
|
private String currencyLogoid;
|
||||||
|
private String logoid;
|
||||||
|
private String providerId;
|
||||||
|
private String sourceLogoid;
|
||||||
|
private String sourceId;
|
||||||
|
private String country;
|
||||||
|
private boolean isPrimaryListing;
|
||||||
|
private List<String> typespecs;
|
||||||
|
|
||||||
|
// Getters and setters
|
||||||
|
// Bạn có thể dùng Lombok nếu muốn ngắn gọn hơn
|
||||||
|
// Hoặc generate getter/setter trong IDE
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
package cn.stock.market.infrastructure.api;
|
||||||
|
import cn.qutaojing.common.utils.SpringUtils;
|
||||||
|
import cn.stock.market.dto.model.ChartCandle;
|
||||||
|
import cn.stock.market.dto.model.StockIndex;
|
||||||
|
import cn.stock.market.web.config.Config;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class HomeApiIndex {
|
||||||
|
private static final OkHttpClient client = new OkHttpClient();
|
||||||
|
static Config config = SpringUtils.getBean(Config.class);
|
||||||
|
private static final String API_URL = config.getStockUrlPrefix() + "/api/ger-market/stocks/query-list?symbols=^DJI:NASDAQ,^GSPC:NASDAQ,^IXIC:NASDAQ,^NDX:NASDAQ,^RUI:NASDAQ";
|
||||||
|
private static final String BASE_URL = config.getStockUrlPrefix() + "/api/ger-market/chart";
|
||||||
|
|
||||||
|
public static List<StockIndex> fetchStockIndices() throws Exception {
|
||||||
|
List<StockIndex> result = new ArrayList<>();
|
||||||
|
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(API_URL)
|
||||||
|
.addHeader("User-Agent", "Mozilla/5.0")
|
||||||
|
.addHeader("Accept", "application/json")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
throw new RuntimeException("HTTP error code: " + response.code());
|
||||||
|
}
|
||||||
|
|
||||||
|
String body = response.body().string();
|
||||||
|
JSONObject json = new JSONObject(body);
|
||||||
|
JSONArray data = json.getJSONArray("data");
|
||||||
|
|
||||||
|
for (int i = 0; i < data.length(); i++) {
|
||||||
|
JSONObject obj = data.getJSONObject(i);
|
||||||
|
StockIndex index = new StockIndex();
|
||||||
|
|
||||||
|
index.setId(obj.optString("id"));
|
||||||
|
index.setSymbol(obj.optString("symbol"));
|
||||||
|
|
||||||
|
index.setName(obj.optString("name"));
|
||||||
|
|
||||||
|
index.setExchange(obj.optString("exchange"));
|
||||||
|
index.setMicCode(obj.optString("mic_code"));
|
||||||
|
index.setDatetime(obj.optString("datetime"));
|
||||||
|
index.setTimestamp(obj.optLong("timestamp"));
|
||||||
|
index.setOpen(getDoubleOrNull(obj, "open"));
|
||||||
|
index.setHigh(getDoubleOrNull(obj, "high"));
|
||||||
|
index.setLow(getDoubleOrNull(obj, "low"));
|
||||||
|
index.setClose(getDoubleOrNull(obj, "close"));
|
||||||
|
index.setVolume(getLongOrNull(obj, "volume"));
|
||||||
|
index.setPreviousClose(getDoubleOrNull(obj, "previous_close"));
|
||||||
|
index.setChange(getDoubleOrNull(obj, "change"));
|
||||||
|
index.setPercentChange(getDoubleOrNull(obj, "percent_change"));
|
||||||
|
index.setAverageVolume(getLongOrNull(obj, "average_volume"));
|
||||||
|
index.setIsMarketOpen(obj.optBoolean("is_market_open"));
|
||||||
|
index.setMarketCap(getLongOrNull(obj, "market_cap"));
|
||||||
|
index.setFiftyTwoWeek(obj.optString("fifty_two_week", null));
|
||||||
|
index.setIcon(obj.optInt("icon", 0));
|
||||||
|
|
||||||
|
result.add(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ChartCandle> fetchChartData(String symbol, int amount) throws Exception {
|
||||||
|
List<ChartCandle> result = new ArrayList<>();
|
||||||
|
|
||||||
|
String url = BASE_URL + "?symbol=" + symbol + "&interval=D&amount=" + amount;
|
||||||
|
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.addHeader("User-Agent", "Mozilla/5.0")
|
||||||
|
.addHeader("Accept", "application/json")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
throw new RuntimeException("HTTP error code: " + response.code());
|
||||||
|
}
|
||||||
|
|
||||||
|
String body = response.body().string();
|
||||||
|
JSONObject json = new JSONObject(body);
|
||||||
|
JSONArray data = json.getJSONArray("data");
|
||||||
|
|
||||||
|
for (int i = 0; i < data.length(); i++) {
|
||||||
|
JSONObject obj = data.getJSONObject(i);
|
||||||
|
ChartCandle candle = new ChartCandle();
|
||||||
|
|
||||||
|
long ts = obj.optLong("time");
|
||||||
|
String formattedTime = convertToGermanTime(ts);
|
||||||
|
|
||||||
|
candle.setUpd_date(formattedTime);
|
||||||
|
candle.setPrice(getDoubleOrNull(obj, "close"));
|
||||||
|
|
||||||
|
result.add(candle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public static List<JSONObject> convertToJsonList(List<ChartCandle> candles) {
|
||||||
|
// List<JSONObject> result = new ArrayList<>();
|
||||||
|
//
|
||||||
|
// for (ChartCandle c : candles) {
|
||||||
|
// JSONObject obj = new JSONObject();
|
||||||
|
// String formattedTime = convertToGermanTime(c.getTime());
|
||||||
|
// obj.put("upd_date", formattedTime);
|
||||||
|
// obj.put("price", c.getClose());
|
||||||
|
// result.add(obj);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static String convertToGermanTime(long epochSeconds) {
|
||||||
|
ZoneId germanyZone = ZoneId.of("Europe/Berlin");
|
||||||
|
Instant instant = Instant.ofEpochSecond(epochSeconds);
|
||||||
|
ZonedDateTime zonedDateTime = instant.atZone(germanyZone);
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
|
||||||
|
return formatter.format(zonedDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper to safely parse nullable numbers
|
||||||
|
private static Double getDoubleOrNull(JSONObject obj, String key) {
|
||||||
|
return obj.isNull(key) ? null : obj.optDouble(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Long getLongOrNull(JSONObject obj, String key) {
|
||||||
|
return obj.isNull(key) ? null : obj.optLong(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package cn.stock.market.infrastructure.api.investing;
|
||||||
|
|
||||||
|
import cn.stock.market.dto.model.ChartCandle;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "指数信息")
|
||||||
|
public class IndiaIndexNewVo {
|
||||||
|
@ApiModelProperty(value = "指数详情")
|
||||||
|
private IndiaStockVO indexVo;
|
||||||
|
@ApiModelProperty(value = "指数k线")
|
||||||
|
private List<ChartCandle> kLine;
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package cn.stock.market.infrastructure.db.po;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.hibernate.annotations.DynamicInsert;
|
||||||
|
import org.hibernate.annotations.DynamicUpdate;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StockPO
|
||||||
|
*
|
||||||
|
* @author rplees
|
||||||
|
* @email rplees.i.ly@gmail.com
|
||||||
|
* @created 2023/06/17
|
||||||
|
*/
|
||||||
|
@SuperBuilder
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Entity
|
||||||
|
@DynamicInsert
|
||||||
|
@DynamicUpdate
|
||||||
|
@Table(name = "stockTemp")
|
||||||
|
public class StockTempPO {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
Integer id;
|
||||||
|
|
||||||
|
String stockType;
|
||||||
|
|
||||||
|
String stockGid;
|
||||||
|
|
||||||
|
String stockLogo;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package cn.stock.market.infrastructure.db.repo;
|
||||||
|
|
||||||
|
import cn.stock.market.infrastructure.db.po.StockPO;
|
||||||
|
import cn.stock.market.infrastructure.db.po.StockTempPO;
|
||||||
|
import com.rp.spring.jpa.GenericJpaRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* StockRepo
|
||||||
|
*
|
||||||
|
* @author rplees
|
||||||
|
* @email rplees.i.ly@gmail.com
|
||||||
|
* @created 2023/06/17
|
||||||
|
*/
|
||||||
|
public interface StockTempRepo extends GenericJpaRepository<StockTempPO, Integer> {
|
||||||
|
}
|
||||||
@@ -16,27 +16,46 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
import org.jsoup.Jsoup;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.jsoup.select.Elements;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Date;
|
import java.time.ZoneId;
|
||||||
import java.util.List;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Map;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/market/investing")
|
||||||
public class InvestingTask {
|
public class InvestingTask {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
StockService stockService;
|
StockService stockService;
|
||||||
@Autowired
|
@Autowired
|
||||||
SiteNewsRepository newsRepository;
|
SiteNewsRepository newsRepository;
|
||||||
|
@Autowired
|
||||||
|
RestTemplate restTemplate;
|
||||||
|
|
||||||
// @Scheduled(cron = "0 0 6 * * ?")
|
// @Scheduled(cron = "0 0 6 * * ?")
|
||||||
public void syncIndiaData(){
|
public void syncIndiaData(){
|
||||||
@@ -110,7 +129,7 @@ public class InvestingTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*新闻接口*/
|
/*新闻接口*/
|
||||||
@Scheduled(cron = "0 0 0/3 * * ?")
|
// @Scheduled(cron = "0 0 0/3 * * ?")
|
||||||
public void saveStockNews() {
|
public void saveStockNews() {
|
||||||
log.info("英文股票新闻数据同步开始");
|
log.info("英文股票新闻数据同步开始");
|
||||||
try {
|
try {
|
||||||
@@ -169,4 +188,185 @@ public class InvestingTask {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*德国新闻接口*/
|
||||||
|
@Scheduled(cron = "0 0 0/3 * * ?")
|
||||||
|
// @PostConstruct
|
||||||
|
public void saveGerNews() {
|
||||||
|
log.info("FMP 股票新闻数据同步开始");
|
||||||
|
int savedCount = 0;
|
||||||
|
int totalCount = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
String newsListUrl = "https://financialmodelingprep.com/stable/news/stock-latest?page=0&limit=30&apikey=57ZI1xeAsqHY7ag0FBuMkwQzt6TQ60dG";
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("accept", "application/json");
|
||||||
|
|
||||||
|
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||||
|
ResponseEntity<String> response = restTemplate.exchange(
|
||||||
|
newsListUrl,
|
||||||
|
HttpMethod.GET,
|
||||||
|
entity,
|
||||||
|
String.class
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.getStatusCode().value() == 200 && response.getBody() != null) {
|
||||||
|
JSONArray newsArray = JSON.parseArray(response.getBody());
|
||||||
|
totalCount = newsArray.size();
|
||||||
|
log.info("Found {} news items to process", totalCount);
|
||||||
|
|
||||||
|
for (int i = 0; i < newsArray.size(); i++) {
|
||||||
|
try {
|
||||||
|
JSONObject newsItem = newsArray.getJSONObject(i);
|
||||||
|
String sourceId = newsItem.getString("url");
|
||||||
|
|
||||||
|
// Check existence
|
||||||
|
List<SiteNews> existingNews = newsRepository.findAll(QSiteNewsPO.siteNewsPO.sourceId.eq(sourceId));
|
||||||
|
if (!existingNews.isEmpty()) {
|
||||||
|
log.debug("News {} already exists, skipping", sourceId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create and populate SiteNews entity
|
||||||
|
SiteNews siteNews = new SiteNews();
|
||||||
|
siteNews.setAddTime(new Date());
|
||||||
|
siteNews.setSourceId(sourceId);
|
||||||
|
siteNews.setTitle(newsItem.getString("title"));
|
||||||
|
siteNews.setSourceName(newsItem.getString("publisher"));
|
||||||
|
siteNews.setDescription(newsItem.getString("symbol"));
|
||||||
|
siteNews.setImgurl(newsItem.getString("image"));
|
||||||
|
siteNews.setContent(newsItem.getString("text"));
|
||||||
|
siteNews.setStatus(1);
|
||||||
|
siteNews.setType(1);
|
||||||
|
siteNews.setViews(0);
|
||||||
|
|
||||||
|
// Parse publishedDate
|
||||||
|
String publishedDate = newsItem.getString("publishedDate");
|
||||||
|
try {
|
||||||
|
ZonedDateTime nyTime = ZonedDateTime.of(
|
||||||
|
LocalDateTime.parse(publishedDate, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
|
||||||
|
ZoneId.of("America/New_York")
|
||||||
|
);
|
||||||
|
|
||||||
|
ZonedDateTime localTime = nyTime.withZoneSameInstant(ZoneId.systemDefault());
|
||||||
|
siteNews.setShowTime(Date.from(localTime.toInstant()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Failed to parse publishedDate with timezone for {}: {}", sourceId, publishedDate);
|
||||||
|
siteNews.setShowTime(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save news
|
||||||
|
newsRepository.save(siteNews);
|
||||||
|
savedCount++;
|
||||||
|
log.info("Saved news [{}/{}]: {}", savedCount, totalCount, siteNews.getTitle());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Error processing news item {}: {}", i, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log.error("Failed to fetch news: HTTP {}", response.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("FMP 股票新闻数据同步完成,总数 {},已保存 {}", totalCount, savedCount);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("FMP 新闻同步异常: {}", e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Scheduled(cron = "0 0 0/3 * * ?")
|
||||||
|
// @PostConstruct
|
||||||
|
public void getBoerseNews(){
|
||||||
|
String url_request = "https://www.boerse-online.de";
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<SiteNews> results = new ArrayList<>();
|
||||||
|
|
||||||
|
String listUrl = url_request + "/nachrichten/1";
|
||||||
|
Document doc = Jsoup.connect(listUrl)
|
||||||
|
.userAgent("Mozilla/5.0")
|
||||||
|
.get();
|
||||||
|
|
||||||
|
Elements articles = doc.select("article.article-list-item");
|
||||||
|
|
||||||
|
for (Element article : articles) {
|
||||||
|
Element aTag = article.selectFirst("h2 a");
|
||||||
|
String title = aTag != null ? aTag.text().trim() : null;
|
||||||
|
String link = aTag != null ? url_request + aTag.attr("href") : null;
|
||||||
|
|
||||||
|
Element imgTag = article.selectFirst("figure a picture img");
|
||||||
|
String image = imgTag != null ? imgTag.attr("src") : null;
|
||||||
|
|
||||||
|
Element timeTag = article.selectFirst("small.article-info time");
|
||||||
|
Date publishedDate = null;
|
||||||
|
|
||||||
|
if (timeTag != null) {
|
||||||
|
String datetimeAttr = timeTag.attr("datetime");
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||||
|
LocalDateTime dateTime = LocalDateTime.parse(datetimeAttr, formatter);
|
||||||
|
ZoneId berlinZone = ZoneId.of("Europe/Berlin");
|
||||||
|
publishedDate = Date.from(dateTime.atZone(berlinZone).toInstant());
|
||||||
|
}
|
||||||
|
|
||||||
|
Element authorTag = article.selectFirst("small.article-info strong");
|
||||||
|
String author = authorTag != null ? authorTag.text().trim() : null;
|
||||||
|
|
||||||
|
// Fetch article detail page
|
||||||
|
String htmlContent = "";
|
||||||
|
if (link != null) {
|
||||||
|
try {
|
||||||
|
Document detailPage = Jsoup.connect(link)
|
||||||
|
.userAgent("Mozilla/5.0")
|
||||||
|
.get();
|
||||||
|
|
||||||
|
Element body = detailPage.selectFirst("div.article-body");
|
||||||
|
if (body != null) {
|
||||||
|
htmlContent = body.html(); // ✅ inner HTML only
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error fetching article detail: " + link);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SiteNews siteNews = new SiteNews();
|
||||||
|
siteNews.setAddTime(new Date());
|
||||||
|
siteNews.setSourceId(link);
|
||||||
|
siteNews.setTitle(title);
|
||||||
|
siteNews.setSourceName("BOERSE");
|
||||||
|
siteNews.setDescription(title);
|
||||||
|
siteNews.setImgurl(image);
|
||||||
|
siteNews.setContent(htmlContent);
|
||||||
|
siteNews.setStatus(1);
|
||||||
|
siteNews.setType(1); // Set as financial news type
|
||||||
|
siteNews.setViews(0);
|
||||||
|
siteNews.setShowTime(publishedDate);
|
||||||
|
try {
|
||||||
|
newsRepository.save(siteNews);
|
||||||
|
log.info("Saved German news : {}", title);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Failed to save German news {}: {}", link, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("Error fetching article detail: {}", e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test method to manually trigger German news sync
|
||||||
|
* This can be called via REST API or scheduled task
|
||||||
|
*/
|
||||||
|
@GetMapping("/test-ger-news")
|
||||||
|
public String testSaveGerNews() {
|
||||||
|
log.info("Testing German news sync...");
|
||||||
|
saveGerNews();
|
||||||
|
log.info("German news sync test completed");
|
||||||
|
return "German news sync test completed. Check logs for details.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,11 +57,11 @@ public class JobBoot {
|
|||||||
/*
|
/*
|
||||||
* 新闻资讯抓取
|
* 新闻资讯抓取
|
||||||
* */
|
* */
|
||||||
@Scheduled(cron = "0 0/30 9-20 * * ?")
|
// @Scheduled(cron = "0 0/30 9-20 * * ?")
|
||||||
public void newsInfoTask() {
|
// public void newsInfoTask() {
|
||||||
MdcUtil.setTraceIdIfAbsent();
|
// MdcUtil.setTraceIdIfAbsent();
|
||||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
// Stopwatch stopwatch = Stopwatch.createStarted();
|
||||||
int count = SiteNewsService.of().grabNews();
|
// int count = SiteNewsService.of().grabNews();
|
||||||
log.info("newsInfoTask执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
// log.info("newsInfoTask执行, 受影响数{}, 耗时:{}毫秒", count, stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class RealTimeTask {
|
|||||||
|
|
||||||
/*每天9点定时删除股票k线数据*/
|
/*每天9点定时删除股票k线数据*/
|
||||||
@Transactional
|
@Transactional
|
||||||
@Scheduled(cron = "0 00 9 * * MON-FRI")
|
// @Scheduled(cron = "0 00 9 * * MON-FRI")
|
||||||
public void deleteStockCode() {
|
public void deleteStockCode() {
|
||||||
log.info("每天9点定时删除股票k线数据");
|
log.info("每天9点定时删除股票k线数据");
|
||||||
repo.deleteStockCode();
|
repo.deleteStockCode();
|
||||||
@@ -24,7 +24,7 @@ public class RealTimeTask {
|
|||||||
|
|
||||||
/*每天0点定时删除期货k线数据*/
|
/*每天0点定时删除期货k线数据*/
|
||||||
@Transactional
|
@Transactional
|
||||||
@Scheduled(cron = "0 00 0 * * MON-FRI")
|
// @Scheduled(cron = "0 00 0 * * MON-FRI")
|
||||||
public void deleteStockFuturesCode() {
|
public void deleteStockFuturesCode() {
|
||||||
log.info("每天0点定时删除期货k线数据");
|
log.info("每天0点定时删除期货k线数据");
|
||||||
repo.deleteStockFuturesCode();
|
repo.deleteStockFuturesCode();
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class Scraper {
|
|||||||
private boolean times = false;
|
private boolean times = false;
|
||||||
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 1 */2 * ?")
|
// @Scheduled(cron = "0 0 1 */2 * ?")
|
||||||
@RequestMapping("/testScraperGetBusinessToday")
|
@RequestMapping("/testScraperGetBusinessToday")
|
||||||
public void schedule() {
|
public void schedule() {
|
||||||
String BASE_URL = "https://akm-img-a-in.tosshub.com/businesstoday/resource/market-widgets/prod/company-master-23-01-2023.json";
|
String BASE_URL = "https://akm-img-a-in.tosshub.com/businesstoday/resource/market-widgets/prod/company-master-23-01-2023.json";
|
||||||
@@ -110,7 +110,7 @@ public class Scraper {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 18 * * ?")
|
// @Scheduled(cron = "0 0 18 * * ?")
|
||||||
// @PostConstruct
|
// @PostConstruct
|
||||||
@RequestMapping("/testScraperGetMoneyControllerNewIPO")
|
@RequestMapping("/testScraperGetMoneyControllerNewIPO")
|
||||||
public void getMoneyControllerNewIPOSchedule() {
|
public void getMoneyControllerNewIPOSchedule() {
|
||||||
@@ -303,7 +303,7 @@ public class Scraper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 19 * * ?")
|
// @Scheduled(cron = "0 0 19 * * ?")
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@RequestMapping("/addMoneyStock")
|
@RequestMapping("/addMoneyStock")
|
||||||
public void addMoneyStock() {
|
public void addMoneyStock() {
|
||||||
|
|||||||
@@ -0,0 +1,186 @@
|
|||||||
|
package cn.stock.market.infrastructure.job;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import cn.stock.market.domain.basic.entity.Stock;
|
||||||
|
import cn.stock.market.domain.basic.entity.StockTemp;
|
||||||
|
import cn.stock.market.domain.basic.repository.StockRepository;
|
||||||
|
import cn.stock.market.domain.basic.repository.StockTempRepository;
|
||||||
|
import cn.stock.market.dto.model.Symbol;
|
||||||
|
import cn.stock.market.infrastructure.db.po.StockPO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
import org.json.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class StockNewTask {
|
||||||
|
private static final OkHttpClient client = new OkHttpClient();
|
||||||
|
private static final String BASE_URL = "https://symbol-search.tradingview.com/symbol_search/v3/";
|
||||||
|
private static final String PARAMS = "?start={start}&hl=1&country=DE&lang=en&search_type=stocks&domain=production&sort_by_country=US&promo=true&exchange={exchange}";
|
||||||
|
|
||||||
|
private static final String US_URL =
|
||||||
|
"https://financialmodelingprep.com/api/v3/stock-screener";
|
||||||
|
private static final String US_API_KEY = "57ZI1xeAsqHY7ag0FBuMkwQzt6TQ60dG";
|
||||||
|
@Autowired
|
||||||
|
StockRepository stockRepository;
|
||||||
|
|
||||||
|
|
||||||
|
// @PostConstruct
|
||||||
|
// @Scheduled(cron = "0 01 22 * * ?")
|
||||||
|
public void syncStock() throws Exception {
|
||||||
|
try {
|
||||||
|
int limit = 20000;
|
||||||
|
List<String> exchanges = Arrays.asList("BER", "DUS", "HAM", "HAN", "MUN", "SWB", "FWB", "XETR");
|
||||||
|
Map<String, Stock> stockGidMap = stockRepository.cacheGidMap();
|
||||||
|
for (String exchange : exchanges) {
|
||||||
|
List<Stock> newStocks = new ArrayList<>();
|
||||||
|
int start = 0;
|
||||||
|
int symbolsRemaining;
|
||||||
|
do {
|
||||||
|
int finalStart = start;
|
||||||
|
if (start > 0) {
|
||||||
|
finalStart = start + 1;
|
||||||
|
}
|
||||||
|
String url = BASE_URL + PARAMS.replace("{start}", String.valueOf(finalStart)).replace("{exchange}", exchange);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.addHeader("Origin", "https://www.tradingview.com")
|
||||||
|
.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)")
|
||||||
|
.addHeader("Accept", "application/json, text/plain, */*")
|
||||||
|
.addHeader("Referer", "https://www.tradingview.com/")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
throw new RuntimeException("Unexpected response code: " + response.code());
|
||||||
|
}
|
||||||
|
|
||||||
|
String responseBody = response.body().string();
|
||||||
|
JSONObject json = new JSONObject(responseBody);
|
||||||
|
JSONArray symbols = json.getJSONArray("symbols");
|
||||||
|
symbolsRemaining = json.getInt("symbols_remaining");
|
||||||
|
|
||||||
|
for (int i = 0; i < symbols.length(); i++) {
|
||||||
|
JSONObject s = symbols.getJSONObject(i);
|
||||||
|
if (s.optString("type").equals("stock") && !stockGidMap.containsKey(s.optString("exchange") + ":" + s.getString("symbol"))) {
|
||||||
|
Stock stock = new Stock();
|
||||||
|
stock.setStockGid(s.optString("exchange") + ":" + s.getString("symbol"));
|
||||||
|
stock.setStockCode(stock.getStockGid());
|
||||||
|
stock.setStockSpell(s.optString("symbol"));
|
||||||
|
stock.setStockName(s.optString("description"));
|
||||||
|
stock.setStockSymbol(s.optString("symbol"));
|
||||||
|
stock.setStockType(s.optString("exchange"));
|
||||||
|
stock.setIsLock(0);
|
||||||
|
stock.setIsShow(0);
|
||||||
|
stock.setAddTime(new Date());
|
||||||
|
stock.setStockState(0);
|
||||||
|
stock.setStockPlate("https://s3-symbol-logo.tradingview.com/" + s.optString("source_logoid") + "--big.svg");
|
||||||
|
newStocks.add(stock);
|
||||||
|
stockGidMap.put(s.optString("exchange") + ":" + s.getString("symbol"), stock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Thread.sleep(500);
|
||||||
|
|
||||||
|
start += symbols.length();
|
||||||
|
System.out.println("Fetched: " + symbols.length() + ", Remaining: " + symbolsRemaining);
|
||||||
|
try {
|
||||||
|
if (!newStocks.isEmpty()) {
|
||||||
|
stockRepository.saveAll(newStocks);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Insert stock failed: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start >= limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (symbolsRemaining > 0);
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
log.error("Insert stock failed: {}", e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 8 * * *")
|
||||||
|
// @PostConstruct
|
||||||
|
public void fetchListStock() {
|
||||||
|
try {
|
||||||
|
List<Stock> nasdaqStocks = fetchStocksByExchange("NASDAQ");
|
||||||
|
List<Stock> nyseStocks = fetchStocksByExchange("NYSE");
|
||||||
|
|
||||||
|
List<Stock> allActiveStocks = new ArrayList<>();
|
||||||
|
allActiveStocks.addAll(nasdaqStocks);
|
||||||
|
allActiveStocks.addAll(nyseStocks);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!allActiveStocks.isEmpty()) {
|
||||||
|
stockRepository.saveAll(allActiveStocks);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Insert stock failed: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error fetchListStock every day: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Stock> fetchStocksByExchange(String exchange) throws Exception {
|
||||||
|
List<Stock> result = new ArrayList<>();
|
||||||
|
|
||||||
|
String url = US_URL + "?exchange=" + exchange + "&apikey=" + US_API_KEY;
|
||||||
|
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.addHeader("accept", "application/json")
|
||||||
|
.addHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
throw new RuntimeException("HTTP error code: " + response.code());
|
||||||
|
}
|
||||||
|
|
||||||
|
String body = response.body().string();
|
||||||
|
JSONArray array = new JSONArray(body);
|
||||||
|
|
||||||
|
for (int i = 0; i < array.length(); i++) {
|
||||||
|
JSONObject obj = array.getJSONObject(i);
|
||||||
|
if (!obj.optBoolean("isActivelyTrading", false) && obj.optBoolean("isEtf", false)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Stock stock = new Stock();
|
||||||
|
|
||||||
|
String stockCodeNew = obj.getString("symbol") + ":" + obj.getString("exchangeShortName");
|
||||||
|
|
||||||
|
stock.setStockName(obj.getString("companyName"));
|
||||||
|
stock.setStockCode(stockCodeNew);
|
||||||
|
stock.setStockSpell(obj.getString("symbol"));
|
||||||
|
stock.setStockType(obj.getString("exchangeShortName"));
|
||||||
|
stock.setStockGid(stockCodeNew);
|
||||||
|
stock.setStockSymbol(obj.getString("symbol"));
|
||||||
|
|
||||||
|
result.add(stock);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Fetched " + result.size() + " stocks for exchange: " + exchange);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -112,7 +112,7 @@ public class StockTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*同步股票列表*/
|
/*同步股票列表*/
|
||||||
@Scheduled(cron = "0 0 6 * * ?")
|
// @Scheduled(cron = "0 0 6 * * ?")
|
||||||
public void syncAFutureStockList() {
|
public void syncAFutureStockList() {
|
||||||
PageInfo<JSONObject> info = EastmoneyApi.ipoApplyDate(1, 300);
|
PageInfo<JSONObject> info = EastmoneyApi.ipoApplyDate(1, 300);
|
||||||
Map<String, Stock> stockMap = StockRepository.of().cacheCodeMap();
|
Map<String, Stock> stockMap = StockRepository.of().cacheCodeMap();
|
||||||
@@ -154,7 +154,7 @@ public class StockTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*同步股票列表*/
|
/*同步股票列表*/
|
||||||
@Scheduled(cron = "0 0 6 * * ?")
|
// @Scheduled(cron = "0 0 6 * * ?")
|
||||||
public void syncAStockList() {
|
public void syncAStockList() {
|
||||||
MdcUtil.setTraceIdIfAbsent();
|
MdcUtil.setTraceIdIfAbsent();
|
||||||
Config config = SpringUtils.getBean(Config.class);
|
Config config = SpringUtils.getBean(Config.class);
|
||||||
|
|||||||
@@ -1,70 +1,53 @@
|
|||||||
//package cn.stock.market.infrastructure.redis.config;
|
package cn.stock.market.infrastructure.redis.config;
|
||||||
//
|
|
||||||
//import java.time.Duration;
|
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
|
||||||
//
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
//import org.redisson.api.RedissonClient;
|
import org.springframework.context.annotation.Bean;
|
||||||
//import org.springframework.cache.CacheManager;
|
import org.springframework.context.annotation.Configuration;
|
||||||
//import org.springframework.cache.annotation.EnableCaching;
|
|
||||||
//import org.springframework.context.annotation.Bean;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
//import org.springframework.context.annotation.Configuration;
|
import org.springframework.data.redis.connection.RedisPassword;
|
||||||
//import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||||
//import org.springframework.data.redis.cache.RedisCacheManager;
|
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||||
//import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
//import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
//import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
|
||||||
//import org.springframework.data.redis.serializer.RedisSerializationContext;
|
@Configuration
|
||||||
//import org.springframework.data.redis.serializer.StringRedisSerializer;
|
@EnableConfigurationProperties(RedisProperties.class)
|
||||||
//
|
public class RedisConfig {
|
||||||
//import cn.qutaojing.common.aop.distributedlock.DistributedLockTemplate;
|
|
||||||
//import cn.stock.market.infrastructure.redis.SingleDistributedLockTemplate;
|
private RedisProperties redisProperties;
|
||||||
//
|
|
||||||
///**
|
public RedisConfig(RedisProperties redisProperties) {
|
||||||
// *
|
this.redisProperties = redisProperties;
|
||||||
// * @author xlfd
|
}
|
||||||
// * @email xlfd@gmail.com
|
|
||||||
// * @version 1.0
|
@Bean
|
||||||
// * @created Jun 3, 2021 4:56:28 PM
|
public RedisConnectionFactory redisConnectionFactory() {
|
||||||
// */
|
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
|
||||||
//@Configuration
|
config.setHostName(redisProperties.getHost());
|
||||||
//@EnableCaching
|
config.setPort(redisProperties.getPort());
|
||||||
//public class RedisConfig {
|
config.setDatabase(redisProperties.getDatabase());
|
||||||
//
|
|
||||||
// @Bean
|
if (redisProperties.getPassword() != null) {
|
||||||
// public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
config.setPassword(RedisPassword.of(redisProperties.getPassword()));
|
||||||
// RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
|
}
|
||||||
// redisTemplate.setConnectionFactory(redisConnectionFactory);
|
|
||||||
// redisTemplate.setValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class));
|
return new LettuceConnectionFactory(config);
|
||||||
// redisTemplate.setKeySerializer(new StringRedisSerializer());
|
}
|
||||||
//
|
|
||||||
// redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class));
|
@Bean
|
||||||
// redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory connectionFactory) {
|
||||||
//
|
RedisTemplate<String, String> template = new RedisTemplate<>();
|
||||||
// return redisTemplate;
|
template.setConnectionFactory(connectionFactory);
|
||||||
// }
|
|
||||||
//
|
StringRedisSerializer serializer = new StringRedisSerializer();
|
||||||
// @Bean
|
template.setKeySerializer(serializer);
|
||||||
// public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
|
template.setValueSerializer(serializer);
|
||||||
// // 配置序列化
|
template.setHashKeySerializer(serializer);
|
||||||
// RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
template.setHashValueSerializer(serializer);
|
||||||
// config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()));
|
|
||||||
// config.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new Jackson2JsonRedisSerializer<>(Object.class)));
|
template.afterPropertiesSet();
|
||||||
//
|
return template;
|
||||||
// // 设置缓存的默认过期时间 ,30分钟
|
}
|
||||||
// config.entryTtl(Duration.ofMinutes(30));
|
}
|
||||||
// // 不缓存空值
|
|
||||||
// config.disableCachingNullValues();
|
|
||||||
// RedisCacheManager cacheManager = RedisCacheManager.builder(redisConnectionFactory).cacheDefaults(config)
|
|
||||||
// .build();
|
|
||||||
// return cacheManager;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 分布式锁实现
|
|
||||||
// * @param redissonClient
|
|
||||||
// * @return
|
|
||||||
// */
|
|
||||||
// @Bean
|
|
||||||
// public DistributedLockTemplate distributedLockTemplate(RedissonClient redissonClient) {
|
|
||||||
// return new SingleDistributedLockTemplate(redissonClient);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,18 +1,24 @@
|
|||||||
package cn.stock.market.web;
|
package cn.stock.market.web;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.qutaojing.common.jpa.ConditionBuilder;
|
||||||
import cn.stock.market.MoneyStockSuggestDTO;
|
import cn.stock.market.MoneyStockSuggestDTO;
|
||||||
import cn.stock.market.domain.basic.entity.MoneyStock;
|
import cn.stock.market.domain.basic.entity.MoneyStock;
|
||||||
import cn.stock.market.domain.basic.entity.OptionalStock;
|
import cn.stock.market.domain.basic.entity.OptionalStock;
|
||||||
|
import cn.stock.market.domain.basic.entity.Stock;
|
||||||
import cn.stock.market.domain.basic.repository.MoneyStockRepository;
|
import cn.stock.market.domain.basic.repository.MoneyStockRepository;
|
||||||
import cn.stock.market.domain.basic.repository.OptionalStockRepository;
|
import cn.stock.market.domain.basic.repository.OptionalStockRepository;
|
||||||
|
import cn.stock.market.domain.basic.repository.StockRepository;
|
||||||
|
import cn.stock.market.domain.basic.service.StockService;
|
||||||
import cn.stock.market.dto.*;
|
import cn.stock.market.dto.*;
|
||||||
import cn.stock.market.dto.query.StockChartDto;
|
import cn.stock.market.dto.query.StockChartDto;
|
||||||
import cn.stock.market.infrastructure.db.po.QMoneyStockPO;
|
import cn.stock.market.infrastructure.db.po.QMoneyStockPO;
|
||||||
|
import cn.stock.market.infrastructure.db.po.QStockPO;
|
||||||
import cn.stock.market.utils.HttpRequest;
|
import cn.stock.market.utils.HttpRequest;
|
||||||
import cn.stock.market.utils.NseIndiaRequest;
|
import cn.stock.market.utils.NseIndiaRequest;
|
||||||
import cn.stock.market.utils.ServerResponse;
|
import cn.stock.market.utils.ServerResponse;
|
||||||
import cn.stock.market.web.annotations.EncryptFilter;
|
import cn.stock.market.web.annotations.EncryptFilter;
|
||||||
|
import cn.stock.market.web.service.MoneyApiService;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@@ -87,8 +93,14 @@ public class MoneyApiController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MoneyApiService moneyApiService;
|
||||||
|
|
||||||
private static final String EXTERNAL_API_URL = "https://priceapi.moneycontrol.com/techCharts/indianMarket/stock/history";
|
private static final String EXTERNAL_API_URL = "https://priceapi.moneycontrol.com/techCharts/indianMarket/stock/history";
|
||||||
private static final String OPTIONAL_STOCK_MONEYCONTROL_URL = "https://priceapi.moneycontrol.com/pricefeed/notapplicable/inidicesindia/";
|
private static final String OPTIONAL_STOCK_MONEYCONTROL_URL = "https://priceapi.moneycontrol.com/pricefeed/notapplicable/inidicesindia/";
|
||||||
|
@Autowired
|
||||||
|
private StockRepository stockRepository;
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "股票详情信息", httpMethod = "GET")
|
@ApiOperation(value = "股票详情信息", httpMethod = "GET")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@@ -197,136 +209,13 @@ public class MoneyApiController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
@EncryptFilter(decryptRequest = false)
|
@EncryptFilter(decryptRequest = false)
|
||||||
public ServerResponse getStockDetail(@RequestParam String stockType, @RequestParam String symbol) {
|
public ServerResponse getStockDetail(@RequestParam String stockType, @RequestParam String symbol) {
|
||||||
MoneyStock moneyStock = moneyStockRepository.findOne(QMoneyStockPO.moneyStockPO.stockType.eq(stockType)
|
Stock stock = stockRepository.findStockByCode(symbol);
|
||||||
.and(QMoneyStockPO.moneyStockPO.moneyScId.eq(symbol))
|
if (stock == null) {
|
||||||
.and(QMoneyStockPO.moneyStockPO.isLock.eq(0))
|
return ServerResponse.createByErrorMsg("Stock is not exist!");
|
||||||
.and(QMoneyStockPO.moneyStockPO.isShow.eq(0)))
|
|
||||||
.orElse(null);
|
|
||||||
/* if(moneyStock==null){
|
|
||||||
return ServerResponse.createByErrorMsg("没有找到该股票");
|
|
||||||
}*/
|
|
||||||
// 设置重试次数
|
|
||||||
if ("ANI".equals(symbol)) {
|
|
||||||
JSONObject json1 = new JSONObject();
|
|
||||||
json1.put("company", "Archit Nuwood Industries Ltd");
|
|
||||||
json1.put("pricepercentchange", "Archit Nuwood Industries Ltd");
|
|
||||||
json1.put("stockType", stockType);
|
|
||||||
json1.put("pricecurrent", "386");
|
|
||||||
json1.put("dataSourceType", "3");
|
|
||||||
json1.put("symbol", "ANI");
|
|
||||||
json1.put("BSEID", "ANI");
|
|
||||||
json1.put("NSEID", "ANI");
|
|
||||||
return ServerResponse.createBySuccess(json1);
|
|
||||||
}
|
}
|
||||||
|
StockQuoteData data = moneyApiService.getSingleStockQuote(symbol);
|
||||||
String url = String.format("https://priceapi.moneycontrol.com/pricefeed/%s/equitycash/%s", stockType.toLowerCase(), symbol);
|
data.setName(stock.getStockName());
|
||||||
int maxRetries = 3;
|
return ServerResponse.createBySuccess(data);
|
||||||
if (moneyStock.getUseFromBseindia()) {
|
|
||||||
String bseUrl = "https://api.bseindia.com/BseIndiaAPI/api/getScripHeaderData/w?Debtflag=&scripcode=" + moneyStock.getNseIndiaId() + "&seriesid=";
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
headers.add("accept", "application/json, text/plain, */*");
|
|
||||||
headers.add("accept-language", "en-US,en;q=0.9,vi;q=0.8");
|
|
||||||
headers.add("origin", "https://www.bseindia.com");
|
|
||||||
headers.add("referer", "https://www.bseindia.com/");
|
|
||||||
headers.add("sec-ch-ua", "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"");
|
|
||||||
headers.add("sec-ch-ua-mobile", "?0");
|
|
||||||
headers.add("sec-ch-ua-platform", "\"Windows\"");
|
|
||||||
headers.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36");
|
|
||||||
|
|
||||||
HttpEntity<String> entity = new HttpEntity<>(headers);
|
|
||||||
|
|
||||||
try {
|
|
||||||
ResponseEntity<String> responseEntity = restTemplate.exchange(bseUrl, HttpMethod.GET, entity, String.class);
|
|
||||||
if (responseEntity.getStatusCode().value() == 200 && responseEntity.getBody() != null) {
|
|
||||||
JSONObject bseData = JSONObject.parseObject(responseEntity.getBody());
|
|
||||||
JSONObject json1 = new JSONObject();
|
|
||||||
json1.put("company", bseData.getJSONObject("Cmpname").getString("FullN"));
|
|
||||||
json1.put("pricepercentchange", bseData.getJSONObject("CurrRate").getString("PcChg"));
|
|
||||||
json1.put("stockType", stockType);
|
|
||||||
json1.put("pricechange", bseData.getJSONObject("CurrRate").getString("Chg"));
|
|
||||||
json1.put("pricecurrent", bseData.getJSONObject("CurrRate").getString("LTP"));
|
|
||||||
json1.put("priceprevclose", bseData.getJSONObject("Header").getString("PrevClose"));
|
|
||||||
json1.put("PREVDATE", "");
|
|
||||||
|
|
||||||
json1.put("dataSourceType", "3");
|
|
||||||
json1.put("symbol", symbol);
|
|
||||||
json1.put("BSEID", moneyStock.getNseIndiaId());
|
|
||||||
json1.put("NSEID", moneyStock.getNseIndiaId());
|
|
||||||
json1.put("LTH", bseData.getJSONObject("Header").getString("High"));
|
|
||||||
json1.put("LTL", bseData.getJSONObject("Header").getString("Low"));
|
|
||||||
json1.put("OPN", bseData.getJSONObject("Header").getString("Open"));
|
|
||||||
|
|
||||||
|
|
||||||
if (moneyStock != null) {
|
|
||||||
json1.put("id", moneyStock.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
json1.put("VOL", this.getVolume(moneyStock.getNseIndiaId()));
|
|
||||||
return ServerResponse.createBySuccess(json1);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Error fetching data from BSE India: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int retry = 1; retry <= maxRetries; retry++) {
|
|
||||||
try {
|
|
||||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, null, String.class);
|
|
||||||
JSONObject json1 = new JSONObject();
|
|
||||||
if (responseEntity.getStatusCode().value() == 200 && responseEntity.getBody() != null) {
|
|
||||||
JSONObject data = JSONObject.parseObject(responseEntity.getBody()).getJSONObject("data");
|
|
||||||
if (data != null) {
|
|
||||||
json1.put("company", data.getString("SC_FULLNM"));
|
|
||||||
json1.put("pricepercentchange", data.getString("pricepercentchange"));
|
|
||||||
json1.put("stockType", stockType);
|
|
||||||
json1.put("pricechange", data.getString("pricechange"));
|
|
||||||
json1.put("pricecurrent", data.getString("pricecurrent"));
|
|
||||||
json1.put("priceprevclose", data.getString("priceprevclose"));
|
|
||||||
json1.put("PREVDATE", data.getString("PREVDATE"));
|
|
||||||
json1.put("VOL", data.getString("VOL"));
|
|
||||||
json1.put("dataSourceType", "3");
|
|
||||||
json1.put("symbol", data.getString("symbol"));
|
|
||||||
json1.put("BSEID", data.getString("BSEID"));
|
|
||||||
json1.put("NSEID", data.getString("NSEID"));
|
|
||||||
json1.put("LTH", data.getString("HP"));
|
|
||||||
json1.put("LTL", data.getString("LP"));
|
|
||||||
json1.put("OPN", data.getString("OPN"));
|
|
||||||
if (null != moneyStock) {
|
|
||||||
json1.put("id", moneyStock.getId());
|
|
||||||
}
|
|
||||||
if (StringUtils.equals(data.getString("pricecurrent"), "0.00")
|
|
||||||
&& (!StringUtils.equals(data.getString("priceprevclose"), "0.00"))) {
|
|
||||||
json1.put("pricecurrent", data.getString("priceprevclose"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (json1.size() > 0)
|
|
||||||
return ServerResponse.createBySuccess(json1);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
// 如果不是最后一次重试,则等待一段时间再进行下一次重试
|
|
||||||
if (retry < maxRetries) {
|
|
||||||
try {
|
|
||||||
// 1秒钟
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (moneyStock != null && moneyStock.getNseIndiaId() != null && !moneyStock.getNseIndiaId().isEmpty()) {
|
|
||||||
try {
|
|
||||||
// Get data from nseindia
|
|
||||||
JSONObject json = NseIndiaRequest.stockByJYSFromHttp(stockType, symbol, moneyStock.getNseIndiaId());
|
|
||||||
json.put("id", moneyStock.getId());
|
|
||||||
json.put("company",moneyStock.getStockName());
|
|
||||||
return ServerResponse.createBySuccess(json);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getVolume(String scripcode) {
|
private String getVolume(String scripcode) {
|
||||||
@@ -651,7 +540,7 @@ public class MoneyApiController {
|
|||||||
|
|
||||||
@ApiOperation(value = "股票推荐TopGainer", httpMethod = "GET")
|
@ApiOperation(value = "股票推荐TopGainer", httpMethod = "GET")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "stockType", value = "BSE或者NSE"),
|
@ApiImplicitParam(name = "stockType", value = "BSE或者NSE或者germany"),
|
||||||
})
|
})
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "" +
|
@ApiResponse(code = 200, message = "" +
|
||||||
@@ -661,42 +550,41 @@ public class MoneyApiController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
@EncryptFilter(decryptRequest = false)
|
@EncryptFilter(decryptRequest = false)
|
||||||
|
|
||||||
public List<MoneyStockSuggestDTO> getTopGainer(@RequestParam String stockType) {
|
public List<MoneyStockSuggestDTO> getTopGainer(@RequestParam(required = false, defaultValue = "germany") String stockType) {
|
||||||
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
|
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
|
||||||
// 尝试从缓存中获取结果
|
// 尝试从缓存中获取结果
|
||||||
moneyStockSuggestDTOS = gainerStockSuggestCache.getIfPresent(stockType);
|
// Use TradingView API for German stocks
|
||||||
|
List<StockQuoteData> stockQuoteDataList = moneyApiService.getTopGainersFromTradingView();
|
||||||
|
moneyStockSuggestDTOS = convertStockQuoteDataToMoneyStockSuggestDTO(stockQuoteDataList);
|
||||||
|
|
||||||
|
|
||||||
if (moneyStockSuggestDTOS == null) {
|
|
||||||
// 缓存未命中,执行业务查询
|
|
||||||
if (StringUtils.equals(stockType, "nse")) {
|
|
||||||
moneyStockSuggestDTOS = nseGainer();
|
|
||||||
} else if (StringUtils.equals(stockType, "bse")) {
|
|
||||||
moneyStockSuggestDTOS = bseGainer();
|
|
||||||
}
|
|
||||||
Map<Object, Boolean> map = new HashMap<>();
|
|
||||||
moneyStockSuggestDTOS = moneyStockSuggestDTOS.stream()
|
|
||||||
.filter(f -> StringUtils.isNotBlank(f.getStockName()))
|
|
||||||
.filter(i -> map.putIfAbsent(i.getStockName(), Boolean.TRUE) == null).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(moneyStockSuggestDTOS)) {
|
|
||||||
List<String> selfUlrList = moneyStockSuggestDTOS.stream().map(MoneyStockSuggestDTO::getStockName).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(selfUlrList)) {
|
|
||||||
List<MoneyStock> all = moneyStockRepository.findAll(QMoneyStockPO.moneyStockPO.stockName.in(selfUlrList));
|
|
||||||
if (CollectionUtils.isNotEmpty(all)) {
|
|
||||||
moneyStockSuggestDTOS.stream().filter(f -> all.stream().anyMatch(s -> s.getStockName().equals(f.getStockName())))
|
|
||||||
.forEach(f -> f.setScId(all.stream().filter(s -> s.getStockName().equals(f.getStockName())).findFirst().orElse(null).getMoneyScId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gainerStockSuggestCache.put(stockType, moneyStockSuggestDTOS);
|
|
||||||
}
|
|
||||||
// 将结果放入缓存
|
|
||||||
}
|
|
||||||
return moneyStockSuggestDTOS;
|
return moneyStockSuggestDTOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<MoneyStockSuggestDTO> convertStockQuoteDataToMoneyStockSuggestDTO(List<StockQuoteData> stockQuoteDataList) {
|
||||||
|
List<MoneyStockSuggestDTO> result = new ArrayList<>();
|
||||||
|
if (CollectionUtils.isNotEmpty(stockQuoteDataList)) {
|
||||||
|
for (StockQuoteData stockQuoteData : stockQuoteDataList) {
|
||||||
|
MoneyStockSuggestDTO dto = new MoneyStockSuggestDTO();
|
||||||
|
dto.setStockName(stockQuoteData.getName());
|
||||||
|
dto.setStockType("XETRA");
|
||||||
|
dto.setLastPrice(String.valueOf(stockQuoteData.getClose()));
|
||||||
|
dto.setChange(String.valueOf(stockQuoteData.getChange()));
|
||||||
|
dto.setChangePercent(String.valueOf(stockQuoteData.getPercent_change()));
|
||||||
|
dto.setHighPrice(String.valueOf(stockQuoteData.getHigh()));
|
||||||
|
dto.setLowPrice(String.valueOf(stockQuoteData.getLow()));
|
||||||
|
dto.setPrevClosePrice(String.valueOf(stockQuoteData.getPrevious_close()));
|
||||||
|
dto.setScId(String.valueOf(stockQuoteData.getSymbol()));
|
||||||
|
dto.setDispId(String.valueOf(stockQuoteData.getSymbol()));
|
||||||
|
result.add(dto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "股票推荐TopLoser", httpMethod = "GET")
|
@ApiOperation(value = "股票推荐TopLoser", httpMethod = "GET")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name = "stockType", value = "BSE或者NSE"),
|
@ApiImplicitParam(name = "stockType", value = "BSE或者NSE或者germany"),
|
||||||
})
|
})
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "" +
|
@ApiResponse(code = 200, message = "" +
|
||||||
@@ -706,41 +594,11 @@ public class MoneyApiController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
@EncryptFilter(decryptRequest = false)
|
@EncryptFilter(decryptRequest = false)
|
||||||
|
|
||||||
public List<MoneyStockSuggestDTO> getTopLoser(@RequestParam String stockType) {
|
public List<MoneyStockSuggestDTO> getTopLoser(@RequestParam(required = false) String stockType) {
|
||||||
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
|
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
|
||||||
moneyStockSuggestDTOS = loserStockSuggestCache.getIfPresent(stockType);
|
List<StockQuoteData> stockQuoteDataList = moneyApiService.getTopLosersFromTradingView();
|
||||||
if (null == moneyStockSuggestDTOS) {
|
moneyStockSuggestDTOS = convertStockQuoteDataToMoneyStockSuggestDTO(stockQuoteDataList);
|
||||||
if (StringUtils.equals(stockType, "nse")) {
|
|
||||||
moneyStockSuggestDTOS = nseTopLoser();
|
|
||||||
} else if (StringUtils.equals(stockType, "bse")) {
|
|
||||||
moneyStockSuggestDTOS = bseTopLoser();
|
|
||||||
}
|
|
||||||
Map<Object, Boolean> map = new HashMap<>();
|
|
||||||
moneyStockSuggestDTOS = moneyStockSuggestDTOS.stream()
|
|
||||||
.filter(f -> StringUtils.isNotBlank(f.getStockName()))
|
|
||||||
.filter(i -> map.putIfAbsent(i.getStockName(), Boolean.TRUE) == null).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(moneyStockSuggestDTOS)) {
|
|
||||||
moneyStockSuggestDTOS.stream().forEach(f -> f.setDispId(extractLastSegment(f.getStockUrl())));
|
|
||||||
List<String> selfUlrList = moneyStockSuggestDTOS.stream().map(MoneyStockSuggestDTO::getStockName).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(selfUlrList)) {
|
|
||||||
List<MoneyStock> all = moneyStockRepository.findAll(QMoneyStockPO.moneyStockPO.stockName.in(selfUlrList));
|
|
||||||
if (CollectionUtils.isNotEmpty(all)) {
|
|
||||||
moneyStockSuggestDTOS.stream().filter(f -> all.stream().anyMatch(s -> s.getStockName().equals(f.getStockName())))
|
|
||||||
.forEach(f -> f.setScId(all.stream().filter(s -> s.getStockName().equals(f.getStockName())).findFirst().orElse(null).getMoneyScId()));
|
|
||||||
}
|
|
||||||
List<MoneyStockSuggestDTO> noScIdList = moneyStockSuggestDTOS.stream().filter(f -> StringUtils.isBlank(f.getScId())).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(noScIdList)) {
|
|
||||||
List<String> dispIdList = noScIdList.stream().map(MoneyStockSuggestDTO::getDispId).collect(Collectors.toList());
|
|
||||||
List<MoneyStock> all1 = moneyStockRepository.findAll(QMoneyStockPO.moneyStockPO.selfDispId.in(dispIdList));
|
|
||||||
if (CollectionUtils.isNotEmpty(all1)) {
|
|
||||||
moneyStockSuggestDTOS.stream().filter(f -> all1.stream().anyMatch(s -> s.getSelfDispId().equals(f.getDispId())))
|
|
||||||
.forEach(f -> f.setScId(all.stream().filter(s -> s.getSelfDispId().equals(f.getDispId())).findFirst().orElse(null).getMoneyScId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
loserStockSuggestCache.put(stockType, moneyStockSuggestDTOS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return moneyStockSuggestDTOS;
|
return moneyStockSuggestDTOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -757,43 +615,35 @@ public class MoneyApiController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
@EncryptFilter(decryptRequest = false)
|
@EncryptFilter(decryptRequest = false)
|
||||||
|
|
||||||
public List<MoneyStockSuggestDTO> getTopActive(@RequestParam String stockType) {
|
public List<StockQuoteData> getTopActive(@RequestParam(value = "stockType", required = false) String stockType, @RequestParam(value = "type", required = false) String type) {
|
||||||
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
|
List<String> topActiveCode = Arrays.asList("AAPL:NASDAQ","MSFT:NASDAQ","GOOGL:NASDAQ","AMZN:NASDAQ","META:NASDAQ","TSLA:NASDAQ","NVDA:NASDAQ","BRK.B:NYSE","JPM:NYSE",
|
||||||
moneyStockSuggestDTOS = activesStockSuggestCache.getIfPresent(stockType);
|
"UNH:NYSE", "V:NYSE", "MA:NYSE","JNJ:NYSE","XOM:NYSE","PG:NYSE","HD:NYSE","LLY:NYSE","KO:NYSE", "PEP:NASDAQ", "NFLX:NASDAQ",
|
||||||
if (moneyStockSuggestDTOS == null) {
|
"SAP:XETR", "SIE:XETR", "DTE:XETR", "ALV:XETR", "BAS:XETR", "BMW:XETR", "VOW3:XETR", "ADS:XETR", "BAYN:XETR", "RWE:XETR",
|
||||||
if (StringUtils.equals(stockType, "nse")) {
|
"DBK:XETR", "MUV2:XETR", "FME:XETR", "FRE:XETR", "HEI:XETR", "HEN3:XETR", "LIN:XETR", "IFX:XETR", "CON:XETR", "ZAL:XETR",
|
||||||
moneyStockSuggestDTOS = nseActives();
|
"ITX:BME", "AIR:BME", "SAN:BME", "IBE:BME", "BBVA:BME", "XPBR:BME", "XPBRA:BME", "CABK:BME", "XAMXB:BME", "CCEP:BME",
|
||||||
} else if (StringUtils.equals(stockType, "bse")) {
|
"XVALO:BME", "AENA:BME", "FER:BME", "AMS:BME", "ELE:BME", "TEF:BME", "NTGY:BME", "XBBDC:BME", "CLNX:BME", "XNOR:BME"
|
||||||
moneyStockSuggestDTOS = bseActives();
|
);
|
||||||
}
|
QStockPO q = QStockPO.stockPO;
|
||||||
Map<Object, Boolean> map = new HashMap<>();
|
ConditionBuilder builder = ConditionBuilder.builder();
|
||||||
moneyStockSuggestDTOS = moneyStockSuggestDTOS.stream()
|
builder.and(q.stockCode.in(topActiveCode));
|
||||||
.filter(f -> StringUtils.isNotBlank(f.getStockName()))
|
if(type != null && !type.trim().isEmpty()) {
|
||||||
.filter(i -> map.putIfAbsent(i.getStockName(), Boolean.TRUE) == null).collect(Collectors.toList());
|
if (type.equals("us")) {
|
||||||
if (CollectionUtils.isNotEmpty(moneyStockSuggestDTOS)) {
|
builder.and(q.stockType.in("NASDAQ", "NYSE"));
|
||||||
moneyStockSuggestDTOS.stream().forEach(f -> f.setDispId(extractLastSegment(f.getStockUrl())));
|
} else if (type.equals("dg")) {
|
||||||
List<String> selfUlrList = moneyStockSuggestDTOS.stream().map(MoneyStockSuggestDTO::getStockName).collect(Collectors.toList());
|
builder.and(q.stockType.in("XETR"));
|
||||||
if (CollectionUtils.isNotEmpty(selfUlrList)) {
|
} else if (type.equals("es")) {
|
||||||
List<MoneyStock> all = moneyStockRepository.findAll(QMoneyStockPO.moneyStockPO.stockName.in(selfUlrList));
|
builder.and(q.stockType.in("BME"));
|
||||||
if (CollectionUtils.isNotEmpty(all)) {
|
|
||||||
moneyStockSuggestDTOS.stream().filter(f -> all.stream().anyMatch(s -> s.getStockName().equals(f.getStockName())))
|
|
||||||
.forEach(f -> f.setScId(all.stream().filter(s -> s.getStockName().equals(f.getStockName())).findFirst().orElse(null).getMoneyScId()));
|
|
||||||
}
|
|
||||||
List<MoneyStockSuggestDTO> noScIdList = moneyStockSuggestDTOS.stream().filter(f -> StringUtils.isBlank(f.getScId())).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(noScIdList)) {
|
|
||||||
List<String> dispIdList = noScIdList.stream().map(MoneyStockSuggestDTO::getDispId).collect(Collectors.toList());
|
|
||||||
List<MoneyStock> all1 = moneyStockRepository.findAll(QMoneyStockPO.moneyStockPO.selfDispId.in(dispIdList));
|
|
||||||
if (CollectionUtils.isNotEmpty(all1)) {
|
|
||||||
moneyStockSuggestDTOS.stream().filter(f -> all1.stream().anyMatch(s -> s.getSelfDispId().equals(f.getDispId())))
|
|
||||||
.forEach(f -> f.setScId(all.stream().filter(s -> s.getSelfDispId().equals(f.getDispId())).findFirst().orElse(null).getMoneyScId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
activesStockSuggestCache.put(stockType, moneyStockSuggestDTOS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<Stock> stocks = stockRepository.findAll(builder.build());
|
||||||
return moneyStockSuggestDTOS;
|
List<StockQuoteData> stockQuoteDatas = moneyApiService.getStocksQuote(stocks);
|
||||||
|
for (StockQuoteData stockQuoteData : stockQuoteDatas) {
|
||||||
|
Stock name = stocks.stream().filter(e->e.getStockCode().equals(stockQuoteData.getSymbol())).findFirst().orElse(null);
|
||||||
|
if (name != null) {
|
||||||
|
stockQuoteData.setName(name.getStockName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stockQuoteDatas;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addToListDouble(List<Double> list, String value) {
|
private static void addToListDouble(List<Double> list, String value) {
|
||||||
@@ -834,343 +684,15 @@ public class MoneyApiController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping({"/market/api/market/money/history/kLine", "/api/market/money/history/kLine"})
|
@GetMapping({"/market/api/market/money/history/kLine", "/api/market/money/history/kLine"})
|
||||||
@ApiOperation(value = "获取kline的money数据源", notes = "获取kline的money数据源", response = StockHistoryResponse.class)
|
@ApiOperation(value = "获取kline的money数据源", notes = "获取kline的money数据源", response = StockHistoryResponse.class)
|
||||||
@ApiImplicitParams({
|
|
||||||
@ApiImplicitParam(name = "symbol", value = "Stock symbol 对应的是NSEID 或者是BSEID", required = true, dataType = "String", paramType = "query"),
|
|
||||||
@ApiImplicitParam(name = "resolution", value = "单位:60 1D 1W 1D 对应H,D,W,Y", required = true, dataType = "String", paramType = "query"),
|
|
||||||
@ApiImplicitParam(name = "from", value = "Start timestamp", required = true, dataType = "long", paramType = "query"),
|
|
||||||
@ApiImplicitParam(name = "to", value = "End timestamp", required = true, dataType = "long", paramType = "query"),
|
|
||||||
@ApiImplicitParam(name = "countback", value = "开始时间和结束时间区间的计划展示的数量", required = true, dataType = "int", paramType = "query"),
|
|
||||||
@ApiImplicitParam(name = "currencyCode", value = "INR 不变", required = true, dataType = "String", paramType = "query")
|
|
||||||
})
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@EncryptFilter(decryptRequest = false)
|
@EncryptFilter(decryptRequest = false)
|
||||||
public ResponseEntity<StockHistoryResponse> getStockHistory(@RequestParam String symbol,
|
public ResponseEntity<StockHistoryResponse> getStockChart(@RequestParam String symbol,
|
||||||
@RequestParam String resolution
|
@RequestParam String interval,
|
||||||
|
@RequestParam(required = false) Integer amount
|
||||||
) {
|
) {
|
||||||
MoneyStock moneyStock1 = moneyStockRepository.findOne(
|
return ResponseEntity.ok(moneyApiService.getStockHistory(symbol, interval, amount));
|
||||||
QMoneyStockPO.moneyStockPO.nseIndiaId.eq(symbol)
|
|
||||||
.and(QMoneyStockPO.moneyStockPO.isLock.eq(0))
|
|
||||||
.and(QMoneyStockPO.moneyStockPO.isShow.eq(0)))
|
|
||||||
.orElse(null);
|
|
||||||
|
|
||||||
if (moneyStock1 != null && moneyStock1.getUseFromBseindia()) {
|
|
||||||
|
|
||||||
String json = this.getChartData(moneyStock1.getNseIndiaId(), resolution);
|
|
||||||
|
|
||||||
Gson gson = new Gson();
|
|
||||||
|
|
||||||
JsonObject outerJson = gson.fromJson(json, JsonObject.class);
|
|
||||||
|
|
||||||
String innerJsonString;
|
|
||||||
|
|
||||||
if (resolution.equals("H")) {
|
|
||||||
innerJsonString = outerJson.get("getDatIResult").getAsString();
|
|
||||||
} else {
|
|
||||||
innerJsonString = outerJson.get("getDatResult").getAsString();
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonObject innerJson = gson.fromJson(innerJsonString, JsonObject.class);
|
|
||||||
|
|
||||||
JsonArray dataInputValues = innerJson.getAsJsonArray("DataInputValues");
|
|
||||||
|
|
||||||
List<Double> openList = new ArrayList<>();
|
|
||||||
List<Double> highList = new ArrayList<>();
|
|
||||||
List<Double> lowList = new ArrayList<>();
|
|
||||||
List<Double> closeList = new ArrayList<>();
|
|
||||||
List<Long> volumeList = new ArrayList<>();
|
|
||||||
List<Long> dateList = new ArrayList<>();
|
|
||||||
|
|
||||||
Map<String, JsonObject> latestDataMap = new LinkedHashMap<>();
|
|
||||||
|
|
||||||
if (dataInputValues.size() > 0) {
|
|
||||||
JsonObject dataObject = dataInputValues.get(0).getAsJsonObject();
|
|
||||||
|
|
||||||
JsonArray openArray = dataObject.getAsJsonArray("OpenData");
|
|
||||||
JsonArray highArray = dataObject.getAsJsonArray("HighData");
|
|
||||||
JsonArray lowArray = dataObject.getAsJsonArray("LowData");
|
|
||||||
JsonArray closeArray = dataObject.getAsJsonArray("CloseData");
|
|
||||||
JsonArray volumeArray = dataObject.getAsJsonArray("VolumeData");
|
|
||||||
JsonArray dateArray = dataObject.getAsJsonArray("DateData");
|
|
||||||
|
|
||||||
if (resolution.equals("H")) {
|
|
||||||
openArray.forEach(o -> addToListDouble(openList, o.getAsJsonObject().get("Open").getAsString()));
|
|
||||||
highArray.forEach(h -> addToListDouble(highList, h.getAsJsonObject().get("High").getAsString()));
|
|
||||||
lowArray.forEach(l -> addToListDouble(lowList, l.getAsJsonObject().get("Low").getAsString()));
|
|
||||||
closeArray.forEach(c -> addToListDouble(closeList, c.getAsJsonObject().get("Close").getAsString()));
|
|
||||||
volumeArray.forEach(v -> addToList(volumeList, v.getAsJsonObject().get("Volume").getAsString()));
|
|
||||||
dateArray.forEach(d -> addDatesToList(dateList, d.getAsJsonObject().get("Date").getAsString()));
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < openArray.size(); i++) {
|
|
||||||
String open = openArray.get(i).getAsJsonObject().get("Open").getAsString();
|
|
||||||
String high = highArray.get(i).getAsJsonObject().get("High").getAsString();
|
|
||||||
String low = lowArray.get(i).getAsJsonObject().get("Low").getAsString();
|
|
||||||
String close = closeArray.get(i).getAsJsonObject().get("Close").getAsString();
|
|
||||||
String volume = volumeArray.get(i).getAsJsonObject().get("Volume").getAsString();
|
|
||||||
String dateStr = dateArray.get(i).getAsJsonObject().get("Date").getAsString();
|
|
||||||
|
|
||||||
Long timestamp = convertToTimestamp(dateStr);
|
|
||||||
|
|
||||||
String dateTimeKey = dateStr;
|
|
||||||
|
|
||||||
JsonObject dataJson = new JsonObject();
|
|
||||||
dataJson.addProperty("Open", open);
|
|
||||||
dataJson.addProperty("High", high);
|
|
||||||
dataJson.addProperty("Low", low);
|
|
||||||
dataJson.addProperty("Close", close);
|
|
||||||
dataJson.addProperty("Volume", volume);
|
|
||||||
dataJson.addProperty("Date", dateStr);
|
|
||||||
|
|
||||||
latestDataMap.put(dateTimeKey, dataJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
latestDataMap.forEach((key, value) -> {
|
|
||||||
// Lấy giá trị các trường Open, High, Low, Close, Volume, Date từ dữ liệu
|
|
||||||
String openData = value.get("Open").getAsString();
|
|
||||||
String highData = value.get("High").getAsString();
|
|
||||||
String lowData = value.get("Low").getAsString();
|
|
||||||
String closeData = value.get("Close").getAsString();
|
|
||||||
String volumeData = value.get("Volume").getAsString();
|
|
||||||
String dateData = value.get("Date").getAsString();
|
|
||||||
|
|
||||||
// Tách các giá trị trong chuỗi bằng dấu phẩy
|
|
||||||
String[] openValues = openData.split(",");
|
|
||||||
String[] highValues = highData.split(",");
|
|
||||||
String[] lowValues = lowData.split(",");
|
|
||||||
String[] closeValues = closeData.split(",");
|
|
||||||
String[] volumeValues = volumeData.split(",");
|
|
||||||
String[] dateValues = dateData.split(",");
|
|
||||||
|
|
||||||
for (int i = 0; i < openValues.length; i++) {
|
|
||||||
double open = Double.parseDouble(openValues[i]);
|
|
||||||
double high = Double.parseDouble(highValues[i]);
|
|
||||||
double low = Double.parseDouble(lowValues[i]);
|
|
||||||
double close = Double.parseDouble(closeValues[i]);
|
|
||||||
long volume = Math.round(Double.parseDouble(volumeValues[i]));
|
|
||||||
long timestamp = convertToTimestamp(dateValues[i]);
|
|
||||||
|
|
||||||
int index = dateList.indexOf(timestamp);
|
|
||||||
if (index == -1) {
|
|
||||||
dateList.add(timestamp);
|
|
||||||
openList.add(open);
|
|
||||||
highList.add(high);
|
|
||||||
lowList.add(low);
|
|
||||||
closeList.add(close);
|
|
||||||
volumeList.add(volume);
|
|
||||||
} else {
|
|
||||||
openList.set(index, open);
|
|
||||||
highList.set(index, high);
|
|
||||||
lowList.set(index, low);
|
|
||||||
closeList.set(index, close);
|
|
||||||
volumeList.set(index, volume);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
StockHistoryResponse response = new StockHistoryResponse();
|
|
||||||
response.setS("ok");
|
|
||||||
response.setT(dateList);
|
|
||||||
response.setO(openList);
|
|
||||||
response.setH(highList);
|
|
||||||
response.setL(lowList);
|
|
||||||
response.setC(closeList);
|
|
||||||
response.setV(volumeList);
|
|
||||||
|
|
||||||
// if (resolution.equals("H")) {
|
|
||||||
// Set<String> desiredTimes = new HashSet<>(Arrays.asList("09:30", "10:30", "11:30", "12:30", "13:30", "14:30"));
|
|
||||||
//
|
|
||||||
// // Filter data based on timestamps
|
|
||||||
// SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
|
|
||||||
// List<Integer> indicesToKeep = new ArrayList<>();
|
|
||||||
// for (int i = 0; i < dateList.size(); i++) {
|
|
||||||
// String time = sdf.format(new Date(dateList.get(i) * 1000));
|
|
||||||
// if (desiredTimes.contains(time)) {
|
|
||||||
// indicesToKeep.add(i);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Filter corresponding data
|
|
||||||
// List<Long> filteredT = indicesToKeep.stream().map(dateList::get).collect(Collectors.toList());
|
|
||||||
// List<Double> filteredO = indicesToKeep.stream().map(openList::get).collect(Collectors.toList());
|
|
||||||
// List<Double> filteredH = indicesToKeep.stream().map(highList::get).collect(Collectors.toList());
|
|
||||||
// List<Double> filteredL = indicesToKeep.stream().map(lowList::get).collect(Collectors.toList());
|
|
||||||
// List<Double> filteredC = indicesToKeep.stream().map(closeList::get).collect(Collectors.toList());
|
|
||||||
// List<Long> filteredV = indicesToKeep.stream().map(volumeList::get).collect(Collectors.toList());
|
|
||||||
// response.setT(filteredT);
|
|
||||||
// response.setO(filteredO);
|
|
||||||
// response.setH(filteredH);
|
|
||||||
// response.setL(filteredL);
|
|
||||||
// response.setC(filteredC);
|
|
||||||
// response.setV(filteredV);
|
|
||||||
// }
|
|
||||||
return ResponseEntity.ok(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 向外部API发起请求,并获取响应
|
|
||||||
StockHistoryRequest request = new StockHistoryRequest();
|
|
||||||
request.setSymbol(symbol);
|
|
||||||
Long to = null;
|
|
||||||
Long from = null;
|
|
||||||
int countback = 5;
|
|
||||||
if(StringUtils.equals("H",resolution)){
|
|
||||||
to = (long) (System.currentTimeMillis() / 1000);
|
|
||||||
from = to - (10 * 60 * 60 );
|
|
||||||
countback = 328;
|
|
||||||
request.setResolution("60");
|
|
||||||
}else if(StringUtils.equals("D",resolution)){
|
|
||||||
to = (long) (System.currentTimeMillis() / 1000);
|
|
||||||
from = to - (2 * 30 * 24 * 60 * 60 );
|
|
||||||
countback = 730;
|
|
||||||
request.setResolution("1D");
|
|
||||||
} else if (StringUtils.equals("W", resolution)) {
|
|
||||||
to = (long) (System.currentTimeMillis() / 1000);
|
|
||||||
from = to - (7 * 24 * 60 * 60);
|
|
||||||
countback = 730;
|
|
||||||
request.setResolution("1W");
|
|
||||||
} else if (StringUtils.equals("M", resolution)) {
|
|
||||||
to = (long) (System.currentTimeMillis() / 1000);
|
|
||||||
from = to - (15 * 30 * 24 * 60 * 60);
|
|
||||||
countback = 730;
|
|
||||||
request.setResolution("1D");
|
|
||||||
}
|
|
||||||
|
|
||||||
request.setFrom(from);
|
|
||||||
request.setTo(to);
|
|
||||||
request.setCountback(countback);
|
|
||||||
request.setCurrencyCode("INR");
|
|
||||||
String apiUrl = buildApiUrl(request);
|
|
||||||
log.info("request url:" + apiUrl);
|
|
||||||
StockHistoryResponse response = null;
|
|
||||||
int maxRetries = 3;
|
|
||||||
int retryCount = 0;
|
|
||||||
|
|
||||||
while (response == null && retryCount < maxRetries) {
|
|
||||||
try {
|
|
||||||
if (StringUtils.equals("M", resolution)) {
|
|
||||||
CloseableHttpClient client = HttpClients.createDefault();
|
|
||||||
HttpGet req = new HttpGet(apiUrl);
|
|
||||||
HttpResponse resp = client.execute(req);
|
|
||||||
String jsonResponse = EntityUtils.toString(resp.getEntity(), "UTF-8");
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
JsonNode rootNode = mapper.readTree(jsonResponse);
|
|
||||||
|
|
||||||
JsonNode timeNode = rootNode.get("t");
|
|
||||||
JsonNode lowNode = rootNode.get("l");
|
|
||||||
JsonNode highNode = rootNode.get("h");
|
|
||||||
JsonNode openNode = rootNode.get("o");
|
|
||||||
JsonNode closeNode = rootNode.get("c");
|
|
||||||
JsonNode volumeNote = rootNode.get("v");
|
|
||||||
|
|
||||||
List<StockChartDto> stocks = new ArrayList<>();
|
|
||||||
for (int i = 0; i < timeNode.size(); i++) {
|
|
||||||
long timestamp = timeNode.get(i).asLong();
|
|
||||||
double closePrice = closeNode.get(i).asDouble();
|
|
||||||
double openPrice = openNode.get(i).asDouble();
|
|
||||||
double volume = volumeNote.get(i).asDouble();
|
|
||||||
double low = lowNode.get(i).asDouble();
|
|
||||||
double high = highNode.get(i).asDouble();
|
|
||||||
|
|
||||||
stocks.add(new StockChartDto(timestamp, openPrice, high, low, closePrice, volume));
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, List<StockChartDto>> groupedByMonth = stocks.stream()
|
|
||||||
.collect(Collectors.groupingBy(
|
|
||||||
sp -> Instant.ofEpochSecond(sp.getTimestamp())
|
|
||||||
.atZone(ZoneId.systemDefault())
|
|
||||||
.toLocalDate()
|
|
||||||
.format(DateTimeFormatter.ofPattern("yyyy-MM")),
|
|
||||||
LinkedHashMap::new,
|
|
||||||
Collectors.toList()
|
|
||||||
));
|
|
||||||
|
|
||||||
List<Long> timestamps = new ArrayList<>();
|
|
||||||
List<Double> opens = new ArrayList<>();
|
|
||||||
List<Double> closes = new ArrayList<>();
|
|
||||||
List<Double> highs = new ArrayList<>();
|
|
||||||
List<Double> lows = new ArrayList<>();
|
|
||||||
List<Long> volumes = new ArrayList<>();
|
|
||||||
|
|
||||||
response = new StockHistoryResponse();
|
|
||||||
groupedByMonth.forEach((month, prices) -> {
|
|
||||||
double open = prices.get(0).getOpen();
|
|
||||||
double close = prices.get(prices.size() - 1).getClose();
|
|
||||||
double high = prices.stream().mapToDouble(StockChartDto::getHigh).max().orElse(0);
|
|
||||||
double low = prices.stream().mapToDouble(StockChartDto::getLow).min().orElse(0);
|
|
||||||
double volume = prices.stream().mapToDouble(StockChartDto::getVolume).sum();
|
|
||||||
|
|
||||||
long timestamp = YearMonth.parse(month, DateTimeFormatter.ofPattern("yyyy-MM")).atDay(1).atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli() / 1000;
|
|
||||||
timestamps.add(timestamp);
|
|
||||||
opens.add(open);
|
|
||||||
closes.add(close);
|
|
||||||
highs.add(high);
|
|
||||||
lows.add(low);
|
|
||||||
volumes.add((long) volume);
|
|
||||||
|
|
||||||
System.out.println("Month: " + month);
|
|
||||||
System.out.println("Open: " + open + ", Close: " + close + ", High: " + high + ", Low: " + low);
|
|
||||||
});
|
|
||||||
|
|
||||||
response.setS("ok");
|
|
||||||
response.setT(timestamps);
|
|
||||||
response.setL(lows);
|
|
||||||
response.setH(highs);
|
|
||||||
response.setO(opens);
|
|
||||||
response.setC(closes);
|
|
||||||
response.setV(volumes);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
response = restTemplate.getForObject(apiUrl, StockHistoryResponse.class);
|
|
||||||
}
|
|
||||||
} catch (RestClientException e) {
|
|
||||||
// Log the exception or perform any other error handling
|
|
||||||
log.error("Error while making API request. Retrying... (Retry count: {})", retryCount + 1);
|
|
||||||
|
|
||||||
// Increment the retry count
|
|
||||||
retryCount++;
|
|
||||||
// Add some delay before the next retry (you can adjust this as needed)
|
|
||||||
try {
|
|
||||||
Thread.sleep(300); // 1 second delay
|
|
||||||
} catch (InterruptedException ex) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
} catch (ClientProtocolException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response != null && !response.getS().equals("error")) {
|
|
||||||
// setResponse(response, resolution);
|
|
||||||
// API request successful, return the response
|
|
||||||
return ResponseEntity.ok(response);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
MoneyStock moneyStock = moneyStockRepository.findOne((QMoneyStockPO.moneyStockPO.moneyScId.eq(symbol))
|
|
||||||
.and(QMoneyStockPO.moneyStockPO.isLock.eq(0))
|
|
||||||
.and(QMoneyStockPO.moneyStockPO.isShow.eq(0)))
|
|
||||||
.orElse(null);
|
|
||||||
|
|
||||||
if (moneyStock != null && moneyStock.getNseIndiaChartId() != null && !moneyStock.getNseIndiaChartId().isEmpty()) {
|
|
||||||
request.setSymbol(moneyStock.getNseIndiaChartId());
|
|
||||||
response = NseIndiaRequest.stockKLineFromHttp(request, resolution);
|
|
||||||
return ResponseEntity.ok(response);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Failed to get data from nseindia.", e.getMessage());
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
// All retries failed, return an error response
|
|
||||||
log.error("Failed to get a successful response after {} retries.", maxRetries);
|
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
|
||||||
}
|
|
||||||
// 返回响应
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping({"/market/api/market/stock/optional", "/api/market/stock/optional"})
|
@GetMapping({"/market/api/market/stock/optional", "/api/market/stock/optional"})
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class SiteNewsController {
|
|||||||
@RequestParam(value = "type", defaultValue = "0") Integer type,
|
@RequestParam(value = "type", defaultValue = "0") Integer type,
|
||||||
@RequestParam(value = "sort", defaultValue = "time1") String sort,
|
@RequestParam(value = "sort", defaultValue = "time1") String sort,
|
||||||
@RequestParam(value = "keyword", required = false) String keyword, HttpServletRequest request) {
|
@RequestParam(value = "keyword", required = false) String keyword, HttpServletRequest request) {
|
||||||
return this.iSiteNewsService.getList(pageNum, pageSize, type, sort, keyword, request);
|
return this.iSiteNewsService.getLatestStockNews(pageNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
//新闻资讯-详情
|
//新闻资讯-详情
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import cn.qutaojing.common.PageParam;
|
|||||||
import cn.qutaojing.common.jpa.ConditionBuilder;
|
import cn.qutaojing.common.jpa.ConditionBuilder;
|
||||||
import cn.stock.market.domain.basic.entity.SiteNews;
|
import cn.stock.market.domain.basic.entity.SiteNews;
|
||||||
import cn.stock.market.domain.basic.repository.SiteNewsRepository;
|
import cn.stock.market.domain.basic.repository.SiteNewsRepository;
|
||||||
|
import cn.stock.market.domain.basic.service.SiteNewsService;
|
||||||
import cn.stock.market.infrastructure.db.po.QSiteNewsPO;
|
import cn.stock.market.infrastructure.db.po.QSiteNewsPO;
|
||||||
import cn.stock.market.infrastructure.job.InvestingTask;
|
import cn.stock.market.infrastructure.job.InvestingTask;
|
||||||
import cn.stock.market.web.annotations.EncryptFilter;
|
import cn.stock.market.web.annotations.EncryptFilter;
|
||||||
@@ -72,6 +73,8 @@ public class StockApiController {
|
|||||||
StockService stockService;
|
StockService stockService;
|
||||||
@Autowired
|
@Autowired
|
||||||
SiteNewsRepository newsRepository;
|
SiteNewsRepository newsRepository;
|
||||||
|
@Autowired
|
||||||
|
SiteNewsService siteNewsService;
|
||||||
|
|
||||||
@RequestMapping({"getRawSinaStock.do"})
|
@RequestMapping({"getRawSinaStock.do"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@@ -167,7 +170,7 @@ public class StockApiController {
|
|||||||
@ApiOperation(value = "印度新闻列表", httpMethod = "GET")
|
@ApiOperation(value = "印度新闻列表", httpMethod = "GET")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ServerResponse getINDNews(@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNum") Integer pageNum) {
|
public ServerResponse getINDNews(@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNum") Integer pageNum) {
|
||||||
return ServerResponse.createBySuccess(newsRepository.findAll(ConditionBuilder.builder().build(), PageParam.of(pageNum, pageSize), QSiteNewsPO.siteNewsPO.id.desc()));
|
return siteNewsService.getLatestStockNews(pageNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping({"test.do"})
|
@RequestMapping({"test.do"})
|
||||||
@@ -249,8 +252,12 @@ public class StockApiController {
|
|||||||
public ServerResponse getIndiaIndexByToday() {
|
public ServerResponse getIndiaIndexByToday() {
|
||||||
String INDEX_CODE = "TODAY_INDEX";
|
String INDEX_CODE = "TODAY_INDEX";
|
||||||
return RequestCacheUtils.cache("getIndiaIndexByToday.do", INDEX_CODE,6000, (string) -> {
|
return RequestCacheUtils.cache("getIndiaIndexByToday.do", INDEX_CODE,6000, (string) -> {
|
||||||
return this.stockService.getIndexByBtoday();
|
try {
|
||||||
});
|
return this.stockService.getIndexByBtoday();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@RequestMapping({"getIndiaIndexByEttech.do"})
|
@RequestMapping({"getIndiaIndexByEttech.do"})
|
||||||
@ApiOperation(value = "印度--获取指定指数信息-Ettech", httpMethod = "GET")
|
@ApiOperation(value = "印度--获取指定指数信息-Ettech", httpMethod = "GET")
|
||||||
|
|||||||
@@ -39,4 +39,5 @@ public class Config {
|
|||||||
String aliyunAccessKeyId;
|
String aliyunAccessKeyId;
|
||||||
String aliyunAccessKeySecret;
|
String aliyunAccessKeySecret;
|
||||||
String aliyunAppCode;
|
String aliyunAppCode;
|
||||||
|
String stockUrlPrefix;
|
||||||
}
|
}
|
||||||
|
|||||||
265
src/main/java/cn/stock/market/web/service/MoneyApiService.java
Normal file
265
src/main/java/cn/stock/market/web/service/MoneyApiService.java
Normal file
@@ -0,0 +1,265 @@
|
|||||||
|
package cn.stock.market.web.service;
|
||||||
|
|
||||||
|
import cn.qutaojing.common.utils.SpringUtils;
|
||||||
|
import cn.stock.market.domain.basic.entity.Stock;
|
||||||
|
import cn.stock.market.domain.basic.repository.StockRepository;
|
||||||
|
import cn.stock.market.dto.*;
|
||||||
|
import cn.stock.market.infrastructure.db.po.QStockPO;
|
||||||
|
import cn.stock.market.web.config.Config;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MoneyApiService {
|
||||||
|
@Autowired
|
||||||
|
private ObjectMapper objectMapper;
|
||||||
|
@Autowired
|
||||||
|
private StockRepository stockRepository;
|
||||||
|
|
||||||
|
public StockHistoryResponse getStockHistory(String symbol, String interval, Integer amount) {
|
||||||
|
Stock stock = stockRepository.findStockByCode(symbol);
|
||||||
|
if (stock != null) {
|
||||||
|
RawStockApiResponse rawData = fetchChartData(symbol, interval, amount);
|
||||||
|
return convertToHistoryResponse(rawData);
|
||||||
|
} else {
|
||||||
|
StockHistoryResponse stockHistoryResponse = new StockHistoryResponse();
|
||||||
|
stockHistoryResponse.setS("fail!");
|
||||||
|
return stockHistoryResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RawStockApiResponse fetchChartData(String symbol, String interval, Integer amount) {
|
||||||
|
Config config = SpringUtils.getBean(Config.class);
|
||||||
|
String url = config.getStockUrlPrefix() + "/api/ger-market/chart?symbol=" + symbol + "&interval=" + interval;
|
||||||
|
if (amount != null) {
|
||||||
|
url += "&amount=" + amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("accept", "application/json, text/plain, */*");
|
||||||
|
headers.add("accept-language", "en-US,en;q=0.9,vi;q=0.8");
|
||||||
|
headers.add("origin", "https://moneytj.com");
|
||||||
|
headers.add("referer", "https://moneytj.com/");
|
||||||
|
headers.add("sec-ch-ua", "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"");
|
||||||
|
headers.add("sec-ch-ua-mobile", "?0");
|
||||||
|
headers.add("sec-ch-ua-platform", "\"Windows\"");
|
||||||
|
headers.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36");
|
||||||
|
|
||||||
|
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
return mapper.readValue(response.getBody(), RawStockApiResponse.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new RawStockApiResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StockQuoteData getSingleStockQuote(String symbol) {
|
||||||
|
Config config = SpringUtils.getBean(Config.class);
|
||||||
|
String url = config.getStockUrlPrefix() + "/api/ger-market/stocks/query-list?symbols=" + symbol;
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("accept", "application/json, text/plain, */*");
|
||||||
|
headers.add("accept-language", "en-US,en;q=0.9,vi;q=0.8");
|
||||||
|
headers.add("origin", "https://moneytj.com");
|
||||||
|
headers.add("referer", "https://moneytj.com/");
|
||||||
|
headers.add("sec-ch-ua", "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"");
|
||||||
|
headers.add("sec-ch-ua-mobile", "?0");
|
||||||
|
headers.add("sec-ch-ua-platform", "\"Windows\"");
|
||||||
|
headers.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36");
|
||||||
|
|
||||||
|
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
StockQuoteResponse quoteResponse = mapper.readValue(response.getBody(), StockQuoteResponse.class);
|
||||||
|
if (quoteResponse != null && quoteResponse.getData() != null && !quoteResponse.getData().isEmpty()) {
|
||||||
|
return quoteResponse.getData().get(0);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StockQuoteData> getStocksQuote(List<Stock> stocks) {
|
||||||
|
Config config = SpringUtils.getBean(Config.class);
|
||||||
|
String codes = stocks.stream().map(e->e.getStockCode()).collect(Collectors.joining(","));
|
||||||
|
|
||||||
|
String url = config.getStockUrlPrefix() + "/api/ger-market/stocks/query-list?symbols=" + codes;
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("accept", "application/json, text/plain, */*");
|
||||||
|
headers.add("accept-language", "en-US,en;q=0.9,vi;q=0.8");
|
||||||
|
headers.add("origin", "https://moneytj.com");
|
||||||
|
headers.add("referer", "https://moneytj.com/");
|
||||||
|
headers.add("sec-ch-ua", "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"");
|
||||||
|
headers.add("sec-ch-ua-mobile", "?0");
|
||||||
|
headers.add("sec-ch-ua-platform", "\"Windows\"");
|
||||||
|
headers.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36");
|
||||||
|
|
||||||
|
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
StockQuoteResponse quoteResponse = mapper.readValue(response.getBody(), StockQuoteResponse.class);
|
||||||
|
if (quoteResponse != null && quoteResponse.getData() != null && !quoteResponse.getData().isEmpty()) {
|
||||||
|
return quoteResponse.getData();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StockHistoryResponse convertToHistoryResponse(RawStockApiResponse apiResponse) {
|
||||||
|
StockHistoryResponse response = new StockHistoryResponse();
|
||||||
|
response.setS("ok");
|
||||||
|
response.setT(new ArrayList<>());
|
||||||
|
response.setO(new ArrayList<>());
|
||||||
|
response.setH(new ArrayList<>());
|
||||||
|
response.setL(new ArrayList<>());
|
||||||
|
response.setC(new ArrayList<>());
|
||||||
|
response.setV(new ArrayList<>());
|
||||||
|
|
||||||
|
List<StockDataDto> data = apiResponse.getData();
|
||||||
|
for (int i = data.size() - 1; i >= 0; i--) {
|
||||||
|
StockDataDto item = data.get(i);
|
||||||
|
response.getT().add(item.getTime());
|
||||||
|
response.getO().add(item.getOpen());
|
||||||
|
response.getH().add(item.getMax());
|
||||||
|
response.getL().add(item.getMin());
|
||||||
|
response.getC().add(item.getClose());
|
||||||
|
response.getV().add(item.getVolume());
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StockQuoteData> getTopGainersFromTradingView() {
|
||||||
|
List<StockQuoteData> result = getTopStocksFromTradingView("desc");
|
||||||
|
// Sort by percent_change in descending order for gainers
|
||||||
|
return result.stream()
|
||||||
|
.sorted((a, b) -> Double.compare(b.getPercent_change(), a.getPercent_change()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StockQuoteData> getTopLosersFromTradingView() {
|
||||||
|
List<StockQuoteData> result = getTopStocksFromTradingView("asc");
|
||||||
|
// Sort by percent_change in ascending order for losers
|
||||||
|
return result.stream()
|
||||||
|
.sorted((a, b) -> Double.compare(a.getPercent_change(), b.getPercent_change()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<StockQuoteData> getTopStocksFromTradingView(String sortOrder) {
|
||||||
|
String url = "https://scanner.tradingview.com/germany/scan";
|
||||||
|
|
||||||
|
// Determine preset based on sort order
|
||||||
|
String preset = "desc".equals(sortOrder) ? "gainers" : "losers";
|
||||||
|
|
||||||
|
// Prepare request body
|
||||||
|
String requestBody = "{\n" +
|
||||||
|
" \"columns\": [\n" +
|
||||||
|
" \"name\",\n" +
|
||||||
|
" \"description\",\n" +
|
||||||
|
" \"logoid\",\n" +
|
||||||
|
" \"update_mode\",\n" +
|
||||||
|
" \"type\",\n" +
|
||||||
|
" \"currency\",\n" +
|
||||||
|
" \"change\",\n" +
|
||||||
|
" \"volume\",\n" +
|
||||||
|
" \"exchange\"\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"filter\": [\n" +
|
||||||
|
" {\n" +
|
||||||
|
" \"left\": \"is_primary\",\n" +
|
||||||
|
" \"operation\": \"equal\",\n" +
|
||||||
|
" \"right\": true\n" +
|
||||||
|
" }\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"options\": {\n" +
|
||||||
|
" \"lang\": \"en\"\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"preset\": \"" + preset + "\",\n" +
|
||||||
|
" \"range\": [\n" +
|
||||||
|
" 0,\n" +
|
||||||
|
" 30\n" +
|
||||||
|
" ],\n" +
|
||||||
|
" \"sort\": {\n" +
|
||||||
|
" \"sortBy\": \"change\",\n" +
|
||||||
|
" \"sortOrder\": \"" + sortOrder + "\"\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"markets\": [\n" +
|
||||||
|
" \"germany\"\n" +
|
||||||
|
" ]\n" +
|
||||||
|
"}";
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("accept", "application/json");
|
||||||
|
headers.add("accept-language", "en-US,en;q=0.9,vi;q=0.8,ug;q=0.7,fr;q=0.6");
|
||||||
|
headers.add("origin", "https://www.tradingview.com");
|
||||||
|
headers.add("referer", "https://www.tradingview.com/");
|
||||||
|
headers.add("user-agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36");
|
||||||
|
headers.add("Content-Type", "application/json");
|
||||||
|
|
||||||
|
HttpEntity<String> entity = new HttpEntity<>(requestBody, headers);
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
TradingViewResponse tradingViewResponse = mapper.readValue(response.getBody(), TradingViewResponse.class);
|
||||||
|
|
||||||
|
if (tradingViewResponse != null && tradingViewResponse.getData() != null) {
|
||||||
|
// Extract symbols from TradingView response
|
||||||
|
List<String> symbols = tradingViewResponse.getData().stream()
|
||||||
|
.filter(item -> item.getS() != null && item.getS().startsWith("XETR:"))
|
||||||
|
.map(item -> item.getS().substring(5)) // Remove "XETR:" prefix
|
||||||
|
.limit(30)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!symbols.isEmpty()) {
|
||||||
|
// Find stocks in database
|
||||||
|
List<Stock> stocks = stockRepository.findAll(QStockPO.stockPO.stockCode.in(symbols));
|
||||||
|
|
||||||
|
if (!stocks.isEmpty()) {
|
||||||
|
List<StockQuoteData> stockQuoteDatas = getStocksQuote(stocks);
|
||||||
|
for (StockQuoteData stockQuoteData : stockQuoteDatas) {
|
||||||
|
Stock name = stocks.stream().filter(e->e.getStockCode().equals(stockQuoteData.getSymbol())).findFirst().orElse(null);
|
||||||
|
if (name != null) {
|
||||||
|
stockQuoteData.setName(name.getStockName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stockQuoteDatas;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,9 +3,9 @@ spring:
|
|||||||
show-sql: true
|
show-sql: true
|
||||||
# Redis配置
|
# Redis配置
|
||||||
redis:
|
redis:
|
||||||
host: 43.153.174.179
|
host: 43.165.126.173
|
||||||
password: a5v8b86P4mVzFlUqJV
|
password: a5v8b86P4mVzFlUqJV
|
||||||
port: 30001
|
port: 6379
|
||||||
database: 1
|
database: 1
|
||||||
lettuce:
|
lettuce:
|
||||||
pool:
|
pool:
|
||||||
@@ -17,9 +17,9 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
stock-market:
|
stock-market:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://43.153.174.179:30000/india_stock?useUnicode=true&characterEncoding=utf-8
|
url: jdbc:mysql://use-cdb-45wol5su.sql.tencentcdb.com:22490/stock-api?useUnicode=true&characterEncoding=utf-8
|
||||||
username: root
|
username: root
|
||||||
password: uNejHIFQGJOUtYTmE
|
password: 6QJXv8dA76klnqsWh6f
|
||||||
maxActive: 500
|
maxActive: 500
|
||||||
testWhileIdle: true
|
testWhileIdle: true
|
||||||
validationQuery: SELECT 1
|
validationQuery: SELECT 1
|
||||||
@@ -28,7 +28,7 @@ spring:
|
|||||||
stock:
|
stock:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
#url: jdbc:mysql://129.226.172.67:3306/vip_huananyong_c?useUnicode=true&characterEncoding=utf-8&useSSL=true&verifyServerCertificate=true&requireSSL=true&clientCertificateKeyStoreUrl=classpath:keystoremysql&clientCertificateKeyStorePassword=abs1234567890&trustCertificateKeyStoreUrl=classpath:truststoremysql&trustCertificateKeyStorePassword=abs1234567890
|
#url: jdbc:mysql://129.226.172.67:3306/vip_huananyong_c?useUnicode=true&characterEncoding=utf-8&useSSL=true&verifyServerCertificate=true&requireSSL=true&clientCertificateKeyStoreUrl=classpath:keystoremysql&clientCertificateKeyStorePassword=abs1234567890&trustCertificateKeyStoreUrl=classpath:truststoremysql&trustCertificateKeyStorePassword=abs1234567890
|
||||||
url: jdbc:mysql://124.156.133.209:33306/vip_huananyong_c?useUnicode=true&characterEncoding=utf-8&useSSL=true
|
url: jdbc:mysql://43.153.142.41:33306/vip_huananyong_c?useUnicode=true&characterEncoding=utf-8&useSSL=true
|
||||||
username: root
|
username: root
|
||||||
password: 33BsUUcnXRYgwt
|
password: 33BsUUcnXRYgwt
|
||||||
maxActive: 500
|
maxActive: 500
|
||||||
@@ -42,6 +42,8 @@ gugudataAppKey: K5LZKV8KAYM4
|
|||||||
aliyunAccessKeyId: LTAI5tJi2z8cegG8fTW7BSQu
|
aliyunAccessKeyId: LTAI5tJi2z8cegG8fTW7BSQu
|
||||||
aliyunAccessKeySecret: fnCI9LUcqLuH7D6nkhvSHQMob1JSm8
|
aliyunAccessKeySecret: fnCI9LUcqLuH7D6nkhvSHQMob1JSm8
|
||||||
aliyunAppCode: 75ef2615da614eaaa71e2e2058fc53b0
|
aliyunAppCode: 75ef2615da614eaaa71e2e2058fc53b0
|
||||||
|
|
||||||
|
stockUrlPrefix: https://apinode-dgdev.moneytj.com
|
||||||
# 具体看类:CloudStorageConfig
|
# 具体看类:CloudStorageConfig
|
||||||
oss:
|
oss:
|
||||||
type: 2 # 类型 1:七牛 2:阿里云 3:腾讯云
|
type: 2 # 类型 1:七牛 2:阿里云 3:腾讯云
|
||||||
|
|||||||
Reference in New Issue
Block a user