智慧农业后台管理
guoshilong
2022-08-01 08afeadee3b2a73266a0a43c899f86cd474a274d
src/main/java/org/springblade/modules/sale/controller/SaleController.java
@@ -30,6 +30,7 @@
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.farmplant.service.FarmProductStockService;
import org.springblade.modules.process.service.IProcessService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -52,6 +53,7 @@
   private final ISaleService saleService;
   private final FarmProductStockService farmProductStockService;
   private final IProcessService processService;
   /**
    * 详情
@@ -123,6 +125,23 @@
      return R.status(saleService.saveOrUpdate(sale));
   }
   /**
    * 新增或修改 销售记录表(加工产品)
    */
   @PostMapping("/submitProcess")
   @ApiOperationSupport(order = 8)
   @ApiOperation(value = "新增或修改", notes = "传入sale")
   public R submitProcess(@Valid @RequestBody SaleVO sale) {
      //对比加工表库存量
      boolean res = processService.stockCompare(sale.getSaleNum(),sale.getProid());
      if (!res){
         throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("当前库存不足!"));
      }else {
         //库存充足,减去相应库存
         processService.stockReduce(sale.getSaleNum(),sale.getProid());
      }
      return R.status(saleService.saveOrUpdate(sale));
   }
   /**
    * 删除 销售记录表