1
zj
2025-04-24 c134d6137dff1d4533b12a07f85e44a1d7d57362
src/main/java/com/nq/utils/task/stock/StockTask.java
@@ -88,7 +88,7 @@
    //原油
    private static final String crude_oil_API_URL = "http://47.112.169.122/fOption_curr.action?username=Qq112233&password=3ce25a66d5b3a8cd661024fea6c79388&id=@CL0W";
    @Scheduled(cron = "0/10 * * * * ?")  // 每6秒执行一次
    @Scheduled(cron = "0/6 * * * * ?")  // 每6秒执行一次
    public void gold() {
        try {
            // 使用RestTemplate发起HTTP请求
@@ -96,7 +96,7 @@
            String response = restTemplate.getForObject(gold_API_URL, String.class);
            // 解析返回的CSV格式数据,去除可能存在的换行符
            if (response != null) {
            if (response != null && !response.contains("参数错误")) {
                // 清除换行符并按逗号分割数据
                String[] parts = response.trim().split(",");
                String price = parts[2].trim();  // "3348.4"
@@ -113,7 +113,7 @@
        }
    }
    @Scheduled(cron = "0/15 * * * * ?")  // 每6秒执行一次
    @Scheduled(cron = "0/7 * * * * ?")  // 每6秒执行一次
    public void crudeOil() {
        try {
            // 使用RestTemplate发起HTTP请求
@@ -121,7 +121,7 @@
            String response = restTemplate.getForObject(crude_oil_API_URL, String.class);
            // 解析返回的CSV格式数据,去除可能存在的换行符
            if (response != null) {
            if (response != null && !response.contains("参数错误")) {
                // 清除换行符并按逗号分割数据
                String[] parts = response.trim().split(",");
                String price = parts[2].trim();  // "3348.4"
@@ -151,11 +151,15 @@
        String[] arr = {"d", "w", "m", "1", "5", "30"};
        for (String str : arr) {
            String g = restTemplate.getForObject(k_gold_API_URL+str, String.class);
            RedisShardedPoolUtils.set("k_gold_"+str, g);
            Thread.sleep(6000);
            if(!g.contains("参数错误")){
                RedisShardedPoolUtils.set("k_gold_"+str, g);
                Thread.sleep(10000);
            }
            String c = restTemplate.getForObject(k_crude_oil_API_URL+str, String.class);
            RedisShardedPoolUtils.set("k_crude_oil_"+str, c);
            Thread.sleep(6000);
            if(!c.contains("参数错误")){
                RedisShardedPoolUtils.set("k_crude_oil_"+str, c);
                Thread.sleep(10000);
            }
        }
    }
    /**