From 2648880bec1583ce4fe1886de65300f0a22638d0 Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Mon, 26 Sep 2022 17:09:31 +0800
Subject: [PATCH] 更改种类描述的判断方式、溯源时地图详情sql调整、农资出库时删除数据回滚修复、大屏接受数据增加展示判断

---
 src/main/java/org/springblade/modules/farmplant/controller/FarmPlantController.java |  109 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 91 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/springblade/modules/farmplant/controller/FarmPlantController.java b/src/main/java/org/springblade/modules/farmplant/controller/FarmPlantController.java
index 31f80af..3dd4c46 100644
--- a/src/main/java/org/springblade/modules/farmplant/controller/FarmPlantController.java
+++ b/src/main/java/org/springblade/modules/farmplant/controller/FarmPlantController.java
@@ -33,10 +33,13 @@
 import org.springblade.core.tool.constant.BladeConstant;
 import org.springblade.core.tool.constant.RoleConstant;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.modules.farm.entity.FarmingRecord;
 import org.springblade.modules.farm.service.FarmingRecordService;
 import org.springblade.modules.farmplant.entity.FarmPlant;
+import org.springblade.modules.farmplant.entity.Strain;
 import org.springblade.modules.farmplant.service.FarmPlantService;
+import org.springblade.modules.farmplant.service.StrainService;
 import org.springblade.modules.farmplant.vo.FarmPlantVO;
 import org.springblade.modules.farmplant.vo.StrainVO;
 import org.springblade.modules.lang.entity.Land;
@@ -73,6 +76,8 @@
 
 	private final ILandService landService;
 
+	private final StrainService strainService;
+
 	/**
 	 * 详情
 	 */
@@ -106,6 +111,27 @@
 		return R.data(pages);
 	}
 
+	/**
+	 *首页当前种养产品总和
+	 */
+	@GetMapping("/strainCount")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入farmPlant")
+	public R<IPage<FarmPlantVO>> strainCount(FarmPlantVO farmPlant, Query query) {
+		IPage<FarmPlantVO> pages = farmplantService.selectFarmPlantPageCount(Condition.getPage(query), farmPlant);
+		return R.data(pages);
+	}
+
+	/**
+	 * 首页秧苗产品总和
+	 */
+	@GetMapping("/strainCountYM")
+	public R<IPage<FarmPlantVO>> strainCountYM(FarmPlantVO farmPlant, Query query) {
+		IPage<FarmPlantVO> pages = farmplantService.selectFarmPlantPageCountYM(Condition.getPage(query), farmPlant);
+		return R.data(pages);
+	}
+
+
 
 	/**
 	 * 查询种养记录列表(不分页)
@@ -115,6 +141,16 @@
 	@GetMapping("/getFarmPlantList")
 	public R getFarmPlantList(FarmPlantVO farmPlant) {
 		return R.data(farmplantService.getFarmPlantList(farmPlant));
+	}
+
+	/**
+	 * 查询种养记录列表(秧苗)(不分页)
+	 * @param farmPlant
+	 * @return
+	 */
+	@GetMapping("/getFarmPlantYMList")
+	public R getFarmPlantYMList(FarmPlantVO farmPlant) {
+		return R.data(farmplantService.getFarmPlantYMList(farmPlant));
 	}
 
 
