Пример #1
0
  /**
   * 解析文件
   *
   * @ejb.interface-method
   */
  public Gnwhdkqy parseLine(String[] fields, String orgNo, String tranDate) throws Exception {
    java.util.Date tmpDate = null;
    java.sql.Date valuedate = null;
    java.sql.Date recdate = null;
    java.sql.Date maturityDate = null;
    Gnwhdkqy gnwhdkqy = new Gnwhdkqy();
    try {
      SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
      // 起息日
      tmpDate = format.parse(fields[7].replaceAll("\"", "").trim());
      valuedate = new java.sql.Date(tmpDate.getTime());
      // 到期日
      tmpDate = format.parse(fields[8].replaceAll("\"", "").trim());
      maturityDate = new java.sql.Date(tmpDate.getTime());
      // 数据接收或创建时间
      recdate = GeneralCalc.strToSQLDate(tranDate);
    } catch (Exception e) {
      System.out.println("核心传递的日期格式有误!" + e.getMessage());
      log.equals("核心传递的日期格式有误!" + e.getMessage());
    }
    try {
      gnwhdkqy.setActiontype("A"); // 操作类型
      gnwhdkqy.setActiondesc(""); // 修改、删除原因
      String hxXnBranchCode = fields[0].replaceAll("\"", "").trim(); // 核心传递的编号(包含国内金融机构标识码)
      gnwhdkqy.setCreditorcode(fields[1].replaceAll("\"", "").trim()); // 债权人代码
      gnwhdkqy.setDebtorcode(fields[2].replaceAll("\"", "").trim()); // 债务人代码
      gnwhdkqy.setDebtorname(fields[3].replaceAll("\"", "").trim()); // 债务人中文名称
      gnwhdkqy.setDofoexlotype(fields[4].replaceAll("\"", "").trim()); // 国内外汇贷款类型
      gnwhdkqy.setLenproname(fields[5].replaceAll("\"", "").trim()); // 转贷项目名称
      gnwhdkqy.setLenagree(fields[6].replaceAll("\"", "").trim()); // 转贷协议号
      gnwhdkqy.setValuedate(valuedate); // 起息日
      gnwhdkqy.setMaturity(maturityDate); // 到期日
      gnwhdkqy.setCurrence(fields[9].replaceAll("\"", "").trim()); // 贷款币种
      if (null != fields[10] || !"".equals(fields[10].replaceAll("\"", "").trim())) // 签约金额
      gnwhdkqy.setContractamount(new BigDecimal(fields[10].replaceAll("\"", "").trim()));
      if (null != fields[11] && !"".equals(fields[11].replaceAll("\"", "").trim()))
        // 根据城商联盟徐宇20130110日说,需要将核心传递的年化利率值除以100
        gnwhdkqy.setAnninrate(
            GeneralCalc.roundFormat(
                Double.parseDouble(fields[11].replaceAll("\"", "").trim()) / 100, 8)); // 年化利率值
      gnwhdkqy.setRemark(fields[12].replaceAll("\"", "").trim());
      gnwhdkqy.setHxxnwzbh(
          fields[13]
              .replaceAll("\"", "")
              .trim()); // 核心虚拟国内外汇贷款编号(不能用于申报),核心传递的用来确定唯一一条记录,方便余额、变动记录的操作
      if (null != recdate && !"".equals(recdate)) gnwhdkqy.setRecdate(recdate); // 接收/创建时间
      gnwhdkqy.setDatasources("HX"); // 数据来源(山东城商联盟)

      // 虚拟国内外汇贷款编号的第3位至14位为银行金融机构标识码
      String branchCode = hxXnBranchCode.substring(2, 14);
      // 根据金融机构标识码,获取国结机构号(采集机构)
      gnwhdkqy.setBank_Id(dao.getOrgNoByBranchCode(branchCode));
      gnwhdkqy.setDofoexlocode(
          DclNoFactory.getEXDEBTCODE(
              "gnwhdkqy", gnwhdkqy.getBank_Id(), null, "")); // 国内外汇贷款编号(核心不传递国内外汇贷款编号,国结自己生成)
      gnwhdkqy.setYwbh(gnwhdkqy.getDofoexlocode()); // 业务编号,资本项下为国内外汇贷款编号
      SerialNoFactory snf = new SerialNoFactory();
      String txnNo = snf.getSerialNo(EbpConstants.DLDCLBSCID, 16);
      gnwhdkqy.setNguid(txnNo); // 国结生成的流水号
      gnwhdkqy.setRwidh(gnwhdkqy.getNguid());
      gnwhdkqy.setSxbz("1");
      gnwhdkqy.setSfzx("Y");
      gnwhdkqy.setSfysb("N");
      gnwhdkqy.setHanddate(DataUtil.getTime(tranDate));
      return gnwhdkqy;
    } catch (Exception e) {
      e.printStackTrace();
      System.out.println("解析核心传递的国内外汇贷款签约数据有误:" + e.getMessage());
      log.equals("解析核心传递的国内外汇贷款签约数据有误:" + e.getMessage());
      throw new Exception("解析核心传递的国内外汇贷款签约数据有误:" + e.getMessage());
    }
  }