智慧农业后台管理
guoshilong
2022-07-29 dfc08a87972e7418f926c1270e448dcca6084b20
src/main/java/org/springblade/modules/soldr/controller/SoldrController.java
@@ -147,6 +147,13 @@
   }
   /**
    * 退回
    * @param num 数量
    * @param id 农资id
    * @param type
    * @return
    */
   @PostMapping("/out")
   public R out(Integer num, Long id, Integer type) {
      //如果等于就修改并删除
@@ -164,6 +171,7 @@
      else {
         Soldr soldr = new Soldr();
         soldr.setSid(id);
         //通过农资库存id找到已出库农资表中对应的农资
         Soldr detail = soldrService.getOne(Condition.getQueryWrapper(soldr));
         Integer amount1 = detail.getAmount1();
         Double census = detail.getCensus();
@@ -175,34 +183,37 @@
            v = num * 0.001;
         }
         //斤
         if (specsValue1 == 1) {
         else if (specsValue1 == 1) {
            v = num * 0.5;
         }
         //公斤
         if (specsValue1 == 2) {
         else if (specsValue1 == 2) {
            v = num;
         }
         //吨
         if (specsValue1 == 3) {
         else if (specsValue1 == 3) {
            v = num * 1000;
         }
         //毫升
         if (specsValue1 == 4) {
         else if (specsValue1 == 4) {
            //毫升换成升
            double s = num * 0.001;
            //升换成公斤
            v = s;
         }
         //升
         if (specsValue1 == 5) {
         else{
            v = num;
         }
         //更新已出库农资的数据
         soldrecordService.updateSold(amount1 - num, id,census-v);
         Stock stock = new Stock();
         stock.setId(id);
         //根据传过来的sid获取对应的库存表数据
         Stock detail1 = stockService.getOne(Condition.getQueryWrapper(stock));
         Integer amount = detail1.getAmount();
         stock.setAmount(amount + num);
         //更新库存表
         stockService.Updaet(stock);
      }
      return R.success("退回成功");