From eb9668cfd9e05e06d6571eac389d7a4968354c14 Mon Sep 17 00:00:00 2001
From: 于紫祥_1901 <email@yuzixiang_1910>
Date: Tue, 10 Nov 2020 14:56:35 +0800
Subject: [PATCH] 标准公式显示
---
src/main/java/com/moral/service/impl/WeatherServiceImpl.java | 40 +++++++++++++++++++++++++++++++---------
1 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/src/main/java/com/moral/service/impl/WeatherServiceImpl.java b/src/main/java/com/moral/service/impl/WeatherServiceImpl.java
index a370f6e..2a64f27 100644
--- a/src/main/java/com/moral/service/impl/WeatherServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/WeatherServiceImpl.java
@@ -569,6 +569,7 @@
//������������
int x = 0;
+ parameters.put("cityCode", code);
List<Map<String, Object>> realList = realWeatherMapper.getRealWeather(parameters);
if (realList.size() == 0) {
//1-23���������������������������������������������������������������������
@@ -670,7 +671,7 @@
listMap.put("city", name);
String time1 = listMap.get("time").toString();
for (Map<String, Object> aqiMap : realAqilist) {
- if(time1.equals(aqiMap.get("time"))){
+ if (time1.equals(aqiMap.get("time"))) {
listMap.putAll(aqiMap);
}
}
@@ -797,20 +798,28 @@
if (rhour == nowHour) {
Map<String, Object> sumO3Map = hangzhouAqiMapper.getSumO3(hashMap);
- double v = value - Double.valueOf(sumO3Map.get("O3Sum").toString());
- resultMap.put("goodValue", v);
+ if (sumO3Map != null) {
+ double v = value - Double.valueOf(sumO3Map.get("O3Sum").toString());
+ resultMap.put("goodValue", v);
+ }
} else if (rhour == nowHour + 1) {
Map<String, Object> sumO3Map = hangzhouAqiMapper.getSumO3(hashMap);
- double v = (value - Double.valueOf(sumO3Map.get("O3Sum").toString())) / 2;
- resultMap.put("goodValue", String.valueOf(Math.round(v)));
+ if (sumO3Map != null) {
+ double v = (value - Double.valueOf(sumO3Map.get("O3Sum").toString())) / 2;
+ resultMap.put("goodValue", String.valueOf(Math.round(v)));
+ }
} else if (rhour == nowHour + 2) {
Map<String, Object> sumO3Map = hangzhouAqiMapper.getSumO3(hashMap);
- double v = (value - Double.valueOf(sumO3Map.get("O3Sum").toString())) / 3;
- resultMap.put("goodValue", String.valueOf(Math.round(v)));
+ if (sumO3Map != null) {
+ double v = (value - Double.valueOf(sumO3Map.get("O3Sum").toString())) / 3;
+ resultMap.put("goodValue", String.valueOf(Math.round(v)));
+ }
} else if (rhour == nowHour + 3) {
Map<String, Object> sumO3Map = hangzhouAqiMapper.getSumO3(hashMap);
- double v = (value - Double.valueOf(sumO3Map.get("O3Sum").toString())) / 4;
- resultMap.put("goodValue", String.valueOf(Math.round(v)));
+ if (sumO3Map != null) {
+ double v = (value - Double.valueOf(sumO3Map.get("O3Sum").toString())) / 4;
+ resultMap.put("goodValue", String.valueOf(Math.round(v)));
+ }
}
}
}
@@ -833,6 +842,19 @@
map.put("river", geographyMap.get("river").toString());
}
}
+ for (int i = 0; i < resultList.size(); i = i + 2) {
+ Map<String, Object> foreMap = resultList.get(i);
+ Map<String, Object> realMap = resultList.get(i + 1);
+ if (foreMap.get("O3C") != null && realMap.get("O3C") != null) {
+ Double foreO3 = Double.valueOf(foreMap.get("O3C").toString());
+ Double realO3 = Double.valueOf(realMap.get("O3C").toString());
+ int round = (int) Math.round((realO3 - foreO3) / realO3 * 100);
+ if (round < 0) {
+ round = -round;
+ }
+ realMap.put("errorRate", round + "%");
+ }
+ }
return resultList;
}
}
--
Gitblit v1.8.0