|
@@ -27,17 +27,20 @@ import java.util.Map;
|
|
|
public class CostServiceImpl extends ServiceImpl<CostMapper, Cost> implements CostService {
|
|
|
@Autowired
|
|
|
private CostMapper costMapper;
|
|
|
+ private static final String globalFarmCode = "14";
|
|
|
|
|
|
@Override
|
|
|
public Result getCostInYearAndMonth(Map<String, String> paramsMap) {
|
|
|
DateUtil dateUtil = new DateUtil();
|
|
|
String farmCode = paramsMap.get("farmCode");
|
|
|
+ if(farmCode == null){
|
|
|
+ farmCode = globalFarmCode;
|
|
|
+ }
|
|
|
QueryWrapper<Cost> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("farm_code",farmCode);
|
|
|
- queryWrapper.eq("year",dateUtil.getThisYear());
|
|
|
- queryWrapper.eq("month",dateUtil.getThisMonth());
|
|
|
+// queryWrapper.eq("year",dateUtil.getThisYear());
|
|
|
+// queryWrapper.eq("month",dateUtil.getThisMonth());
|
|
|
Cost cost = costMapper.selectOne(queryWrapper);
|
|
|
- System.out.println("cost="+cost);
|
|
|
if(cost == null){
|
|
|
cost = new Cost();
|
|
|
cost.setAllDrugCost(new BigDecimal(0));
|
|
@@ -55,4 +58,110 @@ public class CostServiceImpl extends ServiceImpl<CostMapper, Cost> implements Co
|
|
|
}
|
|
|
return new Result(ResultCode.SUCCESS,cost);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result save(Map<String, String> paramsMap) {
|
|
|
+ String farmCode = paramsMap.get("farmCode");
|
|
|
+ if(farmCode == null){
|
|
|
+ farmCode = globalFarmCode;
|
|
|
+ }
|
|
|
+// //allDrugCost
|
|
|
+// String allDrugCost = paramsMap.get("allDrugCost");
|
|
|
+// if(allDrugCost == null){
|
|
|
+// allDrugCost = "0";
|
|
|
+// }
|
|
|
+// //allFeedCost
|
|
|
+// String allFeedCost = paramsMap.get("allFeedCost");
|
|
|
+// if(allFeedCost == null){
|
|
|
+// allFeedCost = "0";
|
|
|
+// }
|
|
|
+// //allSharedCost
|
|
|
+// String allSharedCost = paramsMap.get("allSharedCost");
|
|
|
+// if(allSharedCost == null){
|
|
|
+// allSharedCost = "0";
|
|
|
+// }
|
|
|
+ //BoarDrugCost
|
|
|
+ String boarDrugCost = paramsMap.get("boarDrugCost");
|
|
|
+ if(boarDrugCost == null){
|
|
|
+ boarDrugCost = "0";
|
|
|
+ }
|
|
|
+ //BoarFeedCost
|
|
|
+ String boarFeedCost = paramsMap.get("boarFeedCost");
|
|
|
+ if(boarFeedCost == null){
|
|
|
+ boarFeedCost = "0";
|
|
|
+ }
|
|
|
+ //BoarSharedCost
|
|
|
+ String boarSharedCost = paramsMap.get("boarSharedCost");
|
|
|
+ if(boarSharedCost == null){
|
|
|
+ boarSharedCost = "0";
|
|
|
+ }
|
|
|
+ //SowDrugCost
|
|
|
+ String sowDrugCost = paramsMap.get("sowDrugCost");
|
|
|
+ if(sowDrugCost == null){
|
|
|
+ sowDrugCost = "0";
|
|
|
+ }
|
|
|
+ //SowFeedCost
|
|
|
+ String sowFeedCost = paramsMap.get("sowFeedCost");
|
|
|
+ if(sowFeedCost == null){
|
|
|
+ sowFeedCost = "0";
|
|
|
+ }
|
|
|
+ //SowSharedCost
|
|
|
+ String sowSharedCost = paramsMap.get("sowSharedCost");
|
|
|
+ if(sowSharedCost == null){
|
|
|
+ sowSharedCost = "0";
|
|
|
+ }
|
|
|
+ //FatpigDrugCost
|
|
|
+ String fatpigDrugCost = paramsMap.get("fatpigDrugCost");
|
|
|
+ if(fatpigDrugCost == null){
|
|
|
+ fatpigDrugCost = "0";
|
|
|
+ }
|
|
|
+ //FatpigFeedCost
|
|
|
+ String fatpigFeedCost = paramsMap.get("fatpigFeedCost");
|
|
|
+ if(fatpigFeedCost == null){
|
|
|
+ fatpigFeedCost = "0";
|
|
|
+ }
|
|
|
+ //FatpigSharedCost
|
|
|
+ String fatpigSharedCost = paramsMap.get("fatpigSharedCost");
|
|
|
+ if(fatpigSharedCost == null){
|
|
|
+ fatpigSharedCost = "0";
|
|
|
+ }
|
|
|
+ BigDecimal allSharedCostBd = new BigDecimal(boarSharedCost).add(new BigDecimal(sowSharedCost)).add(new BigDecimal(fatpigSharedCost));
|
|
|
+ BigDecimal allFeedCostBd = new BigDecimal(boarFeedCost).add(new BigDecimal(sowFeedCost)).add(new BigDecimal(fatpigFeedCost));
|
|
|
+ BigDecimal allDrugCostBd = new BigDecimal(boarDrugCost).add(new BigDecimal(sowDrugCost)).add(new BigDecimal(fatpigDrugCost));
|
|
|
+ QueryWrapper<Cost> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("farm_code",farmCode);
|
|
|
+ Cost cost = costMapper.selectOne(queryWrapper);
|
|
|
+ if(cost == null){
|
|
|
+ cost = new Cost();
|
|
|
+ cost.setAllSharedCost(allSharedCostBd);
|
|
|
+ cost.setAllFeedCost(allFeedCostBd);
|
|
|
+ cost.setAllDrugCost(allDrugCostBd);
|
|
|
+ cost.setBoarSharedCost(new BigDecimal(boarSharedCost));
|
|
|
+ cost.setBoarFeedCost(new BigDecimal(boarFeedCost));
|
|
|
+ cost.setBoarDrugCost(new BigDecimal(boarDrugCost));
|
|
|
+ cost.setSowSharedCost(new BigDecimal(sowSharedCost));
|
|
|
+ cost.setSowFeedCost(new BigDecimal(sowFeedCost));
|
|
|
+ cost.setSowDrugCost(new BigDecimal(sowDrugCost));
|
|
|
+ cost.setFatpigSharedCost(new BigDecimal(fatpigSharedCost));
|
|
|
+ cost.setFatpigFeedCost(new BigDecimal(fatpigFeedCost));
|
|
|
+ cost.setFatpigDrugCost(new BigDecimal(fatpigDrugCost));
|
|
|
+ cost.setFarmCode(farmCode);
|
|
|
+ costMapper.insert(cost);
|
|
|
+ }else{
|
|
|
+ cost.setAllSharedCost(allSharedCostBd);
|
|
|
+ cost.setAllFeedCost(allFeedCostBd);
|
|
|
+ cost.setAllDrugCost(allDrugCostBd);
|
|
|
+ cost.setBoarSharedCost(new BigDecimal(boarSharedCost));
|
|
|
+ cost.setBoarFeedCost(new BigDecimal(boarFeedCost));
|
|
|
+ cost.setBoarDrugCost(new BigDecimal(boarDrugCost));
|
|
|
+ cost.setSowSharedCost(new BigDecimal(sowSharedCost));
|
|
|
+ cost.setSowFeedCost(new BigDecimal(sowFeedCost));
|
|
|
+ cost.setSowDrugCost(new BigDecimal(sowDrugCost));
|
|
|
+ cost.setFatpigSharedCost(new BigDecimal(fatpigSharedCost));
|
|
|
+ cost.setFatpigFeedCost(new BigDecimal(fatpigFeedCost));
|
|
|
+ cost.setFatpigDrugCost(new BigDecimal(fatpigDrugCost));
|
|
|
+ costMapper.updateById(cost);
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }
|
|
|
}
|