| | |
| | | avgs.add(average); |
| | | } |
| | | max = avgs.stream().mapToDouble(aDouble -> aDouble).summaryStatistics().getMax(); |
| | | System.out.println(avgs.size()); |
| | | if (avgs.size() < 14) { |
| | | if (max < 160d) { |
| | | return result; |
| | |
| | | return result; |
| | | } |
| | | |
| | | //城市aqi日均值 |
| | | public static Double o3OfDay(List<Map<String, Object>> value) { |
| | | List<Map<String, Object>> o3_8H = getO3_8H(value); |
| | | if (!ObjectUtils.isEmpty(o3_8H)) { |
| | | double o3 = 0d; |
| | | for (Map<String, Object> o : o3_8H) { |
| | | double temp = (double) o.get("o3"); |
| | | if (temp > o3) { |
| | | o3 = temp; |
| | | } |
| | | } |
| | | return sciCal(o3, 0); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * @param data 数据 time:Date类型 |
| | | * @param data 数据 time:Date类型,臭氧key:o3 |
| | | * @return 功能:臭氧8小时滑动值计算 |
| | | */ |
| | | public static List<Map<String, Object>> getO3_8H(List<Map<String, Object>> data) { |
| | |
| | | } |
| | | List<Double> value = new ArrayList<>(); |
| | | for (Map<String, Object> dataMap : data) { |
| | | Double o3 = Double.parseDouble(dataMap.get(Constants.SENSOR_CODE_O3).toString()); |
| | | Map<String, Object> sensorValue = JSONObject.parseObject((String) dataMap.get("value"), Map.class); |
| | | Double o3 = Double.parseDouble(sensorValue.get("o3").toString()); |
| | | Date time = (Date) dataMap.get("time"); |
| | | int hour = DateUtils.getHour(time); |
| | | if (hour == 0) { |
| | |
| | | continue; |
| | | } |
| | | double average = value.stream().mapToDouble(aDouble -> aDouble).summaryStatistics().getAverage(); |
| | | map.put(Constants.SENSOR_CODE_O3, average); |
| | | map.put("o3", average); |
| | | result.add(map); |
| | | } |
| | | return result; |
| | |
| | | Object speed = dataValue.get(Constants.SENSOR_CODE_WIND_SPEED); |
| | | Object flagDir = dataValue.get(Constants.SENSOR_CODE_WIND_DIR + "-" + Constants.MARKER_BIT_KEY); |
| | | Object flagSpeed = dataValue.get(Constants.SENSOR_CODE_WIND_SPEED + "-" + Constants.MARKER_BIT_KEY); |
| | | if (!Constants.MARKER_BIT_TRUE.equals(flagDir) || !Constants.MARKER_BIT_TRUE.equals(flagSpeed)) { |
| | | continue; |
| | | |
| | | if (!ObjectUtils.isEmpty(flagDir) && !ObjectUtils.isEmpty(flagSpeed)) { |
| | | if (!Constants.MARKER_BIT_TRUE.equals(flagDir) || !Constants.MARKER_BIT_TRUE.equals(flagSpeed)) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (ObjectUtils.isEmpty(wind) || ObjectUtils.isEmpty(speed)) { |
| | |
| | | |
| | | //剔除风速和风向超过上下限范围的数据 |
| | | if (!ObjectUtils.isEmpty(windDirUpper)) { |
| | | if (windDir < (Double) windDirUpper) { |
| | | if (windDir > (Double) windDirUpper) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (!ObjectUtils.isEmpty(windDirLower)) { |
| | | if (windDir > (Double) windDirLower) { |
| | | if (windDir < (Double) windDirLower) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (!ObjectUtils.isEmpty(windSpeedUpper)) { |
| | | if (windSpeed < (Double) windSpeedUpper) { |
| | | if (windSpeed > (Double) windSpeedUpper) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | if (!ObjectUtils.isEmpty(windSpeedLower)) { |
| | | if (windSpeed > (Double) windSpeedLower) { |
| | | if (windSpeed < (Double) windSpeedLower) { |
| | | continue; |
| | | } |
| | | } |
| | |
| | | for (Map<String, Object> dataMap : list) { |
| | | Map<String, Object> dataValue = JSONObject.parseObject((String) dataMap.get("value"), Map.class); |
| | | Object o = dataValue.get(Constants.SENSOR_CODE_CO); |
| | | Object flag = dataValue.get(Constants.SENSOR_CODE_CO + "-" + Constants.MARKER_BIT_KEY); |
| | | if (!Constants.MARKER_BIT_TRUE.equals(flag)) { |
| | | continue; |
| | | } |
| | | if (ObjectUtils.isEmpty(o)) { |
| | | continue; |
| | | } |
| | | Double co = Double.parseDouble(o.toString()); |
| | | //剔除超过上下限的数据 |
| | | if (!ObjectUtils.isEmpty(upper)) { |
| | | if (co < (Double) upper) { |
| | | if (co > (Double) upper) { |
| | | continue; |
| | | } |
| | | } |
| | | if (!ObjectUtils.isEmpty(lower)) { |
| | | if (co > (Double) upper) { |
| | | if (co < (Double) lower) { |
| | | continue; |
| | | } |
| | | } |
| | |
| | | for (Map<String, Object> dataMap : list) { |
| | | Map<String, Object> dataValue = JSONObject.parseObject((String) dataMap.get("value"), Map.class); |
| | | Object o = dataValue.get(Constants.SENSOR_CODE_O3); |
| | | Object flag = dataValue.get(Constants.SENSOR_CODE_O3 + "-" + Constants.MARKER_BIT_KEY); |
| | | if (!Constants.MARKER_BIT_TRUE.equals(flag)) { |
| | | continue; |
| | | } |
| | | if (ObjectUtils.isEmpty(o)) { |
| | | continue; |
| | | } |
| | | Double o3 = Double.parseDouble(o.toString()); |
| | | //剔除超过上下限的数据 |
| | | if (!ObjectUtils.isEmpty(upper)) { |
| | | if (o3 < (Double) upper) { |
| | | if (o3 > (Double) upper) { |
| | | continue; |
| | | } |
| | | } |
| | | if (!ObjectUtils.isEmpty(lower)) { |
| | | if (o3 > (Double) upper) { |
| | | if (o3 < (Double) lower) { |
| | | continue; |
| | | } |
| | | } |