@Override public LongHuBangInfo mapLogic(Stock stock) throws Exception { if (stock == null || stock == EmptyObject.emptyStock) return EmptyObject.emptyLongHuBangInfo; Date date = stock.getStockQueryDate(); if (date == EmptyObject.emptyDate) throw new IllegalArgumentException("lost parameter: stockQueryDate"); String dateParam = DateParser.getTimePrefix(date, false); String target = URLMapper.LONGHUBANG_JSON.toString(); RequestParaBuilder builder = new RequestParaBuilder(target) .addParameter("date", dateParam) .addParameter("symbol", stock.getStockNo()); URL url = new URL(builder.build()); String json = request(url); JsonNode node = mapper.readTree(json); return processNode(stock, node); }
private LongHuBangInfo processNode(Stock stock, JsonNode node) { JsonNode detail = node.get("detail"); JsonNode buyListNode = detail.get("tqQtBizunittrdinfoBuyList"); JsonNode saleListNode = detail.get("tqQtBizunittrdinfoSaleList"); Set<LongHuBangInfo.BizsunitInfo> buyList = new HashSet<>(); Set<LongHuBangInfo.BizsunitInfo> saleList = new HashSet<>(); for (JsonNode jsonNode : buyListNode) { LongHuBangInfo.BizsunitInfo info = composeInfo(jsonNode); buyList.add(info); } for (JsonNode jsonNode : saleListNode) { LongHuBangInfo.BizsunitInfo info = composeInfo(jsonNode); saleList.add(info); } return new LongHuBangInfo(stock, stock.getStockQueryDate(), buyList, saleList); }
@Override public Stock copy() { Stock stock = new Stock(this.stockName, this.stockNo); stock.currency_unit = currency_unit; stock.current = current; stock.volume = volume; stock.percentage = percentage; stock.change = change; stock.open = open; stock.high = high; stock.low = low; stock.amplitude = amplitude; stock.rise_stop = rise_stop; stock.fall_stop = fall_stop; stock.close = close; stock.last_close = last_close; stock.high52Week = high52Week; stock.low52week = low52week; stock.marketCapital = marketCapital; stock.float_market_capital = float_market_capital; stock.float_shares = float_shares; stock.totalShares = totalShares; stock.eps = eps; stock.net_assets = net_assets; stock.pe_ttm = pe_ttm; stock.pe_lyr = pe_lyr; stock.dividend = dividend; stock.psr = psr; stock.time = time; stock.amount = amount; stock.turnover_rate = turnover_rate; stock.stockTrend = stockTrend.copy(); stock.shareHoldersTrend = shareHoldersTrend.copy(); stock.stockQueryDate = stockQueryDate; stock.companyInfo = companyInfo; stock.industry = industry; return stock; }