package com.xcong.excoin.quartz.job; import com.xcong.excoin.common.enumerates.CoinTypeEnum; import com.xcong.excoin.modules.blackchain.service.TrxUsdtUpdateService; import com.xcong.excoin.modules.coin.service.BlockCoinService; import com.xcong.excoin.modules.member.dao.MemberCoinAddressDao; import com.xcong.excoin.modules.member.entity.MemberCoinAddressEntity; import com.xcong.excoin.utils.RedisUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.LinkedList; import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; /** * 链上币种同步任务 * * @author wzy * @date 2020-07-02 **/ @Slf4j @Component @ConditionalOnProperty(prefix = "app", name = "block-job", havingValue = "true") public class BlockCoinUpdateJob { @Resource private BlockCoinService blockCoinService; @Resource private TrxUsdtUpdateService trxUsdtUpdateService; @Resource RedisUtils redisUtils; // 创世区块时间 ,每三秒出一个块 private final static Long TRX_CSQK=1530442002L; public static ConcurrentLinkedQueue TRC_BLOCK = new ConcurrentLinkedQueue<>(); /** * TRC20_USDT 同步 */ @Scheduled(cron = "0/2 * * * * ? ") @Async public void usdtTc20Update() { // 波场3秒出一个块 Long blocnNum = TRC_BLOCK.poll(); if(blocnNum==null){ return; } System.out.println(TRC_BLOCK); redisUtils.set("USDT_TRC20_CURRENT_BLOCK_NUM",blocnNum); System.out.println("扫块:"+blocnNum); trxUsdtUpdateService.monitorCoinListener(blocnNum); } @Scheduled(cron = "0/2 * * * * ? ") public void usdtTc20UpdateQueue() { // 查询最新区块号 long getnowblock =trxUsdtUpdateService.getnowblockFromTronScan()-25; System.out.println("getnowblock:"+getnowblock); // 生成块到队列 Object trc20BlockNum = redisUtils.get("USDT_TRC20_BLOCK_NUM"); if(trc20BlockNum==null){ // 没有则取最新的块 trc20BlockNum =getnowblock; redisUtils.set("USDT_TRC20_BLOCK_NUM",getnowblock); } Long blockNum = Long.valueOf(trc20BlockNum.toString()); if(getnowblock