Beispiel #1
0
 @Override
 public String startAsynchronizeQuery(boolean isAsyPrint) throws Exception {
   HandleQuery0773 query = new HandleQuery0773();
   Handle0773QueryResult result = query.query(getQueryCondition());
   List<ReplacementCardItemResult> changeItems = result.getReplacementCardResult();
   if (changeItems == null || changeItems.isEmpty()) {
     return null;
   }
   // 开始生成打印的文件
   if (HdqsConstants.SHFOBZ_DOWNLOAD.equals(getQueryCondition().getShfobz())) {
     return handleDownload(result, changeItems);
   } else if (HdqsConstants.SHFOBZ_PRINT.equals(getQueryCondition().getShfobz())) { // 生成txt文档
     return handlePrint(result, changeItems);
   }
   return null;
 }
Beispiel #2
0
 private int flushTxt(
     Handle0773QueryResult result,
     TxtPrinter0773 txtCreater,
     List<ReplacementCardItemResult> pageItem,
     int pageNum)
     throws Exception {
   pageNum++;
   Page<ReplacementCardItemResult> page = new Page<ReplacementCardItemResult>();
   PageHeader header = getHeader(result.getKEHUZH(), result.getGERZWM());
   page.setHeader(header);
   header.setPageCount("" + pageNum);
   page.setPageItem(pageItem);
   page.getHeader().setTips(result.getRemark());
   try {
     txtCreater.write(page);
   } catch (Exception e) {
     throw e;
   }
   page = null;
   return pageNum;
 }
Beispiel #3
0
  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();
  }