| | |
| | | /*空气质量分指数*/ |
| | | private static Double[] IAQI_Array = new Double[]{0d,50d,100d,150d,200d,300d,400d,500d}; |
| | | |
| | | |
| | | //计算6参未超标因子数 |
| | | public static int standardCount(Map<String,Object> data){ |
| | | int count = 0; |
| | | if(data.get("PM2_5")!=null&&PM2_5IsStandard(Double.valueOf(data.get("PM2_5").toString()))) |
| | | count++; |
| | | if(data.get("PM10")!=null&&PM10IsStandard(Double.valueOf(data.get("PM10").toString()))) |
| | | count++; |
| | | if(data.get("SO2")!=null&&SO2IsStandard(Double.valueOf(data.get("SO2").toString()))) |
| | | count++; |
| | | if(data.get("NO2")!=null&&NO2IsStandard(Double.valueOf(data.get("NO2").toString()))) |
| | | count++; |
| | | if(data.get("CO")!=null&&COIsStandard(Double.valueOf(data.get("CO").toString()))) |
| | | count++; |
| | | if(data.get("O3")!=null&&O3IsStandard(Double.valueOf(data.get("O3").toString()))) |
| | | count++; |
| | | return count; |
| | | } |
| | | |
| | | //判断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: 陈凯裕 |
| | |
| | | if(aqi>50) |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | return 0; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |