智慧农业后台管理
guoshilong
2022-11-08 72b971c98c46531064d74b68fc8fe8864ed0b544
src/main/java/org/springblade/modules/lang/controller/LandController.java
@@ -30,6 +30,7 @@
import org.springblade.core.mp.support.Query;
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.farm.entity.Farm;
import org.springblade.modules.farm.vo.FarmVO;
import org.springblade.modules.resource.endpoint.OssEndpoint;
@@ -107,6 +108,23 @@
      IPage<LandVO> pages = landService.selectLandPage(Condition.getPage(query), land);
      return R.data(pages);
   }
   /**
    * 根据品种id查询对应地块(农产品库存)
    */
   @GetMapping("/selcetByStrainId")
   public R selcetByStrainId(String strainId,String farmId) {
      List<LandVO> list = landService.selectByStrainId(strainId,farmId);
      return R.data(list);
   }
   /**
    * 根据品种id查询对应地块(种养品种)
    */
   @GetMapping("/getByStrainIdFarmId")
   public R getByStrainIdFarmId(LandVO land) {
      List<Land> list = landService.getByStrainIdFarmId(land);
      return R.data(list);
   }
   /**
    * 新增 地块表
@@ -147,7 +165,9 @@
         } else {
            v1 = (double) Math.round(area * 100) / 100;
         }
         String myArea = land.getLandArea();
         land.setLandArea(String.valueOf(v1));
         land.setLandArea(myArea);
      } else {
         land.setLandArea("0");
      }
@@ -163,6 +183,8 @@
            e.printStackTrace();
         }
      }
      land.setType(1);
      return R.status(landService.saveLandInfo(land));
@@ -275,7 +297,15 @@
            e.printStackTrace();
         }
      }
      land.setLandArea(String.valueOf(v1));
      Land myLand = landService.getById(land.getId());
      if (myLand.getLandArea().equals(land.getLandArea())){
         land.setLandArea(String.valueOf(v1));
      }else {
         land.setLandArea(land.getLandArea());
      }
      return R.status(landService.updateLandById(land));
   }
@@ -297,7 +327,13 @@
   @ApiOperationSupport(order = 7)
   @ApiOperation(value = "逻辑删除", notes = "传入ids")
   public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
      return R.status(landService.deleteLogic(Func.toLongList(ids)));
      //先要判断该地块是否还有正在种植的作物,先结束才能删除地块
      List<LandVO> land= landService.findPlantInLand(ids);
      if (land.size()<=0) {
         return R.status(landService.deleteLogic(Func.toLongList(ids)));
      }else {
         throw new org.springblade.core.log.exception.ServiceException(StringUtil.format("请先结束该地块正在种养品种"));
      }
   }
   /**
@@ -308,6 +344,11 @@
      return R.data(landService.selectLandList(userid));
   }
   /**
    * 获取采收地块列表
    */
   @GetMapping("/selectRecoveryLandList")
   public R selectRecoveryLandList(String farmId){return R.data(landService.selectRecoveryLandList(farmId));}
   /**
    * 地块列表(不分页)
@@ -341,7 +382,7 @@
         if (unit.equals("0")) {
            num += area1;
         }
         if (unit.equals("1")) {
         else if (unit.equals("1")) {
            double v = area1 * 0.1;
            num += v;
         } else {
@@ -361,10 +402,10 @@
         if (unit.equals("0")) {
            snum += area1;
         }
         if (unit.equals("1")) {
         else if (unit.equals("1")) {
            double v = area1 * 0.1;
            snum += v;
         } else {
         } else{
            double v = area1 * 0.0015;
            snum += v;
         }
@@ -416,7 +457,7 @@
         if (unit.equals("0")) {
            num += area1;
         }
         if (unit.equals("1")) {
         else if (unit.equals("1")) {
            double v = area1 * 0.1;
            num += v;
         } else {
@@ -436,7 +477,7 @@
         if (unit.equals("0")) {
            snum += area1;
         }
         if (unit.equals("1")) {
         else if (unit.equals("1")) {
            double v = area1 * 0.1;
            snum += v;
         } else {
@@ -456,7 +497,7 @@
         if (unit.equals("0")) {
            wnum += area1;
         }
         if (unit.equals("1")) {
         else if (unit.equals("1")) {
            double v = area1 * 0.1;
            wnum += v;
         } else {
@@ -478,4 +519,14 @@
      return R.data(map);
   }
   /**
    * 查询统计地块是否有轮廓(是否有圈出区域)
    * @param land
    * @return
    */
   @GetMapping("/getLandIsAreaStatistic")
   public R getLandIsAreaStatistic(LandVO land){
      return R.data(landService.getLandIsAreaStatistic(land));
   }
}