guanxf

我的博客:http://blog.sina.com.cn/17learning

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  71 随笔 :: 1 文章 :: 41 评论 :: 0 Trackbacks
1、主要方法:
               String startDate = req.getParameter("startDate"); 
String endDate = req.getParameter("endDate");
UserVO users = (UserVO) req.getSession().getAttribute("users");
List<ReportBaseVO> titleList = MessageCountService.titleList();  //表列
List<ReportBaseVO> mentList=MessageCountService.findMentList(users,messType); //表行
                List<ReportDataVO> dataList=MessageCountService.findData(users,messType,startDate,endDate); //数据集
Map<String,String> dataMap = ReportService.getReport(dataList); //装入Map
2、方法实现:
//0:满意 1:非常满意2:不满意 
public static List<ReportBaseVO> titleList(){
List<ReportBaseVO> list = new ArrayList<ReportBaseVO>();
ReportBaseVO vo1 = new ReportBaseVO();
vo1.setCode("0");
vo1.setName("满意");
list.add(vo1);
ReportBaseVO vo2 = new ReportBaseVO();
vo2.setCode("1");
vo2.setName("基本满意");
list.add(vo2);
ReportBaseVO vo3 = new ReportBaseVO();
vo3.setCode("2");
vo3.setName("不满意");
list.add(vo3);
return list;
}

public static List<ReportBaseVO> findMentList(UserVO users,String type){
List<ReportBaseVO> list = new ArrayList<ReportBaseVO>();
         
if((users.isHave("0") && ("1".equals(type)||type==null||"".equals(type)))||users.isHave("1") && ("1".equals(type)||type==null||"".equals(type))){
ReportBaseVO vo1 = new ReportBaseVO();
vo1.setCode("1");
vo1.setName("局长信箱");
list.add(vo1);
}
}

public static List<ReportDataVO> findData(UserVO users, String messType,String startDate,String endDate){
               List<ReportDataVO> list = new ArrayList<ReportDataVO>();
String sql="select APPRAISAL as titleId,MESS_TYPE as mentId,count(ID) as count from act_message where DELETE_FLAG='0' and APPRAISAL<>'' and MESS_TYPE='1' group by MESS_TYPE,APPRAISAL";
List<ReportDataVO> reportDataList = DBBeanUtil.execute(conn, new ReportDataVO(),sql);
list.addAll(reportDataList);
return list;
}

public static Map<String,String> getReport(List<ReportDataVO> paraList){
Map<String, String> reportMap = new HashMap<String, String>();
for(int i=0;i<paraList.size();i++){
ReportDataVO p = paraList.get(i);
reportMap.put(p.getMentId()+"_"+p.getTitleId(), String.valueOf(p.getCount()));
}
return reportMap;
}

3、遍历数据:
Map<String,String> dataMap = ReportService.getReport(dataList);
String[][] data = new String[mentList.size()][titleList.size()];
for (int i = 0; i < mentList.size(); i++) {
mentList.get(i).getName();  
int typeAll=0;
for (int j = 0; j < titleList.size(); j++) {
String dateMa=mentList.get(i).getCode()+ "_" + titleList.get(j).getCode();
//             out.print("titleList.get(j).getCode():"+titleList.get(j).getCode());
String content = dataMap.get(dateMa);//IsTurn0
if (content == null || "".equals(content)) {
content = "0";
}
data[i][j] = content;
typeAll=Integer.parseInt(content)+typeAll;
}
BigDecimal point = new BigDecimal(0);
BigDecimal mcount=new BigDecimal(data[i][0]).add(new BigDecimal(data[i][1]));//满意发布件数
BigDecimal atotal=mcount.add(new BigDecimal(data[i][2]));//共发布件数
if(atotal.compareTo(new BigDecimal(0))!=0){
point = new BigDecimal(100).multiply(mcount.divide(atotal,2, RoundingMode.HALF_UP));
}
}
posted on 2012-09-12 23:57 管先飞 阅读(334) 评论(0)  编辑  收藏 所属分类: Java技术Struts2

只有注册用户登录后才能发表评论。


网站导航: