From bdded7b3fcc43b82344f1690f3ab2cc1072c7aae Mon Sep 17 00:00:00 2001 From: Achilles Date: Mon, 15 Jan 2024 10:13:00 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/stock/market/web/BTodayStockController.java | 4 ++++ .../java/cn/stock/market/web/MoneyApiController.java | 10 ++++++++++ .../java/cn/stock/market/web/TodayApiController.java | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/src/main/java/cn/stock/market/web/BTodayStockController.java b/src/main/java/cn/stock/market/web/BTodayStockController.java index b711dac..b7d68df 100644 --- a/src/main/java/cn/stock/market/web/BTodayStockController.java +++ b/src/main/java/cn/stock/market/web/BTodayStockController.java @@ -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 diff --git a/src/main/java/cn/stock/market/web/MoneyApiController.java b/src/main/java/cn/stock/market/web/MoneyApiController.java index 742e70d..3fd6821 100644 --- a/src/main/java/cn/stock/market/web/MoneyApiController.java +++ b/src/main/java/cn/stock/market/web/MoneyApiController.java @@ -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); @@ -501,6 +504,8 @@ public class MoneyApiController { }) @GetMapping("/api/market/money/getTopGainer") @ResponseBody + @EncryptFilter(decryptRequest = false) + public List getTopGainer(@RequestParam String stockType) { List moneyStockSuggestDTOS = null; // 尝试从缓存中获取结果 @@ -542,6 +547,8 @@ public class MoneyApiController { }) @GetMapping("/api/market/money/getTopLoser") @ResponseBody + @EncryptFilter(decryptRequest = false) + public List getTopLoser(@RequestParam String stockType) { List moneyStockSuggestDTOS = null; moneyStockSuggestDTOS = loserStockSuggestCache.getIfPresent(stockType); @@ -590,6 +597,8 @@ public class MoneyApiController { }) @GetMapping("/api/market/money/getTopActives") @ResponseBody + @EncryptFilter(decryptRequest = false) + public List getTopActive(@RequestParam String stockType) { List 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 getStockHistory( @RequestParam String symbol, @RequestParam String resolution ) { diff --git a/src/main/java/cn/stock/market/web/TodayApiController.java b/src/main/java/cn/stock/market/web/TodayApiController.java index 9c65047..2fb4931 100644 --- a/src/main/java/cn/stock/market/web/TodayApiController.java +++ b/src/main/java/cn/stock/market/web/TodayApiController.java @@ -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)); } From 56232a42a75cbc3e24c2ef2d16377e325a99a0b3 Mon Sep 17 00:00:00 2001 From: Achilles Date: Tue, 16 Jan 2024 14:17:26 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/stock/market/web/MoneyApiController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/cn/stock/market/web/MoneyApiController.java b/src/main/java/cn/stock/market/web/MoneyApiController.java index 3fd6821..8750ce3 100644 --- a/src/main/java/cn/stock/market/web/MoneyApiController.java +++ b/src/main/java/cn/stock/market/web/MoneyApiController.java @@ -283,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); From 3e26a9db284d18bbbebb9c4667a51a5a67bcda66 Mon Sep 17 00:00:00 2001 From: Achilles Date: Mon, 22 Jan 2024 21:27:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8F=90=E4=BA=A4,?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=8E=B7=E5=8F=96=E6=80=BB=E5=8F=91=E8=A1=8C?= =?UTF-8?q?=E8=82=A1=E7=A5=A8=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../market/infrastructure/job/Scraper.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/cn/stock/market/infrastructure/job/Scraper.java b/src/main/java/cn/stock/market/infrastructure/job/Scraper.java index 23dfa4e..a5def43 100644 --- a/src/main/java/cn/stock/market/infrastructure/job/Scraper.java +++ b/src/main/java/cn/stock/market/infrastructure/job/Scraper.java @@ -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()); From 960946692dc3ed5dbb29af5ffb7ffdf62282637d Mon Sep 17 00:00:00 2001 From: Achilles Date: Tue, 23 Jan 2024 10:26:35 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8F=90=E4=BA=A4,?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E8=8E=B7=E5=8F=96=E6=80=BB=E5=8F=91=E8=A1=8C?= =?UTF-8?q?=E8=82=A1=E7=A5=A8=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cn/stock/market/infrastructure/job/Scraper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/cn/stock/market/infrastructure/job/Scraper.java b/src/main/java/cn/stock/market/infrastructure/job/Scraper.java index a5def43..ac1f84b 100644 --- a/src/main/java/cn/stock/market/infrastructure/job/Scraper.java +++ b/src/main/java/cn/stock/market/infrastructure/job/Scraper.java @@ -197,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()); //保存全部的新股