日期:2014-05-17 浏览次数:20708 次
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8");//设置编码 //取表单数据 String mcbm=request.getParameter("mcID");//卖场编号 String beginTime=request.getParameter("chdTime1");//查询开始时间 String endTime=request.getParameter("chdTime2");//查询结束时间 System.out.println("卖场编号:"+mcbm+"查询开始时间:"+beginTime+"查询结束时间:"+endTime); String djbh=request.getParameter("dj_seqno");//要货单据编号 System.out.println("单据编号:"+djbh); //调用查询方法得到结果集 if(djbh==null){ List<CHD_Infobean> chd_Info=new ArrayList<CHD_Infobean>(); chd_Info=Search_chdBytime.search_chdBytime(mcbm, beginTime, endTime); request.setAttribute("chd_Info", chd_Info); request.getRequestDispatcher("showFiles/chdInfo_show.jsp?mcID="+mcbm+"&chdTime1="+beginTime+"&chdtime2="+endTime+"").forward(request, response); }else{ List<CHD_bean> chd=new ArrayList<CHD_bean>(); chd=Search_chdBytime.search_chdInfo(mcbm, beginTime, endTime, djbh); request.setAttribute("chd", chd); request.getRequestDispatcher("showFiles/chd_show.jsp?mcID="+mcbm+"").forward(request, response); }
//查询在一段时间里的所有要货单 public static List<CHD_Infobean> search_chdBytime(String mcbm,String beginTime,String endTime){ List<CHD_Infobean> chd_InfoArray=new ArrayList<CHD_Infobean>();//要货单集合 CHD_Infobean chd_Infobean=null;//要货单 link=DBConn.getLink();//获取连接 String sql="SELECT RIGHT(djbh,10) djbh,bdzje,COUNT(b.fhzs) bdzs" + "FROM DJ_FHD_DOC a,DJ_FHD_COM b" + "WHERE a.seqno=b.seqno AND shmc=?" + "AND shrq BETWEEN ? AND ?" + "GROUP BY a.seqno,djbh,bdzje" + "ORDER BY RIGHT(djbh,10) DESC"; try { //预编译 run=link.prepareStatement(sql); //解释预编译 run.setString(1, mcbm); run.setString(2, beginTime); run.setString(3, endTime); //获得结果集 content=run.executeQuery(); //对结果集封装 if(content.next()){ while(content.next()){ //结果集封装到实体类 chd_Infobean=new CHD_Infobean(); chd_Infobean.setSeqno(content.getString("djbh")); chd_Infobean.setCh_sum(content.getString("bdzje")); chd_Infobean.setSp_num(content.getString("bdzs")); System.out.println("单据编号:"+chd_Infobean.getSeqno()+"总金额:"+chd_Infobean.getCh_sum()+"总数:"+chd_Infobean.getSp_num()); //实体类封装到集合 chd_InfoArray.add(chd_Infobean); } }else{ return chd_InfoArray; } } catch (Exception e) { // TODO: handle exception }finally{ DBConn.closeLink(link, run, content); } return chd_InfoArray; }