|
@@ -1,11 +1,21 @@
|
|
|
package com.huimv.env.produce.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.huimv.common.utils.Result;
|
|
|
+import com.huimv.common.utils.ResultCode;
|
|
|
import com.huimv.env.produce.entity.FeedDay;
|
|
|
import com.huimv.env.produce.mapper.FeedDayMapper;
|
|
|
+import com.huimv.env.produce.mapper.FeedMonthMapper;
|
|
|
import com.huimv.env.produce.service.FeedDayService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 服务实现类
|
|
@@ -16,5 +26,56 @@ import org.springframework.stereotype.Service;
|
|
|
*/
|
|
|
@Service
|
|
|
public class FeedDayServiceImpl extends ServiceImpl<FeedDayMapper, FeedDay> implements FeedDayService {
|
|
|
+ @Autowired
|
|
|
+ private FeedDayMapper feedDayMapper;
|
|
|
+ @Autowired
|
|
|
+ private FeedMonthMapper feedMonthMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getFeedCount(Map<String, String> paramsMap) {
|
|
|
+ JSONObject resultJo = new JSONObject();
|
|
|
+ //计算今日消耗量、环比
|
|
|
+ BigDecimal todayCountBd = new BigDecimal(0);
|
|
|
+ BigDecimal todayRatioBd = new BigDecimal(0);
|
|
|
+ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 这里写代码计算今日消耗量、环比
|
|
|
+
|
|
|
+ //计算本月消耗量、环比
|
|
|
+ BigDecimal thisMonthCountBd = new BigDecimal(0);
|
|
|
+ BigDecimal thisMonthRatioBd = new BigDecimal(0);
|
|
|
+ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 这里写代码计算本月消耗量、环比
|
|
|
+
|
|
|
+ //计算历史记录
|
|
|
+ List<Map<String,Object>> consumptionList = _getFeedHistoryConsumption(paramsMap);
|
|
|
+
|
|
|
+ //今日消耗量
|
|
|
+ resultJo.put("todayCount",todayCountBd.toString());
|
|
|
+ //今日环比
|
|
|
+ resultJo.put("todayRatio",todayRatioBd.toString());
|
|
|
+ //本月消耗量
|
|
|
+ resultJo.put("thisMonthCount",thisMonthCountBd.toString());
|
|
|
+ //本月环比
|
|
|
+ resultJo.put("thisMonthRatio",thisMonthRatioBd.toString());
|
|
|
+ //每月消耗记录
|
|
|
+ resultJo.put("consumptionList",consumptionList);
|
|
|
+ return new Result(ResultCode.SUCCESS,resultJo);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<Map<String, Object>> _getFeedHistoryConsumption(Map<String, String> paramsMap) {
|
|
|
+ String months = paramsMap.get("months");
|
|
|
+ String days = paramsMap.get("days");
|
|
|
+
|
|
|
+ List<Map<String, Object>> consumptionList = new ArrayList<>();
|
|
|
+ if(months == null && days != null){
|
|
|
+ //读取N天历史记录,以正序返回
|
|
|
+ //+++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
+
|
|
|
+
|
|
|
+ }else if(months != null && days == null){
|
|
|
+ //读取N月历史记录,以正序返回
|
|
|
+ //+++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
+
|
|
|
|
|
|
+ }
|
|
|
+ return consumptionList;
|
|
|
+ }
|
|
|
}
|