From e7aa37f7346468f075fdba498355579d4ede13d4 Mon Sep 17 00:00:00 2001 From: "kings.chan" Date: Fri, 21 Sep 2018 16:32:22 +0800 Subject: [PATCH 01/36] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 19cbcb01..9572949a 100644 --- a/readme.md +++ b/readme.md @@ -16,7 +16,7 @@ ## Demo 效果 -:link: [点我查看效果](http://stock.51so.info/) (demo版) :link: +:link: [点我查看效果](http://211.159.182.106/) (demo版) :link: ## :boom: 效果图 :boom: From 2426ed59215538fab286e0772d4b176f0517d8ba Mon Sep 17 00:00:00 2001 From: kingschan Date: Wed, 10 Oct 2018 15:06:21 +0800 Subject: [PATCH 02/36] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../module/startup/InitQuartzTaskRunner.java | 7 ++++ .../module/task/CleanFileTask.java | 32 +++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/main/java/io.github.kingschan1204.istock/module/task/CleanFileTask.java diff --git a/pom.xml b/pom.xml index 6ce314d4..04831955 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.github.kingschan1204 istock jar - 1.6.3 + 1.6.4 pritice Maven Webapp http://maven.apache.org diff --git a/src/main/java/io.github.kingschan1204.istock/module/startup/InitQuartzTaskRunner.java b/src/main/java/io.github.kingschan1204.istock/module/startup/InitQuartzTaskRunner.java index 0180195b..5b783958 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/startup/InitQuartzTaskRunner.java +++ b/src/main/java/io.github.kingschan1204.istock/module/startup/InitQuartzTaskRunner.java @@ -61,6 +61,13 @@ public void run(ApplicationArguments applicationArguments) throws Exception { "xueqiuDyTask-trigger-group", XueQiuStockDyTask.class, "0 0/1 * * * ?"); + + quartzManager.addJob("CleanFileTask", + "CleanFileTask-group", + "CleanFileTask-trigger", + "CleanFileTask-trigger-group", + CleanFileTask.class, + "0 0 0 * * ?"); } @Override diff --git a/src/main/java/io.github.kingschan1204.istock/module/task/CleanFileTask.java b/src/main/java/io.github.kingschan1204.istock/module/task/CleanFileTask.java new file mode 100644 index 00000000..bbfe8987 --- /dev/null +++ b/src/main/java/io.github.kingschan1204.istock/module/task/CleanFileTask.java @@ -0,0 +1,32 @@ +package io.github.kingschan1204.istock.module.task; + +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.util.Arrays; + +/** + * 数据文件清理 + * @author chenguoxiang + * @create 2018-10-10 14:51 + **/ +@Component +public class CleanFileTask implements Job { + private Logger log = LoggerFactory.getLogger(CleanFileTask.class); + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + + File f = new File("./data/"); + if(!f.exists()){return;} + Arrays.stream(f.listFiles()).forEach(file ->{ + log.info("清理文件:{}-{}",file.getName(),file.delete()); + }); + + + } +} From 42fdc59c336b746a9e938ad3a19d8faffd7ef104 Mon Sep 17 00:00:00 2001 From: kings chan Date: Fri, 12 Oct 2018 14:27:14 +0800 Subject: [PATCH 03/36] =?UTF-8?q?=E4=BF=AE=E6=AD=A3cdn=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/stock/his/his_dy.html | 6 ++++-- src/main/resources/templates/stock/his/his_roe.html | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/resources/templates/stock/his/his_dy.html b/src/main/resources/templates/stock/his/his_dy.html index 8834f8f9..ef3ef8e2 100644 --- a/src/main/resources/templates/stock/his/his_dy.html +++ b/src/main/resources/templates/stock/his/his_dy.html @@ -10,8 +10,10 @@ - - + + + + <#if msg??> diff --git a/src/main/resources/templates/stock/his/his_roe.html b/src/main/resources/templates/stock/his/his_roe.html index c9ca9d84..d85ef1d2 100644 --- a/src/main/resources/templates/stock/his/his_roe.html +++ b/src/main/resources/templates/stock/his/his_roe.html @@ -9,8 +9,8 @@ 历史净资产收益率 - - + + <#if msg??> From a40ae4c3da2328f62fc2ade11eecf949e9d7843e Mon Sep 17 00:00:00 2001 From: kings chan Date: Fri, 12 Oct 2018 16:12:03 +0800 Subject: [PATCH 04/36] =?UTF-8?q?=E6=B8=85=E9=99=A4=E8=BF=87=E6=97=B6?= =?UTF-8?q?=E9=9B=86=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/task/CleanFileTask.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/io.github.kingschan1204.istock/module/task/CleanFileTask.java b/src/main/java/io.github.kingschan1204.istock/module/task/CleanFileTask.java index bbfe8987..3db04780 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/task/CleanFileTask.java +++ b/src/main/java/io.github.kingschan1204.istock/module/task/CleanFileTask.java @@ -1,10 +1,13 @@ package io.github.kingschan1204.istock.module.task; +import io.github.kingschan1204.istock.module.maindata.po.StockHisPbPe; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.stereotype.Component; import java.io.File; @@ -17,7 +20,10 @@ **/ @Component public class CleanFileTask implements Job { + private Logger log = LoggerFactory.getLogger(CleanFileTask.class); + @Autowired + private MongoTemplate mongoTemplate; @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { @@ -27,6 +33,8 @@ public void execute(JobExecutionContext jobExecutionContext) throws JobExecution log.info("清理文件:{}-{}",file.getName(),file.delete()); }); + mongoTemplate.dropCollection(StockHisPbPe.class); + log.info("删除历史pb,pe,price数据"); } } From 604f77a9fa92d609fa8fe724b7ad9a4f89bbe35b Mon Sep 17 00:00:00 2001 From: kingschan Date: Mon, 15 Oct 2018 10:35:30 +0800 Subject: [PATCH 05/36] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=20=E8=84=8F=E6=95=B0=E6=8D=AE=EF=BC=8C?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=87=8D=E5=A4=8D=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/stock/impl/JisiluSpilder.java | 15 ++++++++++++--- .../module/startup/InitQuartzTaskRunner.java | 6 +++--- .../module/task/StockDividendTask.java | 2 +- .../module/task/ThsHisYearReportTask.java | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/JisiluSpilder.java b/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/JisiluSpilder.java index 72c2fb7f..37cc9c96 100644 --- a/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/JisiluSpilder.java +++ b/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/JisiluSpilder.java @@ -31,9 +31,7 @@ public class JisiluSpilder extends DefaultSpiderImpl { * @return */ public JSONObject crawHisPbPePriceAndReports(String code) throws Exception { -// String useAgent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3346.9 Safari/537.36"; String referrer = "https://www.jisilu.cn/data/stock/dividend_rate/#cn"; -// int timeout=8000; JSONObject result = new JSONObject(); String url = String.format("https://www.jisilu.cn/data/stock/%s", code); log.info("craw jisilu page :{}", url); @@ -77,9 +75,20 @@ public JSONObject crawHisPbPePriceAndReports(String code) throws Exception { String pes[] = list.get(3).replaceAll(replaceRegex, "").split(",");//市盈率 JSONArray hisJson = new JSONArray(); for (int i = 0; i < dates.length; i++) { + double price=Double.parseDouble(prices[i]); + if(i!=0){ + double lastPrice=Double.parseDouble(prices[i-1]); + //如果价格 昨天和今天大于,小于 10%的幅度则为脏数据 + double maxPrice=lastPrice+(lastPrice*0.1); + double minPrice=lastPrice-(lastPrice*0.1); + if(price>maxPrice||price list = template.find(query, StockCode.class); if(null==list||list.size()==0){ - log.info("his year report data 当前已全部更新完!"); +// log.info("his year report data 当前已全部更新完!"); return ; } list.stream().forEach(code ->{ From 3f42c65f7c01d4a4665483e4227d6cb91af7b014 Mon Sep 17 00:00:00 2001 From: kingschan Date: Mon, 15 Oct 2018 11:13:37 +0800 Subject: [PATCH 06/36] =?UTF-8?q?=E6=8C=89=E7=85=A7=E9=98=BF=E9=87=8C?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../Application.java | 5 +- .../common/util/quartz/QuartzManager.java | 3 +- .../common/util/stock/StockDateUtil.java | 9 +- .../common/util/stock/StockSpider.java | 5 +- .../util/stock/impl/DefaultSpiderImpl.java | 110 +++++++++++------ .../util/stock/impl/EastmoneySpider.java | 30 +++-- .../module/maindata/po/Stock.java | 30 ++++- .../module/maindata/po/StockCode.java | 10 +- .../module/maindata/po/StockHisDividend.java | 1 - .../module/maindata/po/StockReport.java | 4 +- .../maindata/services/StockService.java | 2 +- .../module/task/StockCodeTask.java | 8 +- .../module/task/StockDividendTask.java | 112 +++++++++--------- .../module/task/ThsHisYearReportTask.java | 1 - .../module/task/XueQiuStockDyTask.java | 6 +- src/main/resources/application.properties | 4 +- .../maindata/services/StockServiceTest.java | 33 +----- 18 files changed, 215 insertions(+), 160 deletions(-) diff --git a/pom.xml b/pom.xml index 04831955..083c4434 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.github.kingschan1204 istock jar - 1.6.4 + 1.6.5 pritice Maven Webapp http://maven.apache.org diff --git a/src/main/java/io.github.kingschan1204.istock/Application.java b/src/main/java/io.github.kingschan1204.istock/Application.java index cdb5e6f8..f38fb4d1 100644 --- a/src/main/java/io.github.kingschan1204.istock/Application.java +++ b/src/main/java/io.github.kingschan1204.istock/Application.java @@ -8,7 +8,10 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; - +/** + * spring boot 启动类 + * @author kings.chan + */ @Controller @EnableCaching @SpringBootApplication diff --git a/src/main/java/io.github.kingschan1204.istock/common/util/quartz/QuartzManager.java b/src/main/java/io.github.kingschan1204.istock/common/util/quartz/QuartzManager.java index 967b6588..cfd8d0c5 100644 --- a/src/main/java/io.github.kingschan1204.istock/common/util/quartz/QuartzManager.java +++ b/src/main/java/io.github.kingschan1204.istock/common/util/quartz/QuartzManager.java @@ -31,8 +31,7 @@ public class QuartzManager { public void addJob(String jobName, String jobGroupName, String triggerName, String triggerGroupName, Class jobClass, String cron) { try { - Scheduler sched = schedulerFactoryBean.getScheduler();//schedulerFactory.getScheduler(); - + Scheduler sched = schedulerFactoryBean.getScheduler(); // 任务名,任务组,任务执行类 JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(jobName, jobGroupName).build(); // 触发器 diff --git a/src/main/java/io.github.kingschan1204.istock/common/util/stock/StockDateUtil.java b/src/main/java/io.github.kingschan1204.istock/common/util/stock/StockDateUtil.java index 54ea43c8..55019bf7 100644 --- a/src/main/java/io.github.kingschan1204.istock/common/util/stock/StockDateUtil.java +++ b/src/main/java/io.github.kingschan1204.istock/common/util/stock/StockDateUtil.java @@ -10,7 +10,9 @@ import java.util.Date; /** - * Created by kingschan on 2017/6/29. + * 代码定时更新任务 + * @author kings.chan + * @date 2018-6-29 */ public class StockDateUtil { @@ -111,8 +113,9 @@ public static long getCurrentTimestamp() { */ public static long dateToUnixTime(String dateString) throws ParseException { Date date1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") - .parse(dateString);// HH:mm:ss - long temp = date1.getTime();// JAVA的时间戳长度是13位 + .parse(dateString); + // JAVA的时间戳长度是13位 + long temp = date1.getTime(); return temp / 1000; } diff --git a/src/main/java/io.github.kingschan1204.istock/common/util/stock/StockSpider.java b/src/main/java/io.github.kingschan1204.istock/common/util/stock/StockSpider.java index 85e6067e..ae2f1541 100644 --- a/src/main/java/io.github.kingschan1204.istock/common/util/stock/StockSpider.java +++ b/src/main/java/io.github.kingschan1204.istock/common/util/stock/StockSpider.java @@ -26,7 +26,7 @@ **/ public interface StockSpider { - static final String REGEX_NUMBER = "^[-+]?([0]{1}(\\.[0-9]+)?|[1-9]{1}\\d*(\\.[0-9]+)?)";//"^[-+]?[0-9]+(\\.[0-9]+)?$"; + static final String REGEX_NUMBER = "^[-+]?([0]{1}(\\.[0-9]+)?|[1-9]{1}\\d*(\\.[0-9]+)?)"; /** * 将股票代码转换成新浪接口的格式http://hq.sinajs.cn/list= @@ -81,6 +81,7 @@ static String findStrByRegx(String text, String regx) { * 是否工作日 * @param date * @return + * @throws IOException */ static boolean isWorkDay(String date) throws IOException { String api =String.format("http://api.goseek.cn/Tools/holiday?date=%s",date); @@ -156,9 +157,9 @@ public void checkServerTrusted(X509Certificate[] certs, String authType) { /** * 得到指定代码的价格 - * * @param stockCode * @return + * @throws Exception */ JSONArray getStockPrice(String[] stockCode) throws Exception; diff --git a/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/DefaultSpiderImpl.java b/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/DefaultSpiderImpl.java index 7bfe3485..f96da0d8 100644 --- a/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/DefaultSpiderImpl.java +++ b/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/DefaultSpiderImpl.java @@ -38,7 +38,10 @@ public class DefaultSpiderImpl implements StockSpider { private static Logger log = LoggerFactory.getLogger(DefaultSpiderImpl.class); @Value("${spider.timeout}") - protected int timeout;//8s超时 + /** + * 8s超时 + */ + protected int timeout; @Value("${spider.useagent}") protected String useAgent; @Value("${xueqiu.token}") @@ -79,24 +82,33 @@ public JSONArray getStockPrice(String[] stockCode) throws Exception { double todayMax = StockSpider.mathFormat(data[5]); double todayMin = StockSpider.mathFormat(data[6]); json = new JSONObject(); - if (xj == 0) { //一般这种是停牌的 - json.put("fluctuate", 0);//波动 + //一般这种是停牌的 + if (xj == 0) { + //波动 + json.put("fluctuate", 0); } else { NumberFormat nf = NumberFormat.getNumberInstance(); // 保留两位小数 nf.setMaximumFractionDigits(2); // 如果不需要四舍五入,可以使用RoundingMode.DOWN nf.setRoundingMode(RoundingMode.UP); - json.put("fluctuate", StockSpider.mathFormat(nf.format(zf)));//波动 + //波动 + json.put("fluctuate", StockSpider.mathFormat(nf.format(zf))); } TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); - json.put("code", data[0]);//代码 + //代码 + json.put("code", data[0]); json.put("type", StockSpider.formatStockCode(data[0]).replaceAll("\\d", "")); - json.put("name", data[1].replaceAll("\\s", ""));//名称 - json.put("price", xj);//现价 - json.put("todayMax", todayMax);//今日最高价 - json.put("todayMin", todayMin);//今日最低价 - json.put("yesterdayPrice", zs);//昨收 + //名称 + json.put("name", data[1].replaceAll("\\s", "")); + //现价 + json.put("price", xj); + //今日最高价 + json.put("todayMax", todayMax); + //今日最低价 + json.put("todayMin", todayMin); + //昨收 + json.put("yesterdayPrice", zs); json.put("priceDate", StockDateUtil.getCurrentDateTimeNumber()); rows.add(json); } @@ -112,27 +124,43 @@ public JSONObject getStockInfo(String code) throws Exception { Elements table = doc.getElementsByTag("table"); //第一个表格的第一行 Elements tds = table.get(0).select("tr").get(0).select("td"); - String zyyw = tds.get(0).text().replaceAll(regex, "");//主营业务 - String sshy = tds.get(1).text().replaceAll(regex, "");//所属行业 + //主营业务 + String zyyw = tds.get(0).text().replaceAll(regex, ""); + //所属行业 + String sshy = tds.get(1).text().replaceAll(regex, ""); Elements tds1 = table.get(1).select("td"); - String dtsyl = tds1.get(0).text().replaceAll(regex, "");//市盈率(动态) - String sjljt = tds1.get(4).text().replaceAll(regex, "");//市盈率(静态) - String sjl = tds1.get(8).text().replaceAll(regex, "");//市净率 - String zsz = tds1.get(11).text().replaceAll("\\D+", "");//总市值 - double mgjzc = StockSpider.mathFormat(tds1.get(12).text().replaceAll("\\[.*|", ""));//每股净资产 + //市盈率(动态) + String dtsyl = tds1.get(0).text().replaceAll(regex, ""); + //市盈率(静态) + String sjljt = tds1.get(4).text().replaceAll(regex, ""); + //市净率 + String sjl = tds1.get(8).text().replaceAll(regex, ""); + //总市值 + String zsz = tds1.get(11).text().replaceAll("\\D+", ""); + //每股净资产 + double mgjzc = StockSpider.mathFormat(tds1.get(12).text().replaceAll("\\[.*|", "")); String jzcsyl = "-1"; if (tds1.size() > 14) { - jzcsyl = tds1.get(14).select("span").get(1).text();//净资产收益率 + //净资产收益率 + jzcsyl = tds1.get(14).select("span").get(1).text(); } JSONObject json = new JSONObject(); - json.put("mainBusiness", zyyw);//主营业务 - json.put("industry", sshy);//所属行业 - json.put("ped", StockSpider.mathFormat(dtsyl));//市盈率(动态) - json.put("pes", StockSpider.mathFormat(sjljt));//市盈率(静态) - json.put("pb", StockSpider.mathFormat(sjl));//市净率 - json.put("totalValue", StockSpider.mathFormat(zsz));//总市值 - json.put("roe", StockSpider.mathFormat(jzcsyl));//净资产收益率 - json.put("bvps", mgjzc);//每股净资产 + //主营业务 + json.put("mainBusiness", zyyw); + //所属行业 + json.put("industry", sshy); + //市盈率(动态) + json.put("ped", StockSpider.mathFormat(dtsyl)); + //市盈率(静态) + json.put("pes", StockSpider.mathFormat(sjljt)); + //市净率 + json.put("pb", StockSpider.mathFormat(sjl)); + //总市值 + json.put("totalValue", StockSpider.mathFormat(zsz)); + //净资产收益率 + json.put("roe", StockSpider.mathFormat(jzcsyl)); + //每股净资产 + json.put("bvps", mgjzc); json.put("infoDate", StockDateUtil.getCurrentDateNumber()); json.put("code", stockCode); json.put("type", StockSpider.formatStockCode(stockCode).replaceAll("\\d", "")); @@ -160,16 +188,26 @@ public JSONArray getHistoryDividendRate(String code) throws Exception { log.debug("报告期:{},A股除权除息日:{},实施日期:{},分红方案说明:{},分红率:{}", data[0], data[6], data[3], data[4], data[9]); json = new JSONObject(); json.put("code", stockCode); - json.put("title", data[0]);//报告期 - json.put("releaseDate", data[1]);//披露时间 董事会日期 - json.put("plan", data[4]);//分红方案 - json.put("sgbl", 0);//送股比例 - json.put("zgbl", 0);//转股比例 - json.put("percent", StockSpider.mathFormat(data[9]));//分红率 - json.put("gqdjr", data[5]);//股权登记日 - json.put("cxcqr", data[6]);//除息除权日 - json.put("progress", data[7]);//方案进度 - json.put("from", "ths");//来源 + //报告期 + json.put("title", data[0]); + //披露时间 董事会日期 + json.put("releaseDate", data[1]); + //分红方案 + json.put("plan", data[4]); + //送股比例 + json.put("sgbl", 0); + //转股比例 + json.put("zgbl", 0); + //分红率 + json.put("percent", StockSpider.mathFormat(data[9])); + //股权登记日 + json.put("gqdjr", data[5]); + //除息除权日 + json.put("cxcqr", data[6]); + //方案进度 + json.put("progress", data[7]); + //来源 + json.put("from", "ths"); jsons.add(json); } return jsons; diff --git a/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/EastmoneySpider.java b/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/EastmoneySpider.java index 2f95d160..9e7acadb 100644 --- a/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/EastmoneySpider.java +++ b/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/EastmoneySpider.java @@ -73,16 +73,26 @@ public JSONArray getHistoryDividendRate(String code) throws Exception { if (title.matches("^\\d{4}\\-06-30$")) { title = title.replaceAll("\\-.*", "") + "中报"; } - temp.put("title", title);//报告期 - temp.put("releaseDate", item.getString("ResultsbyDate").replaceAll(regex, ""));//披露时间 - temp.put("plan", item.getString("AllocationPlan"));//分配预案 - temp.put("sgbl", intFormart(item.getString("SGBL")));//送股比例 - temp.put("zgbl", intFormart(item.getString("ZGBL")));//转股比例 - temp.put("percent", doubleFormat(item.getString("GXL"), true));//股息率 - temp.put("gqdjr", item.getString("GQDJR").replaceAll(regex, ""));//股权登记日 - temp.put("cxcqr", item.getString("CQCXR").replaceAll(regex, ""));//除息除权日 - temp.put("progress", item.getString("ProjectProgress"));//进度 - temp.put("from", "east");//来源 + //报告期 + temp.put("title", title); + //披露时间 + temp.put("releaseDate", item.getString("ResultsbyDate").replaceAll(regex, "")); + //分配预案 + temp.put("plan", item.getString("AllocationPlan")); + //送股比例 + temp.put("sgbl", intFormart(item.getString("SGBL"))); + //转股比例 + temp.put("zgbl", intFormart(item.getString("ZGBL"))); + //股息率 + temp.put("percent", doubleFormat(item.getString("GXL"), true)); + //股权登记日 + temp.put("gqdjr", item.getString("GQDJR").replaceAll(regex, "")); + //除息除权日 + temp.put("cxcqr", item.getString("CQCXR").replaceAll(regex, "")); + //进度 + temp.put("progress", item.getString("ProjectProgress")); + //来源 + temp.put("from", "east"); jsons.add(temp); } diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/po/Stock.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/po/Stock.java index 5c34342a..c0d84eb4 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/po/Stock.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/po/Stock.java @@ -31,13 +31,31 @@ public class Stock { private Double pes; private Double ped; private Integer infoDate; - private String dividendDate;//静态分红日期 + /** + * 静态分红日期 + */ + private String dividendDate; private Double dividend; - private Integer dividendUpdateDay;//静态分红更新时间 - private Double dy;//实时股息率 - private Integer dyDate;//实时股息更新时间 - private Double fiveYearDy;//5年平均股息 - private Double fiveYearRoe;//5年平均Roe + /** + * 静态分红更新时间 + */ + private Integer dividendUpdateDay; + /** + * 实时股息率 + */ + private Double dy; + /** + * 实时股息更新时间 + */ + private Integer dyDate; + /** + * 5年平均股息 + */ + private Double fiveYearDy; + /** + * 5年平均Roe + */ + private Double fiveYearRoe; public String getCode() { diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockCode.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockCode.java index 6f35a346..d92bea5c 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockCode.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockCode.java @@ -13,8 +13,14 @@ public class StockCode { @Id private String code; - private Integer hrdud;//history report data update date 历史年度报表更新时间 - private Integer xlsError;//下载xls错误 + /** + * history report data update date 历史年度报表更新时间 + */ + private Integer hrdud; + /** + * 下载xls错误 + */ + private Integer xlsError; public StockCode(){} public StockCode(String code){ diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockHisDividend.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockHisDividend.java index daa571cd..7355c09a 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockHisDividend.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockHisDividend.java @@ -12,7 +12,6 @@ @Document(collection = "stock_his_dividend") public class StockHisDividend { - //{"date":"2017-07-07","code":"600519","year":"2016年报","executeDate":"2017-07-01","remark":"10派67.87元(含税)","percent":1.44} @Id private String id; private String code; diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockReport.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockReport.java index ef4d66b7..eb87988d 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockReport.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/po/StockReport.java @@ -4,7 +4,9 @@ import org.springframework.data.mongodb.core.mapping.Document; /** - * Created by kingschan on 2018/7/6. + * 代码定时更新任务 + * @author kings.chan + * @date 2018-7-6 */ @Document(collection = "stock_report") public class StockReport { diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java index 58afaded..460af33a 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java @@ -129,7 +129,7 @@ public String queryStock(int pageindex, int pagesize, final String pcode,final S //分页 query.skip((pageindex-1)*pagesize).limit(pagesize); //排序 - List orders = new ArrayList(); //排序 + List orders = new ArrayList(); orders.add(new Sort.Order( "asc".equalsIgnoreCase(psort) ?Sort.Direction.ASC:Sort.Direction.DESC ,orderfidld)); diff --git a/src/main/java/io.github.kingschan1204.istock/module/task/StockCodeTask.java b/src/main/java/io.github.kingschan1204.istock/module/task/StockCodeTask.java index ee5d94e2..2f22d977 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/task/StockCodeTask.java +++ b/src/main/java/io.github.kingschan1204.istock/module/task/StockCodeTask.java @@ -13,7 +13,8 @@ import org.springframework.stereotype.Component; /** - * + * 代码定时更新任务 + * @author kings.chan */ @Component public class StockCodeTask implements Job{ @@ -27,11 +28,6 @@ public class StockCodeTask implements Job{ @Autowired private StockCodeService stockCodeService; -/*// @Scheduled(cron = "0 0 0 * * ?") - public void stockCodeExecute()throws Exception{ - - }*/ - @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { Long start =System.currentTimeMillis(); diff --git a/src/main/java/io.github.kingschan1204.istock/module/task/StockDividendTask.java b/src/main/java/io.github.kingschan1204.istock/module/task/StockDividendTask.java index 37ef546d..758fb5c3 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/task/StockDividendTask.java +++ b/src/main/java/io.github.kingschan1204.istock/module/task/StockDividendTask.java @@ -51,25 +51,26 @@ public class StockDividendTask implements Job { }*/ /** - * 同花顺和东方财富的并集 + * 同花顺和东方财富的并集 + * * @param code * @return * @throws Exception */ - public JSONArray combineHisDy(String code)throws Exception{ - JSONArray ths =defaultSpider.getHistoryDividendRate(code); - JSONArray east =eastmoneySpider.getHistoryDividendRate(code); - if(null==east){ - east=new JSONArray(); + public JSONArray combineHisDy(String code) throws Exception { + JSONArray ths = defaultSpider.getHistoryDividendRate(code); + JSONArray east = eastmoneySpider.getHistoryDividendRate(code); + if (null == east) { + east = new JSONArray(); } - if(null!=ths){ + if (null != ths) { east.addAll(ths); } - JSONArray ret=new JSONArray(); - Set titles=new HashSet(); + JSONArray ret = new JSONArray(); + Set titles = new HashSet(); for (int i = 0; i < east.size(); i++) { - String title =east.getJSONObject(i).getString("title"); - if(!titles.contains(title)){ + String title = east.getJSONObject(i).getString("title"); + if (!titles.contains(title)) { ret.add(east.getJSONObject(i)); titles.add(title); } @@ -79,53 +80,56 @@ public JSONArray combineHisDy(String code)throws Exception{ @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { - Integer dateNumber = StockDateUtil.getCurrentDateNumber()-3; - Criteria cr = new Criteria(); - Criteria c1 = Criteria.where("dividendUpdateDay").lt(dateNumber);//小于 (3天更新一遍) - Criteria c2 = Criteria.where("dividendUpdateDay").exists(false); - Query query = new Query(cr.orOperator(c1, c2)); - query.limit(3); - List list = template.find(query, Stock.class); - for (Stock stock:list) { - Long start =System.currentTimeMillis();//记录开始时间 - int affected=0;//分红更新记录条数 - JSONArray dividends=new JSONArray(); - String date=""; - Double percent=0D; - try { - dividends=combineHisDy(stock.getCode()); - if(null!=dividends&÷nds.size()>0){ - for (int j = 0; j < dividends.size(); j++) { - double tempPercent=dividends.getJSONObject(j).getDouble("percent"); - String tempDate=dividends.getJSONObject(j).getString("cxcqr"); - if(tempPercent>=0&&!"-".equals(tempDate)){ - percent=tempPercent; - date=tempDate; - break; - } + Integer dateNumber = StockDateUtil.getCurrentDateNumber() - 3; + Criteria cr = new Criteria(); + //小于 (3天更新一遍) + Criteria c1 = Criteria.where("dividendUpdateDay").lt(dateNumber); + Criteria c2 = Criteria.where("dividendUpdateDay").exists(false); + Query query = new Query(cr.orOperator(c1, c2)); + query.limit(3); + List list = template.find(query, Stock.class); + for (Stock stock : list) { + //记录开始时间 + Long start = System.currentTimeMillis(); + //分红更新记录条数 + int affected = 0; + JSONArray dividends = new JSONArray(); + String date = ""; + Double percent = 0D; + try { + dividends = combineHisDy(stock.getCode()); + if (null != dividends && dividends.size() > 0) { + for (int j = 0; j < dividends.size(); j++) { + double tempPercent = dividends.getJSONObject(j).getDouble("percent"); + String tempDate = dividends.getJSONObject(j).getString("cxcqr"); + if (tempPercent >= 0 && !"-".equals(tempDate)) { + percent = tempPercent; + date = tempDate; + break; } - //save dividend - List stockDividendList = JSONArray.parseArray(dividends.toJSONString(),StockDividend.class); - template.remove(new Query(Criteria.where("code").is(stock.getCode())),StockDividend.class); - stockHisDividendRepository.save(stockDividendList); - affected=stockDividendList.size(); } - } catch (Exception e) { - log.error("error:{}",e); - e.printStackTrace(); + //save dividend + List stockDividendList = JSONArray.parseArray(dividends.toJSONString(), StockDividend.class); + template.remove(new Query(Criteria.where("code").is(stock.getCode())), StockDividend.class); + stockHisDividendRepository.save(stockDividendList); + affected = stockDividendList.size(); } - WriteResult wr =template.upsert( - new Query(Criteria.where("_id").is(stock.getCode())), - new Update() - .set("_id", stock.getCode()) - .set("dividendDate", date) - .set("dividend", percent) - .set("dividendUpdateDay", dateNumber), - "stock" - ); - affected+=wr.getN(); - log.info("{}分红抓取,耗时{}ms,获得{}行数据",stock.getCode(),(System.currentTimeMillis()-start),affected); + } catch (Exception e) { + log.error("error:{}", e); + e.printStackTrace(); } + WriteResult wr = template.upsert( + new Query(Criteria.where("_id").is(stock.getCode())), + new Update() + .set("_id", stock.getCode()) + .set("dividendDate", date) + .set("dividend", percent) + .set("dividendUpdateDay", dateNumber), + "stock" + ); + affected += wr.getN(); + log.info("{}分红抓取,耗时{}ms,获得{}行数据", stock.getCode(), (System.currentTimeMillis() - start), affected); + } } } diff --git a/src/main/java/io.github.kingschan1204.istock/module/task/ThsHisYearReportTask.java b/src/main/java/io.github.kingschan1204.istock/module/task/ThsHisYearReportTask.java index 474b66ce..7e38825b 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/task/ThsHisYearReportTask.java +++ b/src/main/java/io.github.kingschan1204.istock/module/task/ThsHisYearReportTask.java @@ -82,7 +82,6 @@ public void execute(JobExecutionContext jobExecutionContext) throws JobExecution query.limit(2); List list = template.find(query, StockCode.class); if(null==list||list.size()==0){ -// log.info("his year report data 当前已全部更新完!"); return ; } list.stream().forEach(code ->{ diff --git a/src/main/java/io.github.kingschan1204.istock/module/task/XueQiuStockDyTask.java b/src/main/java/io.github.kingschan1204.istock/module/task/XueQiuStockDyTask.java index a1997b6a..60da733e 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/task/XueQiuStockDyTask.java +++ b/src/main/java/io.github.kingschan1204.istock/module/task/XueQiuStockDyTask.java @@ -63,12 +63,10 @@ int getErrorTotal(){ return val; } -// @Scheduled(cron = "0 0/1 * * * ?") - /* public void stockDividendExecute() throws Exception { - }*/ public void uptateDy(JSONObject data) { - int affected = 0;//受影响行 + //受影响行 + int affected = 0; Integer dateNumber = StockDateUtil.getCurrentDateNumber(); JSONArray rows = data.getJSONArray("list"); List list = rows.toJavaList(Stock.class); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 040a655a..b96addc0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -24,7 +24,7 @@ spring.data.mongodb.port=27017 spider.timeout=8000 spider.useagent=Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3346.9 Safari/537.36 ## token -xueqiu.token= +xueqiu.token=7fb0562a973ec23251a8aa382852a6257f9e346b eastmoney.token=70f12f2f4f091e459a279469fe49eca5 #security @@ -32,6 +32,6 @@ management.context-path=/admin management.security.enabled=false management.security.roles=SUPERUSER security.user.name=root -security.user.password= +security.user.password=kingschan ###ehcache spring.cache.ehcache.config=classpath:ehcache.xml diff --git a/src/test/java/io/github/kingschan1204/istock/module/maindata/services/StockServiceTest.java b/src/test/java/io/github/kingschan1204/istock/module/maindata/services/StockServiceTest.java index d39c170c..19b45f4b 100644 --- a/src/test/java/io/github/kingschan1204/istock/module/maindata/services/StockServiceTest.java +++ b/src/test/java/io/github/kingschan1204/istock/module/maindata/services/StockServiceTest.java @@ -1,22 +1,13 @@ package io.github.kingschan1204.istock.module.maindata.services; -import com.alibaba.fastjson.JSON; -import io.github.kingschan1204.istock.common.util.stock.StockDateUtil; -import io.github.kingschan1204.istock.module.maindata.po.Stock; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.mongodb.core.MongoTemplate; -import org.springframework.data.mongodb.core.query.Criteria; -import org.springframework.data.mongodb.core.query.Query; import org.springframework.test.context.junit4.SpringRunner; -import java.util.List; - /** - * ${DESCRIPTION} * * @author chenguoxiang * @create 2018-03-27 10:47 @@ -28,28 +19,16 @@ public class StockServiceTest { private StockService stockService; @Autowired private MongoTemplate template; + @Autowired + private StockCodeService stockCodeService; - @Ignore @Test - public void addStock() throws Exception { - stockService.addStock(new String[]{ - "000895","601288","000338","601668","601633" - }); + public void saveAllCode() throws Exception { + Long start =System.currentTimeMillis(); + stockCodeService.saveAllStockCode(); + System.out.println(String.format("更新代码共耗时:%s ms",(System.currentTimeMillis()-start))); } - @Test - public void getUpdateInfoQueue(){ - Integer date= StockDateUtil.getCurrentDateNumber(); - Criteria cr = new Criteria(); - Criteria c1 = Criteria.where("Infodate").lt(date); - Criteria c2 = Criteria.where("Infodate").exists(false); - Query query = new Query(cr.orOperator(c1,c2)); - query.limit(3); - List list= template.find(query, Stock.class); - list.stream().forEach(stock -> { - System.out.println(JSON.toJSONString(stock)); - }); - } From 633bf796c052bb85f88bbb85c0f63c16cb9fd0ac Mon Sep 17 00:00:00 2001 From: kingschan Date: Tue, 16 Oct 2018 17:50:30 +0800 Subject: [PATCH 07/36] =?UTF-8?q?=E4=B8=BB=E6=95=B0=E6=8D=AE=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E8=BD=AC=E6=8D=A2=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../util/stock/impl/DefaultSpiderImpl.java | 3 + .../module/maindata/po/Stock.java | 1 - .../maindata/services/StockCodeService.java | 3 - .../maindata/services/StockService.java | 64 +---- .../module/maindata/vo/StockVo.java | 228 ++++++++++++++++++ .../module/task/SinaStockPriceTask.java | 4 - .../module/task/ThsHisYearReportTask.java | 4 - 7 files changed, 242 insertions(+), 65 deletions(-) create mode 100644 src/main/java/io.github.kingschan1204.istock/module/maindata/vo/StockVo.java diff --git a/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/DefaultSpiderImpl.java b/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/DefaultSpiderImpl.java index f96da0d8..ab5d26b8 100644 --- a/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/DefaultSpiderImpl.java +++ b/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/DefaultSpiderImpl.java @@ -228,8 +228,11 @@ public JSONArray getHistoryROE(String code) throws Exception { } //读取excel数据 List list = ExcelOperactionTool.readExcelData(path); + //报告期 年 Object[] year = list.get(1); + //净资产收益率 Object[] roe = list.get(10); + //净资产收益率-摊薄 Object[] roeTb = list.get(11); JSONArray jsons = new JSONArray(); JSONObject json; diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/po/Stock.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/po/Stock.java index c0d84eb4..74a734f0 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/po/Stock.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/po/Stock.java @@ -5,7 +5,6 @@ /** * stock maindata - * * @author chenguoxiang * @create 2018-03-27 10:15 **/ diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockCodeService.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockCodeService.java index 65409e11..b044e8d9 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockCodeService.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockCodeService.java @@ -15,7 +15,6 @@ import java.util.List; /** - * ${DESCRIPTION} * * @author chenguoxiang * @create 2018-04-08 17:11 @@ -37,11 +36,9 @@ public class StockCodeService { public void saveAllStockCode() throws Exception { List szCodes = stockSpider.getStockCodeBySZ(); List shCodes = stockSpider.getStockCodeBySH(); - List allcodes = stockSpider.getAllStockCode(); HashSet codes = new HashSet(); codes.addAll(szCodes); codes.addAll(shCodes); - codes.addAll(allcodes); codes.stream().forEach(code -> { mongoTemplate.upsert( new Query(Criteria.where("_id").is(code)), diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java index 460af33a..c84dcc5c 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java @@ -14,6 +14,8 @@ import io.github.kingschan1204.istock.module.maindata.po.StockHisRoe; import io.github.kingschan1204.istock.module.maindata.repository.StockHisDividendRepository; import io.github.kingschan1204.istock.module.maindata.repository.StockRepository; +import io.github.kingschan1204.istock.module.maindata.vo.StockVo; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.MongoTemplate; @@ -137,59 +139,15 @@ public String queryStock(int pageindex, int pagesize, final String pcode,final S query.with(sort); //code List list =template.find(query,Stock.class); - JSONArray jsons = JSONArray.parseArray(JSONArray.toJSONString(list)); - JSONObject temp; - for (int i = 0; i temp = JSON.parseArray(JSON.toJSONString(list), StockVo.class); JSONObject data= new JSONObject(); long pagetotal=total%pagesize==0?total/pagesize:total/pagesize+1; - data.put("rows",jsons); - data.put("total",pagetotal);//有多少页 - data.put("records",total);// 总共有多少条记录 + data.put("rows",JSONArray.parseArray(JSON.toJSONString(temp))); + //有多少页 + data.put("total",pagetotal); + // 总共有多少条记录 + data.put("records",total); data.put("page",pageindex); return data.toJSONString(); } @@ -204,7 +162,7 @@ public List getStockDividend(String code){ Query query = new Query(); query.addCriteria(Criteria.where("code").is(code)); //排序 - List orders = new ArrayList(); //排序 + List orders = new ArrayList(); orders.add(new Sort.Order(Sort.Direction.ASC,"title")); Sort sort = new Sort(orders); query.with(sort); @@ -218,7 +176,7 @@ public List getStockHisRoe(String code){ Query query = new Query(); query.addCriteria(Criteria.where("code").is(code)); //排序 - List orders = new ArrayList(); //排序 + List orders = new ArrayList(); orders.add(new Sort.Order(Sort.Direction.ASC,"year")); Sort sort = new Sort(orders); query.with(sort); diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/vo/StockVo.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/vo/StockVo.java new file mode 100644 index 00000000..a3af20d2 --- /dev/null +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/vo/StockVo.java @@ -0,0 +1,228 @@ +package io.github.kingschan1204.istock.module.maindata.vo; + +/** + * stock 主数据vo + * @author chenguoxiang + * @create 2018-10-16 14:41 + * http://localhost/stock/q?rows=20&page=1&sidx=&sord=asc& + **/ +public class StockVo { + + private String code; + private String type; + private String name; + private Double price; + private Double yesterdayPrice; + private String fluctuate; + private Double todayMax; + private Double todayMin; + private Long priceDate; + private String industry; + private String totalValue; + private String pb; + private String roe; + private String bvps; + private String pes; + private String ped; + private Integer infoDate; + /** + * 静态分红日期 + */ + private String dividendDate; + private String dividend; + /** + * 实时股息率 + */ + private String dy; + /** + * 5年平均股息 + */ + private String fiveYearDy; + /** + * 5年平均Roe + */ + private String fiveYearRoe; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Double getPrice() { + return price; + } + + public void setPrice(Double price) { + this.price = price; + } + + public Double getYesterdayPrice() { + return yesterdayPrice; + } + + public void setYesterdayPrice(Double yesterdayPrice) { + this.yesterdayPrice = yesterdayPrice; + } + + public String getFluctuate() { + return fluctuate; + } + + public void setFluctuate(Double fluctuate) { + this.fluctuate = String.format("%s%%",fluctuate); + } + + public Double getTodayMax() { + return todayMax; + } + + public void setTodayMax(Double todayMax) { + this.todayMax = todayMax; + } + + public Double getTodayMin() { + return todayMin; + } + + public void setTodayMin(Double todayMin) { + this.todayMin = todayMin; + } + + public Long getPriceDate() { + return priceDate; + } + + public void setPriceDate(Long priceDate) { + this.priceDate = priceDate; + } + + public String getIndustry() { + return industry; + } + + public void setIndustry(String industry) { + this.industry = industry; + } + + public String getTotalValue() { + return totalValue; + } + + public void setTotalValue(Double totalValue) { + this.totalValue = -1==totalValue?"--":String.format("%s亿",totalValue); + } + + public String getPb() { + return pb; + } + + public void setPb(Double pb) { + this.pb = -1==pb?"--":String.format("%s",pb); + } + + public String getRoe() { + return roe; + } + + public void setRoe(Double roe) { + this.roe = -1==roe?"--":String.format("%s%%",roe); + } + + public String getBvps() { + return bvps; + } + + public void setBvps(Double bvps) { + this.bvps = -1==bvps?"--":String.format("%s",bvps); + } + + public String getPes() { + return pes; + } + + public void setPes(Double pes) { + this.pes = -1==pes?"--":String.format("%s",pes); + } + + public String getPed() { + return ped; + } + + public void setPed(Double ped) { + this.ped = -1==ped?"--":String.format("%s",ped); + } + + public Integer getInfoDate() { + return infoDate; + } + + public void setInfoDate(Integer infoDate) { + this.infoDate = infoDate; + } + + public String getDividendDate() { + return dividendDate; + } + + public void setDividendDate(String dividendDate) { + this.dividendDate = dividendDate; + } + + public String getDividend() { + return dividend; + } + + public void setDividend(Double dividend) { + if(0==dividend){ + this.dividend=""; + return; + } + this.dividend = -1==dividend?"--":String.format("%s%%",dividend); + } + + public String getDy() { + return dy; + } + + public void setDy(Double dy) { + this.dy = -1==dy?"--":String.format("%s%%",dy); + } + + public String getFiveYearDy() { + return fiveYearDy; + } + + public void setFiveYearDy(Double fiveYearDy) { + this.fiveYearDy = -1==fiveYearDy?"--":String.format("%s%%",fiveYearDy); + } + + public String getFiveYearRoe() { + return fiveYearRoe; + } + + public void setFiveYearRoe(Double fiveYearRoe) { + this.fiveYearRoe = -1==fiveYearRoe?"--":String.format("%s%%",fiveYearRoe); + } + + public StockVo() { + } +} diff --git a/src/main/java/io.github.kingschan1204.istock/module/task/SinaStockPriceTask.java b/src/main/java/io.github.kingschan1204.istock/module/task/SinaStockPriceTask.java index 239663c7..79fe9228 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/task/SinaStockPriceTask.java +++ b/src/main/java/io.github.kingschan1204.istock/module/task/SinaStockPriceTask.java @@ -41,10 +41,6 @@ public class SinaStockPriceTask implements Job { @Autowired private StockCodeService stockCodeService; -// @Scheduled(cron = "0 0/2 * * * ?") - /* public void stockPriceExecute() throws Exception { - }*/ - @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { if (!StockDateUtil.stockOpenTime()) { diff --git a/src/main/java/io.github.kingschan1204.istock/module/task/ThsHisYearReportTask.java b/src/main/java/io.github.kingschan1204.istock/module/task/ThsHisYearReportTask.java index 7e38825b..23ccb8a1 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/task/ThsHisYearReportTask.java +++ b/src/main/java/io.github.kingschan1204.istock/module/task/ThsHisYearReportTask.java @@ -62,10 +62,6 @@ int getErrorTotal(){ } -// @Scheduled(cron = "*/6 * * * * ?") - /* public void execute() throws Exception { - }*/ - @Override public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { Long start = System.currentTimeMillis(); From b4763d256ee4b60efcbaa3ed2e74b988062e3695 Mon Sep 17 00:00:00 2001 From: kingschan Date: Thu, 18 Oct 2018 14:30:15 +0800 Subject: [PATCH 08/36] =?UTF-8?q?=E8=A7=84=E8=8C=83=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/util/stock/impl/JisiluSpilder.java | 12 ++++++++---- .../module/maindata/ctrl/StockCtrl.java | 4 ++-- .../module/maindata/services/StockService.java | 2 -- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/JisiluSpilder.java b/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/JisiluSpilder.java index 37cc9c96..8bc6bb16 100644 --- a/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/JisiluSpilder.java +++ b/src/main/java/io.github.kingschan1204.istock/common/util/stock/impl/JisiluSpilder.java @@ -69,10 +69,14 @@ public JSONObject crawHisPbPePriceAndReports(String code) throws Exception { List list = StockSpider.findStringByRegx(js.html(), "\\[.*\\]"); //依次顺序 0:日期 1:PRICE 2:PB 3:PE String replaceRegex = "\'|\\[|\\]"; - String dates[] = list.get(0).replaceAll(replaceRegex, "").split(",");//日期 - String prices[] = list.get(1).replaceAll(replaceRegex, "").split(",");//价格 - String pbs[] = list.get(2).replaceAll(replaceRegex, "").split(",");//市净率 - String pes[] = list.get(3).replaceAll(replaceRegex, "").split(",");//市盈率 + //日期 + String dates[] = list.get(0).replaceAll(replaceRegex, "").split(","); + //价格 + String prices[] = list.get(1).replaceAll(replaceRegex, "").split(","); + //市净率 + String pbs[] = list.get(2).replaceAll(replaceRegex, "").split(","); + //市盈率 + String pes[] = list.get(3).replaceAll(replaceRegex, "").split(","); JSONArray hisJson = new JSONArray(); for (int i = 0; i < dates.length; i++) { double price=Double.parseDouble(prices[i]); diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/ctrl/StockCtrl.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/ctrl/StockCtrl.java index 8b1a0760..6928a43b 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/ctrl/StockCtrl.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/ctrl/StockCtrl.java @@ -74,7 +74,7 @@ public String fiveYearsDy() { BasicDBObject item = iter.next(); String code = item.getString("_id"); BasicDBObject value = (BasicDBObject) item.get("value"); - if (value.containsKey("size") && value.getInt("size") > 4) { + if (value.containsField("size") && value.getInt("size") > 4) { double percent = Double.parseDouble(value.getString("percent")); WriteResult wr = template.upsert( new Query(Criteria.where("_id").is(code)), @@ -105,7 +105,7 @@ public String fiveYearsRoe() { BasicDBObject item = iter.next(); String code = item.getString("_id"); BasicDBObject value = (BasicDBObject) item.get("value"); - if (value.containsKey("size") && value.getInt("size") > 4) { + if (value.containsField("size") && value.getInt("size") > 4) { double percent = Double.parseDouble(value.getString("percent")); WriteResult wr = template.upsert( new Query(Criteria.where("_id").is(code)), diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java index c84dcc5c..0d400da9 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockService.java @@ -15,7 +15,6 @@ import io.github.kingschan1204.istock.module.maindata.repository.StockHisDividendRepository; import io.github.kingschan1204.istock.module.maindata.repository.StockRepository; import io.github.kingschan1204.istock.module.maindata.vo.StockVo; -import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.MongoTemplate; @@ -23,7 +22,6 @@ import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; import org.springframework.stereotype.Service; - import java.util.ArrayList; import java.util.List; import java.util.Optional; From 6bc3ab57e1278ea9f8ce4c4819eef9701baf8fb7 Mon Sep 17 00:00:00 2001 From: kingschan Date: Fri, 19 Oct 2018 17:27:10 +0800 Subject: [PATCH 09/36] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/plugs/echar/infographic.js | 204 ++++++++++++++++++ .../resources/static/plugs/echar/macarons.js | 198 +++++++++++++++++ .../resources/templates/stock/his/his_dy.html | 11 +- .../templates/stock/his/his_roe.html | 6 +- 4 files changed, 414 insertions(+), 5 deletions(-) create mode 100644 src/main/resources/static/plugs/echar/infographic.js create mode 100644 src/main/resources/static/plugs/echar/macarons.js diff --git a/src/main/resources/static/plugs/echar/infographic.js b/src/main/resources/static/plugs/echar/infographic.js new file mode 100644 index 00000000..df47b912 --- /dev/null +++ b/src/main/resources/static/plugs/echar/infographic.js @@ -0,0 +1,204 @@ +(function (root, factory) {if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['exports', 'echarts'], factory); + } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { + // CommonJS + factory(exports, require('echarts')); + } else { + // Browser globals + factory({}, root.echarts); + } +}(this, function (exports, echarts) { + var log = function (msg) { + if (typeof console !== 'undefined') { + console && console.error && console.error(msg); + } + }; + if (!echarts) { + log('ECharts is not Loaded'); + return; + } + + var colorPalette = [ + '#C1232B','#27727B','#FCCE10','#E87C25','#B5C334', + '#FE8463','#9BCA63','#FAD860','#F3A43B','#60C0DD', + '#D7504B','#C6E579','#F4E001','#F0805A','#26C0C0' + ]; + + var theme = { + + color: colorPalette, + + title: { + textStyle: { + fontWeight: 'normal', + color: '#27727B' + } + }, + + visualMap: { + color:['#C1232B','#FCCE10'] + }, + + toolbox: { + iconStyle: { + normal: { + borderColor: colorPalette[0] + } + } + }, + + tooltip: { + backgroundColor: 'rgba(50,50,50,0.5)', + axisPointer : { + type : 'line', + lineStyle : { + color: '#27727B', + type: 'dashed' + }, + crossStyle: { + color: '#27727B' + }, + shadowStyle : { + color: 'rgba(200,200,200,0.3)' + } + } + }, + + dataZoom: { + dataBackgroundColor: 'rgba(181,195,52,0.3)', + fillerColor: 'rgba(181,195,52,0.2)', + handleColor: '#27727B' + }, + + categoryAxis: { + axisLine: { + lineStyle: { + color: '#27727B' + } + }, + splitLine: { + show: false + } + }, + + valueAxis: { + axisLine: { + show: false + }, + splitArea : { + show: false + }, + splitLine: { + lineStyle: { + color: ['#ccc'], + type: 'dashed' + } + } + }, + + timeline: { + lineStyle: { + color: '#27727B' + }, + controlStyle: { + normal: { + color: '#27727B', + borderColor: '#27727B' + } + }, + symbol: 'emptyCircle', + symbolSize: 3 + }, + + line: { + itemStyle: { + normal: { + borderWidth:2, + borderColor:'#fff', + lineStyle: { + width: 3 + } + }, + emphasis: { + borderWidth:0 + } + }, + symbol: 'circle', + symbolSize: 3.5 + }, + + candlestick: { + itemStyle: { + normal: { + color: '#C1232B', + color0: '#B5C334', + lineStyle: { + width: 1, + color: '#C1232B', + color0: '#B5C334' + } + } + } + }, + + graph: { + color: colorPalette + }, + + map: { + label: { + normal: { + textStyle: { + color: '#C1232B' + } + }, + emphasis: { + textStyle: { + color: 'rgb(100,0,0)' + } + } + }, + itemStyle: { + normal: { + areaColor: '#ddd', + borderColor: '#eee' + }, + emphasis: { + areaColor: '#fe994e' + } + } + }, + + gauge: { + axisLine: { + lineStyle: { + color: [[0.2, '#B5C334'],[0.8, '#27727B'],[1, '#C1232B']] + } + }, + axisTick: { + splitNumber: 2, + length: 5, + lineStyle: { + color: '#fff' + } + }, + axisLabel: { + textStyle: { + color: '#fff' + } + }, + splitLine: { + length: '5%', + lineStyle: { + color: '#fff' + } + }, + title : { + offsetCenter: [0, -20] + } + } + }; + + echarts.registerTheme('infographic', theme); +})); \ No newline at end of file diff --git a/src/main/resources/static/plugs/echar/macarons.js b/src/main/resources/static/plugs/echar/macarons.js new file mode 100644 index 00000000..398aa3fd --- /dev/null +++ b/src/main/resources/static/plugs/echar/macarons.js @@ -0,0 +1,198 @@ +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['exports', 'echarts'], factory); + } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { + // CommonJS + factory(exports, require('echarts')); + } else { + // Browser globals + factory({}, root.echarts); + } +}(this, function (exports, echarts) { + var log = function (msg) { + if (typeof console !== 'undefined') { + console && console.error && console.error(msg); + } + }; + if (!echarts) { + log('ECharts is not Loaded'); + return; + } + + var colorPalette = [ + '#2ec7c9','#b6a2de','#5ab1ef','#ffb980','#d87a80', + '#8d98b3','#e5cf0d','#97b552','#95706d','#dc69aa', + '#07a2a4','#9a7fd1','#588dd5','#f5994e','#c05050', + '#59678c','#c9ab00','#7eb00a','#6f5553','#c14089' + ]; + + + var theme = { + color: colorPalette, + + title: { + textStyle: { + fontWeight: 'normal', + color: '#008acd' + } + }, + + visualMap: { + itemWidth: 15, + color: ['#5ab1ef','#e0ffff'] + }, + + toolbox: { + iconStyle: { + normal: { + borderColor: colorPalette[0] + } + } + }, + + tooltip: { + backgroundColor: 'rgba(50,50,50,0.5)', + axisPointer : { + type : 'line', + lineStyle : { + color: '#008acd' + }, + crossStyle: { + color: '#008acd' + }, + shadowStyle : { + color: 'rgba(200,200,200,0.2)' + } + } + }, + + dataZoom: { + dataBackgroundColor: '#efefff', + fillerColor: 'rgba(182,162,222,0.2)', + handleColor: '#008acd' + }, + + grid: { + borderColor: '#eee' + }, + + categoryAxis: { + axisLine: { + lineStyle: { + color: '#008acd' + } + }, + splitLine: { + lineStyle: { + color: ['#eee'] + } + } + }, + + valueAxis: { + axisLine: { + lineStyle: { + color: '#008acd' + } + }, + splitArea : { + show : true, + areaStyle : { + color: ['rgba(250,250,250,0.1)','rgba(200,200,200,0.1)'] + } + }, + splitLine: { + lineStyle: { + color: ['#eee'] + } + } + }, + + timeline : { + lineStyle : { + color : '#008acd' + }, + controlStyle : { + normal : { color : '#008acd'}, + emphasis : { color : '#008acd'} + }, + symbol : 'emptyCircle', + symbolSize : 3 + }, + + line: { + smooth : true, + symbol: 'emptyCircle', + symbolSize: 3 + }, + + candlestick: { + itemStyle: { + normal: { + color: '#d87a80', + color0: '#2ec7c9', + lineStyle: { + color: '#d87a80', + color0: '#2ec7c9' + } + } + } + }, + + scatter: { + symbol: 'circle', + symbolSize: 4 + }, + + map: { + label: { + normal: { + textStyle: { + color: '#d87a80' + } + } + }, + itemStyle: { + normal: { + borderColor: '#eee', + areaColor: '#ddd' + }, + emphasis: { + areaColor: '#fe994e' + } + } + }, + + graph: { + color: colorPalette + }, + + gauge : { + axisLine: { + lineStyle: { + color: [[0.2, '#2ec7c9'],[0.8, '#5ab1ef'],[1, '#d87a80']], + width: 10 + } + }, + axisTick: { + splitNumber: 10, + length :15, + lineStyle: { + color: 'auto' + } + }, + splitLine: { + length :22, + lineStyle: { + color: 'auto' + } + }, + pointer : { + width : 5 + } + } + }; + + echarts.registerTheme('macarons', theme); +})); \ No newline at end of file diff --git a/src/main/resources/templates/stock/his/his_dy.html b/src/main/resources/templates/stock/his/his_dy.html index ef3ef8e2..87f01497 100644 --- a/src/main/resources/templates/stock/his/his_dy.html +++ b/src/main/resources/templates/stock/his/his_dy.html @@ -10,6 +10,7 @@ + @@ -53,13 +54,16 @@

