| | |
| | | // 今日00:00:00
|
| | | parameters.put("end", DateUtils.truncate(date, Calendar.DATE));
|
| | |
|
| | | Map<String, Object> average = historyMapper.getMonthAverageBySensor(parameters);
|
| | | Map<String, Object> average = null;
|
| | | average = historyMapper.getMonthAverageBySensor(parameters);
|
| | |
|
| | | if (ObjectUtils.isEmpty(average)) {
|
| | | // 空值临时处理
|
| | | resultMap.put("average", 50.3467 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) / 5);
|
| | | //resultMap.put("average", 50.3467 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) / 5);
|
| | | resultMap.put("average", "N/A");
|
| | | } else {
|
| | | resultMap.putAll(average);
|
| | | //resultMap.putAll(average);
|
| | | //resultMap.put("average", String.format("%.2f", resultMap.get("average")));
|
| | | resultMap.put("average", String.format("%.2f", average.get("average")));
|
| | | }
|
| | | resultMap.put("average", String.format("%.2f", resultMap.get("average")));
|
| | |
|
| | | // 3.0 AQI 指数
|
| | | String[] macKeys = { "e1", "e2", "e10", "e11", "e15", "e16" };
|
| | |
| | | double avg = 0, minMacKey = 0, maxMacKey = 0, minIAQI = 0, maxIAQI = 0;
|
| | | parameters.put("macKey", macKey);
|
| | | average = historyMapper.getMonthAverageBySensor(parameters);
|
| | | if (!ObjectUtils.isEmpty(average)) {
|
| | | if (ObjectUtils.isEmpty(average)) {
|
| | | continue;
|
| | | } else {
|
| | | avg = (Double) average.get("average");
|
| | | if ("e11".equals(macKey) || "e15".equals(macKey) || "e16".equals(macKey)) {
|
| | | avg *= 1000.0;
|
| | | }
|
| | | }
|
| | | String[] macKeyValues = ResourceUtil.getArrValue(macKey);
|
| | | int index = -1;
|
| | |
| | | }
|
| | |
|
| | | if (!resultMap.containsKey("AQI")) {
|
| | | double AQI = Collections.max(IAQIs);
|
| | | // 空值临时处理
|
| | | if (AQI == 0.0) {
|
| | | AQI = 60.670;
|
| | | if (ObjectUtils.isEmpty(IAQIs)) {
|
| | | resultMap.put("AQI", "N/A");
|
| | | }else {
|
| | | double AQI = Collections.max(IAQIs);
|
| | | // 空值临时处理
|
| | | /*if (AQI == 0.0) {
|
| | | AQI = 60.670;
|
| | | }*/
|
| | | resultMap.put("AQI", String.format("%.0f", AQI));
|
| | | }
|
| | | resultMap.put("AQI", String.format("%.0f", AQI));
|
| | | }
|
| | |
|
| | | return resultMap;
|
| | |
| | | List<Map<String, Object>> averageByAll = historyMapper.getAverageByAll(parameters);
|
| | |
|
| | | // 临时方案,空值处理
|
| | | if (ObjectUtils.isEmpty(averageByAll)) {
|
| | | /*if (ObjectUtils.isEmpty(averageByAll)) {
|
| | | String macLog = historyMapper.getMacLogByLast();
|
| | | if (StringUtils.isNotBlank(macLog)) {
|
| | | Map<String, Object> map = JSON.parseObject(macLog);
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }*/
|
| | |
|
| | | for (Map<String, Object> map : averageByAll) {
|
| | | result.put((String) map.get("mac_key"), map.get("avg"));
|