| | |
| | | DataPercentRange fineDays = calculateFineDays(cities, twentyEightCities, heBeiEightCities, startDate, endDate, city); |
| | | //计算6参以及综合指数排名 |
| | | Map<String, DataPercentRange> sixParamMap = calculateSixParam(thisYear, startDate, endDate, city, cities, twentyEightCities, heBeiEightCities); |
| | | Map<String,DataPercentRange> result = new HashMap<>(); |
| | | if(fineDays!=null) |
| | | result.put("fineDays",fineDays); |
| | | if(sixParamMap!=null) |
| | | Map<String, DataPercentRange> result = new HashMap<>(); |
| | | if (fineDays != null) |
| | | result.put("fineDays", fineDays); |
| | | if (sixParamMap != null) |
| | | result.putAll(sixParamMap); |
| | | if(result.size()==0) |
| | | if (result.size() == 0) |
| | | return null; |
| | | return result; |
| | | } |
| | |
| | | |
| | | //查询优良天气数 |
| | | CityPollutionLevel cityPollutionLevel = cityAqiDailyService.calculateDaysByTimeAndSysArea(city, startDate, endDate); |
| | | if(cityPollutionLevel==null) |
| | | if (cityPollutionLevel == null) |
| | | return null; |
| | | Integer fineDays = cityPollutionLevel.getExcellentWeatherDays() + cityPollutionLevel.getGoodWeatherDays(); |
| | | //计算同比数据 |
| | |
| | | Date compareEndDate = DateUtils.addMonths(endDate, -12); |
| | | CityPollutionLevel cityPollutionLevelCompare = cityAqiDailyService.calculateDaysByTimeAndSysArea(city, compareStartDate, compareEndDate); |
| | | String percent = null; |
| | | if(cityPollutionLevelCompare!=null){ |
| | | if (cityPollutionLevelCompare != null) { |
| | | Integer compareFineDays = cityPollutionLevelCompare.getExcellentWeatherDays() + cityPollutionLevelCompare.getGoodWeatherDays(); |
| | | percent = (fineDays - compareFineDays) + " 天"; |
| | | Integer percentInt = fineDays - compareFineDays; |
| | | if (percentInt > 0) { |
| | | percent = "+" + percentInt + " 天"; |
| | | } else { |
| | | percent = percentInt + " 天"; |
| | | } |
| | | |
| | | } |
| | | //计算省内排名 |
| | | Integer provinceRange = null; |
| | | if(provinceCities!=null) |
| | | if (provinceCities != null) |
| | | provinceRange = calculateFineDaysRange(provinceCities, city, startDate, endDate); |
| | | //计算2+26城市排名 |
| | | Integer twentyEightRange = null; |
| | |
| | | Map<String, Double> compareCentration = getConcentration(thisYear, compareStartDate, compareEndDate, cityCode); |
| | | //计算6参以及综指同比结果 |
| | | Map<String, String> compareResult = null; |
| | | if(compareCentration!=null) |
| | | if (compareCentration != null) |
| | | compareResult = calculateSixParamYOY(concentration, compareCentration); |
| | | //计算省内排名 |
| | | Map<String, Integer> provinceRangeResult = null; |
| | |
| | | DataPercentRange O3 = packageSixParam(concentration, compareResult, provinceRangeResult, twentyEightRangeResult, provinceChannelRangeResult, "O3", 0, "μg/m³"); |
| | | DataPercentRange CO = packageSixParam(concentration, compareResult, provinceRangeResult, twentyEightRangeResult, provinceChannelRangeResult, "CO", 1, "mg/m³"); |
| | | DataPercentRange compositeIndex = packageSixParam(concentration, compareResult, provinceRangeResult, twentyEightRangeResult, provinceChannelRangeResult, "compositeIndex", 3, ""); |
| | | result.put("PM2_5",PM2_5); |
| | | result.put("PM10",PM10); |
| | | result.put("SO2",SO2); |
| | | result.put("NO2",NO2); |
| | | result.put("O3",O3); |
| | | result.put("CO",CO); |
| | | result.put("compositeIndex",compositeIndex); |
| | | result.put("PM2_5", PM2_5); |
| | | result.put("PM10", PM10); |
| | | result.put("SO2", SO2); |
| | | result.put("NO2", NO2); |
| | | result.put("O3", O3); |
| | | result.put("CO", CO); |
| | | result.put("compositeIndex", compositeIndex); |
| | | return result; |
| | | } |
| | | |
| | |
| | | |
| | | Double pm2_5 = calculateSensorYOY(dataMap, compareDataMap, "PM2_5"); |
| | | if (pm2_5 != null) |
| | | result.put("PM2_5", pm2_5.intValue() + " μg/m³"); |
| | | result.put("PM2_5", pm2_5.intValue() > 0 ? "+" + pm2_5.intValue() + " μg/m³" : pm2_5.intValue() + " μg/m³"); |
| | | |
| | | Double pm10 = calculateSensorYOY(dataMap, compareDataMap, "PM10"); |
| | | if (pm10 != null) |
| | | result.put("PM10", pm10.intValue() + " μg/m³"); |
| | | result.put("PM10", pm10.intValue() > 0 ? "+" + pm10.intValue() + " μg/m³" : pm10.intValue() + " μg/m³"); |
| | | |
| | | Double so2 = calculateSensorYOY(dataMap, compareDataMap, "SO2"); |
| | | if (so2 != null) |
| | | result.put("SO2", so2.intValue() + " μg/m³"); |
| | | result.put("SO2", so2.intValue() > 0 ? "+" + so2.intValue() + " μg/m³" : so2.intValue() + " μg/m³"); |
| | | |
| | | |
| | | Double no2 = calculateSensorYOY(dataMap, compareDataMap, "NO2"); |
| | | if (no2 != null) |
| | | result.put("NO2", no2.intValue() + " μg/m³"); |
| | | result.put("NO2", no2.intValue() > 0 ? "+" + no2.intValue() + " μg/m³" : no2.intValue() + " μg/m³"); |
| | | |
| | | |
| | | Double o3 = calculateSensorYOY(dataMap, compareDataMap, "O3"); |
| | | if (o3 != null) |
| | | result.put("O3", o3.intValue() + " μg/m³"); |
| | | result.put("O3", o3.intValue() > 0 ? "+" + o3.intValue() + " μg/m³" : o3.intValue() + " μg/m³"); |
| | | |
| | | |
| | | Double co = calculateSensorYOY(dataMap, compareDataMap, "CO"); |
| | | if (co != null) { |
| | | co = AmendUtils.sciCal(co, 1); |
| | | result.put("CO", co + " mg/m³"); |
| | | result.put("CO", co.intValue() > 0 ? "+" + co.intValue() + " mg/m³" : co.intValue() + " mg/m³"); |
| | | } |
| | | |
| | | //计算综合指数同比数据 |
| | |
| | | if (compositeIndex != null && compareCompositeIndex != null) { |
| | | Double compareResult = MathUtils.division(compositeIndex - compareCompositeIndex, compareCompositeIndex, 3); |
| | | compareResult = MathUtils.mul(compareResult, 100); |
| | | result.put("compositeIndex", compareResult + "%"); |
| | | result.put("compositeIndex", compareResult > 0 ? "+" + compareResult + " %" : compareResult + " %"); |
| | | } |
| | | if (result.size() != 7) |
| | | return null; |