jspamd的专栏

/** * 订单导出(用于统计利润) * @return */public String orderExport() throws IOException{if (queryOrderList_currentPage == null || queryOrderList_currentPage <= 0) {queryOrderList_currentPage = 1;}OrderInfo order = new OrderInfo();if (!StringUtil.isNull(queryOrderList_orderStatus)) {order.setOrderStatus(queryOrderList_orderStatus);}if (!StringUtil.isNull(queryOrderList_orderCard)) {order.setOrderCard(queryOrderList_orderCard);}if (!StringUtil.isNull(queryOrderList_memberPhone)) {order.setMemberPhone(queryOrderList_memberPhone);}if (!StringUtil.isNull(queryOrderList_memberContactsPhone)) {order.setMemberContactsPhone(queryOrderList_memberContactsPhone);}if (queryOrderList_businessId != null && queryOrderList_businessId > 0) {order.setBusinessId(queryOrderList_businessId);}if (!StringUtil.isNull(queryOrderList_addressDesc)) {order.setAddressDesc(queryOrderList_addressDesc);}if (!StringUtil.isNull(queryOrderList_beginTime) && !StringUtil.isNull(queryOrderList_endTime)) {order.setBeginTime(queryOrderList_beginTime);order.setEndTime(queryOrderList_endTime);}try {HttpServletResponse response = ServletActionContext.getResponse();queryOrderList_pageBean = statisticsService.queryOrderListByCompanyConditions(order,queryOrderList_currentPage, queryOrderList_pageSize);int totalPage = queryOrderList_pageBean.getTotalPage();response.reset();SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy-MM-dd");String fname= "订单导出"+sdFormat.format(new Date());fname=new String(fname.getBytes("GBK"),"ISO_8859_1");//文件名称{避免出现乱码}response.setHeader("Content-disposition", "attachment; filename="+fname+".csv");// 设定输出文件头response.setContentType("text/csv");response.setCharacterEncoding("UTF-8");OutputStream out = response.getOutputStream();String sep = ",";//列名for(int column=0;column<CompanyConfig.ORDER_EXPORT_COLUMN.split(",").length;column++){out.write(CompanyConfig.ORDER_EXPORT_COLUMN.split(",")[column].getBytes());out.write(sep.getBytes());}//换行符out.write(System.getProperty("line.separator").getBytes());//数据OrderInfo newOrderInfo =new OrderInfo();if(queryOrderList_pageBean.getList()!=null && queryOrderList_pageBean.getList().size()>0){for (int i = 0; i < queryOrderList_pageBean.getList().size(); i++) {newOrderInfo=(OrderInfo)queryOrderList_pageBean.getList().get(i);getOut(out,newOrderInfo,sep);}}if(totalPage>1){for (int m = 2; m <= totalPage; m++) {queryOrderList_pageBean = statisticsService.queryOrderListByCompanyConditions(order,queryOrderList_currentPage, queryOrderList_pageSize);List list =queryOrderList_pageBean.getList();if(list!=null && list.size()>0){for (int j = 0; j < list.size(); j++){OrderInfo nOrderInfo=(OrderInfo)list.get(j);getOut(out, nOrderInfo, sep);}}}}out.flush();out.close();} catch (Exception e) {e.printStackTrace();}return null;}public void getOut(OutputStream out,OrderInfo newOrderInfo,String sep) throws IOException{if(!StringUtil.isNull(newOrderInfo.getOrderCard())){out.write(String.valueOf(newOrderInfo.getOrderCard()).getBytes()); }else{out.write(String.valueOf("订单编号为空").getBytes()); }out.write((sep).getBytes());if(!StringUtil.isNull(newOrderInfo.getMemberContactsPhone())){out.write(newOrderInfo.getMemberContactsPhone().getBytes()); }else{out.write(String.valueOf("用户联系电话为空").getBytes());}out.write((sep).getBytes()); if(newOrderInfo.getAddressDesc()!=null){out.write(newOrderInfo.getAddressDesc().getBytes());}else{out.write(String.valueOf("联系地址为空").getBytes());}out.write((sep).getBytes()); if(newOrderInfo.getGenerateTime()!=null){out.write(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(newOrderInfo.getGenerateTime()).getBytes());}else{out.write(String.valueOf("下单时间为空").getBytes());}out.write(System.getProperty("line.separator").getBytes());}

,在乎的应该是沿途的风景以及看风景的心情。

jspamd的专栏

相关文章:

你感兴趣的文章:

标签云: