Browse Source

天气相关的定时任务新增执行条件

lvy 2 months ago
parent
commit
2b8c7ef1c8

+ 10 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/WeatherInfoServiceImpl.java

@@ -16,6 +16,7 @@ import org.springblade.business.entity.WeatherInfo;
 import org.springblade.business.mapper.WeatherInfoMapper;
 import org.springblade.business.service.WeatherInfoService;
 import org.springblade.common.utils.BaiduApiUtil;
+import org.springblade.common.utils.SystemUtils;
 import org.springblade.common.utils.YiKeYunApiUtils;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.tool.utils.DateUtil;
@@ -121,6 +122,9 @@ public class WeatherInfoServiceImpl extends ServiceImpl<WeatherInfoMapper, Weath
      */
     @Scheduled(cron = "0 18 10 * * ?")
     public void syncWeatherInfo() {
+        if (!SystemUtils.isLinux()) {
+            return;
+        }
         //获取所有合同段的定位信息
         List<ProjectContractArea> areaList = this.projectContractAreaClient.queryAllContractArea();
         Map<String, Map<String, String>> cachedWeatherMap = new HashMap<>();
@@ -176,6 +180,9 @@ public class WeatherInfoServiceImpl extends ServiceImpl<WeatherInfoMapper, Weath
      */
     @Scheduled(cron = "0 0 8 * * ?")
     public void syncHistoryWeatherInfo() {
+        if (!SystemUtils.isLinux()) {
+            return;
+        }
         //获取所有合同段的定位信息
         List<ProjectContractArea> areaList = this.projectContractAreaClient.queryAllContractArea();
 
@@ -290,6 +297,9 @@ public class WeatherInfoServiceImpl extends ServiceImpl<WeatherInfoMapper, Weath
     //去除重复天气,并填充每个合同段缺失的天气
     @Scheduled(cron = "0 0 9 * * ?")
     public void scanMissWeather(){
+        if (!SystemUtils.isLinux()) {
+            return;
+        }
         //获取所有项目的合同段
         List<ContractInfoVO> contractInfos = baseMapper.getAllContract();
         for (ContractInfoVO contract : contractInfos) {