| | |
| | | import com.moral.api.service.SysAreaService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.pojo.AQI; |
| | | import com.moral.util.AQIUtils; |
| | | import com.moral.util.AmendUtils; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | import com.moral.util.MathUtils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | Date date = (Date) forecastDatum.get("time"); |
| | | String value = forecastDatum.get("value").toString(); |
| | | Map<String, Object> data = JSONObject.parseObject(value, Map.class); |
| | | Object o3 = data.get("o3"); |
| | | Object o3 = data.get("O3"); |
| | | if (i == DateUtils.getHour(date) * 2) { |
| | | if (!ObjectUtils.isEmpty(o3)) { |
| | | map.put("O3", o3); |
| | |
| | | Date date = (Date) measuredDatum.get("time"); |
| | | String value = measuredDatum.get("value").toString(); |
| | | Map<String, Object> data = JSONObject.parseObject(value, Map.class); |
| | | Object o3 = data.get("o3"); |
| | | Object o3 = data.get("O3"); |
| | | if (i == (DateUtils.getHour(date) * 2 + 1)) { |
| | | if (!ObjectUtils.isEmpty(o3)) { |
| | | map.put("O3", o3); |
| | |
| | | if (value == null) |
| | | value = queryCityAqiByRegionCodeFromDB(regionCode); |
| | | //根据AQI计算污染等级 |
| | | if (value == null || value.get("aqi") == null) |
| | | if (value == null || value.get("AQI") == null) |
| | | return null; |
| | | Integer aqi = Integer.parseInt(value.get("aqi").toString()); |
| | | Integer aqi = Integer.parseInt(value.get("AQI").toString()); |
| | | String category = AQIUtils.classOfPollutionByAqi(aqi); |
| | | value.put("category", category); |
| | | return value; |
| | |
| | | continue; |
| | | } |
| | | Map<String, Object> allDataMap = JSON.parseObject(allDataJson, Map.class); |
| | | Object aqiData = allDataMap.get("aqi"); |
| | | Object aqiData = allDataMap.get("AQI"); |
| | | if (aqiData == null) |
| | | result.put(key, ""); |
| | | else |
| | |
| | | //计算平均数 |
| | | Map<String, Object> sixParamAvg = calculate6ParamAvg(cityAqis); |
| | | //计算累计aqi和首要污染物 |
| | | Map<String, Object> result = AQIUtils.hourlyAqi_pollutant(sixParamAvg); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | AQI aqi = AQIUtils.hourlyAQI(sixParamAvg); |
| | | result.put("aqi",aqi.getAQIValue()); |
| | | result.put("pollutant",aqi.getPrimaryPollutantNames()); |
| | | //结果集添加时间 |
| | | CityAqi lastCityAqi = cityAqis.get(cityAqis.size() - 1); |
| | | String time = DateUtils.dateToDateString(lastCityAqi.getTime(), "HH:mm"); |
| | |
| | | sortByField(ranks, "aqi"); |
| | | //日排名结果 |
| | | Map<String, Object> dayMap = rankByField(ranks, cityCode, "aqi", cityCodes.size()); |
| | | if (ObjectUtils.isEmpty(dayMap)) { |
| | | dayMap.put("rank", null); |
| | | dayMap.put("size", null); |
| | | } |
| | | dayMap.put("aqi", dayMap.remove("value")); |
| | | result.put("day", dayMap); |
| | | |
| | |
| | | sortByField(ranks, "compositeIndexMonth"); |
| | | //月排名结果 |
| | | Map<String, Object> monthMap = rankByField(ranks, cityCode, "compositeIndexMonth", cityCodes.size()); |
| | | if (ObjectUtils.isEmpty(monthMap)) { |
| | | monthMap.put("rank", null); |
| | | monthMap.put("size", null); |
| | | } |
| | | monthMap.put("compositeIndex", monthMap.remove("value")); |
| | | result.put("month", monthMap); |
| | | |
| | | |
| | | //年排名,按累计综指排 |
| | | sortByField(ranks, "compositeIndexYear"); |
| | | //年排名结果 |
| | | sortByField(ranks, "compositeIndexYear"); |
| | | Map<String, Object> yearMap = rankByField(ranks, cityCode, "compositeIndexYear", cityCodes.size()); |
| | | if (ObjectUtils.isEmpty(yearMap)) { |
| | | yearMap.put("rank", null); |
| | | yearMap.put("size", null); |
| | | } |
| | | yearMap.put("compositeIndex", yearMap.remove("value")); |
| | | result.put("year", yearMap); |
| | | |