瀏覽代碼

饲料消耗查询

yjj 2 年之前
父節點
當前提交
092d4599fc

+ 9 - 5
huimv-env-platform/huimv-env-produce/src/main/java/com/huimv/env/produce/service/impl/FeedDayServiceImpl.java

@@ -63,8 +63,10 @@ public class FeedDayServiceImpl extends ServiceImpl<FeedDayMapper, FeedDay> impl
             if (feedDays.size() < 2) {
                 todayRatioBd = BigDecimal.ZERO;
             }
-            BigDecimal yesterdayCountBd = feedDays.get(1).getConsumption();
-            todayRatioBd = (todayCountBd.subtract(yesterdayCountBd)).divide(yesterdayCountBd);
+            if (feedDays.size()>=2) {
+                BigDecimal yesterdayCountBd = feedDays.get(1).getConsumption();
+                todayRatioBd = (todayCountBd.subtract(yesterdayCountBd)).divide(yesterdayCountBd);
+            }
         } else {
             todayCountBd = BigDecimal.ZERO;
             todayRatioBd = BigDecimal.ZERO;
@@ -79,11 +81,13 @@ public class FeedDayServiceImpl extends ServiceImpl<FeedDayMapper, FeedDay> impl
         List<FeedMonth> feedMonths = feedMonthMapper.selectList(queryWrapper1);
         if (!feedMonths.isEmpty()) {
             thisMonthCountBd = feedMonths.get(0).getConsumption();
-            if (feedDays.size() < 2) {
+            if (feedMonths.size() < 2) {
                 thisMonthRatioBd = BigDecimal.ZERO;
             }
-            BigDecimal LastMonthCountBd = feedDays.get(1).getConsumption();
-            thisMonthRatioBd = (thisMonthRatioBd.subtract(LastMonthCountBd)).divide(LastMonthCountBd);
+            if (feedMonths.size()>=2) {
+                BigDecimal LastMonthCountBd = feedMonths.get(1).getConsumption();
+                thisMonthRatioBd = (thisMonthCountBd.subtract(LastMonthCountBd)).divide(LastMonthCountBd);
+            }
         } else {
             thisMonthCountBd = BigDecimal.ZERO;
             thisMonthRatioBd = BigDecimal.ZERO;