From bc76e975aae3837eae625a2e3ffff7d02a5fc3f3 Mon Sep 17 00:00:00 2001
From: tangzy <tangzy123456>
Date: Mon, 13 Sep 2021 17:27:24 +0800
Subject: [PATCH] 1.山洪

---
 src/main/java/org/springblade/modules/regionWeight/controller/RegionWeightController.java |  174 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 171 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/springblade/modules/regionWeight/controller/RegionWeightController.java b/src/main/java/org/springblade/modules/regionWeight/controller/RegionWeightController.java
index 966dc23..b2cec61 100644
--- a/src/main/java/org/springblade/modules/regionWeight/controller/RegionWeightController.java
+++ b/src/main/java/org/springblade/modules/regionWeight/controller/RegionWeightController.java
@@ -300,8 +300,8 @@
 			});
 			//拼接前3位降雨最大的区域
 			double v3 = (double) Math.round(num * 10) / 10;
-			String text = "抚州市降雨:" + v3 + "(毫米)。 ";
-			String text1 = "前三降雨量的是: ";
+			String text = "全市日平均降雨量:" + v3 + "(毫米)。 ";
+			String text1 = "县市区平均降雨量前3位为: ";
 			String tx = "";
 			for (int i = 0; i < entryList2.size(); i++) {
 				Map mapa = new HashMap();
@@ -427,7 +427,7 @@
 		if (maps.size() == 0) {
 			a = yday + "暂无降雨信息。";
 		} else {
-			a = yday + "点降雨量前三为:" + text.substring(0, text.length() - 1) + "。";
+			a = yday + "站点最大降雨量前3位为:" + text.substring(0, text.length() - 1) + "。";
 		}
 		map.put("text", a);
 		lists.add(map);
@@ -896,5 +896,173 @@
 		return R.data(lists);
 	}
 
