| | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.*; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | if (itemService.isSuspended(symbol)) { |
| | | return; |
| | | } |
| | | /*if (realtime.getSymbol().equals("axsusdt")) { |
| | | System.out.println("axsusdt1" + realtime); |
| | | /*if (realtime.getSymbol().equals("galausdt")) { |
| | | System.out.println("galausdt111" + realtime); |
| | | }*/ |
| | | DataCache.putLatestRealTime(symbol, realtime); |
| | | DataCache.putLatestOpen(symbol, realtime.getOpen()); |
| | |
| | | return realtime; |
| | | } |
| | | |
| | | @Override |
| | | public void cacheBefore24Hour(String symbol) { |
| | | // 计算“24小时前”的时间戳(毫秒级) |
| | | long twentyFourHoursAgo = Instant.now().minus(24, ChronoUnit.HOURS).toEpochMilli(); |
| | | RequestDataHelper.set("symbol", symbol); |
| | | LambdaQueryWrapper<Realtime> queryWrapper = new LambdaQueryWrapper<Realtime>() |
| | | .eq(Realtime::getSymbol, symbol) |
| | | .ge(Realtime::getTs, twentyFourHoursAgo) // 时间戳 >= 24小时前(前24小时内) |
| | | .orderByDesc(Realtime::getClose) // 24小时最高 |
| | | .last("LIMIT 1"); |
| | | Realtime realtimeHigh = realtimeService.getBaseMapper().selectOne(queryWrapper); |
| | | LambdaQueryWrapper<Realtime> queryWrapper2 = new LambdaQueryWrapper<Realtime>() |
| | | .eq(Realtime::getSymbol, symbol) |
| | | .ge(Realtime::getTs, twentyFourHoursAgo) // 时间戳 >= 24小时前(前24小时内) |
| | | .orderByAsc(Realtime::getClose) // 24小时最低 |
| | | .last("LIMIT 1"); |
| | | Realtime realtimeLow = realtimeService.getBaseMapper().selectOne(queryWrapper2); |
| | | RequestDataHelper.clear(); |
| | | System.out.println("realtimeHigh:" + realtimeHigh); |
| | | System.out.println("realtimeLow:" + realtimeLow); |
| | | if (realtimeHigh != null) { |
| | | DataCache.getRealtimeHigh().put(symbol, realtimeHigh.getClose().doubleValue()); |
| | | System.out.println("putRealtimeHigh:" + realtimeHigh.getClose().doubleValue()); |
| | | } |
| | | if (realtimeLow != null) { |
| | | DataCache.getRealtimeLow().put(symbol, realtimeLow.getClose().doubleValue()); |
| | | System.out.println("putRealtimeLow:" + realtimeLow.getClose().doubleValue()); |
| | | } |
| | | } |
| | | |
| | | public void deleteRealtime(int days) { |
| | | for (int i = 0; i <= Constants.TABLE_PARTITIONS - 1; i++) { |
| | | Map<String, Object> parameters = new HashMap(); |