1
zyy
2 days ago 4fefff17528a878d345ff3311c297a66a671b8d6
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
package com.yami.trading.huobi.task;
 
import com.yami.trading.bean.data.domain.Depth;
import com.yami.trading.bean.item.domain.Item;
import com.yami.trading.huobi.data.DataCache;
import com.yami.trading.huobi.data.internal.DepthTimeObject;
import com.yami.trading.huobi.hobi.internal.SpiderService;
import com.yami.trading.huobi.hobi.internal.XueQiuDataServiceImpl;
import com.yami.trading.service.item.ItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * @哪吒出海 股票市场socket
 */
@Component
@Lazy(value = false)
@Slf4j
public class AStockPanKouTask {
    @Autowired
    private ItemService itemService;
 
    @Autowired
    private XueQiuDataServiceImpl xueQiuDataService;
 
    private volatile boolean isAstockInit = false;
 
    //@哪吒出海 取消买入卖出数据,会导致雪球接口频繁,[暂不启用]
    //@Scheduled(cron = "*/5 * * * * ?")
    public void sendTask() {
        String remarks = new ArrayList<Item>(itemService.list()).stream().filter(t-> t.isActive() && Item.A_STOCKS.equalsIgnoreCase(t.getOpenCloseType())).map(Item::getRemarks).collect(Collectors.joining(","));
        List<Depth> pankous = xueQiuDataService.pankous(remarks);
        pankous.stream().forEach(d -> {
            String symbol = d.getSymbol();
            DepthTimeObject timeObject = new DepthTimeObject();
            timeObject.setDepth(d);
            DataCache.putDepth(itemService.getSymbolByRemarks(symbol), timeObject);
        });
 
        isAstockInit = true;
    }
}