swb
2024-07-05 f577294fad6b5636a22ce872b3b762ae40fd7799
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
package com.moral.api.task;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import com.moral.api.service.CityWeatherForecastService;
import com.moral.api.service.CityWeatherService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
 
@Component
public class WeatherTask {
 
    @Autowired
    private CityWeatherService cityWeatherService;
 
    @Autowired
    private CityWeatherForecastService cityWeatherForecastService;
 
    //城市逐小时气象实测数据insert
    @XxlJob("insertCityWeather")
    public ReturnT insertCityWeather() {
        try {
            cityWeatherService.insertCityWeather();
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
 
    //城市明日逐小时预测气象预测数据insert
    @XxlJob("insertCityWeatherForecast")
    public ReturnT insertCityWeatherForecast() {
        try {
            cityWeatherForecastService.insertCityWeatherForecast();
        } catch (Exception e) {
            XxlJobHelper.log(e.getMessage());
            return new ReturnT(ReturnT.FAIL_CODE, e.getMessage());
        }
        return ReturnT.SUCCESS;
    }
}