智慧农业后台管理
src/main/java/org/springblade/modules/sale/controller/SaleController.java
@@ -29,6 +29,7 @@
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.InventoryLoss.entity.Inventory;
import org.springblade.modules.farmplant.entity.FarmProductStock;
import org.springblade.modules.farmplant.service.FarmProductStockService;
import org.springblade.modules.process.service.IProcessService;
@@ -129,6 +130,7 @@
         //库存充足,减去相应库存
         farmProductStockService.stockReduce(sale.getSaleNum(),sale.getProid());
      }
      sale.setProdId(sale.getProid());
      return R.status(saleService.saveOrUpdate(sale));
   }
@@ -164,6 +166,7 @@
         sale.setLandId(processInvVO.getLandId());
         processInvService.updateById(processInv);
      }
      sale.setProdId(sale.getProid());
      return R.status(saleService.saveOrUpdate(sale));
   }
@@ -175,10 +178,17 @@
   @ApiOperation(value = "逻辑删除", notes = "传入ids")
   public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
      Sale sale = saleService.getById(Long.parseLong(ids));
      FarmProductStock farmProductStock = farmProductStockService.selectBy2Id(sale.getStrainId(), sale.getLandId());
      Double weight = Double.parseDouble(farmProductStock.getWeight())+sale.getSaleNum();
      farmProductStock.setWeight(weight.toString());
      farmProductStockService.updateById(farmProductStock);
      if (sale.getType() == 0){
         FarmProductStock farmProductStock = farmProductStockService.getById(sale.getProdId());
         Double weight = Double.parseDouble(farmProductStock.getWeight())+sale.getSaleNum();
         farmProductStock.setWeight(weight.toString());
         farmProductStockService.updateById(farmProductStock);
      }else {
         ProcessInv inv = processInvService.findById(sale.getProdId());
         Double weight = inv.getProductInventoryNum()+sale.getSaleNum();
         inv.setProductInventoryNum(weight);
         processInvService.updateById(inv);
      }
      return R.status(saleService.deleteLogic(Func.toLongList(ids)));
   }