From 5145384586f87e6c39b13fdac8180007582fee57 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期六, 29 七月 2023 08:45:09 +0800 Subject: [PATCH] 2 --- src/main/java/com/yssh/service/WarningAnalyseService.java | 99 +++++++++++++++---------------------------------- 1 files changed, 30 insertions(+), 69 deletions(-) diff --git a/src/main/java/com/yssh/service/WarningAnalyseService.java b/src/main/java/com/yssh/service/WarningAnalyseService.java index 15f7a0d..02f36e8 100644 --- a/src/main/java/com/yssh/service/WarningAnalyseService.java +++ b/src/main/java/com/yssh/service/WarningAnalyseService.java @@ -327,6 +327,33 @@ return CalculateUtils.sort(result, "value", true).subList(0, 10); } + /** + * 涓夊皬鏃剁洃娴嬬珯鐐规暟鎹彉鍖栬秼鍔� + */ + public Object select3Hours(Date endDate) { + Integer end = Integer.parseInt(DateUtils.getYyyyMmDdHh(endDate)); + Date startDate = DateUtils.getAPeriodOfTime(endDate, -2, Calendar.HOUR_OF_DAY); + Integer start = Integer.parseInt(DateUtils.getYyyyMmDdHh(startDate)); + + // List<String> times = DateUtils.get3Hours(); + List<Qxsh> list = qxshMapper.selectByBeginAndEnd(start, end); + if (null == list || list.isEmpty()) { + return null; + } + + /* Map<String, List<Double>> map = new LinkedHashMap<>(); + for (Qxsh qxsh : list) { + String name = qxsh.getName(); + List<Double> values = map.computeIfAbsent(name, k -> new ArrayList<>()); + values.add(qxsh.getValue()); + }*/ + + return list; + } + + /** + * 鑾峰彇鏈湀鐩戞祴澶ф暟鎹珯鐐规渶澶у�糡OP10 + */ public List<Qxsh> selectMonthTop10() { String time = DateUtils.getYyyyMm(new Date()); List<Qxsh> list = qxshMapper.selectMonthTop10(time + "%"); @@ -334,24 +361,9 @@ return list; } - public Map<String, List<Double>> select3Hours() { - Map<String, List<Double>> map = new LinkedHashMap<>(); - - List<String> times = DateUtils.get3Hours(); - List<Qxsh> list = qxshMapper.select3Hours(times); - if (null == list || list.isEmpty()) { - return map; - } - - for (Qxsh qxsh : list) { - String name = qxsh.getName(); - List<Double> values = map.computeIfAbsent(name, k -> new ArrayList<>()); - values.add(qxsh.getValue()); - } - - return map; - } - + /** + * 鏍规嵁鏃堕棿鑾峰彇鎶ヨ鍜岄璀︿俊鎭� + */ public List<Report> getAlarmAndWarnByTime(Date beginDate, Date endDate) { String strStart = DateUtils.getYyyyMmDdHh(beginDate); String strEnd = DateUtils.getYyyyMmDdHh(endDate); @@ -402,57 +414,6 @@ } return dict; - } - - public List<Report> getAlarmAndWarnByTime2(Date begin, Date end) { - String startTime = DateUtils.getYyyyMmDdHhMmSs(begin); - String endTime = DateUtils.getYyyyMmDdHhMmSs(end); - - List<WarningDetail> rs = new ArrayList<>(); - List<WarningDetail> rsYj = warningDetailMapper.selectByTimeForYj(startTime, endTime); - if (null != rsYj && rsYj.size() > 0) rs.addAll(rsYj); - - List<WarningDetail> rsBj = warningDetailMapper.selectByTimeForBj(startTime, endTime); - if (null != rsBj && rsBj.size() > 0) rs.addAll(rsBj); - - Hashtable<String, Boolean> dict = new Hashtable<>(); - List<Report> list = new ArrayList<>(); - for (WarningDetail wd : rs) { - /*DistanceSuYuan suYuan = suYuanMapper.getSuYuanById(wd.getTableName(), wd.getSuYuanId()); - Double lastVal = warningDetailMapper.getLastYearVal(wd.getId()); - - int rows = suYuanMapper.isTableExists(wd.getTableName()); - DistanceSuYuan suMax = null; - if (rows > 0) { - MonitorPointPosition point = commonService.select3dCheckPointByName(wd.getLocationName()); - List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50); - suMax = suYuanMapper.getSuYuan500Max(wd.getTableName(), ids3d); - } else { - suMax = suYuan; - }*/ - if (dict.containsKey(wd.getTableName())) { - if (!dict.get(wd.getTableName())) continue; - } else { - Boolean b = suYuanMapper.isTableExists(wd.getTableName()) > 0; - dict.put(wd.getTableName(), b); - if (!b) continue; - } - - DistanceSuYuan suYuan = suYuanMapper.getSuYuanById(wd.getTableName(), wd.getSuYuanId()); - Double lastVal = warningDetailMapper.getLastYearVal(wd.getId()); - - MonitorPointPosition point = commonService.select3dCheckPointByName(wd.getLocationName()); - List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50); - DistanceSuYuan suMax = suYuanMapper.getSuYuan500Max(wd.getTableName(), ids3d); - suMax.setAddr(getAddr(suMax.getId())); - - Report report = Report.calcReport(wd, suYuan, suMax); - report.setLastVal(lastVal); - - list.add(report); - } - - return list; } private String getAddr(String id) { -- Gitblit v1.9.3