+	/**
+	 * 面降雨量
+	 */
+	@GetMapping("/selectReMs")
+	public R selectReMs(String beginTime, String endTime) {
+		String substring = beginTime.substring(0, 10);
+		String r = beginTime.substring(11, 13);
+		//截取月日
+		String[] strs = substring.split("-");
+		//月
+		String year = strs[1].toString();
+		//日
+		String day = strs[2].toString();
+		String substrings = endTime.substring(0, 10);
+		String rs = endTime.substring(11, 13);
+		//截取月日
+		String[] strss = substrings.split("-");
+		//月
+		String years = strss[1].toString();
+		//日
+		String days = strss[2].toString();
+		String yday = year + "月" + day + "日" + r + "时-" + years + "月" + days + "日" + rs + "时。";
+		String ss = regionWeightService.selectCodeM();
+		String[] split = ss.split(",");
+		String strArrays = "";
+		for (int i = 0; i < split.length; i++) {
+			strArrays += "'" + split[i] + "',";
+		}
+		String code = strArrays.substring(0, strArrays.length() - 1);
+		//List<Map<String, Object>> map = regionWeightService.selectReM(beginTime, endTime);
+		List<Map<String, Object>> map = regionWeightService.selectReMs(beginTime, endTime,code);
+		List<Map<String, Object>> mapAll = regionWeightService.selectAll();
+		//权重值
+		List<Map<String, Object>> list = regionWeightService.selectWeight();
+		Map map1 = new HashMap();
+		Map mapc = new HashMap();
+		List<Map<String, Object>> list1 = new ArrayList<Map<String, Object>>();
+		List<Map<String, Object>> lists = new ArrayList<Map<String, Object>>();
+		List<Map<String, Object>> listc = new ArrayList<Map<String, Object>>();
+		double v = 0;
+		//统计抚州市雨量
+		Double num = 0.0;
+		String region_code = null;
+		if (map.size() == 0) {
+			List<Map<String, Object>> l = new ArrayList<Map<String, Object>>();
+			List<Map<String, Object>> m = new ArrayList<Map<String, Object>>();
+			mapc.put("List", l);
+			mapc.put("Num", m);
+			mapc.put("text", yday + "暂无降雨信息。");
+			lists.add(mapc);
+		} else {
+			for (int i = 0; i < map.size(); i++) {
+				region_code = map.get(i).get("REGION_CODE").toString();
+				//获取行政区编码
+				if (i != 0) {
+					String region_code1 = map.get(i - 1).get("REGION_CODE").toString();
+					if (!region_code.equals(region_code1)) {
+						map1.put("id", region_code1);
+						map1.put("value", v);
+						list1.add(map1);
+						v = 0;
+						map1 = new HashMap();
+						for (int j = 0; j < list.size(); j++) {
+							if (region_code.equals(list.get(j).get("STATION_CODE").toString())) {
+								BigDecimal bigDecimaldrp = (BigDecimal) map.get(i).get("DRP");
+								double drp = bigDecimaldrp.floatValue();
+								String weight1 = map.get(i).get("WEIGHT").toString();
+								float weight = Float.parseFloat(weight1);
+								v += drp * weight;
+								break;
+							}
+						}
+					} else {
+						for (int j = 0; j < list.size(); j++) {
+							if (region_code.equals(list.get(j).get("STATION_CODE").toString())) {
+								BigDecimal bigDecimaldrp = (BigDecimal) map.get(i).get("DRP");
+								double drp = bigDecimaldrp.floatValue();
+								String weight1 = map.get(i).get("WEIGHT").toString();
+								float weight = Float.parseFloat(weight1);
+								System.out.println(Math.round(drp));
+								v += drp * weight;
+								break;
+							}
+						}
+					}
+				} else {
+					for (int j = 0; j < list.size(); j++) {
+						if (region_code.equals(list.get(j).get("STATION_CODE").toString())) {
+							BigDecimal bigDecimaldrp = (BigDecimal) map.get(i).get("DRP");
+							double drp = bigDecimaldrp.floatValue();
+							String weight1 = map.get(i).get("WEIGHT").toString();
+							float weight = Float.parseFloat(weight1);
+							System.out.println(Math.round(drp));
+							v += drp * weight;
+							break;
+						}
+					}
+				}
+			}
+			map1.put("id", region_code);
+			map1.put("value", v);
+			list1.add(map1);
+			Map<String, Object> result1 = new HashMap<String, Object>();
+			//县/区面雨量值
+			for (Map<String, Object> maps : list1) {
+				String id = maps.get("id").toString();
+				Double value = Double.parseDouble(maps.get("value").toString());
+				if (result1.containsKey(id)) {
+					Double temp = Double.parseDouble(result1.get(id).toString());
+					value += temp;
+				}
+				result1.put(id, value);
+			}
+			//计算市的面雨量
+			for (String k : result1.keySet()) {
+				for (int c = 0; c < list.size(); c++) {
+					if (k.equals(list.get(c).get("STATION_CODE").toString())) {
+						String s = result1.get(k).toString();
+						Double w = Double.parseDouble(s);
+						String weight = list.get(c).get("WEIGHT").toString();
+						Double weights = Double.parseDouble(weight);
+						double v1 = w * weights;
+						num += v1;
+					} else {
+						continue;
+					}
+
+				}
+			}
+			// 排序
+			List<Map.Entry<String, Object>> entryList2 = new ArrayList<Map.Entry<String, Object>>(result1.entrySet());
+			Collections.sort(entryList2, new Comparator<Map.Entry<String, Object>>() {
+				@Override
+				public int compare(Entry<String, Object> me1, Entry<String, Object> me2) {
+					return me2.getValue().toString().compareTo(me1.getValue().toString()); // 升序排序
+				}
+			});
+			//拼接前3位降雨最大的区域
+			double v3 = (double) Math.round(num * 10) / 10;
+			String text = "全市日平均降雨量:" + v3 + "(毫米)。 ";
+			String text1 = "县市区平均降雨量前3位为: ";
+			String tx = "";
+			for (int i = 0; i < entryList2.size(); i++) {
+				Map mapa = new HashMap();
+				String codes = entryList2.get(i).getKey();
+				String values = entryList2.get(i).getValue().toString();
+				Double a = Double.parseDouble(values);
+				double as = (double) Math.round(a * 10) / 10;
+				for (int j = 0; j < list.size(); j++) {
+					if (codes.equals(list.get(j).get("STATION_CODE").toString())) {
+						String station_name = list.get(j).get("STATION_NAME").toString();
+						mapa.put("region", station_name);
+						mapa.put("dyp", as);
+						listc.add(mapa);
+						if (i < 3) {
+							tx += station_name + "降雨量为:" + as + "(毫米),";
+						}
+					}
+
+				}
+			}
+			mapc.put("List", listc);
+			mapc.put("Num", mapAll);
+			mapc.put("text", yday + text);
+			lists.add(mapc);
+		}
+		return R.data(lists);
+	}
 
 }

--
Gitblit v1.9.3