From 72b971c98c46531064d74b68fc8fe8864ed0b544 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Tue, 08 Nov 2022 09:04:56 +0800
Subject: [PATCH] 大屏溯源统计次数sql修改

---
 src/main/java/org/springblade/modules/farm/controller/FarmController.java |   68 ++++++++++++++++++++++++++++++++-
 1 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/springblade/modules/farm/controller/FarmController.java b/src/main/java/org/springblade/modules/farm/controller/FarmController.java
index 09f2abb..d2fb1eb 100644
--- a/src/main/java/org/springblade/modules/farm/controller/FarmController.java
+++ b/src/main/java/org/springblade/modules/farm/controller/FarmController.java
@@ -24,18 +24,26 @@
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.BladeUser;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.farm.entity.Farm;
 import org.springblade.modules.farm.service.FarmService;
 import org.springblade.modules.farm.vo.FarmVO;
+import org.springblade.modules.system.vo.RoleVO;
 import org.springframework.web.bind.annotation.*;
+
 import javax.validation.Valid;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 农场控制器
- * @since 2022-05-10
+ *
  * @author zhongrj
+ * @since 2022-05-10
  */
 @RestController
 @AllArgsConstructor
@@ -52,6 +60,15 @@
 	@ApiOperation(value = "详情", notes = "传入farm")
 	public R<Farm> detail(Farm farm) {
 		Farm detail = farmService.getOne(Condition.getQueryWrapper(farm));
+		return R.data(detail);
+	}
+
+	/**
+	 * 详情信息(自定义查询)
+	 */
+	@GetMapping("/details")
+	public R<Farm> details(FarmVO farm) {
+		Farm detail = farmService.getFarmInfo(farm);
 		return R.data(detail);
 	}
 
@@ -78,13 +95,34 @@
 	}
 
 	/**
+	 * 自定义查询所有农场信息(不分页)
+	 * @param farm
+	 * @return
+	 */
+	@GetMapping("/getFarmList")
+	public R<List<FarmVO>> getFarmList(FarmVO farm) {
+		List<FarmVO> farmList = farmService.getFarmList(farm);
+		return R.data(farmList);
+	}
+
+	/**
 	 * 新增
 	 */
 	@PostMapping("/save")
 	@ApiOperationSupport(order = 4)
 	@ApiOperation(value = "新增", notes = "传入farm")
 	public R save(@Valid @RequestBody Farm farm) {
-		return R.status(farmService.save(farm));
+		farm.setCreateTime(new Date());
+		farm.setUpdateTime(new Date());
+		//坐标转换
+		if (null != farm.getPosition() && !farm.getPosition().equals("")) {
+			//替换逗号为空格
+			String sNull = farm.getPosition().replaceAll(",", " ");
+			//替换分号为逗号
+			String replaceAll = sNull.replaceAll(";", ",");
+			farm.setPosition("'POLYGON((" + replaceAll + "))'");
+		}
+		return R.status(farmService.saveFarmInfo(farm));
 	}
 
 	/**
@@ -94,7 +132,17 @@
 	@ApiOperationSupport(order = 5)
 	@ApiOperation(value = "修改", notes = "传入farm")
 	public R update(@Valid @RequestBody Farm farm) {
-		return R.status(farmService.updateById(farm));
+		farm.setUpdateTime(new Date());
+		//坐标转换
+//		if (null != farm.getPosition() && !farm.getPosition().equals("")) {
+//			//替换逗号为空格
+//			String sNull = farm.getPosition().replaceAll(",", " ");
+//			//替换分号为逗号
+//			String replaceAll = sNull.replaceAll(";", ",");
+//			farm.setPosition("'POLYGON((" + replaceAll + "))'");
+//		}
+		//更新并返回
+		return R.status(farmService.updateFarmById(farm));
 	}
 
 	/**
@@ -118,4 +166,18 @@
 		return R.status(farmService.removeByIds(Func.toLongList(ids)));
 	}
 
+	/**
+	 * 大屏农场数量与人员数量
+	 */
+	@GetMapping("/SelectCount")
+	public R SelectCount() {
+		//农场数量
+		Integer integer = farmService.selectCountFarm();
+		//人员数量
+		Integer integer1 = farmService.selectCountUser();
+		Map map = new HashMap<>();
+		map.put("ncnum", integer);
+		map.put("rynum", integer1);
+		return R.data(map);
+	}
 }

--
Gitblit v1.9.3