Exemplo n.º 1
0
  /**
   * @param systemcode 要查询的系统别 房贷/消费信贷(1/2) 数据
   * @return
   */
  public List<T100101ResponseRecord> start(String systemcode) {
    XStream xstream = new XStream(new DomDriver());
    xstream.processAnnotations(T100101Request.class);
    xstream.processAnnotations(T100101Response.class);

    T100101Request request = new T100101Request();

    request.initHeader("0100", "100101", "3");

    // 查询 房贷/消费信贷(1/2) 数据
    request.setStdcxlx(systemcode);
    int pkgcnt = 100;
    int startnum = 1;
    request.setStdymjls(String.valueOf(pkgcnt));
    // request.setStdqsjls("1");

    NewCmsManager ncm = new NewCmsManager();

    List<T100101ResponseRecord> responseList = new ArrayList();
    int totalcount = processTxn(responseList, ncm, xstream, request, pkgcnt, startnum);
    logger.info("received list zise:" + responseList.size());
    if (totalcount != responseList.size()) {
      logger.error("获取还款数据笔数有误!应收笔数:" + responseList.size() + "实收笔数:" + totalcount);
      throw new RuntimeException("获取还款数据笔数有误.");
    }
    return responseList;
  }
Exemplo n.º 2
0
  /**
   * 递归获取服务器数据
   *
   * @param responseList
   * @param ncm
   * @param xstream
   * @param request
   * @param pkgcnt
   * @param startnum
   * @return
   */
  public int processTxn(
      List<T100101ResponseRecord> responseList,
      NewCmsManager ncm,
      XStream xstream,
      T100101Request request,
      int pkgcnt,
      int startnum) {

    // 查询 房贷/消费信贷(1/2) 数据
    request.setStdqsjls(String.valueOf(startnum));

    String strXml = "<?xml version=\"1.0\" encoding=\"GBK\"?>" + "\n" + xstream.toXML(request);
    // System.out.println(strXml);

    // 发送请求
    String responseBody = ncm.doPostXml(strXml);

    T100101Response response = (T100101Response) xstream.fromXML(responseBody);

    // 头部总记录数
    String std400acur = response.getStd400acur();
    if (std400acur == null || std400acur == "") {
      std400acur = "0";
    }
    int totalcount = Integer.parseInt(std400acur);

    if (totalcount == 0) {

    } else {
      List<T100101ResponseRecord> tmpList = response.getBody().getContent();

      int currCnt = tmpList.size();
      logger.info(currCnt);
      logger.info("totalcount:" + totalcount + " currCnt:" + currCnt + " startnum:" + startnum);

      // 打包到返回list中
      for (T100101ResponseRecord record : tmpList) {
        responseList.add(record);
      }

      // 一个包不可以处理完
      if (totalcount > pkgcnt) {
        startnum += pkgcnt;
        if (startnum <= totalcount) {
          processTxn(responseList, ncm, xstream, request, pkgcnt, startnum);
        }
      }
    }

    // uploadCutpayResultBatch(response.getBody().getContent());
    return totalcount;
  }