From 9485a0cb33bb4535bb553a5bf49debeadbe0c89d Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Wed, 03 Nov 2021 11:48:55 +0800
Subject: [PATCH] city_aqi o3_8h,综指,首要污染物计算
---
screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java | 42 ++++++++++++++++++++++++++++++++++++------
1 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java
index c22f67e..67408e5 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/DataDisplayServiceImpl.java
@@ -136,8 +136,8 @@
time = time + " 0" + i;
else
time = time + " " + i;
- if(timeValueMap.get(time)==null)
- timeValueMap.put(time,null);
+ if (timeValueMap.get(time) == null)
+ timeValueMap.put(time, null);
}
}
//������������������
@@ -158,11 +158,13 @@
time = time + "-0" + i;
else
time = time + "-" + i;
- if(timeValueMap.get(time)==null)
- timeValueMap.put(time,null);
+ if (timeValueMap.get(time) == null)
+ timeValueMap.put(time, null);
}
} else
return null;
+ //������������
+ timeValueMap = sortMapByTime(timeValueMap, reportType);
//������������������
List<SensorComparisonDisplayDTO> dtos = new ArrayList<>();
for (String sensor : sensors) {
@@ -171,7 +173,7 @@
dto.setSensorCode(sensor);
timeValueMap.forEach((time, valueJson) -> {
Map<String, Object> listMap = new HashMap<>();
- //������������������������������
+ //���������������������������������������������
if (valueJson == null) {
listMap.put("time", time);
listMap.put("value", "");
@@ -180,7 +182,7 @@
}
Map<String, Object> valueMap = JSON.parseObject(valueJson, Map.class);
Object sensorValueObject = valueMap.get(sensor);
- //������������������������������������������null
+ //���������������������������������������������
if (sensorValueObject == null) {
listMap.put("time", time);
listMap.put("value", "");
@@ -189,6 +191,7 @@
}
//������������������������������������������
if (reportType.equals(Constants.DAILY_REPORT)) {
+ //���������������������N���������������
if (!Constants.NORMAL_FLAG.equals(valueMap.get(sensor + "-Flag"))) {
listMap.put("time", time);
listMap.put("value", "");
@@ -209,6 +212,33 @@
return dtos;
}
+ private Map<String, String> sortMapByTime(Map<String, String> timeValueMap, String reportType) {
+ List<Map.Entry<String, String>> entries = new ArrayList(timeValueMap.entrySet());
+ Collections.sort(entries, new Comparator<Map.Entry<String, String>>() {
+ @Override
+ public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
+ if (Constants.DAILY_REPORT.equals(reportType)) {
+ String atime = o1.getKey();
+ String btime = o2.getKey();
+ atime = atime.substring(11, 13);
+ btime = btime.substring(11, 13);
+ return Integer.parseInt(atime) - Integer.parseInt(btime);
+ } else if (Constants.MONTHLY_REPORT.equals(reportType)) {
+ String atime = o1.getKey();
+ String btime = o2.getKey();
+ atime = atime.substring(8, 10);
+ btime = btime.substring(8, 10);
+ return Integer.parseInt(atime) - Integer.parseInt(btime);
+ }
+ return 0;
+ }
+ });
+ Map<String, String> sortedMap = new LinkedHashMap<>();
+ for (Map.Entry<String, String> entry : entries) {
+ sortedMap.put(entry.getKey(), entry.getValue());
+ }
+ return sortedMap;
+ }
/**
* @Description: ������������������������������
--
Gitblit v1.8.0