| | |
| | | |
| | | 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); |
| | | /*param.put("type", 0); |
| | | List<WarningVo> alarms = warningDetailMapper.selectWarningDetailByMap(param); |
| | | if (StringUtils.isNull(alarms)) { |
| | | alarms = new ArrayList<>(); |
| | | } |
| | | result.put("alarmNumber", alarms.size()); |
| | | result.put("alarmNumber", alarms.size());*/ |
| | | Integer alarmNum = warningDetailMapper.countAlarmByMap(param); |
| | | result.put("alarmNumber", null == alarmNum ? 0 : alarmNum); |
| | | |
| | | param.put("type", 1); |
| | | List<WarningVo> warnings = warningDetailMapper.selectWarningDetailByMap(param); |
| | | /*List<WarningVo> warnings = warningDetailMapper.selectWarningDetailByMap(param); |
| | | if (StringUtils.isNull(warnings)) { |
| | | warnings = new ArrayList<>(); |
| | | } |
| | | result.put("warningNumber", warnings.size()); |
| | | result.put("warningNumber", warnings.size());*/ |
| | | Integer warnNum = warningDetailMapper.countWarnByMap(param); |
| | | result.put("warningNumber", null == warnNum ? 0 : warnNum); |
| | | |
| | | return result; |
| | | } |
| | |
| | | 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<WarningVo> getAlarmAndWarnByTime(Date begin, Date end) { |
| | | String startTime = ymdhms.format(begin); |
| | | String endTime = ymdhms.format(end); |
| | | public List<Report> getAlarmAndWarnByTime(Date begin, Date end) { |
| | | String startTime = DateUtils.getYyyyMmDdHhMmSs(begin); |
| | | String endTime = DateUtils.getYyyyMmDdHhMmSs(end); |
| | | |
| | | List<WarningDetail> rs = warningDetailMapper.selectByTime(startTime, endTime); |
| | | if (null == rs || rs.isEmpty()) { |
| | | return null; |
| | | } |
| | | List<WarningDetail> rs = new ArrayList<>(); |
| | | List<WarningDetail> rsYj = warningDetailMapper.selectByTimeForYj(startTime, endTime); |
| | | if (null != rsYj && rsYj.size() > 0) rs.addAll(rsYj); |
| | | |
| | | List<WarningVo> list = new ArrayList<>(); |
| | | List<WarningDetail> rsBj = warningDetailMapper.selectByTimeForBj(startTime, endTime); |
| | | if (null != rsBj && rsBj.size() > 0) rs.addAll(rsBj); |
| | | |
| | | List<Report> list = new ArrayList<>(); |
| | | for (WarningDetail wd : rs) { |
| | | String time = ymdh.format(wd.getCreateTime()); |
| | | list.add(new WarningVo(wd.getLocationName(), wd.getSuYuanId(), 0.0, 0.0, wd.getValue(), time)); |
| | | //String time = ymdh.format(wd.getCreateTime()); |
| | | //list.add(new WarningVo(wd.getLocationName(), wd.getSuYuanId(), 0.0, 0.0, wd.getValue(), time)); |
| | | |
| | | DistanceSuYuan suYuan = suYuanMapper.getSuYuanById(wd.getTableName(), wd.getSuYuanId()); |
| | | Double lastVal = warningDetailMapper.getLastYearVal(wd.getId()); |
| | | |
| | | int rows = suYuanMapper.isTableExists(wd.getTableName()); |
| | | DistanceSuYuan suMax = null; |
| | | if (rows > 0) { |
| | | MonitorPointPosition point = commonService.select3dCheckPointByName(wd.getLocationName()); |
| | | List<String> ids3d = CalculateUtils.aloneCrosswiseExtend(point, 50); |
| | | suMax = suYuanMapper.getSuYuan500Max(wd.getTableName(), ids3d); |
| | | } else { |
| | | suMax = suYuan; |
| | | } |
| | | |
| | | Report report = Report.calcReport(wd, suYuan, suMax); |
| | | report.setLastVal(lastVal); |
| | | |
| | | list.add(report); |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | } |