动态Scheduled
This commit is contained in:
parent
8edd0cdb16
commit
80412011af
|
|
@ -9,6 +9,11 @@ import org.springframework.stereotype.Component;
|
||||||
@ConfigurationProperties(prefix = "t1h-download")
|
@ConfigurationProperties(prefix = "t1h-download")
|
||||||
public class T1hDownloadProperties {
|
public class T1hDownloadProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时器cron
|
||||||
|
*/
|
||||||
|
private String cron;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* python环境路径
|
* python环境路径
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package org.jeecg.job;
|
package org.jeecg.job;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.StopWatch;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -12,8 +13,8 @@ import org.jeecg.common.util.ExecutePyUtils;
|
||||||
import org.jeecg.modules.base.entity.WeatherData;
|
import org.jeecg.modules.base.entity.WeatherData;
|
||||||
import org.jeecg.service.WeatherDataService;
|
import org.jeecg.service.WeatherDataService;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.util.StopWatch;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
|
@ -29,17 +30,16 @@ import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@Component
|
||||||
public class DownloadT1hJob {
|
public class DownloadT1hJob {
|
||||||
private final WeatherDataService weatherDataService;
|
private final WeatherDataService weatherDataService;
|
||||||
private final SystemStorageProperties systemStorageProperties;
|
private final SystemStorageProperties systemStorageProperties;
|
||||||
private final T1hDownloadProperties t1hDownloadProperties;
|
private final T1hDownloadProperties t1hDownloadProperties;
|
||||||
|
|
||||||
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
private static final int PROCESS_TIMEOUT_SECONDS = 3600; // 30分钟超时
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 1 * * ?")
|
@Scheduled(cron = "#{@t1hDownloadProperties.cron}")
|
||||||
|
// @Scheduled(cron = "0 0 1 * * ?")
|
||||||
public void downloadT1HFile() {
|
public void downloadT1HFile() {
|
||||||
log.info("开始执行T1H文件下载任务");
|
log.info("开始执行T1H文件下载任务");
|
||||||
StopWatch stopWatch = new StopWatch();
|
StopWatch stopWatch = new StopWatch();
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
|
@ -21,6 +23,7 @@ import java.net.UnknownHostException;
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@EnableFeignClients
|
@EnableFeignClients
|
||||||
|
@EnableScheduling
|
||||||
public class JeecgWeatherCloudApplication extends SpringBootServletInitializer implements CommandLineRunner {
|
public class JeecgWeatherCloudApplication extends SpringBootServletInitializer implements CommandLineRunner {
|
||||||
|
|
||||||
private final RedisTemplate<String, Object> redisTemplate;
|
private final RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user