• 交易Txt文件导出


    private void writeFYFileToTxt(List list, HttpServletRequest request, String drxh, FileOutputStream fos, String currDate, int start, int end, List<P2pLoanExtInfo> extList,List<P2pProductRate> pprList) throws APSException {
        try {
           List<P2pRepayInfo> ePriList = getConvertRepayInfoList(list, start, end);//去list中的第n到第m条数据
       
           // 生成 汇总信息  0002900F0230755|AC01|20150611|001A|425|1061199.91
           StringBuilder collectInfo = new StringBuilder(ConstantsApplication.MERCHANT_NUMBER);
           collectInfo.append("|").append(ConstantsApplication.AC_OPERATION_CODE).append("|").append(currDate);
           collectInfo.append("|").append(drxh + "A").append("|").append(ePriList.size()).append("|").append(countFYTotalAmount(ePriList));
           fos.write((collectInfo.toString() + getTxtNewLine()).getBytes());
           fos.flush();
           collectInfo = null;
           // 生成明细信息

          //000001|0105|622700182400007108X|郑红|1402.75|14569|FZ201404220042|13950316334
          //000002|0105|622700189254026136X|李丽|2104.13|15175|FZ201404230043|18605935575
         for (int i = 0; i < ePriList.size(); i++) {
            P2pRepayInfo ePri = (P2pRepayInfo) ePriList.get(i);
            StringBuilder detailInfo = new StringBuilder(StringOperator.getSeq(i + 1)); // 明细序列
            detailInfo.append("|").append(ePri.getRepayOpenBankCode());
            detailInfo.append("|").append(ePri.getRepayAccountNo()).append("|").append(ePri.getLoanName()).append("|");
            detailInfo.append(ePri.getMonthRtnAmount()).append("|").append(ePri.getPriNumber()).append("|").append(ePri.getLoanContractNo()).append       ("|").append(ePri.getLoanNamePhone());
            fos.write((detailInfo.toString() + getTxtNewLine()).getBytes());//内容自动换行
            fos.flush();//本次读取全部写入文件
            detailInfo = null;
          }
      } catch (Exception e) {
       e.printStackTrace();
      }
     }

     //获得换行符
     private String getTxtNewLine() {
      byte[] newLine = new byte[2];
      newLine[0]=0x0d;
      newLine[1]=0x0a;
      return new String(newLine);
     }

    //序列化字符串

    public static String getSeq(int seq){
      String rslt="";
      try{
       String seqStr=String.valueOf(seq);
       if(seqStr.length()==1){
        rslt="00000"+seqStr;
       }
       if(seqStr.length()==2){
        rslt="0000"+seqStr;
       }
       if(seqStr.length()==3){
        rslt="000"+seqStr;
       }
       if(seqStr.length()==4){
        rslt="00"+seqStr;
       }
       if(seqStr.length()==5){
        rslt="0"+seqStr;
       }
       if(seqStr.length()==6){
        rslt=seqStr;
       }
      }
      catch(Exception e){
       e.printStackTrace();
      }
      return rslt;
     }

  • 相关阅读:
    Cause: java.sql.SQLIntegrityConstraintViolationException: Duplicate entry '1288372549423476738' for key 'PRIMARY'
    环形数组循环
    less命令
    ln命令
    Vue中$refs的理解
    cut命令
    除数博弈
    find命令
    file命令
    最长公共前缀
  • 原文地址:https://www.cnblogs.com/Defry/p/4576886.html
Copyright © 2020-2023  润新知