kaiyu
2020-11-16 cd264145f9b4107f1430da46269dd306d26f3116
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);
                }
            }
@@ -826,19 +827,39 @@
        //地理特征
        Map<String, Object> geographyMap = shAreaMapper.getGeography(name);
        for (Map<String, Object> map : resultList) {
            double longitude = Double.valueOf(geographyMap.get("lng").toString());
            double latitude = Double.valueOf(geographyMap.get("lat").toString());
            map.put("longitude", df.format(longitude));
            map.put("latitude", df.format(latitude));
            if (geographyMap.get("altitude") != null) {
                map.put("altitude", geographyMap.get("altitude").toString());
        if (geographyMap != null) {
            for (Map<String, Object> map : resultList) {
                if (geographyMap.get("lng") != null) {
                    double longitude = Double.valueOf(geographyMap.get("lng").toString());
                    map.put("longitude", df.format(longitude));
                }
                if (geographyMap.get("lat") != null) {
                    double latitude = Double.valueOf(geographyMap.get("lat").toString());
                    map.put("latitude", df.format(latitude));
                }
                if (geographyMap.get("altitude") != null) {
                    map.put("altitude", geographyMap.get("altitude").toString());
                }
                if (geographyMap.get("vegetation") != null) {
                    map.put("vegetation", geographyMap.get("vegetation").toString());
                }
                if (geographyMap.get("river") != null) {
                    map.put("river", geographyMap.get("river").toString());
                }
            }
            if (geographyMap.get("vegetation") != null) {
                map.put("vegetation", geographyMap.get("vegetation").toString());
            }
            if (geographyMap.get("river") != null) {
                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;