| | |
| | | /*空气质量分指数*/ |
| | | private static Double[] IAQI_Array = new Double[]{0d,50d,100d,150d,200d,300d,400d,500d}; |
| | | |
| | | public static void main(String[] args) { |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("a34002",60); |
| | | map.put("a34004",56); |
| | | map.put("a21004",99); |
| | | map.put("a21005",0.54); |
| | | map.put("a21026",27); |
| | | map.put("a05024",72); |
| | | System.out.println(dailyAQI(map)); |
| | | //判断aqi是否达标 |
| | | public static boolean aqiIsStandard(int aqi){ |
| | | if(aqi<=100) |
| | | return true; |
| | | return false; |
| | | } |
| | | public static boolean PM2_5IsStandard(Double pm2_5){ |
| | | if(pm2_5<=75) |
| | | return true; |
| | | return false; |
| | | } |
| | | public static boolean PM10IsStandard(Double pm10){ |
| | | if(pm10<=150) |
| | | return true; |
| | | return false; |
| | | } |
| | | public static boolean SO2IsStandard(Double so2){ |
| | | if(so2<=500) |
| | | return true; |
| | | return false; |
| | | } |
| | | public static boolean NO2IsStandard(Double no2){ |
| | | if(no2<=80) |
| | | return true; |
| | | return false; |
| | | } |
| | | public static boolean COIsStandard(Double co){ |
| | | if(co<=4) |
| | | return true; |
| | | return false; |
| | | } |
| | | public static boolean O3IsStandard(Double o3){ |
| | | if(o3<=200) |
| | | return true; |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 计算AQI污染等级 |
| | | * @Description: 计算AQI污染等级,返回污染等级名称 |
| | | * @Param: |
| | | * @return: |
| | | * @Author: 陈凯裕 |
| | |
| | | */ |
| | | public static String classOfPollutionByAqi(Integer aqi){ |
| | | if(aqi>300) |
| | | return Constants.SERVER; |
| | | return Constants.SERVER_WEATHER; |
| | | if(aqi>200) |
| | | return Constants.SERIOUS; |
| | | return Constants.SERIOUS_WEATHER; |
| | | if(aqi>150) |
| | | return Constants.MIDDLE; |
| | | return Constants.MIDDLE_WEATHER; |
| | | if(aqi>100) |
| | | return Constants.MILD; |
| | | return Constants.MILD_WEATHER; |
| | | if(aqi>50) |
| | | return Constants.GOOD; |
| | | return Constants.EXCELLENT; |
| | | return Constants.GOOD_WEATHER; |
| | | return Constants.EXCELLENT_WEATHER; |
| | | } |
| | | |
| | | /** |
| | | * @Description: 根据AQI计算污染等级,返回污染等级Code |
| | | * @Param: [aqi] |
| | | * @return: java.lang.String |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/11/11 |
| | | */ |
| | | public static String classCodeOfPollutionByAqi(Integer aqi){ |
| | | if(aqi>300) |
| | | return Constants.SERVER_WEATHER_CODE; |
| | | if(aqi>200) |
| | | return Constants.SERIOUS_WEATHER_CODE; |
| | | if(aqi>150) |
| | | return Constants.MIDDLE_WEATHER_CODE; |
| | | if(aqi>100) |
| | | return Constants.MILD_WEATHER_CODE; |
| | | if(aqi>50) |
| | | return Constants.GOOD_WEATHER_CODE; |
| | | return Constants.EXCELLENT_WEATHER_CODE; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | } |
| | | |