public Map<String, Double> findAppMachineNumber(int appDayId, Date start, Date end) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); Map<Integer, String> map = MonitorDayAo.get().getKeyMap(); Set<Integer> keyList = new HashSet<Integer>(); for (Map.Entry<Integer, String> entry : map.entrySet()) { if (entry.getValue().startsWith("HOSTS_")) { keyList.add(entry.getKey()); } } Map<String, Double> mapMachine = new HashMap<String, Double>(); for (Integer keyId : keyList) { List<KeyValuePo> listQps = MonitorDayAo.get().findMonitorCountByDate(appDayId, keyId, start, end); for (KeyValuePo po : listQps) { String key = sdf.format(po.getCollectTime()); Double v = mapMachine.get(key); if (v == null) { mapMachine.put(key, Double.parseDouble(po.getValueStr())); } else { mapMachine.put(key, Double.parseDouble(po.getValueStr()) + v); } } } return mapMachine; }
public Map<Date, Integer> findAppHostCount(int appId, Integer[] keyIds, Date start, Date end) { Map<Date, Integer> map = new HashMap<Date, Integer>(); for (Integer keyId : keyIds) { List<KeyValuePo> list = dao.findMonitorCountByDate(appId, keyId, start, end); for (KeyValuePo po : list) { Integer n = map.get(po.getCollectTime()); if (n == null) { map.put(po.getCollectTime(), Integer.parseInt(po.getValueStr())); } else { map.put(po.getCollectTime(), n + Integer.parseInt(po.getValueStr())); } } } return map; }
public String parseCenterAppQps(Integer appId, Integer keyId, String collectTime) { SimpleDateFormat sdf1 = new SimpleDateFormat("HHmm"); List<KeyValuePo> listPo = findMonitorDataListByTime(appId, keyId, collectTime); Double aveValue = 0d; int size = 0; for (KeyValuePo po : listPo) { Date date = po.getCollectTime(); Double value = Double.parseDouble(po.getValueStr()); int time = Integer.parseInt(sdf1.format(date)); if (time >= 2030 && time <= 2230) { aveValue = Arith.add(aveValue, value); size++; } } if (size > 0) { aveValue = Arith.div(aveValue, size, 2); return aveValue.toString(); } return "0"; }