zj
2024-06-03 4afe73cb84c5a609662b8b4ee20693de9b86b9a3
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.nq.config;
 
import com.nq.dao.RealTimeMapper;
import com.nq.dao.StockFuturesMapper;
import com.nq.dao.StockIndexMapper;
import com.nq.dao.StockMapper;
import com.nq.pojo.Stock;
import com.nq.pojo.StockFutures;
import com.nq.pojo.StockIndex;
import com.nq.utils.stock.BuyAndSellUtils;
import com.nq.utils.stock.sina.SinaStockApi;
 
import java.math.BigDecimal;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
 
@Component
public class StockPoll {
    @Resource
    StockMapper stockMapper;
 
    @Resource
    RealTimeMapper realTimeMapper;
 
    @Resource
    StockFuturesMapper stockFuturesMapper;
 
    @Resource
    StockIndexMapper stockIndexMapper;
 
    private ThreadPoolExecutor pool;
 
    @PostConstruct
    public void initPool() {
        this.pool = new ThreadPoolExecutor(50, 70, 20L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(240));
        this.pool.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
    }
 
    public void test(String stockType, Integer stock_num, Integer stock_nums) {
        List<Stock> stockCodes = this.stockMapper.findStockCode(stockType, stock_num, stock_nums);
        System.out.println("stockCodes" + stockCodes.size() + "--stockCodes");
        for (Stock stock : stockCodes) {
            String stockGid = stock.getStockGid();
            String sinaStock = SinaStockApi.getInStockDetail( stockGid);
            String[] arrayOfString = sinaStock.split(",");
            StockTask stockTask = new StockTask();
            stockTask.splits((Object[])arrayOfString);
            stockTask.stockGid(stockGid);
            stockTask.averagePrice(Double.parseDouble("0"));
            stockTask.StockPoll(this);
            stockTask.RealTimeMapper(this.realTimeMapper);
 
            this.pool.submit(stockTask);
        }
    }
 
    //0-540
//    public void z1() {
//        test("sz", Integer.valueOf(0), Integer.valueOf(300));
//    }
//    public void z11() {
//        test("sz", Integer.valueOf(300), Integer.valueOf(300));
//    }
//    public void z12() {
//        test("sz", Integer.valueOf(600), Integer.valueOf(200));
//    }
//
//    //540-540
//    public void z2() {
//        test("sz", Integer.valueOf(800), Integer.valueOf(300));
//    }
//    public void z21() {
//        test("sz", Integer.valueOf(1100), Integer.valueOf(300));
//    }
//    public void z22() {
//        test("sz", Integer.valueOf(1400), Integer.valueOf(200));
//    }
//
//    //1080 - 540
//    public void z3() {
//        test("sz", Integer.valueOf(1600), Integer.valueOf(300));
//    }
//    public void z31() {
//        test("sz", Integer.valueOf(1900), Integer.valueOf(300));
//    }
//    public void z32() {
//        test("sz", Integer.valueOf(2200), Integer.valueOf(200));
//    }
//
//    //1620 - 539
//    public void z4() {
//      //  test("sz", Integer.valueOf(2400), Integer.valueOf(200));
//    }
//    public void z41() {
//        test("sz", Integer.valueOf(2600), Integer.valueOf(100));
//    }
//    public void z42() {
//        test("sz", Integer.valueOf(2700), Integer.valueOf(100));
//    }
//
//    //0-484
//    public void h1() {
//        test("sh", Integer.valueOf(0), Integer.valueOf(300));
//    }
//    public void h11() {
//        test("sh", Integer.valueOf(300), Integer.valueOf(300));
//    }
//    public void h12() {
//        test("sh", Integer.valueOf(600), Integer.valueOf(100));
//    }
//
//    //484-484
//    public void h2() {
//        test("sh", Integer.valueOf(700), Integer.valueOf(300));
//    }
//    public void h21() {
//        test("sh", Integer.valueOf(1000), Integer.valueOf(300));
//    }
//    public void h22() {
//        test("sh", Integer.valueOf(1300), Integer.valueOf(100));
//    }
//
//    //968-485
//    public void h3() {
//        test("sh", Integer.valueOf(1400), Integer.valueOf(300));
//    }
//    public void h31() {
//        test("sh", Integer.valueOf(1700), Integer.valueOf(300));
//    }
//    public void h32() {
//        test("sh", Integer.valueOf(2000), Integer.valueOf(200));
//    }
//
//    //bj 0-121
//    public void bj1() {
//        test("bj", Integer.valueOf(0), Integer.valueOf(200));
//    }
 
//    public void qh1() {
//        qhDataGrab("qh", Integer.valueOf(0), Integer.valueOf(540));
//    }
 
 
}