WeatherTask.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package com.xunmei.job.task;
  2. import cn.hutool.core.lang.UUID;
  3. import com.alibaba.fastjson.JSON;
  4. import com.xunmei.common.core.constant.SecurityConstants;
  5. import com.xunmei.common.core.web.domain.AjaxResult;
  6. import com.xunmei.system.api.RemoteRetrievalTaskService;
  7. import com.xunmei.system.api.RemoteWeatherTaskService;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.springframework.stereotype.Component;
  10. import javax.annotation.Resource;
  11. import java.time.LocalDate;
  12. import java.util.Date;
  13. /**
  14. * 监控调阅定时任务
  15. *
  16. * @author xunmei
  17. */
  18. @Slf4j
  19. @Component("WeatherTask")
  20. public class WeatherTask {
  21. @Resource
  22. private RemoteWeatherTaskService remoteWeatherTaskService;
  23. /**
  24. * 每天定时获取天气预警数据
  25. */
  26. public void getDataFromApi()
  27. { String id = UUID.fastUUID().toString();
  28. log.info("开始执行获取天气预警数据的任务,当前任务 id:{},当前时间:{}", id, new Date());
  29. AjaxResult result = remoteWeatherTaskService.getDataFromApi( SecurityConstants.INNER);
  30. log.info("获取天气预警数据的任务执行结束,当前任务 id:{},当前时间:{},结果:{}", id, new Date(), JSON.toJSONString(result));
  31. }
  32. /**
  33. * 每天定时获取天气预警数据
  34. */
  35. public void getDataFromAliyun()
  36. { String id = UUID.fastUUID().toString();
  37. log.info("开始执行获取天气预警数据的任务,当前任务 id:{},当前时间:{}", id, new Date());
  38. AjaxResult result = remoteWeatherTaskService.getDataFromAliyun( SecurityConstants.INNER);
  39. log.info("获取天气预警数据的任务执行结束,当前任务 id:{},当前时间:{},结果:{}", id, new Date(), JSON.toJSONString(result));
  40. }
  41. }