public void calTrendMaMonitor(String code, List<Indicator> indicatorList) { List<ProdIndex> prodIndexList = prodIndexBuss.queryAscByCode(code); indicatorList .stream() .forEach( indicator -> { TrendMaMonitor trendMaMonitor1 = trendMaMonitorRepos.findByCodeAndTrend(code, indicator.getName()); TrendMaMonitor trendMaMonitor2 = new TrendMaMonitor(); trendMaMonitor2.setTrend(indicator.getName()); trendMaMonitor2.setCode(code); TrendMaMonitor trendMaMonitor = trendMaMonitor1 == null ? trendMaMonitor2 : trendMaMonitor1; prodIndexList .stream() .forEach( prodIndex -> { indicator.push(prodIndex.getDt(), prodIndex.getPrice()); if (indicator.getLine().isEmpty()) { return; } Price maPrice = indicator.getLine().get(indicator.getLine().size() - 1); calTrendMaMonitor( trendMaMonitor, prodIndex.getDt(), prodIndex.getPrice(), maPrice.getP()); }); trendMaMonitorRepos.save(trendMaMonitor); }); trendMaMonitorRepos.flush(); }
public List<TrendMaMonitor> queryTrendMaMonitorList() { return trendMaMonitorRepos.findAll(); }