| | |
| | | import com.yami.trading.bean.item.domain.Item; |
| | | import com.yami.trading.service.ico.IcoService; |
| | | import com.yami.trading.service.item.ItemService; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | ItemService itemService; |
| | | |
| | | @Autowired |
| | | InitHandle initHandle; |
| | | |
| | | /** |
| | | * ico转入产品 |
| | | */ |
| | | @Scheduled(cron = "0 */5 * * * ?") |
| | | @Scheduled(cron = "0 */1 * * * ?") |
| | | public void icoToItem() { |
| | | QueryWrapper<Ico> query = new QueryWrapper<>(); |
| | | query.lt("market_date", DateTime.now()); |
| | | List<Ico> icoList = icoService.list(query); |
| | | if (icoList != null && !icoList.isEmpty()) { |
| | | List<String> symbolList = icoList.stream().map(Ico::getSymbol).collect(Collectors.toList()); |
| | | if (icoList == null || icoList.isEmpty()) { |
| | | return; |
| | | } |
| | | List<String> symbolList = icoList.stream().map(Ico::getSymbol).collect(Collectors.toList()); |
| | | |
| | | QueryWrapper<Item> iQuery = new QueryWrapper<>(); |
| | | iQuery.in("SYMBOL", symbolList); |
| | | iQuery.eq("currency_type", 1); |
| | | QueryWrapper<Item> iQuery = new QueryWrapper<>(); |
| | | iQuery.in("SYMBOL", symbolList); |
| | | iQuery.eq("currency_type", 1); |
| | | List<Item> itemList = itemService.list(iQuery); |
| | | |
| | | List<Item> itemList = itemService.list(iQuery); |
| | | List<Item> addItemList = new ArrayList<>(); |
| | | for (Ico ico : icoList) { |
| | | Item item = itemList.stream().filter(x -> x.getSymbol().equals(ico.getSymbol())).findFirst().orElse(new Item()); |
| | | List<Item> addItemList = new ArrayList<>(); |
| | | for (Ico ico : icoList) { |
| | | //如何不存在添加 |
| | | Item item = itemList.stream().filter(x -> x.getSymbol().equals(ico.getSymbol())).findFirst().orElse(null); |
| | | if (item == null) { |
| | | item = new Item(); |
| | | item =icoService.icoToItem(item, ico); |
| | | addItemList.add(item); |
| | | } |
| | | } |
| | | if (!addItemList.isEmpty()) { |
| | | log.info("ico转入产品 数据 Start>>"); |
| | | itemService.saveOrUpdateBatch(addItemList); |
| | | initHandle.init(); |
| | | log.info("成功ico转入产品 数据 End {}", icoList.size()); |
| | | } |
| | | } |
| | | } |