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> 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));
}
}