From 659abe57f755e128e68d0a56bfc473e0baa4260b Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 26 四月 2023 18:28:08 +0800 Subject: [PATCH] 1 --- src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java | 73 +++++++++++++++++++++++++++++++++++- 1 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java b/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java index ce640f9..9bb33f5 100644 --- a/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java +++ b/src/main/java/com/yssh/service/impl/WarningAnalyseServiceImpl.java @@ -57,7 +57,9 @@ @Autowired private IAsyncService asyncService; - private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHH"); + private SimpleDateFormat ymdh = new SimpleDateFormat("yyyyMMddHH"); + + private SimpleDateFormat ymdhms = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @Override @Async("threadPoolTaskExecutor") @@ -208,7 +210,7 @@ @Override public Map<String, Integer> countThisMonthAlarmAndWarning() { Map<String, Integer> result = new HashMap<>(); - Map<String, Object> param = new HashMap<String, Object>(); + Map<String, Object> param = new HashMap<>(); param.put("type", 0); param.put("startTime", DateUtils.getMonthStart()); param.put("endTime", DateUtils.getMonthEnd()); @@ -347,4 +349,71 @@ return CalculateUtils.sort(result, "value", true).subList(0, 10); } + + @Override + public List<WarningVo> getAlarmAndWarnByTime(Date begin, Date end) { + List<WarningVo> list = new ArrayList<>(); + List<String> ids = CalculateUtils.assembleId(commonService.getCheckPoints3d()); + if (ids.size() == 0) { + return list; + } + List<DictRecord> dictList = dictRecordMapper.selectByTime(ymdhms.format(begin), ymdhms.format(end)); + if (null == dictList || dictList.isEmpty()) { + return list; + } + List<String> tables = new ArrayList<>(); + for (DictRecord dr : dictList) { + tables.add(dr.getTableName()); + } + + for (String tab : tables) { + List<WarningDetail> alarmList = getAlarmByTime(tab, ids); + for (WarningDetail s : alarmList) { + list.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue())); + } + } + + for (String tab : tables) { + List<WarningDetail> warnList = getWarnByTime(tab, ids); + for (WarningDetail s : warnList) { + list.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue())); + } + } + + return list; + } + + private List<WarningDetail> getAlarmByTime(String tableName, List<String> ids) { + List<WarningDetail> result = new ArrayList<>(); + List<SuYuan2d> list = suYuanMapper.getAlarmsAnalyse(tableName, ids); + if (null != list && list.size() > 0) { + Date date = getDateByTabName(tableName); + for (SuYuan2d s : list) { + String locationName = commonService.select3dCheckPointById(s.getId()).getName(); + result.add(new WarningDetail(0L, tableName, s.getId(), locationName, date, 0, s.getValue())); + } + } + return result; + } + + private List<WarningDetail> getWarnByTime(String tableName, List<String> ids) { + List<WarningDetail> result = new ArrayList<>(); + List<SuYuan2d> list = suYuanMapper.getWarningAnalyse(tableName, ids); + if (null != list && list.size() > 0) { + Date date = getDateByTabName(tableName); + for (SuYuan2d s : list) { + String locationName = commonService.select3dCheckPointById(s.getId()).getName(); + result.add(new WarningDetail(0L, tableName, s.getId(), locationName, date, 1, s.getValue())); + } + } + return result; + } + + private Date getDateByTabName(String tab) { + try { + return ymdh.parse(tab.replace("su_yuan_", "")); + } catch (Exception e) { + return new Date(); + } + } } -- Gitblit v1.9.3