新增前端vue
This commit is contained in:
@@ -1,54 +1,11 @@
|
|||||||
package com.jeesite.modules.app.Job;
|
package com.jeesite.modules.app.Job;
|
||||||
|
|
||||||
import com.jeesite.common.config.Global;
|
|
||||||
import com.jeesite.modules.app.dao.DailyWeather;
|
|
||||||
import com.jeesite.modules.app.dao.DateInfo;
|
|
||||||
import com.jeesite.modules.app.utils.DateUtils;
|
|
||||||
import com.jeesite.modules.app.utils.LoggerUtils;
|
|
||||||
import com.jeesite.modules.app.utils.WeatherUtils;
|
|
||||||
import com.jeesite.modules.biz.entity.BizCalendarInfo;
|
|
||||||
import com.jeesite.modules.biz.service.BizCalendarInfoService;
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class appJob {
|
public class appJob {
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private BizCalendarInfoService bizCalendarInfoService;
|
|
||||||
|
|
||||||
|
|
||||||
String API_KEY = "7e6a6422c4b949dd90a5ad3302137b76";
|
|
||||||
|
|
||||||
private String LOCATION = Global.getConfig("biz.weather.Loc", "101010100");
|
|
||||||
|
|
||||||
private static final LoggerUtils logger = LoggerUtils.getInstance();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 日历定时任务
|
|
||||||
*/
|
|
||||||
@Scheduled(cron = "0 10 2 * * ?")
|
|
||||||
public void initJob() {
|
public void initJob() {
|
||||||
try {
|
|
||||||
WeatherUtils weather = new WeatherUtils(API_KEY);
|
|
||||||
DailyWeather todayWeather = weather.getTodayWeather(LOCATION);
|
|
||||||
DateInfo dateInfo = DateUtils.getDateInfo(todayWeather.getDate());
|
|
||||||
BizCalendarInfo calendarInfo = new BizCalendarInfo();
|
|
||||||
calendarInfo.setCalendarDate(todayWeather.getDate());
|
|
||||||
calendarInfo.setWeekDay(dateInfo.getDayOfWeek());
|
|
||||||
calendarInfo.setLunarCalendar(dateInfo.getFullChineseDate());
|
|
||||||
calendarInfo.setIsHoliday(dateInfo.isWeekend() ? 1 : 0);
|
|
||||||
calendarInfo.setDayWeather(todayWeather.getTextDay());
|
|
||||||
calendarInfo.setNightWeather(todayWeather.getTextNight());
|
|
||||||
calendarInfo.setMaxTemperature(todayWeather.getTempMax());
|
|
||||||
calendarInfo.setMinTemperature(todayWeather.getTempMin());
|
|
||||||
calendarInfo.setWindDirection(todayWeather.getWindDirDay());
|
|
||||||
calendarInfo.setWindGrade(todayWeather.getWindScaleDay());
|
|
||||||
bizCalendarInfoService.save(calendarInfo);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user