@@ -168,6 +204,7 @@
 		farmPlant.setCreateTime(new Date());
 		boolean save = farmplantService.save(farmPlant);
 		if (save) {
+			Strain strain = strainService.getById(farmPlant.getStrainId());
 			//同时生成农事记录
 			FarmingRecord record = new FarmingRecord();
 			record.setCreateTime(new Date());
@@ -175,6 +212,7 @@
 			record.setTime(farmPlant.getTransplanTime());
 			record.setDeptId(farmPlant.getDeptId());
 			record.setTenantId(farmPlant.getTenantId());
+			record.setStrainId(farmPlant.getStrainId());
 			if (farmPlant.getPlantingWay().equals("0")) {
 				//移栽
 				record.setType("10");
@@ -183,9 +221,17 @@
 				//直播
 				record.setType("11");
 			}
+			if(farmPlant.getPlantingWay().equals("2")){
+				//秧苗
+				record.setType("13");
+			}
 			record.setLandId(farmPlant.getLandId());
 			record.setOperator(farmPlant.getCreateUser());
-			record.setContent("品种: " + farmPlant.getVarieties());
+			if (StringUtil.isBlank(farmPlant.getVarieties())){
+				record.setContent("品种: " + strain.getStrainName());
+			}else {
+				record.setContent("品种: " + strain.getStrainName()+"-"+farmPlant.getVarieties());
+			}
 			//新增
 			farmingRecordService.save(record);
 
@@ -230,6 +276,32 @@
 		}
 		//更新并返回
 		return R.status(status);
+	}
+
+	@PostMapping("/overAll")
+	public R overAll(@RequestBody FarmPlantVO farmPlantVO){
+		boolean status = false;
+		for (int i=0;i<farmPlantVO.getIds().length;i++){
+			FarmPlant farmPlant = new FarmPlant();
+			farmPlant.setId(farmPlantVO.getIds()[i]);
+			farmPlant.setEndPlantTime(farmPlantVO.getEndPlantTime());
+			farmPlant.setStatus("2");
+			status = farmplantService.updateById(farmPlant);
+			//判断该地块是否还有种植的农产品
+			FarmPlant farmPlant2 = farmplantService.getById(farmPlant.getId());
+			FarmPlant farmPlant1 = new FarmPlant();
+			farmPlant1.setLandId(farmPlant2.getLandId());
+			farmPlant1.setStatus("1");
+			List<FarmPlant> list = farmplantService.list(new QueryWrapper<>(farmPlant1));
+			if (list.size() < 1) {
+				//更新该地块的耕种状态
+				Land land = new Land();
+				land.setType(1);
+				land.setId(Long.parseLong(farmPlant2.getLandId()));
+				landService.updateById(land);
+			}
+		}
+		return R.data(status);
 	}
 
 	/**
@@ -389,24 +461,25 @@
 	 */
 	@GetMapping("/getFarmPlantStatisticsCountx")
 	public R getFarmPlantStatisticsCountx(FarmPlantVO farmPlant, Query query) {
-		Double num = 0.0;
+//		Double num = 0.0;
 		IPage<FarmPlantVO> pages = farmplantService.getFarmPlantStatisticsCountz(Condition.getPage(query), farmPlant);
-		for (int i = 0; i < pages.getRecords().size(); i++) {
-			String area = pages.getRecords().get(i).getArea();
-			Double a = Double.parseDouble(area);
-			DecimalFormat df = new DecimalFormat("#.00");
-			String format = df.format(a);
-			pages.getRecords().get(i).setArea(format);
-			num += a;
-		}
-		Map map = new HashMap();
-		List list = new ArrayList();
-		DecimalFormat df = new DecimalFormat("#.00");
-		String format = df.format(num);
-		map.put("znum", format);
-		list.add(map);
-		list.add(pages);
-		return R.data(list);
+//		for (int i = 0; i < pages.getRecords().size(); i++) {
+//			String area = pages.getRecords().get(i).getArea();
+//			Double a = Double.parseDouble(area);
+//			DecimalFormat df = new DecimalFormat("#.00");
+//			String format = df.format(a);
+//			pages.getRecords().get(i).setArea(format);
+//			num += a;
+//		}
+//		Map map = new HashMap();
+//		List list = new ArrayList();
+//		DecimalFormat df = new DecimalFormat("#.00");
+//		String format = df.format(num);
+//		map.put("znum", format);
+//		list.add(map);
+//		list.add(pages);
+//		return R.data(list);
+		return R.data(pages);
 	}
 
 

--
Gitblit v1.9.3