| | |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.text.split.SplitIter; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.google.common.base.Splitter; |
| | | import com.google.common.collect.Lists; |
| | | import com.yami.trading.bean.data.domain.Realtime; |
| | |
| | | items.addAll(itemsTop); |
| | | } else if ("US-stocks".equals(type)) { |
| | | // 只查询指数top6 |
| | | items = itemService.cacheGetAll().stream().filter(item -> "global".equals(item.getCategory())).limit(3).collect(Collectors.toList()); |
| | | List<Item> itemsTop = itemService.cacheGetAll().stream().filter(item -> "technology,prominent".equals(item.getCategory())).sorted(Comparator.comparing(Item::getSorted).reversed()).limit(size) |
| | | .collect(Collectors.toList()); |
| | | items.addAll(itemsTop); |
| | | items = itemService.cacheGetAll().stream().filter(item -> "US-stocks".equals(item.getType())).limit(6).collect(Collectors.toList()); |
| | | // List<Item> itemsTop = itemService.cacheGetAll().stream().filter(item -> "technology,prominent".equals(item.getCategory())).sorted(Comparator.comparing(Item::getSorted).reversed()).limit(size) |
| | | // .collect(Collectors.toList()); |
| | | // items.addAll(itemsTop); |
| | | } |
| | | // 加密货币、外汇、 top4 |
| | | else { |
| | |
| | | @RequestParam(required = false) Integer pageNo, |
| | | @RequestParam(required = false) Integer pageSize) { |
| | | try { |
| | | pageSize = null == pageSize ? 1000 : pageSize; |
| | | pageSize = null == pageSize ? 100 : pageSize; |
| | | List<Item> itemsTotal; |
| | | List<Item> items = new ArrayList<>(); |
| | | //按字符串排序 |
| | | List<Item> itemList = itemService.cacheGetAll().stream().sorted(Comparator.comparing(Item::getSorted).reversed()).collect(Collectors.toList()); |
| | | List<Item> itemList = itemService.cacheGetAll().stream() |
| | | .sorted(Comparator.comparing( |
| | | item -> Integer.parseInt(item.getSorted()), |
| | | Comparator.reverseOrder() |
| | | )) |
| | | .collect(Collectors.toList()); |
| | | |
| | | //按数字排序 |
| | | // List<Item> itemList = itemService.cacheGetAll().stream().sorted(Comparator.comparing(Item::getSorted, (x,y)->{ |
| | | // int xInt = 0; |
| | |
| | | if (null != type && null != category) { |
| | | // 知名类 需要模糊查询 |
| | | if ("prominent".equals(category)) { |
| | | itemsTotal = new ArrayList<>(itemList).stream().filter(item -> item.getType().equals(type) |
| | | && item.getCategory().contains(category)).collect(Collectors.toList()); |
| | | itemsTotal = itemService.list(new LambdaQueryWrapper<Item>().eq(Item::getType,type)); |
| | | } else { |
| | | itemsTotal = new ArrayList<>(itemList).stream().filter(item -> item.getType().equals(type) |
| | | && item.getCategory().equals(category)).collect(Collectors.toList()); |