Browse Source

产蛋定时器

Newspaper 1 year ago
parent
commit
c7845c7c6c

+ 21 - 21
huimv-farm-datacenter-egg/huimv-farm-environ/src/main/java/com/huimv/environ/eco/timer/LayEggTimer.java

@@ -28,27 +28,27 @@ public class LayEggTimer {
     @Autowired
     private FeedUsageMapper feedUsageMapper;
 
-//    @Scheduled(cron = "0 5 0 * * ?")
-////@Scheduled(cron = "0/10 * * * * ?")
-//    @Transactional
-//    public void saveLayEgg(){
-//        LocalDate localDate = LocalDate.now();
-//        LocalDate yesterday = localDate.minusDays(1);
-//        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
-//        String date = yesterday.format(formatter);
-//        Integer count = layEggMapper.selectCount(new QueryWrapper<LayEgg>().lambda().eq(LayEgg::getDate, date));
-//        if (count == 0){
-//            for (int i = 1; i <= 7; i++){
-//                LayEgg layEgg = new LayEgg();
-//                layEgg.setDate(date);
-//                layEgg.setUnitName(i+"舍");
-//                layEgg.setAvgWeight(BigDecimal.ZERO);
-//                layEgg.setEggProduction(0);
-//                layEgg.setTotalWeight(BigDecimal.ZERO);
-//                layEggMapper.insert(layEgg);
-//            }
-//        }
-//    }
+    @Scheduled(cron = "0 5 0 * * ?")
+//@Scheduled(cron = "0/10 * * * * ?")
+    @Transactional
+    public void saveLayEgg(){
+        LocalDate localDate = LocalDate.now();
+        LocalDate yesterday = localDate.minusDays(1);
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
+        String date = yesterday.format(formatter);
+        Integer count = layEggMapper.selectCount(new QueryWrapper<LayEgg>().lambda().eq(LayEgg::getDate, date));
+        if (count == 0){
+            for (int i = 1; i <= 7; i++){
+                LayEgg layEgg = new LayEgg();
+                layEgg.setDate(date);
+                layEgg.setUnitName(i+"舍");
+                layEgg.setAvgWeight(BigDecimal.ZERO);
+                layEgg.setEggProduction(0);
+                layEgg.setTotalWeight(BigDecimal.ZERO);
+                layEggMapper.insert(layEgg);
+            }
+        }
+    }
 //
 //    @Scheduled(cron = "0 10 0 * * ?")
 ////    @Scheduled(cron = "0/10 * * * * ?")