//导出xml信息
public InputStream BuildXMLDoc2(String beginDate,String endDate,String grdj,String gjdj,String fl) throws IOException {
int count = billDao.countExportBillInfo2(beginDate,endDate,grdj,gjdj,fl);//总记录数
// int count = billDao.expoertBillCount(beginDate,endDate);
// count = 150000;
int pageSize = 3000;
BDXCPageContext context = new BDXCPageContext();
context.setPageSize(pageSize);
context.setTotalNum(count);
int pageCount = context.getPageCount();
List list = null;
String sbh = billDao.getNsrsbh();
String mc = billDao.getNsrmc();
Date d = new Date(); //导出日期
SimpleDateFormat sd = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat sd2 = new SimpleDateFormat("yyyy-MM-dd");
String beginStr= "";//采集开始日期
if(beginDate !=null && !"".equals(beginDate)){
try {
Date date = sd2.parse(beginDate);
beginStr=sd.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
}
String endStr = "";//采集结束日期
if(endDate !=null && !"".equals(endDate)){
try {
Date date = sd2.parse(endDate);
endStr=sd.format(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
StringBuffer sb = new StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"GBK\"?>");
sb.append("<body>");
sb.append("<head>");
sb.append("<nsrsbh>");
sb.append(sbh);
sb.append("</nsrsbh>");
sb.append("<nsrmc>");
sb.append(mc);
sb.append("</nsrmc>");
sb.append("<dcrq>");
sb.append(sd.format(d));
sb.append("</dcrq>");
sb.append("<sssq_q>");
sb.append(beginStr);
sb.append("</sssq_q>");
sb.append("<sssq_z>");
sb.append(endStr);
sb.append("</sssq_z>");
sb.append("<records>");
sb.append(count);
sb.append("</records>");
sb.append("</head>");
sb.append("<data>");
int id = 1;
System.out.println("当前页数:"+pageCount);
for (int i = 1; i <= pageCount; i++) {
System.out.println("当前页码:" + i + ";总条数:" + count);
context.setCurrPage(i);
list = billDao.exportBillInfo2(beginDate,fl,context);//拼接字符串
for(int j = 0; j < list.size(); j++){//150000
Object[] obj = (Object[]) list.get(j);
sb.append("<record id=\"" + (id++) + "\">");
sb.append("<fpdm>");
sb.append(obj[0]);
sb.append("</fpdm>");
sb.append("<fpmc>");
sb.append("松原市热力公司发票");
sb.append("</fpmc>");
sb.append("<fphm>");
sb.append(obj[2]);
sb.append("</fphm>");
sb.append("<kprq>");
sb.append(obj[3]);
sb.append("</kprq>");
sb.append("<kplx>");
sb.append(obj[4]);
sb.append("</kplx>");
sb.append("<fkfmc>");
sb.append(obj[5]);
sb.append("</fkfmc>");
sb.append("<jehj>");
sb.append(obj[6]);
sb.append("</jehj>");;
sb.append("<yfpdm>");
sb.append(obj[7]==null?"":obj[7]+"");
sb.append("</yfpdm>");
sb.append("<yfphm>");
sb.append(obj[8]==null?"":obj[8]+"");
sb.append("</yfphm>");
sb.append("<pm>");
sb.append(obj[9]);
sb.append("</pm>");
sb.append("<dw>");
sb.append(obj[10]);
sb.append("</dw>");
sb.append("<dj>");
sb.append(obj[11]);
sb.append("</dj>");
sb.append("<sl>");
sb.append(obj[12]);
sb.append("</sl>");
sb.append("<je>");
sb.append(obj[13]);
sb.append("</je>");
sb.append("</record>");
}
}
sb.append("</data>");
sb.append("</body>");
ByteArrayInputStream is = new ByteArrayInputStream(sb.toString().getBytes("GBK")); return is; } 原文链接:https://www.f2er.com/xml/298734.html