| | |
| | | @GetMapping("api/hobi!getRealtime.action") |
| | | public Result<List<Realtime>> getRealtime(@RequestParam String symbol) { |
| | | try { |
| | | if (symbol == null || symbol.isEmpty()){ |
| | | return Result.succeed(); |
| | | } |
| | | List<Realtime> data = this.dataService.realtime(symbol); |
| | | data.forEach(d->{ |
| | | Item bySymbol = itemService.findBySymbol(d.getSymbol()); |
| | |
| | | List<Item> items = new ArrayList<>(); |
| | | //按字符串排序 |
| | | List<Item> itemList = itemService.cacheGetAll().stream().sorted(Comparator.comparing(Item::getSorted).reversed()).collect(Collectors.toList()); |
| | | if (type != null && type.equalsIgnoreCase(Item.US_STOCKS)) { |
| | | category = null; |
| | | } |
| | | //按数字排序 |
| | | // List<Item> itemList = itemService.cacheGetAll().stream().sorted(Comparator.comparing(Item::getSorted, (x,y)->{ |
| | | // int xInt = 0; |
| | |
| | | // })).collect(Collectors.toList()); |
| | | |
| | | if (null != type && null != category) { |
| | | String finalCategory = category; |
| | | // 知名类 需要模糊查询 |
| | | if ("prominent".equals(category)) { |
| | | itemsTotal = new ArrayList<>(itemList).stream().filter(item -> item.getType().equals(type) |
| | | && item.getCategory().contains(category)).collect(Collectors.toList()); |
| | | && item.getCategory().contains(finalCategory)).collect(Collectors.toList()); |
| | | } else { |
| | | itemsTotal = new ArrayList<>(itemList).stream().filter(item -> item.getType().equals(type) |
| | | && item.getCategory().equals(category)).collect(Collectors.toList()); |
| | | && item.getCategory().equals(finalCategory)).collect(Collectors.toList()); |
| | | } |
| | | if (pageNo * pageSize - pageSize < itemsTotal.size()) { |
| | | int pages = itemsTotal.size() % pageSize == 0 ? itemsTotal.size() / pageSize : itemsTotal.size() / pageSize + 1; |