📄 resitemresbo.java
字号:
package com.asiainfo.ainx.slaconf.bo;
import java.util.ArrayList;
import java.util.HashMap;
import com.asiainfo.ainx.slaconf.dao.ResItemResDAO;
import com.asiainfo.ainx.slaconf.vo.*;
import org.apache.log4j.Logger;
/**
*
* @author qihong
*
*/
public class ResItemResBO {
private static Logger log = Logger
.getLogger("com.asiainfo.ainx.slaconf.bo.ResItemResBO");
/**
* @description: AutoCode 获取表单纪录的列表
*
* @return
* @throws java.lang.Exception
*/
public ArrayList getResInfo()
throws Exception {
/**
* 创建 DAO 对象
*/
ResItemResDAO nodedao = new ResItemResDAO();
/**
* 获取表单记录列表
*/
ArrayList col = nodedao.getResItemResource();
return col;
}
/**
* 获取资源指标状态信息
* @return
* @throws Exception
*/
public HashMap getResStatusInfo(int userid, String resType, String filterType)
throws Exception {
/**
* 创建 DAO 对象
*/
ResItemResDAO nodedao = new ResItemResDAO();
/**
* 获取表单记录列表
*/
ArrayList col = nodedao.getResStatusList(userid,resType, filterType);
/**
* 将资源指标列表整理为按照资源排列的列表
*/
HashMap map = new HashMap();
try{
for(int i =0; i < col.size(); i++){
ResItemVO itemVO =(ResItemVO)col.get(i);
String resid = String.valueOf(itemVO.getResId());
if(map.containsKey(resid)){
/**
* hashmap中已经存在资源指标项,将新的指标项添加在itemMap
*/
SlaResItemStatusVO resVO = (SlaResItemStatusVO)map.get(resid);
HashMap itemMap = resVO.getItemMap();
String itemid = String.valueOf(itemVO.getItemId());
itemMap.put(itemid,itemVO);
resVO.setItemMap(itemMap);
map.put(resid, resVO);
}else{
/**
* hashmap中不存在该资源的指标,新增指标到map,并填写资源信息
*/
SlaResItemStatusVO resVO = new SlaResItemStatusVO();
resVO.setResId(resid);
resVO.setResName(itemVO.getResname());
resVO.setParam(itemVO.getParam());
resVO.setCurTime(itemVO.getCurtime());
HashMap itemMap = new HashMap();
String itemid = String.valueOf(itemVO.getItemId());
itemMap.put(itemid, itemVO);
resVO.setItemMap(itemMap);
map.put(resid, resVO);
}
}
}catch(Exception e){
e.printStackTrace();
}
System.out.println("map.size="+map.size());
return map;
}
public static void main(String args[]){
ResItemResBO bo = new ResItemResBO();
try{
log.info("get 3 info");
HashMap map = bo.getResStatusInfo(0,"3","");
Object[] array = map.values().toArray();
String line="\n";
if(array!=null){
for(int i =0; i < array.length; i++){
SlaResItemStatusVO vo =(SlaResItemStatusVO)array[i];
line += vo.getResName()+",";
line += vo.getParam()+",";
line += vo.getCurTime()+",";
Object[] items = vo.getItemMap().values().toArray();
for(int j =0; j < items.length; j++){
ResItemVO itemvo = (ResItemVO)items[j];
line+=itemvo.getItemname()+",";
line+=itemvo.getCurstatus()+",";
line+=itemvo.getCurvalue()+",";
}
line+="\n";
}
}
log.info("line="+line);
}catch(Exception e){
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -