| | |
| | | package org.example.task; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.core.type.TypeReference; |
| | |
| | | * 同步mexc交易所交易对 |
| | | */ |
| | | @Scheduled(cron = "0 0/30 * * * ?") |
| | | // @Scheduled(cron = "0/10 * * * * ?") |
| | | public void syncCurrency() { |
| | | // 使用Lock来确保同步 |
| | | syncCurrencyLock.lock(); |
| | |
| | | }.getType()); |
| | | |
| | | // 获取数据库中已有的symbol列表 |
| | | List<Currency> dbList = currencyService.list(); |
| | | List<Currency> dbList = currencyService.list(new LambdaQueryWrapper<Currency>().eq(Currency::getSource, "mexc")); |
| | | Set<String> symbolSet = dbList.stream().map(Currency::getSymbol).collect(Collectors.toSet()); |
| | | |
| | | // 比对接口返回的数据和数据库中已有的数据,找出新增的数据 |