| | |
| | | @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") |
| | |
| | | @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()); |
| | |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | } |