From 1bd9b7f5767b2f1dce2b63b4c9174f457e5775bc Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Thu, 19 May 2022 15:55:58 +0800
Subject: [PATCH] 首页地块统计
---
src/main/java/org/springblade/modules/lang/controller/LandController.java | 69 ++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 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 8be108d..4df3c4e 100644
--- a/src/main/java/org/springblade/modules/lang/controller/LandController.java
+++ b/src/main/java/org/springblade/modules/lang/controller/LandController.java
@@ -43,7 +43,9 @@
import java.awt.geom.Point2D;
import java.text.DecimalFormat;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* 地块表 控制器
@@ -218,4 +220,71 @@
return R.data(landService.selectLandList(userid));
}
+
+ /**
+ * 首页地块统计接口
+ */
+ @GetMapping("/selectCount")
+ public R selectCount() {
+ List<Map<String, Object>> list = landService.selectZAre();
+ List<Map<String, Object>> lists = landService.selectSAre();
+ List list1 = landService.selectNum();
+ //总面积
+ Double num=0.0;
+ for (int i=0;i<list.size();i++){
+ //面积
+ String area = list.get(i).get("area").toString();
+ //单位
+ String unit = list.get(i).get("unit").toString();
+ Double area1=Double.parseDouble(area);
+ //面积单位(0: 亩 1:分 2:平方米)
+ if (unit.equals("0")){
+ num+=area1;
+ }
+ if (unit.equals("1")){
+ double v = area1 * 0.1;
+ num+=v;
+ }
+ else {
+ double v = area1 *0.0015;
+ num+=v;
+ }
+ }
+ //使用面积
+ Double snum=0.0;
+ for (int i=0;i<lists.size();i++){
+ //面积
+ String area = lists.get(i).get("area").toString();
+ //单位
+ String unit = lists.get(i).get("unit").toString();
+ Double area1=Double.parseDouble(area);
+ //面积单位(0: 亩 1:分 2:平方米)
+ if (unit.equals("0")){
+ snum+=area1;
+ }
+ if (unit.equals("1")){
+ double v = area1 * 0.1;
+ snum+=v;
+ }
+ else {
+ double v = area1 *0.0015;
+ snum+=v;
+ }
+ }
+ //品种数量
+ int size = list1.size();
+ //地块使用率
+ double v = snum / num;
+ double v1 = v * 100;
+ DecimalFormat df = new DecimalFormat("#0.00");
+ String format = df.format(v1);
+ Double a=Double.parseDouble(format);
+ Map map =new HashMap();
+ map.put("rate",a);
+ map.put("zarea",(double) Math.round(num * 100) / 100);
+ map.put("sarea",(double) Math.round(snum * 100) / 100);
+ map.put("num",size);
+ return R.data(map);
+ }
+
}
--
Gitblit v1.9.3