${msg}

+ @@ -52,7 +53,7 @@

${msg}

+ + + + + + + + + + +
+
+

基本信息

+
+
+
代码
+
{{info._id}}
+
名称
+
{{info.name}}
+
行业
+
{{info.industry}}
+
+
+
当前价格
+
{{info.price}}
+
昨收
+
{{info.yesterdayPrice}}
+
涨幅
+
{{info.fluctuate}}%
+
+
+
今日最高
+
{{info.todayMax}}
+
今日最低
+
{{info.todayMin}}
+
市值
+
{{info.totalValue}}亿
+
+
+
市净率
+
{{info.pb}}
+
净资产收益率
+
{{info.roe}}%
+
每股收益
+
{{info.bvps}}
+
+
+
市盈率(静)
+
{{info.pes}}
+
市盈率(动)
+
{{info.ped}}
+
最新股息
+
{{info.dy}}%
+
+
+
上次分红
+
{{info.dividend}}%
+
上次分红日期
+
{{info.dividendDate}}
+
最新股息
+
{{info.dy}}%
+
+
+
五年平均股息
+
{{info.fiveYearDy}}%
+
五年平均ROE
+
{{info.fiveYearRoe}}%
+
+ +
+

公司信息

+
+
+
公司全名
+
{{info.info[0].fullname}}
+
所在地
+
{{info.company[0].province}} - {{info.info[0].area}}
+
上市日期
+
{{info.info[0].list_date}}
+
+
+
所属板块
+
{{info.info[0].market}}
+
法人代表
+
{{info.company[0].chairman}}
+
总经理
+
{{info.company[0].manager}}
+
+
+
董秘
+
{{info.company[0].secretary}}
+
注册资本
+
{{info.company[0].regCapital}}
+
注册日期
+
{{info.company[0].setupDate}}
+
+
+
公司主页
+ +
电子邮件
+
{{info.company[0].email}}
+
+
+
办公室
+
{{info.company[0].office}}
+
员工人数
+
{{info.company[0].employees}}
+
+
+
主要业务及产品
+
{{info.company[0].mainBusiness}}
+
+
+
经营范围
+
{{info.company[0].businessScope}}
+
+
+
公司介绍
+
{{info.company[0].introduction}}
+
+ +
+

