jinpengyong
2020-12-01 dc9091d686b412eab84d461d13d0611f79e65810
PM2.5,PM10预测
2 files modified
42 ■■■■■ changed files
src/main/java/com/moral/service/impl/WeatherServiceImpl.java 26 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/WeatherMapper.xml 16 ●●●● patch | view | raw | blame | history
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,23 +194,20 @@
                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("windDir", windDir);
                    pmSamples = getSample(hashMap1, years);
                    if (pmSamples.size() > 100) {
                        hashMap1.put("startPressure", pressure - 5);
@@ -214,6 +215,7 @@
                        pmSamples = getSample(hashMap1, years);
                    }
                }
                }
                hashMap1.put("slicedTime1", slicedTime1);
                hashMap1.put("slicedTime2", slicedTime2);
                Map<String, List<String>> sectionTimesMap1 = getSectionTimes(hashMap1, pmSamples, years);
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>