| | |
| | | package com.nq.utils.task.stock; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.nq.Repository.StockRepository; |
| | | import com.nq.dao.StockConfigMapper; |
| | | import com.nq.dao.StockMapper; |
| | | import com.nq.dao.UserPositionMapper; |
| | | import com.nq.enums.EConfigKey; |
| | |
| | | @Autowired |
| | | private ExchangeRateService exchangeRateService; |
| | | |
| | | @Autowired |
| | | StockConfigMapper stockConfigMapper; |
| | | |
| | | /** |
| | | * test |
| | | */ |
| | | //@Scheduled(cron = "0 0/1 * * * ?") |
| | | @Scheduled(cron = "*/5 * * * * *") |
| | | public void test() { |
| | | /*ExchangeRate model = new ExchangeRate(); |
| | | model.setCurrency("MXN"); |
| | | model.setConversionCurrency("USD"); |
| | | model.setRata(BigDecimal.valueOf(0.0520)); |
| | | exchangeRateService.updateRate(model,null);*/ |
| | | |
| | | //iStockService.getStockByType(1, 20, "desc","st" , "US", null); |
| | | //istockService.getIndicesList("US"); |
| | | //istockService.getIndicesAndKData("15882", "US"); |
| | | } |
| | | //@Scheduled(cron = "*/5 * * * * *") |
| | | public void test() {} |
| | | |
| | | /** |
| | | * 同步系统所需要的股票 |
| | |
| | | // 1. 定义需要处理的所有股票类型(集中管理,新增类型只需添加到列表) |
| | | List<EStockType> stockTypes = Arrays.asList( |
| | | EStockType.US, |
| | | EStockType.HK, |
| | | EStockType.IN, |
| | | EStockType.TW |
| | | EStockType.JP |
| | | ); |
| | | |
| | | // 2. 批量创建所有异步任务 |
| | |
| | | return; |
| | | } |
| | | List<String> stockCodeList = list.stream().map(DataStockBean::getId).collect(Collectors.toList()); |
| | | List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().in("stock_code", stockCodeList)); |
| | | List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().in("stock_code", stockCodeList).ne("is_show", 0)); |
| | | |
| | | List<Stock> updateStockList = new ArrayList<>(); |
| | | for (DataStockBean o : list) { |
| | |
| | | * 同步指数股票后缓存k线图 |
| | | */ |
| | | public void cacheKData(String stockType, List<DataStockBean> list) { |
| | | StringBuilder codeList = new StringBuilder(); |
| | | /*StringBuilder codeList = new StringBuilder(); |
| | | codeList.append(PropertiesUtil.getProperty("us_home_indices_code")); |
| | | codeList.append(PropertiesUtil.getProperty("hk_home_indices_code")); |
| | | codeList.append(PropertiesUtil.getProperty("in_home_indices_code")); |
| | | codeList.append(PropertiesUtil.getProperty("tw_home_indices_code")); |
| | | codeList.append(PropertiesUtil.getProperty("tw_home_indices_code"));*/ |
| | | |
| | | |
| | | List<StockConfig> stockConfigList = stockConfigMapper.selectList |
| | | (new LambdaQueryWrapper<StockConfig>() |
| | | .like(StockConfig::getCKey, EConfigKey.INDICES.getCode())); |
| | | String codeList = null; |
| | | if (stockConfigList != null && !stockConfigList.isEmpty()) { |
| | | codeList = stockConfigList.stream().filter(Objects::nonNull) |
| | | .map(x -> { return x.getCValue() == null ? "" : x.getCValue(); |
| | | }).collect(Collectors.joining(",")); |
| | | } |
| | | if (codeList == null || codeList.isEmpty()) { |
| | | return; |
| | | } |
| | | for (DataStockBean dataStockBean : list) { |
| | | //缓存首页指数k线图 |
| | | if (codeList.toString().contains(dataStockBean.getId())) { |
| | | if (codeList.contains(dataStockBean.getId())) { |
| | | // 获取K线数据 |
| | | Object kData = istockService.getKData(dataStockBean.getId(), "D", stockType); |
| | | if (kData != null) { |
| | |
| | | return; |
| | | } |
| | | List<String> stockCodeList = list.stream().map(DataStockBean::getId).collect(Collectors.toList()); |
| | | List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().in("stock_code", stockCodeList)); |
| | | List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().in("stock_code", stockCodeList).ne("is_show", 0)); |
| | | List<Stock> updateStockList = new ArrayList<>(); |
| | | for (DataStockBean o : list) { |
| | | //Stock stock = stockMapper.findStockByCode(o.getId()); |