| | |
| | | import org.example.pojo.bo.CurrencyBitgetBo; |
| | | import org.example.server.impl.CurrencySerivceImpl; |
| | | import org.example.util.ConverterUtil; |
| | | import org.example.util.RedisUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | |
| | | }.getType()); |
| | | |
| | | getList.parallelStream().forEach(person -> person.setSymbol(StringUtils.remove(person.getSymbol(), "-"))); |
| | | |
| | | List<Currency> dbList = currencyService.list(new LambdaQueryWrapper<Currency>().eq(Currency::getSource,"bitget")); |
| | | Set<String> symbolSet = getList.stream().map(CurrencyBitgetBo::getSymbol).collect(Collectors.toSet()); |
| | | List<Currency> removeList = dbList.stream() |
| | | .filter(currency -> !symbolSet.contains(currency.getSymbol())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | if(CollectionUtils.isNotEmpty(removeList)){ |
| | | removeList.forEach(f->{ |
| | | RedisUtil.delete("bitget"+f.getSymbol()); |
| | | }); |
| | | } |
| | | |
| | | // 获取数据库中已有的symbol列表 |
| | | currencyService.remove(new LambdaQueryWrapper<Currency>().eq(Currency::getSource,"bitget")); |
| | | // 比对接口返回的数据和数据库中已有的数据,找出新增的数据 |
| | | |
| | | List<Currency> saveList = getList.stream() |
| | | .map(currency -> { |
| | | Currency newCurrency = new Currency(); |