Exemple #1
0
  /**
   * 根据结算单位,账户取账户对应的VO 拆分出来做公用方法
   *
   * @return
   */
  public static CurrtypeVO getCurrTypeVO(String pk_accid) throws BusinessException {
    StringBuffer whereClause =
        new StringBuffer()
            .append(" bd_currtype.pk_currtype = ")
            .append(" (select e.pk_currtype from bd_accid e where ")
            .append(" e.pk_accid='")
            .append(pk_accid)
            .append("')");
    SuperVO[] vos = null;
    try {
      vos = HYPubBO_Client.queryByCondition(CurrtypeVO.class, whereClause.toString());
    } catch (UifException e) {
      Logger.error(e.getMessage(), e);
      throw new BusinessException(
          nc.ui.ml.NCLangRes.getInstance().getStrByID("fbmcomm", "UPPFBMComm-000155") /*
																								 * @res
																								 * "根据结算单位和账户查询账户币种异常"
																								 */);
    }
    if (vos == null || vos.length == 0) {
      throw new BusinessException(
          nc.ui.ml.NCLangRes.getInstance().getStrByID("fbmcomm", "UPPFBMComm-000156") /*
																								 * @res
																								 * "根据结算单位和账户无法查询到账户对应币种"
																								 */);
    }
    return (CurrtypeVO) vos[0];
  }
  public void end() {
    // 处理组合单元格
    if (!mergeCells.isEmpty()) {
      Region[] regs = new Region[mergeCells.size()];
      mergeCells.values().toArray(regs);
      int len = regs.length;
      for (int i = 0; i < len; i++) m_sheet.addMergedRegion(regs[i]);
    }

    try {
      flushToFile();
    } catch (Exception e) {
      m_spool.setErrorMsg(e.getMessage());
    } finally {
      if (out != null)
        try {
          out.close();
        } catch (IOException e) {
          Logger.error(e.getMessage(), e);
        }
    }

    StringBuffer msg = new StringBuffer();
    // 最后给出完整的提示
    if (sheetCounter > 1) {
      String filename =
          m_filepath.substring(m_filepath.lastIndexOf(System.getProperty("file.separator")) + 1);
      msg.append(
          nc.ui.ml.NCLangRes.getInstance()
              .getStrByID(
                  "10100108", "UPP10100108-000856") /*@res "\n您要导出的内容太多,为减小内存的使用量,它们被存储到目录 \n"*/);
      msg.append(
          m_filepath.substring(0, m_filepath.lastIndexOf(System.getProperty("file.separator"))));
      msg.append(
          nc.ui.ml.NCLangRes.getInstance()
              .getStrByID("10100108", "UPP10100108-000857") /*@res " 下的多个Excel文件中,分别是:\n"*/);
      msg.append(filename).append(",");
      for (int i = 2; i <= sheetCounter; i++) {
        if (i != sheetCounter) {
          msg.append(filename.substring(0, filename.indexOf('.')) + "-" + i + ".xls").append(",");
        } else {
          msg.append(filename.substring(0, filename.indexOf('.')) + "-" + i + ".xls");
        }
      }
    } else {
      msg.append(
          nc.ui.ml.NCLangRes.getInstance()
                  .getStrByID("10100108", "UPP10100108-000858") /*@res "导出内容被存放在文件 \n"*/
              + m_filepath
              + nc.ui.ml.NCLangRes.getInstance()
                  .getStrByID("10100108", "UPP10100108-000859") /*@res " 中."*/);
    }

    m_spool.setMsg(msg.toString());
    mergeCells = new Hashtable(); // 存放所有组合单元格
    styles = new Hashtable();
  }
 /**
  * 设置进度条信息
  *
  * @param progressValue
  */
 private void setProgressBarHintMsg() {
   m_spool.setHintmessage(
       nc.ui.ml.NCLangRes.getInstance()
               .getStrByID("10100108", "UPP10100108-001014") /*@res "共要导出"*/
           + m_spool.getWholeLineCount()
           + nc.ui.ml.NCLangRes.getInstance()
               .getStrByID("10100108", "UPP10100108-001015") /*@res "行数据,"*/
           + nc.ui.ml.NCLangRes.getInstance()
               .getStrByID("10100108", "UPP10100108-001016") /*@res "已完成,"*/
           + m_spool.getCurrentLineCount() * 100 / m_spool.getTotalLineCount()
           + "%,");
   m_spool.setMsg(
       nc.ui.ml.NCLangRes.getInstance()
               .getStrByID("10100108", "UPP10100108-001017") /*@res "正在导出数据...已导出,"*/
           + m_spool.getExportedLineCount()
           + nc.ui.ml.NCLangRes.getInstance()
               .getStrByID("10100108", "UPP10100108-001018") /*@res "行数据,"*/);
 }
  public void run() {
    int pagesize = PAGESIZE;
    try {
      while (!m_spool.isHasError() && !m_spool.isEmpty()) {
        if (linecounter >= pagesize) {
          // 处理组合单元格
          if (!mergeCells.isEmpty()) {
            Region[] regs = new Region[mergeCells.size()];
            mergeCells.values().toArray(regs);
            int len = regs.length;
            for (int i = 0; i < len; i++) m_sheet.addMergedRegion(regs[i]);
          }
          try {
            flushToFile();
          } catch (Exception e) {
            Logger.error(e.getMessage(), e);
            m_spool.setErrorMsg(e.getMessage());
          } finally {
            if (out != null)
              try {
                out.close();
              } catch (IOException e) {
                Logger.error(e.getMessage(), e);
              }
          }

          m_workbook = new HSSFWorkbook(); // 创建工作薄
          m_sheet = m_workbook.createSheet(); // 创建表单
          mergeCells = new Hashtable(); // 存放所有组合单元格
          styles = new Hashtable();
          linecounter = 0;
          sheetCounter++;
        }

        PrintCellData[] data = null;
        data = (PrintCellData[]) m_spool.retrieve();
        linecounter = linecounter + data.length; // 其实为单元格数目,非行数

        fileUtil.exportSheet2(m_templateData, data, m_sheet, m_workbook, styles, mergeCells);

        /* 每往Excel写入一行,进度条+1,已导出的行数+1 */
        m_spool.setExportedLineCount(m_spool.getExportedLineCount() + 1);
        stepProgressBar(1);
        setProgressBarHintMsg();
      }
    } catch (Exception e) {
      Logger.error(e.getMessage(), e);
      m_spool.setErrorMsg(e.getMessage());
    } catch (OutOfMemoryError e) {
      Logger.error(e.getMessage(), e);
      m_spool.setErrorMsg(
          nc.ui.ml.NCLangRes.getInstance()
              .getStrByID(
                  "10100108", "UPP10100108-000860") /*@res "内存不足,请修改Java Plugin参数,将内存调整大一些"*/);
    }
  }
  public ButtonVO getButtonVO() {
    ButtonVO bvo = new ButtonVO();
    bvo.setBtnNo(IFBMButton.Discount_Calculate);
    bvo.setBtnChinaName("лЫожйткЦ");
    bvo.setBtnCode("DISCOUNT");
    bvo.setBtnName(
        nc.ui.ml.NCLangRes.getInstance()
            .getStrByID("fbmcomm", "UPPFBMComm-000012") /* @res"лЫожйткЦ"*/);
    bvo.setHintStr(
        nc.ui.ml.NCLangRes.getInstance()
            .getStrByID("fbmcomm", "UPPFBMComm-000012") /* @res"лЫожйткЦ"*/);
    bvo.setHotKey("D");
    bvo.setDisplayHotKey("(Shift+D)");
    bvo.setModifiers(Event.SHIFT_MASK);
    //        bvo.setOperateStatus(new int[]{IBillOperate.OP_NOTEDIT,IBillOperate.OP_INIT});
    //        bvo.setBusinessStatus(new int[]{IFBMStatus.Transact});

    return bvo;
  }
  public ButtonVO getButtonVO() {
    ButtonVO btnVo = new ButtonVO();
    btnVo.setBtnChinaName("全消");
    btnVo.setBtnName(
        nc.ui.ml.NCLangRes.getInstance().getStrByID("36201005", "UPP36201005-000030") /*
																									 * @res
																									 * "全消"
																									 */);
    btnVo.setHintStr(
        nc.ui.ml.NCLangRes.getInstance().getStrByID("36201005", "UPP36201005-000030") /*
																									 * @res
																									 * "全消"
																									 */);
    btnVo.setBtnCode("CANCELSELECT");
    btnVo.setBtnNo(IFBMButton.FBM_CANCELSELECT);
    btnVo.setOperateStatus(new int[] {IBillOperate.OP_NOTEDIT});
    btnVo.setModifiers(Event.CTRL_MASK);
    btnVo.setHotKey("N");
    btnVo.setDisplayHotKey("(Ctrl+N)");
    return btnVo;
  }
 private SortDLG getSortDlg() {
   if (sortDlg == null)
     sortDlg =
         new SortDLG(
             getReportBaseUI(),
             nc.ui.ml.NCLangRes.getInstance()
                 .getStrByID(
                     "uifactory_report", "UPPuifactory_report-000006") /* @res "ÅÅÐòÉèÖÃ" */,
             getReportBaseUI().getVisibleFields(),
             null);
   return sortDlg;
 }
 public void execute() throws Exception {
   if (getSortDlg().showModal() == UIDialog.ID_OK) {
     if (getSortDlg().getSortFields() != null) {
       String[] fields = getSortDlg().getSortFields();
       int[] asc = getSortDlg().getAscOrDesc();
       getReportBaseUI().onSort(fields, asc);
       getReportBaseUI()
           .showHintMessage(
               nc.ui.ml.NCLangRes.getInstance()
                   .getStrByID(
                       "uifactory_report", "UPPuifactory_report-000034") /* @res "ÅÅÐò³É¹¦" */);
     }
   }
 }
 /* (non-Javadoc)
  * @see nc.ui.fbm.pub.AbstractUIChecker#check()
  */
 @Override
 public String check() {
   String cctype =
       (String) getUI().getBillCardPanel().getHeadItem(RegisterVO.CCTYPE).getValueObject();
   String pk_loanbank =
       (String) getUI().getBillCardPanel().getHeadItem(RegisterVO.PK_LOANBANK).getValueObject();
   if (!cctype.equals(FbmBusConstant.CCTYPE_NONE)) {
     if (CommonUtil.isNull(pk_loanbank)) {
       return nc.ui.ml.NCLangRes.getInstance()
           .getStrByID("36201505", "UPP36201505-000002") /* @res" 使用授信额度,贷款银行不能为空"*/;
     }
   }
   return null;
 }