| | |
| | | import com.moral.api.service.CityConfigService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.RedisConstants; |
| | | import com.moral.util.AQIUtils; |
| | | import com.moral.util.AmendUtils; |
| | | import com.moral.util.ComprehensiveIndexUtils; |
| | | import com.moral.util.DateUtils; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | aqi.put("co", aqi.remove("coC")); |
| | | aqi.put("o3", aqi.remove("o3C")); |
| | | aqi.put("aqi", aqi.remove("value")); |
| | | |
| | | //o3滑动值计算 |
| | | //获取一天内每个小时o3数据 |
| | | QueryWrapper<CityAqi> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("time", "value").eq("city_code", cityCode); |
| | | List<Map<String, Object>> cityAqis = cityAqiMapper.selectMaps(queryWrapper); |
| | | List<Map<String, Object>> o3_8H = AmendUtils.getO3_8H(cityAqis); |
| | | if (!ObjectUtils.isEmpty(o3_8H)) { |
| | | for (Map<String, Object> o3Map : o3_8H) { |
| | | String hourTime = o3Map.get("time").toString(); |
| | | if (DateUtils.dateToDateString(time, DateUtils.yyyy_MM_dd_HH_mm_ss_EN).equals(hourTime)) { |
| | | o3Map.get("o3"); |
| | | aqi.put("o3_8h", o3Map.get("o3")); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //综合指数计算 |
| | | Map<String, Object> temp = new HashMap<>(aqi); |
| | | temp.put("o3", temp.get("o3_8h")); |
| | | Double compositeIndex = ComprehensiveIndexUtils.dailyData(temp); |
| | | aqi.put("compositeIndex", compositeIndex); |
| | | |
| | | |
| | | //首要污染物计算 |
| | | Map<String, Object> pollutant = AQIUtils.cityAqiPollutant(aqi); |
| | | if (!ObjectUtils.isEmpty(pollutant)) { |
| | | aqi.putAll(pollutant); |
| | | } |
| | | |
| | | |
| | | CityAqi cityAqi = new CityAqi(); |
| | | cityAqi.setCityCode(cityCode); |
| | | cityAqi.setTime(time); |