private String handleDownload( Handle0773QueryResult result, List<ReplacementCardItemResult> changeItems) throws Exception { QueryDocumentContext document = new QueryDocumentContext(); String outputDir = QueryMethodUtils.generateOutputDir(getQueryCondition()); getLog().debug("查询任务的输入出目录是" + outputDir); getQueryCondition() .setPdfFile(outputDir + File.separator + getQueryCondition().getSlbhao() + ".pdf"); PDFMaker pdfMaker = new PdfMaker0773(getQueryCondition(), document); List<ReplacementCardItemResult> pageItem = new ArrayList<ReplacementCardItemResult>(); int itemNum = QueryConfUtils.getActiveConfig().getInt(QueryConstants.HANDLE_LINE_PER_PAGE, 35); int pageNum = 0; for (ReplacementCardItemResult item : changeItems) { pageItem.add(item); if (pageItem.size() != 0 && pageItem.size() % itemNum == 0) { pageNum++; Page<ReplacementCardItemResult> page = new Page<ReplacementCardItemResult>(); PageHeader header = getHeader(result.getKEHUZH(), result.getGERZWM()); header.setPageCount("" + pageNum); page.setHeader(header); header.setGuiyuan(getQueryCondition().getJio1gy()); page.setPageItem(pageItem); page.getHeader().setTips(result.getRemark()); try { pdfMaker.write(page); } catch (NeedNewDocumentException nDocEx) { getLog().info("需要创建新文档"); createNewDocument(getQueryCondition()); } page = null; } } if (pageItem.size() != 0) { pageNum++; Page<ReplacementCardItemResult> page = new Page<ReplacementCardItemResult>(); PageHeader header = getHeader(result.getKEHUZH(), result.getGERZWM()); header.setPageCount("" + pageNum); page.setHeader(header); page.setPageItem(pageItem); page.getHeader().setTips(result.getRemark()); try { pdfMaker.write(page); } catch (NeedNewDocumentException nDocEx) { getLog().info("需要创建新文档"); pdfMaker = new PdfMaker0773(getQueryCondition(), document); } page = null; } pdfMaker.endHtml(); pdfMaker.makePdf(); getQueryCondition().setPdfFile(document.getCurrentPDF().getFileName()); return getQueryCondition().getPdfFile(); }
private String handlePrint( Handle0773QueryResult result, List<ReplacementCardItemResult> changeItems) throws Exception { getLog().debug("开始生成TXT文档."); TxtPrinter0773 txtCreater = new TxtPrinter0773(getQueryCondition()); getLog().debug("TXT文档的输出路径是:" + txtCreater.getTxtFile()); List<ReplacementCardItemResult> pageItem = new ArrayList<ReplacementCardItemResult>(); int itemNum = QueryConfUtils.getActiveConfig().getInt(QueryConstants.PRINT_TXT_LINE_PER_PAGE, 20); int pageNum = 0; for (ReplacementCardItemResult item : changeItems) { pageItem.add(item); if (pageItem.size() != 0 && pageItem.size() % itemNum == 0) { flushTxt(result, txtCreater, pageItem, pageNum); } } if (pageItem.size() != 0) { flushTxt(result, txtCreater, pageItem, pageNum); } return txtCreater.getTxtFile(); }