Browse Source

新增 获取虫情指定害虫预警功能

zhaiyifei 9 tháng trước cách đây
mục cha
commit
5709eaf030

+ 2 - 2
src/main/java/com/yunfeiyun/agmp/iots/warn/job/WarnJob.java

@@ -39,8 +39,8 @@ public class WarnJob {
     /**
      * 病虫害告警定时检查方法
      */
-    @Scheduled(cron = "* * * * * ?")
-//    @Scheduled(cron = "0 0/20 * * * ?")
+//    @Scheduled(cron = "* * * * * ?")
+    @Scheduled(cron = "0 0/20 * * * ?")
     public void pestWarnJob() {
         // 处理虫害
         warnService.processWarningPestData();

+ 5 - 1
src/main/java/com/yunfeiyun/agmp/iots/warn/service/WarnPestService.java

@@ -20,6 +20,7 @@ import com.yunfeiyun.agmp.iots.warn.util.WarnMessageBuilderUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -36,6 +37,9 @@ public class WarnPestService {
     @Autowired
     private IIotPestService iotPestService;
 
+    @Value("warn.cbdDateDiff:1")
+    private int cbdDateDiff;
+
     /**
      * 虫害处理入口
      */
@@ -104,7 +108,7 @@ public class WarnPestService {
     }
 
     String getDateBefore() {
-        return DateUtils.parseDateToStr("yyyy-MM-dd", DateUtils.addDays(new Date(), -1));
+        return DateUtils.parseDateToStr("yyyy-MM-dd", DateUtils.addDays(new Date(), -cbdDateDiff));
     }
 
     /**

+ 4 - 0
src/main/resources/application-dev.yml

@@ -277,3 +277,7 @@ map:
   gaode:
     api: http://restapi.amap.com
     key: 78ce288400f4fc6d9458989875c833c2
+
+#只允许在228机器上访问,其他环境不要配置
+warn:
+  cbdDateDiff: 0