From dc9091d686b412eab84d461d13d0611f79e65810 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Tue, 01 Dec 2020 16:18:09 +0800
Subject: [PATCH] PM2.5,PM10预测
---
src/main/resources/mapper/WeatherMapper.xml | 16 ++++------------
src/main/java/com/moral/service/impl/WeatherServiceImpl.java | 30 ++++++++++++++++--------------
2 files changed, 20 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/moral/service/impl/WeatherServiceImpl.java b/src/main/java/com/moral/service/impl/WeatherServiceImpl.java
index 36e1d0d..9fdd356 100644
--- a/src/main/java/com/moral/service/impl/WeatherServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/WeatherServiceImpl.java
@@ -133,8 +133,12 @@
hashMap.put("end", end);
hashMap.put("typeFormat", "%Y-%m-%d %H:%i:%s");
int condition = Integer.parseInt(nextDayMap.get("condition").toString());
- double temp = Double.parseDouble(nextDayMap.get("temp").toString());
+ int temp = Integer.parseInt(nextDayMap.get("temp").toString());
int pressure = Integer.parseInt(nextDayMap.get("pressure").toString());
+ //���������������������
+ String windDir = nextDayMap.get("windDir").toString();
+ //������
+ String windScale = nextDayMap.get("windScale").toString();
String time = nextDayMap.remove("time").toString();
//������������
hours.add(time.substring(11, 13));
@@ -162,8 +166,8 @@
Collections.addAll(years, timeUnits1, timeUnits2, timeUnits3, timeUnits4);
List<String> O3Samples = getSample(hashMap, years);
if (O3Samples.size() > 100) {
- hashMap.put("startTemp", temp - 1.0);
- hashMap.put("endTemp", temp + 1.0);
+ hashMap.put("startTemp", temp - 1);
+ hashMap.put("endTemp", temp + 1);
O3Samples = getSample(hashMap, years);
if (O3Samples.size() > 100) {
hashMap.put("startPressure", pressure - 5);
@@ -190,28 +194,26 @@
Double O3Avg3 = getAvg(params, times3);
Double resultO3 = O3Avg1 * 0.7 + O3Avg2 * 0.15 + O3Avg3 * 0.15;
nextDayMap.put("O3C", String.valueOf(Math.round(resultO3)));
- //pm2.5,pm10���������������
- //������,pm2.5,pm10������������������
- String month = time.substring(5, 7);
- //���������������������
- String windDir = nextDayMap.get("windDir").toString();
- //������
- String windScale = nextDayMap.get("windScale").toString();
+ //pm2.5,pm10���������������,������������������������������
Map<String, Object> hashMap1 = new HashMap<>();
hashMap1.put("cityCode", cityCode);
hashMap1.put("start", start);
hashMap1.put("end", end);
hashMap1.put("typeFormat", "%Y-%m-%d %H:%i:%s");
- hashMap1.put("month", month);
+ hashMap1.put("startTemp", temp - 1);
+ hashMap1.put("endTemp", temp + 1);
List<String> pmSamples = getSample(hashMap1, years);
if (pmSamples.size() > 100) {
- hashMap1.put("windDir", windDir);
hashMap1.put("windScale", windScale);
pmSamples = getSample(hashMap1, years);
if (pmSamples.size() > 100) {
- hashMap1.put("startPressure", pressure - 5);
- hashMap1.put("endPressure", pressure + 5);
+ hashMap1.put("windDir", windDir);
pmSamples = getSample(hashMap1, years);
+ if (pmSamples.size() > 100) {
+ hashMap1.put("startPressure", pressure - 5);
+ hashMap1.put("endPressure", pressure + 5);
+ pmSamples = getSample(hashMap1, years);
+ }
}
}
hashMap1.put("slicedTime1", slicedTime1);
diff --git a/src/main/resources/mapper/WeatherMapper.xml b/src/main/resources/mapper/WeatherMapper.xml
index 51d8c73..9dda41b 100644
--- a/src/main/resources/mapper/WeatherMapper.xml
+++ b/src/main/resources/mapper/WeatherMapper.xml
@@ -138,11 +138,11 @@
</if>
<if test="startTemp != null">
- and cast(value->'$.temp' as decimal(10, 1)) >= #{startTemp}
+ and cast(value->'$.temp' as decimal(10, 0)) >= #{startTemp}
</if>
<if test="endTemp != null">
- and cast(value->'$.temp' as decimal(10, 1)) <![CDATA[<=]]> #{endTemp}
+ and cast(value->'$.temp' as decimal(10, 0)) <![CDATA[<=]]> #{endTemp}
</if>
<if test="startPressure != null">
@@ -166,10 +166,6 @@
<foreach collection="hours" open="(" separator="," close=")" item="hour">
#{hour}
</foreach>
- </if>
-
- <if test="month != null">
- and DATE_FORMAT(time, '%m') = #{month}
</if>
</where>
</select>
@@ -197,11 +193,11 @@
</if>
<if test="startTemp != null">
- and cast(json->'$.temp' as decimal(10, 1)) >= #{startTemp}
+ and cast(json->'$.temp' as decimal(10, 0)) >= #{startTemp}
</if>
<if test="endTemp != null">
- and cast(json->'$.temp' as decimal(10, 1)) <![CDATA[<=]]> #{endTemp}
+ and cast(json->'$.temp' as decimal(10, 0)) <![CDATA[<=]]> #{endTemp}
</if>
<if test="startPressure != null">
@@ -225,10 +221,6 @@
<foreach collection="hours" open="(" separator="," close=")" item="hour">
#{hour}
</foreach>
- </if>
-
- <if test="month != null">
- and DATE_FORMAT(time, '%m') = #{month}
</if>
</where>
</select>
--
Gitblit v1.8.0