| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.yaml.snakeyaml.nodes.CollectionNode; |
| | | |
| | | import java.util.*; |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |
| | | //处理月报数据 |
| | |
| | | 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) { |
| | |
| | | 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: 计算自定义报表的数据 |