Esempio n. 1
0
  public static Long getOrderTypeByTranType(Long tranType) {
    String tranTypeStr = Constant.toLong(tranType) + "";
    Long orderType = Long.valueOf(0);

    if (StringUtil.containsExistString(tranTypeStr, TRAN_TYPE_GROUP_1201, ",")) {
      orderType = Statement.ORDERTYPE_1201;
    }
    if (StringUtil.containsExistString(tranTypeStr, TRAN_TYPE_GROUP_15, ",")) {
      orderType = Statement.ORDERTYPE_15;
    }
    if (StringUtil.containsExistString(tranTypeStr, TRAN_TYPE_GROUP_1400, ",")) {
      orderType = Statement.ORDERTYPE_1400;
    }
    if (StringUtil.containsExistString(tranTypeStr, TRAN_TYPE_GROUP_1300, ",")) {
      orderType = Statement.ORDERTYPE_1300;
    }
    return orderType;
  }
Esempio n. 2
0
  private boolean executeQuery() {
    boolean returnVaue = true;
    int beginRow = 0;
    boolean moveIF = true;
    String lineOne = "";
    ResultSet rst = null;
    ResultSetMetaData rstMetaData = null;
    int columnCount = 0;
    String temp = "";
    rowNum = 0;
    if (querySQL == "") {
      writeLog("??????????");
      quickField = "";
      quickValue = "";
      quickRow = -1;
      return false;
    }
    quickRow = -1;
    try {
      if (isProcedure) {
        rst = cstmt.executeQuery();
      } else {
        if (stmt == null) init2();
        rst = stmt.executeQuery(querySQL);
      }
    } catch (Exception e) {
      writeLog(
          (new StringBuilder("??��???????"))
              .append(e.toString())
              .append(",sql=")
              .append(querySQL)
              .toString());
      try {
        if (isProcedure && cstmt != null) cstmt.close();
        else if (stmt != null) stmt.close();
      } catch (SQLException sqlexception) {
      }
      returnVaue = false;
      return returnVaue;
    }
    try {
      rst.last();
      totalRowCount = rst.getRow();
      rst.beforeFirst();
    } catch (Exception ex) {
      totalRowCount = 0;
      writeLog((new StringBuilder("??��???????")).append(ex.toString()).toString());
      return returnVaue;
    }
    pageCount = BigInteger.valueOf(totalRowCount).divide(BigInteger.valueOf(perPage)).intValue();
    if (BigInteger.valueOf(totalRowCount).mod(BigInteger.valueOf(perPage)).intValue() > 0)
      pageCount++;
    if (pageCount == 0) nextPage = 0;
    else if (nextPage > pageCount) nextPage = 0;
    beginRow = nextPage * perPage;
    beginRow++;
    curPage = nextPage;
    if (pageCount <= 1) {
      ifNext = false;
      nextPage = 0;
    } else if (nextPage > pageCount) {
      ifNext = false;
      nextPage = 0;
    } else {
      ifNext = true;
    }
    if (nextPage < 0) nextPage = 0;
    if (quickField != null
        && quickField.compareTo("") != 0
        && pageCount != 0
        && quickValue != null
        && quickValue.compareTo("") != 0)
      try {
        int colIndex = 0;
        String quickFieldName = "";
        String quickFieldType = "";
        String quickFieldTmp[] = (String[]) null;
        boolean haveFound = false;
        int findRow = 0;
        quickFieldTmp = StringUtil.split(quickField, ",");
        if (quickFieldTmp == null)
          throw new Exception((new StringBuilder("??????��??")).append(quickField).toString());
        quickFieldName = quickFieldTmp[0];
        quickFieldType = quickFieldTmp[1];
        colIndex = rst.findColumn(quickFieldName);
        rst.beforeFirst();
        while (!haveFound && rst.next()) {
          String tmpValue = "";
          if (rst.getObject(colIndex) != null) {
            tmpValue = rst.getObject(colIndex).toString();
            if (quickFieldType.compareToIgnoreCase("date") == 0) {
              int indexPos = -1;
              tmpValue = StringUtil.mk_date(tmpValue, 2);
              indexPos = tmpValue.indexOf(quickValue);
              if (indexPos == -1) {
                haveFound = false;
              } else {
                haveFound = true;
                findRow = rst.getRow();
              }
            } else if (quickFieldType.compareToIgnoreCase("long") == 0) {
              int indexPos = -1;
              indexPos = tmpValue.compareTo(quickValue);
              if (indexPos == 0) {
                haveFound = true;
                findRow = rst.getRow();
              } else {
                haveFound = false;
              }
            } else if (quickFieldType.compareToIgnoreCase("char") == 0) {
              int indexPos = -1;
              indexPos = tmpValue.indexOf(quickValue);
              if (indexPos == -1) {
                haveFound = false;
              } else {
                haveFound = true;
                findRow = rst.getRow();
              }
            }
          }
        }
        if (findRow > 0) {
          int pageTmp = 0;
          int modTmp = 0;
          pageTmp = BigInteger.valueOf(findRow).divide(BigInteger.valueOf(perPage)).intValue();
          modTmp = BigInteger.valueOf(findRow).mod(BigInteger.valueOf(perPage)).intValue();
          if (modTmp == 0) {
            nextPage = pageTmp - 1;
            quickRow = perPage;
          } else {
            nextPage = pageTmp;
            quickRow = modTmp;
          }
          beginRow = nextPage * perPage;
          beginRow++;
          curPage = nextPage;
          if (nextPage >= pageCount - 1) {
            ifNext = false;
            nextPage = 0;
          } else {
            ifNext = true;
            nextPage = nextPage + 1;
          }
        }
      } catch (Exception exx) {
        writeLog(exx.toString());
        quickRow = -1;
      }
    quickField = "";
    quickValue = "";
    try {
      rstMetaData = rst.getMetaData();
    } catch (Exception e) {
      writeLog((new StringBuilder("???????")).append(e.toString()).toString());
      returnVaue = false;
    }
    try {
      columnCount = rstMetaData.getColumnCount();
    } catch (Exception e) {
      writeLog((new StringBuilder("??��??")).append(e.toString()).toString());
      returnVaue = false;
    }
    Object object = null;
    for (int i = 1; i <= columnCount; i++)
      try {
        fieldVector.add(rstMetaData.getColumnName(i));
      } catch (Exception e) {
        writeLog(
            (new StringBuilder("Exception while getColumnName?G")).append(e.toString()).toString());
      }

    try {
      if (pageCount > 0) {
        try {
          rst.absolute(beginRow);
          moveIF = true;
        } catch (Exception exx) {
          moveIF = false;
        }
        if (moveIF) {
          for (int i = 1; i <= columnCount; i++) {
            try {
              object = rst.getObject(i);
              if (object == null) temp = "";
              else temp = object.toString();
            } catch (Exception e) {
              temp = "";
            }
            if (temp == null) temp = "";
            lineOne = (new StringBuilder(String.valueOf(lineOne))).append(temp).toString();
            valueVector.add(temp);
          }

          if (lineOne.equals("")) {
            valueVector = new ArrayList();
            rowNum = 0;
          } else {
            rowNum = 1;
          }
          for (int i = 1; i < perPage; i++)
            if (rst.next()) {
              rowNum++;
              for (int k = 1; k <= columnCount; k++) {
                try {
                  if (rst.getObject(k) == null) temp = "";
                  else temp = rst.getObject(k).toString();
                } catch (Exception e) {
                  temp = "";
                }
                if (temp == null) temp = "";
                valueVector.add(temp);
              }
            }
        }
      }
    } catch (Exception e) {
      writeLog((new StringBuilder("??????")).append(e.toString()).toString());
      returnVaue = false;
    }
    try {
      rst.close();
    } catch (Exception exception) {
    }
    try {
      if (stmt != null) stmt.close();
    } catch (Exception exception1) {
    }
    if (!returnVaue) resetBean();
    colCount = columnCount;
    close();
    return returnVaue;
  }