|
@@ -9,9 +9,11 @@ import com.huimv.cattle.service.StockStatusService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.huimv.common.utils.Result;
|
|
import com.huimv.common.utils.Result;
|
|
import com.huimv.common.utils.ResultCode;
|
|
import com.huimv.common.utils.ResultCode;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -29,8 +31,12 @@ public class StockStatusServiceImpl extends ServiceImpl<StockStatusMapper, Stock
|
|
private StockStatusMapper stockStatusMapper;
|
|
private StockStatusMapper stockStatusMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Result getStockStatus() {
|
|
|
|
- StockStatus stockStatus = stockStatusMapper.getStockStatus();
|
|
|
|
|
|
+ public Result getStockStatus(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
|
+ String farmCode = request.getHeader("farmCode");
|
|
|
|
+ if (StringUtils.isBlank(farmCode)){
|
|
|
|
+ farmCode = paramsMap.get("farmCode");
|
|
|
|
+ }
|
|
|
|
+ StockStatus stockStatus = stockStatusMapper.getStockStatus(farmCode);
|
|
if (ObjectUtil.isEmpty(stockStatus)){
|
|
if (ObjectUtil.isEmpty(stockStatus)){
|
|
stockStatus = new StockStatus();
|
|
stockStatus = new StockStatus();
|
|
stockStatus.setBreedStock(0);
|
|
stockStatus.setBreedStock(0);
|
|
@@ -42,14 +48,27 @@ public class StockStatusServiceImpl extends ServiceImpl<StockStatusMapper, Stock
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Result saveStockStatus(StockStatus stockStatus) {
|
|
|
|
- if (ObjectUtil.isEmpty(stockStatusMapper.selectById(stockStatus))){
|
|
|
|
- StockStatus stockStatus1 = new StockStatus();
|
|
|
|
- stockStatus1.setBreedStock(stockStatus.getBreedStock());
|
|
|
|
- stockStatus1.setRaiseStock(stockStatus.getRaiseStock());
|
|
|
|
- stockStatus1.setCalfStock(stockStatus.getCalfStock());
|
|
|
|
|
|
+ public Result saveStockStatus(HttpServletRequest request, Map<String, String> paramsMap) {
|
|
|
|
+ String farmCode = request.getHeader("farmCode");
|
|
|
|
+ if (StringUtils.isBlank(farmCode)){
|
|
|
|
+ farmCode = paramsMap.get("farmCode");
|
|
|
|
+ }
|
|
|
|
+ String breedStock = paramsMap.get("breedStock");
|
|
|
|
+ String raiseStock = paramsMap.get("raiseStock");
|
|
|
|
+ String calfStock = paramsMap.get("calfStock");
|
|
|
|
+
|
|
|
|
+ StockStatus stockStatus1 = new StockStatus();
|
|
|
|
+ stockStatus1.setBreedStock(Integer.parseInt(breedStock));
|
|
|
|
+ stockStatus1.setRaiseStock(Integer.parseInt(raiseStock));
|
|
|
|
+ stockStatus1.setCalfStock(Integer.parseInt(calfStock));
|
|
|
|
+ stockStatus1.setFarmCode(farmCode);
|
|
|
|
+ StockStatus stockStatus = stockStatusMapper.selectOne(new QueryWrapper<StockStatus>().eq("farm_code", farmCode));
|
|
|
|
+ if (ObjectUtil.isEmpty(stockStatus)){
|
|
stockStatusMapper.insert(stockStatus1);
|
|
stockStatusMapper.insert(stockStatus1);
|
|
}else {
|
|
}else {
|
|
|
|
+ stockStatus.setBreedStock(Integer.parseInt(breedStock));
|
|
|
|
+ stockStatus.setCalfStock(Integer.parseInt(calfStock));
|
|
|
|
+ stockStatus.setRaiseStock(Integer.parseInt(raiseStock));
|
|
stockStatusMapper.updateById(stockStatus);
|
|
stockStatusMapper.updateById(stockStatus);
|
|
}
|
|
}
|
|
return new Result(ResultCode.SUCCESS);
|
|
return new Result(ResultCode.SUCCESS);
|