| | |
| | | Double o3 = Double.parseDouble(dataValue.get(Constants.SENSOR_CODE_O3).toString()); |
| | | |
| | | //O3数据标记位 |
| | | Object flag = dataValue.get(Constants.SENSOR_CODE_O3 + Constants.MARKER_BIT_KEY); |
| | | Object flag = dataValue.get(Constants.SENSOR_CODE_O3 + "-" + Constants.MARKER_BIT_KEY); |
| | | //剔除有效性不足的数据 |
| | | if (!Constants.MARKER_BIT_TRUE.equals(flag)) { |
| | | continue; |
| | |
| | | Object windSpeedUpper = params.get("windSpeedUpper"); |
| | | Object windSpeedLower = params.get("windSpeedLower"); |
| | | |
| | | double avgDir; |
| | | double sumSin = 0d; |
| | | double sumCos = 0d; |
| | | int size = 0; |
| | | Double avgDir = null; |
| | | Double sumSin = 0d; |
| | | Double sumCos = 0d; |
| | | Integer size = 0; |
| | | for (Map<String, Object> map : data) { |
| | | Map<String, Object> dataValue = JSONObject.parseObject((String) map.get("value"), Map.class); |
| | | Object wind = dataValue.get(Constants.SENSOR_CODE_WIND_DIR); |
| | | 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); |
| | | 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; |
| | | } |
| | |
| | | |
| | | double avgSin = sumSin / size; |
| | | double avgCos = sumCos / size; |
| | | |
| | | if (avgSin > 0 && avgCos > 0) { |
| | | avgDir = Math.atan(avgSin / avgCos) * 180 / Math.PI; |
| | | } else if (avgCos < 0) { |
| | | } else if ((avgSin > 0 && avgCos < 0) || (avgSin < 0 && avgCos < 0)) { |
| | | avgDir = Math.atan(avgSin / avgCos) * 180 / Math.PI + 180; |
| | | } else { |
| | | } else if (avgSin < 0 && avgCos > 0) { |
| | | avgDir = Math.atan(avgSin / avgCos) * 180 / Math.PI + 360; |
| | | } |
| | | double v = sciCal(avgDir, 4); |
| | | result.put(Constants.SENSOR_CODE_WIND_DIR, v); |
| | | if ("hour".equals(type)) { |
| | | //有效值>=45个,打标记位 N,<45打H H:有效性不足 |
| | | if (size >= 45) { |
| | | result.put(Constants.SENSOR_CODE_WIND_DIR + Constants.MARKER_BIT_KEY, Constants.MARKER_BIT_TRUE); |
| | | } else { |
| | | result.put(Constants.SENSOR_CODE_WIND_DIR + Constants.MARKER_BIT_KEY, Constants.MARKER_BIT_FALSE); |
| | | if (!ObjectUtils.isEmpty(avgDir)) { |
| | | double v = sciCal(avgDir, 4); |
| | | result.put(Constants.SENSOR_CODE_WIND_DIR, v); |
| | | if ("hour".equals(type)) { |
| | | //有效值>=45个,打标记位 N,<45打H H:有效性不足 |
| | | if (size >= 45) { |
| | | result.put(Constants.SENSOR_CODE_WIND_DIR + "-" + Constants.MARKER_BIT_KEY, Constants.MARKER_BIT_TRUE); |
| | | } else { |
| | | result.put(Constants.SENSOR_CODE_WIND_DIR + "-" + Constants.MARKER_BIT_KEY, Constants.MARKER_BIT_FALSE); |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | |
| | | 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); |
| | | Object flag = dataValue.get(Constants.SENSOR_CODE_CO + "-" + Constants.MARKER_BIT_KEY); |
| | | if (!Constants.MARKER_BIT_TRUE.equals(flag)) { |
| | | 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); |
| | | Object flag = dataValue.get(Constants.SENSOR_CODE_O3 + "-" + Constants.MARKER_BIT_KEY); |
| | | if (!Constants.MARKER_BIT_TRUE.equals(flag)) { |
| | | continue; |
| | | } |