| package cc.mrbird.febs.mall.chain.ercCoin.quartz; | 
|   | 
| import cc.mrbird.febs.common.utils.AppContants; | 
| import cc.mrbird.febs.common.utils.RedisUtils; | 
| import cc.mrbird.febs.mall.chain.ercCoin.ChainEnum; | 
| import cc.mrbird.febs.mall.chain.ercCoin.ChainService; | 
| import cc.mrbird.febs.mall.chain.ercCoin.ContractEventService; | 
| import lombok.extern.slf4j.Slf4j; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.boot.ApplicationArguments; | 
| import org.springframework.boot.ApplicationRunner; | 
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | 
| import org.springframework.stereotype.Component; | 
|   | 
| import java.math.BigInteger; | 
|   | 
| @Slf4j | 
| @Component | 
| @ConditionalOnProperty(prefix = "chain", name = "bsc", havingValue = "true") | 
| public class ChainSDMRunner  implements ApplicationRunner { | 
|     @Autowired | 
|     private ContractEventService bscUsdtContractEvent; | 
|   | 
|     @Autowired | 
|     private RedisUtils redisUtils; | 
|   | 
|     @Override | 
|     public void run(ApplicationArguments args) throws Exception { | 
|         long start = System.currentTimeMillis(); | 
|         log.info("区块链USDT开始启动"); | 
|   | 
|         Object incrementObj = redisUtils.get(AppContants.REDIS_KEY_BLOCK_ETH_INCREMENT_NUM); | 
|         BigInteger newest = ChainService.getInstance(ChainEnum.BSC_USDT.name()).blockNumber(); | 
|         BigInteger block; | 
|         if (incrementObj == null) { | 
|             block = newest; | 
|         } else { | 
|             block = (BigInteger) incrementObj; | 
|         } | 
|   | 
|         BigInteger section = BigInteger.valueOf(5000); | 
|         log.info("监听:[{} - {} - {}]", newest,block,newest.subtract(block).compareTo(section) > -1); | 
|         while (newest.subtract(block).compareTo(section) > -1) { | 
|             BigInteger end = block.add(section); | 
|             log.info("监听:[{} - {}]", block, end); | 
|             ChainService.sdmUSDTEventListener(block, end, bscUsdtContractEvent, ChainEnum.BSC_USDT.name()); | 
|   | 
|             block = block.add(section); | 
|             if (block.compareTo(newest) > 0) { | 
|                 block = newest; | 
|             } | 
|         } | 
|   | 
|         ChainService.sdmUSDTEventListener(block, null, bscUsdtContractEvent, ChainEnum.BSC_USDT.name()); | 
|   | 
|         long end = System.currentTimeMillis(); | 
|         log.info("区块链滑点启动完成, 消耗时间{}", end - start); | 
|     } | 
| } |