| | |
| | | if (stockSetting.getType().equals("0")) { |
| | | return new BigDecimal(stockSetting.getPrice()); |
| | | } else { |
| | | String s = doPost(stock.getStockCode()); |
| | | String s = doPost(stock.getStockCode(),stock.getStockType()); |
| | | if (null != s) { |
| | | Map<String, Object> stringObjectMap = jsonToMap(s); |
| | | return new BigDecimal(stringObjectMap.get("last").toString()).multiply(new BigDecimal(stockSetting.getPrice())); |
| | | if(stock.getStockType().equals("US")){ |
| | | return new BigDecimal(stringObjectMap.get("Last").toString()).multiply(new BigDecimal(stockSetting.getPrice())); |
| | | }else{ |
| | | return new BigDecimal(stringObjectMap.get("last").toString()).multiply(new BigDecimal(stockSetting.getPrice())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | String s = doPost(stock.getStockCode()); |
| | | String s = doPost(stock.getStockCode(),stock.getStockType()); |
| | | if (null != s) { |
| | | Map<String, Object> stringObjectMap = jsonToMap(s); |
| | | return new BigDecimal(stringObjectMap.get("last").toString()); |
| | | if(stock.getStockType().equals("US")){ |
| | | return new BigDecimal(stringObjectMap.get("Last").toString()); |
| | | }else{ |
| | | return new BigDecimal(stringObjectMap.get("last").toString()); |
| | | } |
| | | } |
| | | return BigDecimal.ZERO; |
| | | } |
| | |
| | | @Override |
| | | public Map<String, Object> getNewStock(String stockCode) { |
| | | Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", stockCode)); |
| | | String s = doPost(stock.getStockCode()); |
| | | String s = doPost(stock.getStockCode(),stock.getStockType()); |
| | | if (null != s) { |
| | | Map<String, Object> stringObjectMap = jsonToMap(s); |
| | | return stringObjectMap; |
| | |
| | | } |
| | | } |
| | | |
| | | public String doPost(String pid) { |
| | | |
| | | public String doPost(String pid,String stockType) { |
| | | String url; |
| | | if(stockType.equals("JP")){ |
| | | url = PropertiesUtil.getProperty("JP_HTTP_API") + "stock?version=v1&key=" + PropertiesUtil.getProperty("JP_KEY"); |
| | | }else{ |
| | | url = PropertiesUtil.getProperty("US_HTTP_API") + "stock?version=v1&key=" + PropertiesUtil.getProperty("US_KEY"); |
| | | } |
| | | try { |
| | | String url = PropertiesUtil.getProperty("JP_HTTP_API") + "stock?version=v1&key=" + PropertiesUtil.getProperty("JP_KEY"); |
| | | URL obj = new URL(url); |
| | | HttpURLConnection con = (HttpURLConnection) obj.openConnection(); |
| | | |