10大股东

+
+
+ + + + + + + + + + + + + + + +
持有者公告日期报告期持有数量(股)持有比例
{{item.holderName}}{{item.annDate}}{{item.endDate}}{{item.holdAmount}}{{item.holdRatio}}%
+
+
+ + + \ No newline at end of file From c218f94c7846e3b6b8270d27defc48cc0d7484d4 Mon Sep 17 00:00:00 2001 From: kingschan Date: Fri, 2 Nov 2018 17:40:27 +0800 Subject: [PATCH 28/36] =?UTF-8?q?=E5=85=AC=E5=8F=B8=E8=AF=A6=E7=BB=86?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E9=A1=B5=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/templates/index.html | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 4ac1f435..30edec7b 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -60,7 +60,7 @@ - +
当前价格
-
{{info.price}}
+
{{stock.price}}
昨收
-
{{info.yesterdayPrice}}
+
{{stock.yesterdayPrice}}
涨幅
-
{{info.fluctuate}}%
+
{{stock.fluctuate}}
今日最高
-
{{info.todayMax}}
+
{{stock.todayMax}}
今日最低
-
{{info.todayMin}}
+
{{stock.todayMin}}
市值
-
{{info.totalValue}}亿
+
{{stock.totalValue}}
市净率
-
{{info.pb}}
+
{{stock.pb}}
净资产收益率
-
{{info.roe}}%
+
{{stock.roe}}
每股收益
-
{{info.bvps}}
+
{{stock.bvps}}
市盈率(静)
-
{{info.pes}}
+
{{stock.pes}}
市盈率(动)
-
{{info.ped}}
+
{{stock.ped}}
最新股息
-
{{info.dy}}%
+
{{stock.dy}}
上次分红
-
{{info.dividend}}%
+
{{stock.dividend}}
上次分红日期
-
{{info.dividendDate}}
+
{{stock.dividendDate}}
最新股息
-
{{info.dy}}%
+
{{stock.dy}}
五年平均股息
-
{{info.fiveYearDy}}%
+
{{stock.fiveYearDy}}
五年平均ROE
-
{{info.fiveYearRoe}}%
+
{{stock.fiveYearRoe}}
@@ -113,7 +119,7 @@
办公室
-
{{info.company[0].office}}
+
{{info.company[0].office}}
员工人数
{{info.company[0].employees}}
@@ -150,6 +156,8 @@ {{item.holdRatio}}% + +
@@ -158,8 +166,67 @@ var app = new Vue({ el: '#app', data: { - info:result + info:result, + stock:${stock} + }, methods:{ + pieTitle:function(){ + var list =this.info.holders; + console.info(list); + var titles= new Array(); + for(var i=0;i{b} : {c}股 " + }, + /* legend: { + type: 'scroll', + orient: 'vertical', + x: 'left', + data: app.pieTitle() //名称 + //selected: data.selected + },*/ + series : [ + { + name: '持有者', + type: 'pie', + radius : '55%', + center: ['40%', '50%'], + data: app.pieData(), + itemStyle: { + emphasis: { + shadowBlur: 10, + shadowOffsetX: 0, + shadowColor: 'rgba(0, 0, 0, 0.5)' + } + } + } + ] + }; + roeChart.setOption(option); \ No newline at end of file From ad1bba1f8677ebf631da24b2a37b87ed0dcec1e4 Mon Sep 17 00:00:00 2001 From: kingschan Date: Wed, 7 Nov 2018 14:20:44 +0800 Subject: [PATCH 32/36] =?UTF-8?q?=E6=9F=A5=E8=AF=A2code=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/maindata/services/StockTopHoldersService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockTopHoldersService.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockTopHoldersService.java index 1b6c7a4d..0724b84a 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockTopHoldersService.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockTopHoldersService.java @@ -2,8 +2,6 @@ import com.alibaba.fastjson.JSONArray; import io.github.kingschan1204.istock.common.util.stock.impl.TushareSpider; -import io.github.kingschan1204.istock.module.maindata.po.StockCodeInfo; -import io.github.kingschan1204.istock.module.maindata.po.StockHisRoe; import io.github.kingschan1204.istock.module.maindata.po.StockTopHolders; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,8 +45,9 @@ public void refreshTopHolders(String code){ break; } } + String query_code=code.replaceAll("\\D+",""); //先删除再新增 - mongoTemplate.remove(new Query(Criteria.where("code").is(code)),StockTopHolders.class); + mongoTemplate.remove(new Query(Criteria.where("code").is(query_code)),StockTopHolders.class); mongoTemplate.insertAll(list); } From f4a0f7724ed0e8d99ed87ac52c6ba84e3b3dc30a Mon Sep 17 00:00:00 2001 From: kingschan Date: Wed, 7 Nov 2018 14:23:49 +0800 Subject: [PATCH 33/36] =?UTF-8?q?=E6=9F=A5=E8=AF=A2code=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/maindata/services/StockTopHoldersService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockTopHoldersService.java b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockTopHoldersService.java index 0724b84a..8c68ad49 100644 --- a/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockTopHoldersService.java +++ b/src/main/java/io.github.kingschan1204.istock/module/maindata/services/StockTopHoldersService.java @@ -1,6 +1,7 @@ package io.github.kingschan1204.istock.module.maindata.services; import com.alibaba.fastjson.JSONArray; +import com.mongodb.WriteResult; import io.github.kingschan1204.istock.common.util.stock.impl.TushareSpider; import io.github.kingschan1204.istock.module.maindata.po.StockTopHolders; import org.slf4j.Logger; @@ -47,8 +48,9 @@ public void refreshTopHolders(String code){ } String query_code=code.replaceAll("\\D+",""); //先删除再新增 - mongoTemplate.remove(new Query(Criteria.where("code").is(query_code)),StockTopHolders.class); + WriteResult wr= mongoTemplate.remove(new Query(Criteria.where("code").is(query_code)),StockTopHolders.class); mongoTemplate.insertAll(list); + log.info("top10 holders :remove {} ,insert {} ",wr.getN(),list.size()); } } From 81f2a975ebf7b6b98ad76168178a1122b13f3e58 Mon Sep 17 00:00:00 2001 From: kingschan Date: Thu, 8 Nov 2018 14:27:23 +0800 Subject: [PATCH 34/36] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/stock/info/stock_info.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/resources/templates/stock/info/stock_info.html b/src/main/resources/templates/stock/info/stock_info.html index c1e6c2fc..75f5892a 100644 --- a/src/main/resources/templates/stock/info/stock_info.html +++ b/src/main/resources/templates/stock/info/stock_info.html @@ -9,7 +9,6 @@ -