Merge branch 'develop' into 'main'

Develop

See merge request india/india_market_java!7
This commit is contained in:
rplees
2024-01-24 06:27:47 +00:00
4 changed files with 42 additions and 8 deletions

View File

@@ -31,6 +31,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
@@ -148,7 +149,14 @@ public class Scraper {
stockIpo.setStockPrice(entry.getBigDecimal("issue_price"));
stockIpo.setSubscriptionDate(convertStringToTimestamp(entry.getString("open_date")));
stockIpo.setListingDate(convertStringToTimestamp(entry.getString("listing_date")));
stockIpo.setTotalNumber(entry.getInteger("lot_size"));
Integer totalNumber = 0;
if(null!=entry.getInteger("issue_size")&&entry.getBigDecimal("issue_price")!=null&&!entry.getBigDecimal("issue_price").equals(BigDecimal.valueOf(0))){
Integer issue_size = entry.getInteger("issue_size");
BigDecimal issueSize = new BigDecimal(issue_size);
BigDecimal totalNumberBigDecimal = issueSize.divide(entry.getBigDecimal("issue_price"), 2, BigDecimal.ROUND_HALF_UP);
totalNumber = totalNumberBigDecimal.intValue();
}
stockIpo.setTotalNumber(totalNumber);
stockIpo.setApply(entry.getString("total_subs"));
stockIpo.setCreateDate(new Date());
stockIpo.setUpdateDate(new Date());
@@ -164,7 +172,14 @@ public class Scraper {
stockIpo.setStockPrice(entry.getBigDecimal("issue_price"));
stockIpo.setSubscriptionDate(convertStringToTimestamp(entry.getString("open_date")));
stockIpo.setListingDate(convertStringToTimestamp(entry.getString("listing_date")));
stockIpo.setTotalNumber(entry.getInteger("lot_size"));
Integer totalNumber = 0;
if(null!=entry.getInteger("issue_size")&&entry.getBigDecimal("issue_price")!=null&&!entry.getBigDecimal("issue_price").equals(BigDecimal.valueOf(0))){
Integer issue_size = entry.getInteger("issue_size");
BigDecimal issueSize = new BigDecimal(issue_size);
BigDecimal totalNumberBigDecimal = issueSize.divide(entry.getBigDecimal("issue_price"), 2, BigDecimal.ROUND_HALF_UP);
totalNumber = totalNumberBigDecimal.intValue();
}
stockIpo.setTotalNumber(totalNumber);
stockIpo.setApply(entry.getString("total_subs"));
stockIpo.setCreateDate(new Date());
stockIpo.setUpdateDate(new Date());
@@ -182,7 +197,7 @@ public class Scraper {
.collect(Collectors.toList());
listStockIpoList = listStockIpoList.stream()
.filter(stockIpos -> !existingStockScIds.contains(stockIpos.getStockCode()))
.filter(stockIpos -> !existingStockScIds.contains(stockIpos.getStockCode())).filter(stockIpo -> StringUtils.isNotBlank(stockIpo.getStockName()))
.collect(Collectors.toList());
//保存全部的新股

View File

@@ -2,6 +2,7 @@ package cn.stock.market.web;
import cn.stock.market.domain.basic.entity.BtodayStock;
import cn.stock.market.domain.basic.service.BtodayStockService;
import cn.stock.market.web.annotations.EncryptFilter;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -43,6 +44,8 @@ public class BTodayStockController {
@ApiImplicitParam(name="durationtype",value = "D(1D的时候传D),D(5D的时候传D),M(3M的时候传M),Y(1Y的时候传Y),Y(5Y的时候传Y),Y(10Y的时候传Y)"),
@ApiImplicitParam(name="duration",value = "1(1D的时候传1),5(5D的时候传5),3(3M的时候传3),1(1Y的时候传1),5(5Y的时候传5),10(10Y的时候传10)"),
})
@EncryptFilter(decryptRequest = false)
public JSONArray getPriceChartCompanyPullView(
@RequestParam(value = "exchange") String exchange,
@RequestParam(value = "co_code") String coCode,
@@ -138,6 +141,7 @@ public class BTodayStockController {
})
@GetMapping("/api/bToday/stockDetail")
@EncryptFilter(decryptRequest = false)
public com.alibaba.fastjson.JSONObject getPriceChartCompanyPullView(
@RequestParam(value = "exchange") String exchange,
@RequestParam(value = "co_code") String coCode

View File

@@ -8,6 +8,7 @@ import cn.stock.market.dto.StockHistoryResponse;
import cn.stock.market.infrastructure.db.po.QMoneyStockPO;
import cn.stock.market.utils.RequestCacheUtils;
import cn.stock.market.utils.ServerResponse;
import cn.stock.market.web.annotations.EncryptFilter;
import com.alibaba.fastjson.JSONObject;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
@@ -167,6 +168,8 @@ public class MoneyApiController {
})
@GetMapping("/api/market/money/getStockDetail")
@ResponseBody
@EncryptFilter(decryptRequest = false)
public ServerResponse getStockDetail(@RequestParam String stockType, @RequestParam String symbol ) {
String url = String.format("https://priceapi.moneycontrol.com/pricefeed/%s/equitycash/%s",stockType,symbol);
MoneyStock moneyStock = moneyStockRepository.findOne(QMoneyStockPO.moneyStockPO.stockType.eq(stockType).and(QMoneyStockPO.moneyStockPO.moneyScId.eq(symbol))).orElse(null);
@@ -280,18 +283,18 @@ public class MoneyApiController {
dto.setStockUrl(stockUrl);
}
String highPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(2)").first());
String highPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(3)").first());
dto.setHighPrice(highPrice);
String lowPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(3)").first());
String lowPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(4)").first());
dto.setLowPrice(lowPrice);
String lastPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(4)").first());
String lastPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(5)").first());
dto.setLastPrice(lastPrice);
String prevClosePrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(5)").first());
/* String prevClosePrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(6)").first());
dto.setPrevClosePrice(prevClosePrice);
*/
String changePercent = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(6)").first());
dto.setChangePercent(changePercent);
@@ -501,6 +504,8 @@ public class MoneyApiController {
})
@GetMapping("/api/market/money/getTopGainer")
@ResponseBody
@EncryptFilter(decryptRequest = false)
public List<MoneyStockSuggestDTO> getTopGainer(@RequestParam String stockType) {
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
// 尝试从缓存中获取结果
@@ -542,6 +547,8 @@ public class MoneyApiController {
})
@GetMapping("/api/market/money/getTopLoser")
@ResponseBody
@EncryptFilter(decryptRequest = false)
public List<MoneyStockSuggestDTO> getTopLoser(@RequestParam String stockType) {
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
moneyStockSuggestDTOS = loserStockSuggestCache.getIfPresent(stockType);
@@ -590,6 +597,8 @@ public class MoneyApiController {
})
@GetMapping("/api/market/money/getTopActives")
@ResponseBody
@EncryptFilter(decryptRequest = false)
public List<MoneyStockSuggestDTO> getTopActive(@RequestParam String stockType) {
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
moneyStockSuggestDTOS = activesStockSuggestCache.getIfPresent(stockType);
@@ -639,6 +648,7 @@ public class MoneyApiController {
@ApiImplicitParam(name = "currencyCode", value = "INR 不变", required = true, dataType = "String", paramType = "query")
})
@ResponseBody
@EncryptFilter(decryptRequest = false)
public ResponseEntity<StockHistoryResponse> getStockHistory( @RequestParam String symbol,
@RequestParam String resolution
) {

View File

@@ -2,6 +2,7 @@ package cn.stock.market.web;
import cn.stock.market.infrastructure.api.TodayApis;
import cn.stock.market.utils.ServerResponse;
import cn.stock.market.web.annotations.EncryptFilter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
@@ -17,6 +18,7 @@ public class TodayApiController {
@RequestMapping({"getTopGainers.do"})
@ApiOperation(value = "获取Top Gainers",notes = "exchange传nse或者bse", httpMethod = "GET")
@ResponseBody
@EncryptFilter(decryptRequest = false)
public ServerResponse getTopGainers(@RequestParam("exchange") String exchange) {
return ServerResponse.createBySuccess(TodayApis.getTopGainers(exchange));
}
@@ -24,6 +26,7 @@ public class TodayApiController {
@RequestMapping({"getTopLosers.do"})
@ApiOperation(value = "获取 Top Losers",notes = "exchange传nse或者bse", httpMethod = "GET")
@ResponseBody
@EncryptFilter(decryptRequest = false)
public ServerResponse getTopLosers(@RequestParam("exchange") String exchange) {
return ServerResponse.createBySuccess(TodayApis.getTopLosers(exchange));
}
@@ -31,6 +34,7 @@ public class TodayApiController {
@RequestMapping({"getMostActiveVolume.do"})
@ApiOperation(value = "获取 Most Active Volume",notes = "exchange传nse或者bse", httpMethod = "GET")
@ResponseBody
@EncryptFilter(decryptRequest = false)
public ServerResponse getMostActiveVolume(@RequestParam("exchange") String exchange) {
return ServerResponse.createBySuccess(TodayApis.getMostActiveVolume(exchange));
}
@@ -38,6 +42,7 @@ public class TodayApiController {
@RequestMapping({"getMostActiveValue.do"})
@ApiOperation(value = "获取 Most Active Value",notes = "exchange传nse或者bse",httpMethod = "GET")
@ResponseBody
@EncryptFilter(decryptRequest = false)
public ServerResponse getMostActiveValue(@RequestParam("exchange") String exchange) {
return ServerResponse.createBySuccess(TodayApis.getMostActiveValue(exchange));
}