From cd7beee3c18d5875a556cb9da86d805ff2045618 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Thu, 01 Sep 2022 17:31:05 +0800
Subject: [PATCH] 大屏返回加工数据

---
 src/main/java/org/springblade/modules/lang/controller/LandController.java |   48 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/springblade/modules/lang/controller/LandController.java b/src/main/java/org/springblade/modules/lang/controller/LandController.java
index a68688b..75c8de4 100644
--- a/src/main/java/org/springblade/modules/lang/controller/LandController.java
+++ b/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;
@@ -106,6 +107,23 @@
 	public R<IPage<LandVO>> page(LandVO land, Query query) {
 		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);
 	}
 
 	/**
@@ -297,7 +315,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("请先结束该地块正在种养品种"));
+		}
 	}
 
 	/**
@@ -341,7 +365,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 +385,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 +440,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 +460,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 +480,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 +502,14 @@
 		return R.data(map);
 	}
 
+	/**
+	 * 查询统计地块是否有轮廓(是否有圈出区域)
+	 * @param land
+	 * @return
+	 */
+	@GetMapping("/getLandIsAreaStatistic")
+	public R getLandIsAreaStatistic(LandVO land){
+		return R.data(landService.getLandIsAreaStatistic(land));
+	}
+
 }

--
Gitblit v1.9.3