From d18eb5bd8b9cf93ba7adb4ee97fdcaccd3838e79 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Wed, 24 Aug 2022 10:36:10 +0800
Subject: [PATCH] 删除回滚完善,销售损耗添加字段type、prodId、地块选择数据返回增加库存量和面积

---
 src/main/java/org/springblade/modules/lang/controller/LandController.java |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 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 2261a08..f140855 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;
@@ -112,7 +113,7 @@
 	 */
 	@GetMapping("/selcetByStrainId")
 	public R selcetByStrainId(String strainId,String farmId) {
-		List<Land> list = landService.selectByStrainId(strainId,farmId);
+		List<LandVO> list = landService.selectByStrainId(strainId,farmId);
 		return R.data(list);
 	}
 
@@ -314,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("请先结束该地块正在种养品种"));
+		}
 	}
 
 	/**
@@ -358,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 {
@@ -378,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;
 			}

--
Gitblit v1.9.3