| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import com.yssh.entity.WarningVo; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | |
| | | /** |
| | | * 获取实时报警 |
| | | */ |
| | | public List<Qxsh> getRunTimeAlarmAnalyse(Date endDate) { |
| | | Integer end = Integer.parseInt(DateUtils.getYyyyMmDdHh(endDate)); |
| | | Date startDate = DateUtils.getAPeriodOfTime(endDate, -5, Calendar.HOUR_OF_DAY); |
| | | Integer start = Integer.parseInt(DateUtils.getYyyyMmDdHh(startDate)); |
| | | |
| | | public List<Qxsh> getRunTimeAlarmAnalyse(Integer start, Integer end) { |
| | | return qxshMapper.selectAlarmByBeginAndEnd(start, end); |
| | | } |
| | | |
| | | /** |
| | | * 获取实时预警 |
| | | */ |
| | | public List<Qxsh> getRunTimeWarningAnalyse(Date endDate) { |
| | | Integer end = Integer.parseInt(DateUtils.getYyyyMmDdHh(endDate)); |
| | | Date startDate = DateUtils.getAPeriodOfTime(endDate, -5, Calendar.HOUR_OF_DAY); |
| | | Integer start = Integer.parseInt(DateUtils.getYyyyMmDdHh(startDate)); |
| | | |
| | | public List<Qxsh> getRunTimeWarningAnalyse(Integer start, Integer end) { |
| | | return qxshMapper.selectWarnByBeginAndEnd(start, end); |
| | | } |
| | | |
| | | // 已废弃 * |
| | | public void warningOperationStorage(Date date) { |
| | | List<WarningDetail> allData = new ArrayList<>(); |
| | | List<WarningDetail> alarms = this.getAlarmWarnAnalyse(date, false); |
| | | if (StringUtils.isNotEmpty(alarms)) { |
| | | allData.addAll(alarms); |
| | | } |
| | | |
| | | List<WarningDetail> warnings = this.getAlarmWarnAnalyse(date, true); |
| | | if (StringUtils.isNotEmpty(warnings)) { |
| | | allData.addAll(warnings); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(allData)) { |
| | | try { |
| | | insertWarningDetails(allData); |
| | | } catch (Exception e) { |
| | | logger.error("批量插入告警数据出现异常!!!", e); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private List<WarningDetail> getAlarmWarnAnalyse(Date date, boolean isWarn) { |
| | | List<String> ids = CalculateUtils.assembleId(commonService.getCheckPoints3d()); |
| | | |
| | | String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); |
| | | DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); |
| | | if (null == dictRecord) return null; |
| | | |
| | | String tableName = dictRecord.getTableName(); |
| | | 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; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | return null; |
| | | } |
| | | |
| | | // 已废弃 * |
| | | public void warningOperationStorage(Date date) { |
| | | List<WarningDetail> allData = new ArrayList<>(); |
| | | List<WarningDetail> alarms = this.getAlarmWarnAnalyse(date, false); |
| | | if (StringUtils.isNotEmpty(alarms)) { |
| | | allData.addAll(alarms); |
| | | } |
| | | |
| | | List<WarningDetail> warnings = this.getAlarmWarnAnalyse(date, true); |
| | | if (StringUtils.isNotEmpty(warnings)) { |
| | | allData.addAll(warnings); |
| | | } |
| | | |
| | | if (StringUtils.isNotEmpty(allData)) { |
| | | try { |
| | | insertWarningDetails(allData); |
| | | } catch (Exception e) { |
| | | logger.error("批量插入告警数据出现异常!!!", e); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 已废弃 * |
| | | private List<WarningDetail> getAlarmWarnAnalyse(Date date, boolean isWarn) { |
| | | List<String> ids = CalculateUtils.assembleId(commonService.getCheckPoints3d()); |
| | | |
| | | String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, date); |
| | | DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); |
| | | if (null == dictRecord) return null; |
| | | |
| | | String tableName = dictRecord.getTableName(); |
| | | 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; |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | } |