|
@@ -1,11 +1,19 @@
|
|
|
package com.huimv.cattle.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.huimv.cattle.pojo.Overview;
|
|
|
import com.huimv.cattle.mapper.OverviewMapper;
|
|
|
import com.huimv.cattle.service.OverviewService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.huimv.common.utils.Result;
|
|
|
+import com.huimv.common.utils.ResultCode;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 服务实现类
|
|
@@ -17,4 +25,55 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class OverviewServiceImpl extends ServiceImpl<OverviewMapper, Overview> implements OverviewService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OverviewMapper overviewMapper;
|
|
|
+ @Override
|
|
|
+ public Result overList(Map<String, String> paramsMap) {
|
|
|
+ Overview overview = overviewMapper.getOverList();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ if (ObjectUtil.isEmpty(overview)) {
|
|
|
+ jsonObject.put("stockCount", 0);
|
|
|
+ jsonObject.put("outCount", 0);
|
|
|
+ jsonObject.put("breedCount", 0);
|
|
|
+ jsonObject.put("farmCount", 0);
|
|
|
+ jsonObject.put("outputValue", 0);
|
|
|
+ jsonObject.put("variety", 0);
|
|
|
+ } else {
|
|
|
+ jsonObject.put("stockCount", overview.getStockCount());
|
|
|
+ jsonObject.put("outCount", overview.getOutCount());
|
|
|
+ jsonObject.put("breedCount", overview.getBreedCount());
|
|
|
+ jsonObject.put("farmCount", overview.getFarmCount());
|
|
|
+ jsonObject.put("outputValue", overview.getOutputValue());
|
|
|
+ jsonObject.put("variety", overview.getVariety());
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,jsonObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result add(Map<String, String> paramsMap) {
|
|
|
+ String id = paramsMap.get("id");
|
|
|
+ if (ObjectUtil.isEmpty(overviewMapper.selectById(id))) {
|
|
|
+ Overview overview = new Overview();
|
|
|
+ overview.setStockCount(Integer.parseInt(paramsMap.get("stockCount")));
|
|
|
+ overview.setOutCount(Integer.parseInt(paramsMap.get("outCount")));
|
|
|
+ overview.setBreedCount(Integer.parseInt(paramsMap.get("breedCount")));
|
|
|
+ overview.setFarmCount(Integer.parseInt(paramsMap.get("farmCount")));
|
|
|
+ BigDecimal bg = new BigDecimal(paramsMap.get("outputValue"));
|
|
|
+ overview.setOutputValue(bg);
|
|
|
+ overview.setVariety(paramsMap.get("variety"));
|
|
|
+ overviewMapper.insert(overview);
|
|
|
+ return new Result(ResultCode.SUCCESS,"添加成功");
|
|
|
+ } else {
|
|
|
+ Overview overview1 = overviewMapper.selectById(id);
|
|
|
+ overview1.setStockCount(Integer.parseInt(paramsMap.get("stockCount")));
|
|
|
+ overview1.setOutCount(Integer.parseInt(paramsMap.get("outCount")));
|
|
|
+ overview1.setBreedCount(Integer.parseInt(paramsMap.get("breedCount")));
|
|
|
+ overview1.setFarmCount(Integer.parseInt(paramsMap.get("farmCount")));
|
|
|
+ BigDecimal bg = new BigDecimal(paramsMap.get("outputValue"));
|
|
|
+ overview1.setOutputValue(bg);
|
|
|
+ overview1.setVariety(paramsMap.get("variety"));
|
|
|
+ overviewMapper.updateById(overview1);
|
|
|
+ return new Result(ResultCode.SUCCESS,"修改成功");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|