| | |
| | | import java.math.RoundingMode; |
| | | import java.text.DecimalFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | d.setAmount(d.getAmount().setScale(2, RoundingMode.HALF_UP)); |
| | | } |
| | | d.setSymbolData(bySymbol.getSymbolData()); |
| | | BigDecimal open = DataCache.getLatestOpen(d.getSymbol()); |
| | | if (open != null) { |
| | | d.setOpen(open); |
| | | } |
| | | d.setChangeRatio(dataDBService.getChangeRatio(d, d.getSymbol())); |
| | | d.setSort(Integer.parseInt(bySymbol.getSorted())); |
| | | }); |
| | | |
| | | List<Realtime> result = new ArrayList<>(); |
| | | if (!data.isEmpty()) { |
| | | Realtime realtime = data.stream().filter(x -> x.getSymbol().equalsIgnoreCase("btcusdt")).findFirst().orElse(null); |
| | | if (realtime != null) { |
| | | result.add(realtime); |
| | | data.remove(realtime); |
| | | } |
| | | Realtime realtime2 = data.stream().filter(x -> x.getSymbol().equalsIgnoreCase("ethusdt")).findFirst().orElse(null); |
| | | if (realtime2 != null) { |
| | | result.add(realtime2); |
| | | data.remove(realtime2); |
| | | } |
| | | Realtime realtime3 = data.stream().filter(x -> x.getSymbol().equalsIgnoreCase("xrpusdt")).findFirst().orElse(null); |
| | | if (realtime3 != null) { |
| | | result.add(realtime3); |
| | | data.remove(realtime3); |
| | | } |
| | | if (!data.isEmpty()) { |
| | | result.addAll(data); |
| | | } |
| | | } |
| | | return Result.ok(result); |
| | | data.sort(Comparator.comparing(Realtime::getSort).reversed()); |
| | | return Result.ok(data); |
| | | } catch (Exception e) { |
| | | log.error("c", e); |
| | | throw new YamiShopBindException("生成实时数据失败"); |