| | |
| | | @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") |
| | |
| | | public List<WarningVo> getRunTimeAlarmAnalyse() { |
| | | List<WarningVo> result = new ArrayList<>(); |
| | | Date nowDate = DateUtils.getNowDate(); |
| | | String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate); |
| | | DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); |
| | | if (StringUtils.isNull(dictRecord)) { |
| | | nowDate = DateUtils.getAPeriodOfTime(nowDate, -1, Calendar.HOUR_OF_DAY); |
| | | } |
| | | |
| | | //String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate); |
| | | //DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); |
| | | //if (StringUtils.isNull(dictRecord)) { |
| | | // nowDate = DateUtils.getAPeriodOfTime(nowDate, -1, Calendar.HOUR_OF_DAY); |
| | | //} |
| | | //List<WarningDetail> list = alarmAnalyseOperation(nowDate); |
| | | |
| | | List<WarningDetail> list = new ArrayList<>(); |
| | |
| | | list.addAll(rs); |
| | | } |
| | | } |
| | | |
| | | list.forEach(s -> { |
| | | result.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue())); |
| | | }); |
| | |
| | | public List<WarningVo> getRunTimeWarningAnalyse() { |
| | | List<WarningVo> result = new ArrayList<>(); |
| | | Date nowDate = DateUtils.getNowDate(); |
| | | String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate); |
| | | DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); |
| | | if (StringUtils.isNull(dictRecord)) { |
| | | nowDate = DateUtils.getAPeriodOfTime(nowDate, -1, Calendar.HOUR_OF_DAY); |
| | | } |
| | | |
| | | //String time = DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate); |
| | | //DictRecord dictRecord = dictRecordMapper.selectByCreateTime(Long.parseLong(time)); |
| | | //if (StringUtils.isNull(dictRecord)) { |
| | | // nowDate = DateUtils.getAPeriodOfTime(nowDate, -1, Calendar.HOUR_OF_DAY); |
| | | //} |
| | | //List<WarningDetail> list = warningAnalyseOperation(nowDate); |
| | | |
| | | List<WarningDetail> list = new ArrayList<>(); |
| | | Calendar calendar = getCalendar(nowDate); |
| | | for (int i = 0; i < 3; i++) { |
| | |
| | | list.addAll(rs); |
| | | } |
| | | } |
| | | |
| | | list.forEach(s -> { |
| | | result.add(new WarningVo(s.getLocationName(), s.getSuYuanId(), 0.0, 0.0, s.getValue())); |
| | | }); |
| | |
| | | } |
| | | |
| | | public List<WarningDetail> alarmAnalyseOperation(Date date) { |
| | | List<WarningDetail> result = new ArrayList<WarningDetail>(); |
| | | 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 (StringUtils.isNull(dictRecord)) { |
| | | if (null == dictRecord) { |
| | | return result; |
| | | } |
| | | String tableName = dictRecord.getTableName(); |
| | | if (suYuanMapper.isTableExists(tableName) == 0) { |
| | | return result; |
| | | } |
| | | |
| | | List<SuYuan2d> list = suYuanMapper.getAlarmsAnalyse(tableName, ids); |
| | | list.forEach(s -> { |
| | | String locationName = commonService.select3dCheckPointById(s.getId()).getName(); |
| | | result.add(new WarningDetail(0L, tableName, s.getId(), locationName, date, 0, s.getValue())); |
| | | }); |
| | | 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<WarningDetail>(); |
| | | 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 (StringUtils.isNull(dictRecord)) { |
| | | if (null == dictRecord) { |
| | | return result; |
| | | } |
| | | String tableName = dictRecord.getTableName(); |
| | | if (suYuanMapper.isTableExists(tableName) == 0) { |
| | | return result; |
| | | } |
| | | |
| | | List<SuYuan2d> list = suYuanMapper.getWarningAnalyse(tableName, ids); |
| | | list.forEach(s -> { |
| | | String locationName = commonService.select3dCheckPointById(s.getId()).getName(); |
| | | result.add(new WarningDetail(0L, tableName, s.getId(), locationName, date, 1, s.getValue())); |
| | | }); |
| | | 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())); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | |
| | | @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()); |
| | |
| | | |
| | | @Override |
| | | public Map<String, List<Double>> selectEachLocationDataChange() { |
| | | Map<String, List<Double>> result = new LinkedHashMap<>(); |
| | | /*Map<String, List<Double>> result = new LinkedHashMap<>(); |
| | | List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d(); |
| | | Date nowDate = DateUtils.getNowDate(); |
| | | Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate)); |
| | |
| | | result.put(c.getName(), values); |
| | | } |
| | | }); |
| | | return result;*/ |
| | | |
| | | Map<String, List<Double>> result = new LinkedHashMap<>(); |
| | | List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d(); |
| | | Date nowDate = DateUtils.getNowDate(); |
| | | Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, nowDate)); |
| | | Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getAPeriodOfTime(nowDate, -3, Calendar.HOUR_OF_DAY))); |
| | | List<DictRecord> recordList = dictRecordMapper.selectByTimeDictRecordList(startTime, endTime); |
| | | |
| | | List<String> tableNames = new ArrayList<>(); |
| | | for (DictRecord dr : recordList) { |
| | | if (suYuanMapper.isTableExists(dr.getTableName()) > 0) { |
| | | tableNames.add(dr.getTableName()); |
| | | } |
| | | } |
| | | if (tableNames.isEmpty()) { |
| | | return result; |
| | | } |
| | | |
| | | for (MonitorPointPosition c : checkPoints) { |
| | | List<Double> values = new ArrayList<>(); |
| | | List<SuYuanMonitorData> data = suYuanMapper.getMonitorData(tableNames, c.getId()); |
| | | if (null != data && data.size() > 0) { |
| | | for (SuYuanMonitorData v : data) { |
| | | values.add(v.getValue()); |
| | | } |
| | | } |
| | | result.put(c.getName(), values); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> selectThisMonthLocationValueDataTop10() { |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | /*List<Map<String, Object>> result = new ArrayList<>(); |
| | | List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d(); |
| | | Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthStart())); |
| | | Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthEnd())); |
| | |
| | | } |
| | | result.add(map); |
| | | }); |
| | | return CalculateUtils.sort(result, "value", true).subList(0, 10);*/ |
| | | |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d(); |
| | | Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthStart())); |
| | | Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthEnd())); |
| | | List<DictRecord> recordList = dictRecordMapper.selectByTimeDictRecordList(startTime, endTime); |
| | | |
| | | List<String> tableNames = new ArrayList<>(); |
| | | for (DictRecord dr : recordList) { |
| | | if (suYuanMapper.isTableExists(dr.getTableName()) > 0) { |
| | | tableNames.add(dr.getTableName()); |
| | | } |
| | | } |
| | | if (tableNames.isEmpty()) { |
| | | return result; |
| | | } |
| | | |
| | | for (MonitorPointPosition c : checkPoints) { |
| | | Map<String, Object> map = suYuanMapper.getMonthValueDataMax(tableNames, c.getId()); |
| | | if (null != map && map.size() > 0) { |
| | | String suYuanId = map.get("id").toString(); |
| | | map.put("name", commonService.select3dCheckPointById(suYuanId).getName()); |
| | | map.remove("id"); |
| | | } |
| | | result.add(map); |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | } |
| | | } |