From 0e8c298a310465190cdbcda830f95a51f09ca0b3 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 16 五月 2023 16:39:20 +0800 Subject: [PATCH] 1 --- src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java | 5 ++++- src/main/java/com/yssh/utils/CalculateUtils.java | 48 ++++++++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java b/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java index a85700e..ef8932c 100644 --- a/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java +++ b/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java @@ -330,6 +330,9 @@ List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d(); Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthStart())); Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthEnd())); + //startTime = 2023040100L; + //endTime = 2023043023L; + List<DictRecord> recordList = dictRecordMapper.selectByTimeDictRecordList(startTime, endTime); List<String> tableNames = new ArrayList<>(); @@ -355,8 +358,8 @@ //map.put("name", commonService.select3dCheckPointById(suYuanId).getName()); //map.remove("id"); map.put("name", c.getName()); + result.add(map); } - result.add(map); } return CalculateUtils.sort(result, "value", true).subList(0, 10); diff --git a/src/main/java/com/yssh/utils/CalculateUtils.java b/src/main/java/com/yssh/utils/CalculateUtils.java index 26fdd80..8632877 100644 --- a/src/main/java/com/yssh/utils/CalculateUtils.java +++ b/src/main/java/com/yssh/utils/CalculateUtils.java @@ -1,10 +1,6 @@ package com.yssh.utils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; import com.yssh.entity.MonitorPointPosition; @@ -143,26 +139,30 @@ Collections.sort(list, new Comparator<Map<String, Object>>(){ @Override public int compare(Map<String, Object> o1, Map<String, Object> o2) { - Object oo1 = o1.get(property); - Object oo2 = o2.get(property); - if(oo1 == null || "null".equals(oo1.toString()) || "".equals(oo1.toString()) || oo1.toString().endsWith("999") ){ - oo1 = 0; + try { + Object oo1 = o1.get(property); + Object oo2 = o2.get(property); + if (oo1 == null || "null".equals(oo1.toString()) || "".equals(oo1.toString()) || oo1.toString().endsWith("999")) { + oo1 = 0; + } + if (oo2 == null || "null".equals(oo2.toString()) || "".equals(oo2.toString()) || oo2.toString().endsWith("999")) { + oo2 = 0; + } + if (order) { + if (Double.parseDouble(oo1.toString()) < Double.parseDouble(oo2.toString())) { + return 1; + } + } else { + if (Double.parseDouble(oo1.toString()) > Double.parseDouble(oo2.toString())) { + return 1; + } + } + if (Double.parseDouble(oo1.toString()) == Double.parseDouble(oo2.toString())) { + return 0; + } + }catch (Exception ex){ + System.out.println(ex.getMessage()); } - if(oo2 == null || "null".equals(oo2.toString()) || "".equals(oo2.toString()) || oo2.toString().endsWith("999") ){ - oo2 = 0; - } - if(order){ - if(Double.parseDouble(oo1.toString()) < Double.parseDouble(oo2.toString()) ){ - return 1; - } - }else{ - if(Double.parseDouble(oo1.toString()) > Double.parseDouble(oo2.toString()) ){ - return 1; - } - } - if(Double.parseDouble(oo1.toString()) == Double.parseDouble(oo2.toString())){ - return 0; - } return -1; } }); -- Gitblit v1.9.3