|
@@ -6,10 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.huimv.guowei.admin.common.utils.DataUill;
|
|
|
import com.huimv.guowei.admin.common.utils.Result;
|
|
|
import com.huimv.guowei.admin.common.utils.ResultCode;
|
|
|
-import com.huimv.guowei.admin.entity.DuckHealthInfo;
|
|
|
-import com.huimv.guowei.admin.entity.EnvMoveCall;
|
|
|
-import com.huimv.guowei.admin.entity.EnvRegularCallEgg;
|
|
|
-import com.huimv.guowei.admin.entity.EnvRegularCallFeeding;
|
|
|
+import com.huimv.guowei.admin.entity.*;
|
|
|
import com.huimv.guowei.admin.mapper.EnvRegularCallFeedingMapper;
|
|
|
import com.huimv.guowei.admin.service.IEnvRegularCallFeedingService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -17,10 +14,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.Calendar;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -120,4 +119,64 @@ public class EnvRegularCallFeedingServiceImpl extends ServiceImpl<EnvRegularCall
|
|
|
return new Result(ResultCode.SUCCESS, feedingMapper.selectList(queryWrapper));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result getScrrenFeed(Map<String, String> paramsMap) {
|
|
|
+ String unitId = paramsMap.get("unitId");
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
+ Date timesmorning = DataUill.getTimesmorning();
|
|
|
+ Date timesMonthmorning = DataUill.getTimesMonthmorning();
|
|
|
+
|
|
|
+ Map resultMap = new HashMap();
|
|
|
+ //今日
|
|
|
+ QueryWrapper<EnvRegularCallFeeding> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.eq("d.unit_id",unitId).eq("f.farm_id",farmId).ge("f.call_date",timesmorning);
|
|
|
+ BigDecimal dayFeed = feedingMapper.getFeed(queryWrapper1);
|
|
|
+ //昨日
|
|
|
+ LocalDate yesterday = LocalDate.now().minusDays(1);
|
|
|
+ LocalDateTime startOfDay = yesterday.atStartOfDay();
|
|
|
+ LocalDateTime endOfDay = yesterday.atTime(LocalTime.MAX);
|
|
|
+ QueryWrapper<EnvRegularCallFeeding> queryWrapper2 = new QueryWrapper<>();
|
|
|
+ queryWrapper2.eq("d.unit_id",unitId).eq("f.farm_id",farmId).between("f.call_date",startOfDay,endOfDay);
|
|
|
+ BigDecimal lastDayFeed = feedingMapper.getFeed(queryWrapper2);
|
|
|
+ //日环比
|
|
|
+ BigDecimal dayGap = dayFeed.subtract(lastDayFeed).divide(lastDayFeed).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.UP);
|
|
|
+
|
|
|
+ //本月
|
|
|
+ QueryWrapper<EnvRegularCallFeeding> queryWrapper3 = new QueryWrapper<>();
|
|
|
+ queryWrapper3.eq("d.unit_id",unitId).eq("f.farm_id",farmId).ge("f.call_date",timesMonthmorning);
|
|
|
+ BigDecimal monthFeed = feedingMapper.getFeed(queryWrapper3);
|
|
|
+ //上月
|
|
|
+ Date lastMonthStartMorning = DataUill.getLastMonthStartMorning();
|
|
|
+ Date lastMonthEndNight = DataUill.getLastMonthEndNight();
|
|
|
+ QueryWrapper<EnvRegularCallFeeding> queryWrapper4 = new QueryWrapper<>();
|
|
|
+ queryWrapper4.eq("d.unit_id",unitId).eq("f.farm_id",farmId).between("f.call_date",lastMonthStartMorning,lastMonthEndNight);
|
|
|
+ BigDecimal lastMonthFeed = feedingMapper.getFeed(queryWrapper4);
|
|
|
+ //月环比
|
|
|
+ BigDecimal monthGap = monthFeed.subtract(lastMonthFeed).divide(lastMonthFeed).multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.UP);
|
|
|
+
|
|
|
+ resultMap.put("dayFeed",dayFeed);
|
|
|
+ resultMap.put("dayFeedGap",dayGap+"%");
|
|
|
+ resultMap.put("monthFeed",monthFeed);
|
|
|
+ resultMap.put("monthFeedGap",monthGap+"%");
|
|
|
+
|
|
|
+ return new Result(ResultCode.SUCCESS,resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result listScrrenFeed(Map<String, String> paramsMap) {
|
|
|
+ String unitId = paramsMap.get("unitId");
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
+ String type = paramsMap.get("type");
|
|
|
+ List<EnvRegularCallFeeding> envRegularCallFeedingList;
|
|
|
+ //六个月
|
|
|
+ if ("1".equals(type)){
|
|
|
+ envRegularCallFeedingList = feedingMapper.listSixMonthFeed(farmId, unitId);
|
|
|
+ }
|
|
|
+ //七天
|
|
|
+ else {
|
|
|
+ envRegularCallFeedingList = feedingMapper.listSevenDayFeed(farmId, unitId);
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,envRegularCallFeedingList);
|
|
|
+ }
|
|
|
+
|
|
|
}
|