我遇到的的问题是报表统计问题,请帮忙,谢谢老大!
我遇到的的问题是报表统计问题:
jsp页面显示内容是在一个月中:以所有下单客户为行,以所有下单机种为列,把相对应的数量显示在所对应的行和列中,把数量为空的部分以“0”显示出来;以此来做一个表格统计。
现在我已经完成了:
1、我首先统计出了下单客户,并以行显示出
2、我再以客户为条件统计出了下单的机种类别,并以列显示出
3、我以相应的客户和机种也从数据库中查出了数量
现在我遇到的问题是:
1、我如何在jsp页面中把数量和它相对应的行和列联系起来显示出来,并在为空的部分显示为"0"(有的客户没有下单该机种)
我曾考虑过用map的键--值对的方式来完成,但做到一半就行不通了,就放弃了!现在请大家帮个忙分析下,谢谢!!!!
所对应代码如下:
String month_str = req.getParameter("month_str");
String cust_id = null ;
List all = null ;
List<String> jizhong_name_all = new ArrayList<String>();
List<Integer> quantity_count_all = new ArrayList<Integer>();
int quantity_count = 0 ;
try {
all = DaoFactory.getInventoryDaoImplInstance().getCustId(order_year, month_str); //得到客户ID
Iterator iter = all.iterator();
while(iter.hasNext())
{
InventorymainBean imb = (InventorymainBean)iter.next();
cust_id = imb.getCustid();
cust_shortname = DaoFactory.getCustomerDaoImplInstance().getCustomerShortName(cust_id); //得到客户简称
List list = DaoFactory.getInventoryDaoImplInstance().getJizhongName(order_year, month_str, cust_id); //由客户简称得到机种名称
Iterator iter_list = list.iterator();
while(iter_list.hasNext())
{
InventorysubBean isb = (InventorysubBean)iter_list.next();
String jizhong_name = isb.getJizhong_name();
if(jizhong_name_all.contains(jizhong_name))
{
}
else
{
jizhong_name_all.add(jizhong_name);
}
quantity_count = DaoFactory.getInventoryDaoImplInstance().getQuantityCount(order_year, month_str, cust_id, jizhong_name); //由机种名和客户得到数量统计。
quantity_count_all.add(new Integer(quantity_count));
}
cust_shortname_all.add(cust_shortname);
}
} catch (SQLException e) {
e.printStackTrace();
}
req.setAttribute("month_str", month_str);
req.setAttribute("jizhong_name_all", jizhong_name_all);
req.setAttribute("quantity_count_all", quantity_count_all);
req.setAttribute("cust_shortname_all", cust_shortname_all);
req.getRequestDispatcher("jinxiao/get_everycust_onemon_differentprod_sales_result.jsp").forward(req, resp);