智慧农业后台管理
guoshilong
2022-08-01 08afeadee3b2a73266a0a43c899f86cd474a274d
src/main/java/org/springblade/modules/InventoryLoss/controller/InventoryController.java
@@ -32,6 +32,7 @@
import org.springblade.modules.InventoryLoss.entity.Inventory;
import org.springblade.modules.InventoryLoss.service.InventoryService;
import org.springblade.modules.InventoryLoss.vo.InventoryVO;
import org.springblade.modules.process.service.IProcessService;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
@@ -50,6 +51,7 @@
   private final InventoryService inventoryService;
   private final FarmProductStockService farmProductStockService;
   private final IProcessService processService;
   /**
    * 详情
@@ -121,6 +123,22 @@
      return R.status(inventoryService.saveOrUpdate(inventory));
   }
   /**
    * 新增或修改 库存损耗记录表
    */
   @PostMapping("/submitProcess")
   @ApiOperationSupport(order = 8)
   @ApiOperation(value = "新增或修改", notes = "传入sale")
   public R submitProcess(@Valid @RequestBody InventoryVO inventory) {
      boolean res = processService.stockCompare(inventory.getSaleNum(),inventory.getProid());
      if (!res){
         throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!"));
      }else {
         //库存充足,减去相应库存
         processService.stockReduce(inventory.getSaleNum(),inventory.getProid());
      }
      return R.status(inventoryService.saveOrUpdate(inventory));
   }
   /**
    * 删除 库存损耗记录表