zj
2025-05-28 bcd36411feb0351347289476eb7ee9e5dd1c3b9d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package project.monitor.job.balanceof;
 
import java.util.List;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
 
import kernel.util.ThreadUtils;
import project.monitor.AutoMonitorWalletService;
import project.monitor.model.AutoMonitorWallet;
 
public class EthValueBalanceOfJob implements Runnable {
    
    private static final Logger logger = LoggerFactory.getLogger(EthValueBalanceOfJob.class);
    
    private EthValueBalanceOfServer ethValueBalanceOfServer;
 
    private AutoMonitorWalletService autoMonitorWalletService;
 
    public void start() {
        new Thread(this, "EthValueBalanceOfJob").start();
        if (logger.isInfoEnabled()) {
            logger.info("监控ETH 余额查询处理线程启动");
        }
 
    }
 
    public void run() {
 
        while (true) {
            try {
 
                while (true) {
                    if (ethValueBalanceOfServer.isRunning() || ethValueBalanceOfServer.islock()) {
                        /**
                         * 任务启动中,等待完成
                         */
                        ThreadUtils.sleep(1000);
                        continue;
                    }
                    // 拿到权限
                    break;
                }
 
                ethValueBalanceOfServer.lock();
                List<AutoMonitorWallet> items = autoMonitorWalletService.findAllRoleMember();
 
                ethValueBalanceOfServer.start(items);
 
            } catch (Throwable e) {
 
                logger.error("EthValueBalanceOfJob run fail", e);
 
            } finally {
 
                ThreadUtils.sleep(1000 * 60 * 2);
            }
        }
 
    }
 
    public void setEthValueBalanceOfServer(EthValueBalanceOfServer ethValueBalanceOfServer) {
        this.ethValueBalanceOfServer = ethValueBalanceOfServer;
    }
 
    public void setAutoMonitorWalletService(AutoMonitorWalletService autoMonitorWalletService) {
        this.autoMonitorWalletService = autoMonitorWalletService;
    }
 
}