| | |
| | | Calendar calendar = getCalendar(nowDate); |
| | | for (int i = 0; i < 3; i++) { |
| | | calendar.add(Calendar.HOUR, -1); |
| | | List<WarningDetail> rs = alarmAnalyseOperation(calendar.getTime()); |
| | | List<WarningDetail> rs = getAlarmWarnAnalyse(calendar.getTime(), false); |
| | | if (null != rs && rs.size() > 0) { |
| | | list.addAll(rs); |
| | | } |
| | |
| | | Calendar calendar = getCalendar(nowDate); |
| | | for (int i = 0; i < 3; i++) { |
| | | calendar.add(Calendar.HOUR, -1); |
| | | List<WarningDetail> rs = warningAnalyseOperation(calendar.getTime()); |
| | | List<WarningDetail> rs = getAlarmWarnAnalyse(calendar.getTime(), true); |
| | | if (null != rs && rs.size() > 0) { |
| | | list.addAll(rs); |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | public List<WarningDetail> alarmAnalyseOperation(Date date) { |
| | | List<WarningDetail> result = new ArrayList<>(); |
| | | String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); |
| | | private List<WarningDetail> getAlarmWarnAnalyse(Date date, boolean isWarn) { |
| | | List<String> ids = CalculateUtils.assembleId(commonService.getCheckPoints3d()); |
| | | if (ids.size() == 0) { |
| | | return result; |
| | | } |
| | | DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); |
| | | if (null == dictRecord) { |
| | | return result; |
| | | } |
| | | String tableName = dictRecord.getTableName(); |
| | | if (suYuanMapper.isTableExists(tableName) == 0) { |
| | | return result; |
| | | } |
| | | |
| | | List<SuYuan2d> list = suYuanMapper.getAlarmsAnalyse(tableName, ids); |
| | | if (null != list && list.size() > 0) { |
| | | 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; |
| | | } |
| | | |
| | | public List<WarningDetail> warningAnalyseOperation(Date date) { |
| | | List<WarningDetail> result = new ArrayList<>(); |
| | | String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); |
| | | List<String> ids = CalculateUtils.assembleId(commonService.getCheckPoints3d()); |
| | | if (ids.size() == 0) { |
| | | return result; |
| | | } |
| | | DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); |
| | | if (null == dictRecord) { |
| | | return result; |
| | | } |
| | | if (null == dictRecord) return null; |
| | | |
| | | String tableName = dictRecord.getTableName(); |
| | | if (suYuanMapper.isTableExists(tableName) == 0) { |
| | | return result; |
| | | if (suYuanMapper.isTableExists(tableName) == 0) return null; |
| | | |
| | | List<SuYuan2d> list = isWarn ? suYuanMapper.getWarningAnalyse(tableName, ids) : suYuanMapper.getAlarmsAnalyse(tableName, ids); |
| | | if (null == list || list.isEmpty()) { |
| | | return null; |
| | | } |
| | | |
| | | List<SuYuan2d> list = suYuanMapper.getWarningAnalyse(tableName, ids); |
| | | if (null != list && list.size() > 0) { |
| | | for (SuYuan2d s : list) { |
| | | String locationName = commonService.select3dCheckPointById(s.getId()).getName(); |
| | | result.add(new WarningDetail(0L, tableName, s.getId(), locationName, date, 1, s.getValue())); |
| | | } |
| | | int type = isWarn ? 1 : 0; |
| | | List<WarningDetail> result = new ArrayList<>(); |
| | | for (SuYuan2d s : list) { |
| | | String locationName = commonService.select3dCheckPointById(s.getId()).getName(); |
| | | result.add(new WarningDetail(0L, tableName, s.getId(), locationName, date, type, s.getValue())); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public void warningOperationStorage(Date date) { |
| | | List<WarningDetail> allData = new ArrayList<>(); |
| | | List<WarningDetail> alarms = this.alarmAnalyseOperation(date); |
| | | List<WarningDetail> alarms = this.getAlarmWarnAnalyse(date, false); |
| | | if (StringUtils.isNotEmpty(alarms)) { |
| | | allData.addAll(alarms); |
| | | } |
| | | List<WarningDetail> warnings = this.warningAnalyseOperation(date); |
| | | |
| | | List<WarningDetail> warnings = this.getAlarmWarnAnalyse(date, true); |
| | | if (StringUtils.isNotEmpty(warnings)) { |
| | | allData.addAll(warnings); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(allData)) { |
| | | try { |
| | | insertWarningDetails(allData); |