| | |
| | | |
| | | private SimpleDateFormat ym = new SimpleDateFormat("yyyyMM%"); |
| | | |
| | | private SimpleDateFormat ymdh = new SimpleDateFormat("yyyyMMddHH"); |
| | | |
| | | private SimpleDateFormat ymdhms = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | @Override |
| | | @Async("threadPoolTaskExecutor") |
| | | public void insertWarningDetails(List<WarningDetail> warning) throws Exception { |
| | |
| | | } |
| | | } |
| | | list.forEach(s -> { |
| | | String time = ymdh.format(s.getCreateTime()); |
| | | String time = DateUtils.getYyyyMmDdHh(s.getCreateTime()); |
| | | result.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time)); |
| | | }); |
| | | return result; |
| | |
| | | } |
| | | } |
| | | list.forEach(s -> { |
| | | String time = ymdh.format(s.getCreateTime()); |
| | | String time = DateUtils.getYyyyMmDdHh(s.getCreateTime()); |
| | | result.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time)); |
| | | }); |
| | | return result; |
| | |
| | | public Map<String, Integer> countThisMonthAlarmAndWarning() { |
| | | Map<String, Integer> result = new HashMap<>(); |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("startTime", ymdhms.format(DateUtils.getMonthStart())); |
| | | param.put("endTime", ymdhms.format(DateUtils.getMonthEnd())); |
| | | param.put("startTime", DateUtils.getYyyyMmDdHhMmSs(DateUtils.getMonthStart())); |
| | | param.put("endTime", DateUtils.getYyyyMmDdHhMmSs(DateUtils.getMonthEnd())); |
| | | |
| | | /*param.put("type", 0); |
| | | List<WarningVo> alarms = warningDetailMapper.selectWarningDetailByMap(param); |
| | |
| | | Map<String, Object> param = new HashMap<String, Object>(); |
| | | Date now = new Date(); |
| | | Date last = DateUtils.getAPeriodOfTime(now, -7, Calendar.DATE); // 上周的今天 |
| | | param.put("startTime", ymdhms.format(last)); |
| | | param.put("endTime", ymdhms.format(now)); |
| | | param.put("startTime", DateUtils.getYyyyMmDdHhMmSs(last)); |
| | | param.put("endTime", DateUtils.getYyyyMmDdHhMmSs(now)); |
| | | |
| | | param.put("type", 0); |
| | | List<Map<String, Object>> alarmDayCount = warningDetailMapper.selectWarningDayCountByMap(param); |
| | |
| | | |
| | | @Override |
| | | public List<Qxsh> selectMonthTop10() { |
| | | String time = ym.format(new Date()); |
| | | String time = DateUtils.getYyyyMm(new Date()); |
| | | |
| | | List<Qxsh> list = qxshMapper.selectMonthTop10(time); |
| | | List<Qxsh> list = qxshMapper.selectMonthTop10(time + "%"); |
| | | |
| | | return list; |
| | | } |
| | |
| | | |
| | | @Override |
| | | public List<Report> getAlarmAndWarnByTime(Date begin, Date end) { |
| | | String startTime = ymdhms.format(begin); |
| | | String endTime = ymdhms.format(end); |
| | | String startTime = DateUtils.getYyyyMmDdHhMmSs(begin); |
| | | String endTime = DateUtils.getYyyyMmDdHhMmSs(end); |
| | | |
| | | List<WarningDetail> rs = new ArrayList<>(); |
| | | List<WarningDetail> rsYj = warningDetailMapper.selectByTimeForYj(startTime, endTime); |
| | |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | |
| | | public List<WarningVo> getAlarmAndWarnByTime_old(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) { |
| | | if (suYuanMapper.isTableExists(dr.getTableName()) > 0) { |
| | | tables.add(dr.getTableName()); |
| | | } |
| | | } |
| | | if (tables.size() == 0) { |
| | | return list; |
| | | } |
| | | |
| | | for (String tab : tables) { |
| | | List<WarningDetail> alarmList = getAlarmByTime(tab, ids); |
| | | for (WarningDetail s : alarmList) { |
| | | String time = ymdh.format(s.getCreateTime()); |
| | | list.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time)); |
| | | } |
| | | } |
| | | for (String tab : tables) { |
| | | List<WarningDetail> warnList = getWarnByTime(tab, ids); |
| | | for (WarningDetail s : warnList) { |
| | | String time = ymdh.format(s.getCreateTime()); |
| | | list.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue(), time)); |
| | | } |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | } |