Example #1
0
 /**
  * 采用批方式插入多条数据
  *
  * @param collection collection
  * @throws Exception
  */
 public void insertAll(Collection collection) throws Exception {
   StringBuffer buffer = new StringBuffer(200);
   buffer.append("INSERT INTO LineLoss (");
   buffer.append("LineCode,");
   buffer.append("R,");
   buffer.append("LineLong,");
   buffer.append("Volt,");
   buffer.append("T,");
   buffer.append("ValidStatus,");
   buffer.append("Flag,");
   buffer.append("Remark ");
   buffer.append(") ");
   buffer.append("VALUES(?,?,?,?,?,?,?,?)");
   if (logger.isDebugEnabled()) {
     logger.debug(buffer.toString());
   }
   dbManager.prepareStatement(buffer.toString());
   for (Iterator i = collection.iterator(); i.hasNext(); ) {
     LineLossDto lineLossDto = (LineLossDto) i.next();
     dbManager.setString(1, lineLossDto.getLineCode());
     dbManager.setDouble(2, lineLossDto.getR());
     dbManager.setDouble(3, lineLossDto.getLineLong());
     dbManager.setDouble(4, lineLossDto.getVolt());
     dbManager.setDouble(5, lineLossDto.getT());
     dbManager.setString(6, lineLossDto.getValidStatus());
     dbManager.setString(7, lineLossDto.getFlag());
     dbManager.setString(8, lineLossDto.getRemark());
     dbManager.addBatch();
   }
   dbManager.executePreparedUpdateBatch();
 }
 /**
  * 采用批方式插入多条数据
  *
  * @param collection collection
  * @throws Exception
  */
 public void insertAll(Collection collection) throws Exception {
   StringBuffer buffer = new StringBuffer(200);
   buffer.append("INSERT INTO LwWholeSalePrice (");
   buffer.append("PowerClass,");
   buffer.append("SaleArea,");
   buffer.append("VoltageBegin,");
   buffer.append("VoltageEnd,");
   buffer.append("Price,");
   buffer.append("ValidStatus,");
   buffer.append("Flag,");
   buffer.append("Remark ");
   buffer.append(") ");
   buffer.append("VALUES(?,?,?,?,?,?,?,?)");
   if (logger.isDebugEnabled()) {
     logger.debug(buffer.toString());
   }
   dbManager.prepareStatement(buffer.toString());
   for (Iterator i = collection.iterator(); i.hasNext(); ) {
     LwWholeSalePriceDto lwWholeSalePriceDto = (LwWholeSalePriceDto) i.next();
     dbManager.setString(1, lwWholeSalePriceDto.getPowerClass());
     dbManager.setString(2, lwWholeSalePriceDto.getSaleArea());
     dbManager.setDouble(3, lwWholeSalePriceDto.getVoltageBegin());
     dbManager.setDouble(4, lwWholeSalePriceDto.getVoltageEnd());
     dbManager.setDouble(5, lwWholeSalePriceDto.getPrice());
     dbManager.setString(6, lwWholeSalePriceDto.getValidStatus());
     dbManager.setString(7, lwWholeSalePriceDto.getFlag());
     dbManager.setString(8, lwWholeSalePriceDto.getRemark());
     dbManager.addBatch();
   }
   dbManager.executePreparedUpdateBatch();
 }
  /**
   * 按条件查询多条数据
   *
   * @param conditions 查询条件
   * @param pageNo 页号
   * @param rowsPerPage 每页的行数
   * @return Collection
   * @throws Exception
   */
  public Collection findByConditions(String conditions, int pageNo, int rowsPerPage)
      throws Exception {
    StringBuffer buffer = new StringBuffer(200);
    // 拼SQL语句
    buffer.append("SELECT ");
    buffer.append("LineCode,");
    buffer.append("StatMonth,");
    buffer.append("PowerClass,");
    buffer.append("ElectricQuantity,");
    buffer.append("PointerQuantity,");
    buffer.append("SanXiaFee,");
    buffer.append("Surcharge,");
    buffer.append("SumFee,");
    buffer.append("ValidStatus,");
    buffer.append("Flag,");
    buffer.append("Remark,");
    buffer.append("TransLoss,");
    buffer.append("LineLoss,");
    buffer.append("UnPointerQuantity,");
    buffer.append("RateCode,");
    buffer.append("AdjustRate,");
    buffer.append("FarmUseScale,");
    buffer.append("FarmUsePrice,");
    buffer.append("FarmUseQuantity,");
    buffer.append("FarmUseFee,");
    buffer.append("ProductScale,");
    buffer.append("ProductPrice,");
    buffer.append("ProductQuantity,");
    buffer.append("ProductFee,");
    buffer.append("DenizenScale,");
    buffer.append("DenizenPrice,");
    buffer.append("DenizenQuantity,");
    buffer.append("DenizenFee,");
    buffer.append("UnDenizenScale,");
    buffer.append("UnDenizenPrice,");
    buffer.append("UnDenizenQuantity,");
    buffer.append("UnDenizenFee,");
    buffer.append("IndustryScale,");
    buffer.append("IndustryPrice,");
    buffer.append("IndustryQuantity,");
    buffer.append("IndustryFee,");
    buffer.append("BizScale,");
    buffer.append("BizPrice,");
    buffer.append("BizQuantity,");
    buffer.append("BizFee,");
    buffer.append("PowerRateFee,");
    buffer.append("UpCompany,");
    buffer.append("PowerFee,");
    buffer.append("InputDate,");
    buffer.append("Kv,");
    buffer.append("Wholesaletype,");
    buffer.append("WorkNum,");
    buffer.append("UnWorkNum,");
    buffer.append("OtherSurcharge,");
    buffer.append("DifferenceQuantity,");
    buffer.append("UnTransLoss,");
    buffer.append("UnLineLoss ");
    buffer.append("FROM LwWholeSaleSummary WHERE ");
    buffer.append(conditions);
    boolean supportPaging = false; // 数据库是否支持分页
    if (pageNo > 0) {
      // 对Oracle优化
      if (dbManager
          .getConnection()
          .getMetaData()
          .getDatabaseProductName()
          .equalsIgnoreCase("Oracle")) {
        buffer.insert(0, "SELECT * FROM ( SELECT row_.*, rownum rownum_ FROM (");
        buffer.append(
            ") row_ WHERE rownum <= "
                + rowsPerPage * pageNo
                + ") WHERE rownum_ > "
                + rowsPerPage * (pageNo - 1));
        supportPaging = true;
      } else if (dbManager
          .getConnection()
          .getMetaData()
          .getDatabaseProductName()
          .equalsIgnoreCase("DB2")) {
        String sql = buffer.toString();
        buffer.setLength(0);
        buffer.append("select * from ( select rownumber() over(");
        int orderByIndex = sql.toLowerCase().indexOf("order by");
        if (orderByIndex > 0) {
          buffer.append(sql.substring(orderByIndex));
        }
        buffer.append(") as rownumber_,");
        buffer.append(sql.substring(6));
        buffer.append(" ) as temp_ where rownumber_");
        buffer.append(
            " between " + (rowsPerPage * (pageNo - 1) + 1) + " and " + rowsPerPage * pageNo);
        supportPaging = true;
      }
    }
    if (logger.isDebugEnabled()) {
      logger.debug(buffer.toString());
    }
    ResultSet resultSet = dbManager.executeQuery(buffer.toString());
    int count = 0;
    if (supportPaging == false && pageNo > 1) {
      dbManager.locate(resultSet, rowsPerPage * (pageNo - 1));
    }

    // 定义返回结果集合
    Collection collection = new ArrayList(rowsPerPage);
    LwWholeSaleSummaryDto lwWholeSaleSummaryDto = null;
    while (resultSet.next()) {
      if (supportPaging == false && pageNo > 0) {
        count++;
        if (count > rowsPerPage) {
          break;
        }
      }

      lwWholeSaleSummaryDto = new LwWholeSaleSummaryDto();
      lwWholeSaleSummaryDto.setLineCode(dbManager.getString(resultSet, "LineCode"));
      lwWholeSaleSummaryDto.setStatMonth(dbManager.getString(resultSet, "StatMonth"));
      lwWholeSaleSummaryDto.setPowerClass(dbManager.getString(resultSet, "PowerClass"));
      lwWholeSaleSummaryDto.setElectricQuantity(dbManager.getDouble(resultSet, "ElectricQuantity"));
      lwWholeSaleSummaryDto.setPointerQuantity(dbManager.getDouble(resultSet, "PointerQuantity"));
      lwWholeSaleSummaryDto.setSanXiaFee(dbManager.getDouble(resultSet, "SanXiaFee"));
      lwWholeSaleSummaryDto.setSurcharge(dbManager.getDouble(resultSet, "Surcharge"));
      lwWholeSaleSummaryDto.setSumFee(dbManager.getDouble(resultSet, "SumFee"));
      lwWholeSaleSummaryDto.setValidStatus(dbManager.getString(resultSet, "ValidStatus"));
      lwWholeSaleSummaryDto.setFlag(dbManager.getString(resultSet, "Flag"));
      lwWholeSaleSummaryDto.setRemark(dbManager.getString(resultSet, "Remark"));
      lwWholeSaleSummaryDto.setTransLoss(dbManager.getDouble(resultSet, "TransLoss"));
      lwWholeSaleSummaryDto.setLineLoss(dbManager.getDouble(resultSet, "LineLoss"));
      lwWholeSaleSummaryDto.setUnPointerQuantity(
          dbManager.getDouble(resultSet, "UnPointerQuantity"));
      lwWholeSaleSummaryDto.setRateCode(dbManager.getDouble(resultSet, "RateCode"));
      lwWholeSaleSummaryDto.setAdjustRate(dbManager.getDouble(resultSet, "AdjustRate"));
      lwWholeSaleSummaryDto.setFarmUseScale(dbManager.getDouble(resultSet, "FarmUseScale"));
      lwWholeSaleSummaryDto.setFarmUsePrice(dbManager.getDouble(resultSet, "FarmUsePrice"));
      lwWholeSaleSummaryDto.setFarmUseQuantity(dbManager.getDouble(resultSet, "FarmUseQuantity"));
      lwWholeSaleSummaryDto.setFarmUseFee(dbManager.getDouble(resultSet, "FarmUseFee"));
      lwWholeSaleSummaryDto.setProductScale(dbManager.getDouble(resultSet, "ProductScale"));
      lwWholeSaleSummaryDto.setProductPrice(dbManager.getDouble(resultSet, "ProductPrice"));
      lwWholeSaleSummaryDto.setProductQuantity(dbManager.getDouble(resultSet, "ProductQuantity"));
      lwWholeSaleSummaryDto.setProductFee(dbManager.getDouble(resultSet, "ProductFee"));
      lwWholeSaleSummaryDto.setDenizenScale(dbManager.getDouble(resultSet, "DenizenScale"));
      lwWholeSaleSummaryDto.setDenizenPrice(dbManager.getDouble(resultSet, "DenizenPrice"));
      lwWholeSaleSummaryDto.setDenizenQuantity(dbManager.getDouble(resultSet, "DenizenQuantity"));
      lwWholeSaleSummaryDto.setDenizenFee(dbManager.getDouble(resultSet, "DenizenFee"));
      lwWholeSaleSummaryDto.setUnDenizenScale(dbManager.getDouble(resultSet, "UnDenizenScale"));
      lwWholeSaleSummaryDto.setUnDenizenPrice(dbManager.getDouble(resultSet, "UnDenizenPrice"));
      lwWholeSaleSummaryDto.setUnDenizenQuantity(
          dbManager.getDouble(resultSet, "UnDenizenQuantity"));
      lwWholeSaleSummaryDto.setUnDenizenFee(dbManager.getDouble(resultSet, "UnDenizenFee"));
      lwWholeSaleSummaryDto.setIndustryScale(dbManager.getDouble(resultSet, "IndustryScale"));
      lwWholeSaleSummaryDto.setIndustryPrice(dbManager.getDouble(resultSet, "IndustryPrice"));
      lwWholeSaleSummaryDto.setIndustryQuantity(dbManager.getDouble(resultSet, "IndustryQuantity"));
      lwWholeSaleSummaryDto.setIndustryFee(dbManager.getDouble(resultSet, "IndustryFee"));
      lwWholeSaleSummaryDto.setBizScale(dbManager.getDouble(resultSet, "BizScale"));
      lwWholeSaleSummaryDto.setBizPrice(dbManager.getDouble(resultSet, "BizPrice"));
      lwWholeSaleSummaryDto.setBizQuantity(dbManager.getDouble(resultSet, "BizQuantity"));
      lwWholeSaleSummaryDto.setBizFee(dbManager.getDouble(resultSet, "BizFee"));
      lwWholeSaleSummaryDto.setPowerRateFee(dbManager.getDouble(resultSet, "PowerRateFee"));
      lwWholeSaleSummaryDto.setUpCompany(dbManager.getString(resultSet, "UpCompany"));
      lwWholeSaleSummaryDto.setPowerFee(dbManager.getDouble(resultSet, "PowerFee"));
      lwWholeSaleSummaryDto.setInputDate(dbManager.getString(resultSet, "InputDate"));
      lwWholeSaleSummaryDto.setKv(dbManager.getString(resultSet, "Kv"));
      lwWholeSaleSummaryDto.setWholesaletype(dbManager.getString(resultSet, "Wholesaletype"));
      lwWholeSaleSummaryDto.setWorkNum(dbManager.getDouble(resultSet, "WorkNum"));
      lwWholeSaleSummaryDto.setUnWorkNum(dbManager.getDouble(resultSet, "UnWorkNum"));
      lwWholeSaleSummaryDto.setOtherSurcharge(dbManager.getDouble(resultSet, "OtherSurcharge"));
      lwWholeSaleSummaryDto.setDifferenceQuantity(
          dbManager.getString(resultSet, "DifferenceQuantity"));
      lwWholeSaleSummaryDto.setUnTransLoss(dbManager.getDouble(resultSet, "UnTransLoss"));
      lwWholeSaleSummaryDto.setUnLineLoss(dbManager.getDouble(resultSet, "UnLineLoss"));
      collection.add(lwWholeSaleSummaryDto);
    }
    resultSet.close();
    return collection;
  }
 /**
  * 采用批方式插入多条数据
  *
  * @param collection collection
  * @throws Exception
  */
 public void insertAll(Collection collection) throws Exception {
   StringBuffer buffer = new StringBuffer(200);
   buffer.append("INSERT INTO LwWholeSaleSummary (");
   buffer.append("LineCode,");
   buffer.append("StatMonth,");
   buffer.append("PowerClass,");
   buffer.append("ElectricQuantity,");
   buffer.append("PointerQuantity,");
   buffer.append("SanXiaFee,");
   buffer.append("Surcharge,");
   buffer.append("SumFee,");
   buffer.append("ValidStatus,");
   buffer.append("Flag,");
   buffer.append("Remark,");
   buffer.append("TransLoss,");
   buffer.append("LineLoss,");
   buffer.append("UnPointerQuantity,");
   buffer.append("RateCode,");
   buffer.append("AdjustRate,");
   buffer.append("FarmUseScale,");
   buffer.append("FarmUsePrice,");
   buffer.append("FarmUseQuantity,");
   buffer.append("FarmUseFee,");
   buffer.append("ProductScale,");
   buffer.append("ProductPrice,");
   buffer.append("ProductQuantity,");
   buffer.append("ProductFee,");
   buffer.append("DenizenScale,");
   buffer.append("DenizenPrice,");
   buffer.append("DenizenQuantity,");
   buffer.append("DenizenFee,");
   buffer.append("UnDenizenScale,");
   buffer.append("UnDenizenPrice,");
   buffer.append("UnDenizenQuantity,");
   buffer.append("UnDenizenFee,");
   buffer.append("IndustryScale,");
   buffer.append("IndustryPrice,");
   buffer.append("IndustryQuantity,");
   buffer.append("IndustryFee,");
   buffer.append("BizScale,");
   buffer.append("BizPrice,");
   buffer.append("BizQuantity,");
   buffer.append("BizFee,");
   buffer.append("PowerRateFee,");
   buffer.append("UpCompany,");
   buffer.append("PowerFee,");
   buffer.append("InputDate,");
   buffer.append("Kv,");
   buffer.append("Wholesaletype,");
   buffer.append("WorkNum,");
   buffer.append("UnWorkNum,");
   buffer.append("OtherSurcharge,");
   buffer.append("DifferenceQuantity,");
   buffer.append("UnTransLoss,");
   buffer.append("UnLineLoss ");
   buffer.append(") ");
   buffer.append(
       "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
   if (logger.isDebugEnabled()) {
     logger.debug(buffer.toString());
   }
   dbManager.prepareStatement(buffer.toString());
   for (Iterator i = collection.iterator(); i.hasNext(); ) {
     LwWholeSaleSummaryDto lwWholeSaleSummaryDto = (LwWholeSaleSummaryDto) i.next();
     dbManager.setString(1, lwWholeSaleSummaryDto.getLineCode());
     dbManager.setString(2, lwWholeSaleSummaryDto.getStatMonth());
     dbManager.setString(3, lwWholeSaleSummaryDto.getPowerClass());
     dbManager.setDouble(4, lwWholeSaleSummaryDto.getElectricQuantity());
     dbManager.setDouble(5, lwWholeSaleSummaryDto.getPointerQuantity());
     dbManager.setDouble(6, lwWholeSaleSummaryDto.getSanXiaFee());
     dbManager.setDouble(7, lwWholeSaleSummaryDto.getSurcharge());
     dbManager.setDouble(8, lwWholeSaleSummaryDto.getSumFee());
     dbManager.setString(9, lwWholeSaleSummaryDto.getValidStatus());
     dbManager.setString(10, lwWholeSaleSummaryDto.getFlag());
     dbManager.setString(11, lwWholeSaleSummaryDto.getRemark());
     dbManager.setDouble(12, lwWholeSaleSummaryDto.getTransLoss());
     dbManager.setDouble(13, lwWholeSaleSummaryDto.getLineLoss());
     dbManager.setDouble(14, lwWholeSaleSummaryDto.getUnPointerQuantity());
     dbManager.setDouble(15, lwWholeSaleSummaryDto.getRateCode());
     dbManager.setDouble(16, lwWholeSaleSummaryDto.getAdjustRate());
     dbManager.setDouble(17, lwWholeSaleSummaryDto.getFarmUseScale());
     dbManager.setDouble(18, lwWholeSaleSummaryDto.getFarmUsePrice());
     dbManager.setDouble(19, lwWholeSaleSummaryDto.getFarmUseQuantity());
     dbManager.setDouble(20, lwWholeSaleSummaryDto.getFarmUseFee());
     dbManager.setDouble(21, lwWholeSaleSummaryDto.getProductScale());
     dbManager.setDouble(22, lwWholeSaleSummaryDto.getProductPrice());
     dbManager.setDouble(23, lwWholeSaleSummaryDto.getProductQuantity());
     dbManager.setDouble(24, lwWholeSaleSummaryDto.getProductFee());
     dbManager.setDouble(25, lwWholeSaleSummaryDto.getDenizenScale());
     dbManager.setDouble(26, lwWholeSaleSummaryDto.getDenizenPrice());
     dbManager.setDouble(27, lwWholeSaleSummaryDto.getDenizenQuantity());
     dbManager.setDouble(28, lwWholeSaleSummaryDto.getDenizenFee());
     dbManager.setDouble(29, lwWholeSaleSummaryDto.getUnDenizenScale());
     dbManager.setDouble(30, lwWholeSaleSummaryDto.getUnDenizenPrice());
     dbManager.setDouble(31, lwWholeSaleSummaryDto.getUnDenizenQuantity());
     dbManager.setDouble(32, lwWholeSaleSummaryDto.getUnDenizenFee());
     dbManager.setDouble(33, lwWholeSaleSummaryDto.getIndustryScale());
     dbManager.setDouble(34, lwWholeSaleSummaryDto.getIndustryPrice());
     dbManager.setDouble(35, lwWholeSaleSummaryDto.getIndustryQuantity());
     dbManager.setDouble(36, lwWholeSaleSummaryDto.getIndustryFee());
     dbManager.setDouble(37, lwWholeSaleSummaryDto.getBizScale());
     dbManager.setDouble(38, lwWholeSaleSummaryDto.getBizPrice());
     dbManager.setDouble(39, lwWholeSaleSummaryDto.getBizQuantity());
     dbManager.setDouble(40, lwWholeSaleSummaryDto.getBizFee());
     dbManager.setDouble(41, lwWholeSaleSummaryDto.getPowerRateFee());
     dbManager.setString(42, lwWholeSaleSummaryDto.getUpCompany());
     dbManager.setDouble(43, lwWholeSaleSummaryDto.getPowerFee());
     dbManager.setString(44, lwWholeSaleSummaryDto.getInputDate());
     dbManager.setString(45, lwWholeSaleSummaryDto.getKv());
     dbManager.setString(46, lwWholeSaleSummaryDto.getWholesaletype());
     dbManager.setDouble(47, lwWholeSaleSummaryDto.getWorkNum());
     dbManager.setDouble(48, lwWholeSaleSummaryDto.getUnWorkNum());
     dbManager.setDouble(49, lwWholeSaleSummaryDto.getOtherSurcharge());
     dbManager.setString(50, lwWholeSaleSummaryDto.getDifferenceQuantity());
     dbManager.setDouble(51, lwWholeSaleSummaryDto.getUnTransLoss());
     dbManager.setDouble(52, lwWholeSaleSummaryDto.getUnLineLoss());
     dbManager.addBatch();
   }
   dbManager.executePreparedUpdateBatch();
 }
Example #5
0
  /**
   * 按条件查询多条数据
   *
   * @param conditions 查询条件
   * @param pageNo 页号
   * @param rowsPerPage 每页的行数
   * @return Collection
   * @throws Exception
   */
  public Collection findByConditions(String conditions, int pageNo, int rowsPerPage)
      throws Exception {
    StringBuffer buffer = new StringBuffer(200);
    // 拼SQL语句
    buffer.append("SELECT ");
    buffer.append("LineCode,");
    buffer.append("R,");
    buffer.append("LineLong,");
    buffer.append("Volt,");
    buffer.append("T,");
    buffer.append("ValidStatus,");
    buffer.append("Flag,");
    buffer.append("Remark ");
    buffer.append("FROM LineLoss WHERE ");
    buffer.append(conditions);
    boolean supportPaging = false; // 数据库是否支持分页
    if (pageNo > 0) {
      // 对Oracle优化
      if (dbManager
          .getConnection()
          .getMetaData()
          .getDatabaseProductName()
          .equalsIgnoreCase("Oracle")) {
        buffer.insert(0, "SELECT * FROM ( SELECT row_.*, rownum rownum_ FROM (");
        buffer.append(
            ") row_ WHERE rownum <= "
                + rowsPerPage * pageNo
                + ") WHERE rownum_ > "
                + rowsPerPage * (pageNo - 1));
        supportPaging = true;
      } else if (dbManager
          .getConnection()
          .getMetaData()
          .getDatabaseProductName()
          .equalsIgnoreCase("DB2")) {
        String sql = buffer.toString();
        buffer.setLength(0);
        buffer.append("select * from ( select rownumber() over(");
        int orderByIndex = sql.toLowerCase().indexOf("order by");
        if (orderByIndex > 0) {
          buffer.append(sql.substring(orderByIndex));
        }
        buffer.append(") as rownumber_,");
        buffer.append(sql.substring(6));
        buffer.append(" ) as temp_ where rownumber_");
        buffer.append(
            " between " + (rowsPerPage * (pageNo - 1) + 1) + " and " + rowsPerPage * pageNo);
        supportPaging = true;
      }
    }
    if (logger.isDebugEnabled()) {
      logger.debug(buffer.toString());
    }
    ResultSet resultSet = dbManager.executeQuery(buffer.toString());
    int count = 0;
    if (supportPaging == false && pageNo > 1) {
      dbManager.locate(resultSet, rowsPerPage * (pageNo - 1));
    }

    // 定义返回结果集合
    Collection collection = new ArrayList(rowsPerPage);
    LineLossDto lineLossDto = null;
    while (resultSet.next()) {
      if (supportPaging == false && pageNo > 0) {
        count++;
        if (count > rowsPerPage) {
          break;
        }
      }

      lineLossDto = new LineLossDto();
      lineLossDto.setLineCode(dbManager.getString(resultSet, "LineCode"));
      lineLossDto.setR(dbManager.getDouble(resultSet, "R"));
      lineLossDto.setLineLong(dbManager.getDouble(resultSet, "LineLong"));
      lineLossDto.setVolt(dbManager.getDouble(resultSet, "Volt"));
      lineLossDto.setT(dbManager.getDouble(resultSet, "T"));
      lineLossDto.setValidStatus(dbManager.getString(resultSet, "ValidStatus"));
      lineLossDto.setFlag(dbManager.getString(resultSet, "Flag"));
      lineLossDto.setRemark(dbManager.getString(resultSet, "Remark"));
      collection.add(lineLossDto);
    }
    resultSet.close();
    return collection;
  }
  /**
   * 按条件查询多条数据
   *
   * @param conditions 查询条件
   * @param pageNo 页号
   * @param rowsPerPage 每页的行数
   * @return Collection
   * @throws Exception
   */
  public Collection findByConditions(String conditions, int pageNo, int rowsPerPage)
      throws Exception {
    StringBuffer buffer = new StringBuffer(200);
    // 拼SQL语句
    buffer.append("SELECT ");
    buffer.append("UserNo,");
    buffer.append("UserName,");
    buffer.append("Address,");
    buffer.append("ReadDate,");
    buffer.append("StatMonth,");
    buffer.append("ThisWorkNum,");
    buffer.append("MidWorkNum,");
    buffer.append("LastWorkNum,");
    buffer.append("Rate,");
    buffer.append("ReadQuantity,");
    buffer.append("ExcepQuantity,");
    buffer.append("ChgAmmeterQuantity,");
    buffer.append("CompensateQuantity,");
    buffer.append("AppendCalQuantity,");
    buffer.append("TranferLossQuantity,");
    buffer.append("PeoplePrice,");
    buffer.append("NotPeoplePrice,");
    buffer.append("FarmPrice,");
    buffer.append("ProducePrice,");
    buffer.append("BusinessPrice,");
    buffer.append("Voltlevel,");
    buffer.append("IndustryPrice,");
    buffer.append("ValidStatus,");
    buffer.append("Flag,");
    buffer.append("Remark,");
    buffer.append("InputDate ");
    buffer.append("FROM LwTownIndicator WHERE ");
    buffer.append(conditions);
    boolean supportPaging = false; // 数据库是否支持分页
    if (pageNo > 0) {
      // 对Oracle优化
      if (dbManager
          .getConnection()
          .getMetaData()
          .getDatabaseProductName()
          .equalsIgnoreCase("Oracle")) {
        buffer.insert(0, "SELECT * FROM ( SELECT row_.*, rownum rownum_ FROM (");
        buffer.append(
            ") row_ WHERE rownum <= "
                + rowsPerPage * pageNo
                + ") WHERE rownum_ > "
                + rowsPerPage * (pageNo - 1));
        supportPaging = true;
      } else if (dbManager
          .getConnection()
          .getMetaData()
          .getDatabaseProductName()
          .equalsIgnoreCase("DB2")) {
        String sql = buffer.toString();
        buffer.setLength(0);
        buffer.append("select * from ( select rownumber() over(");
        int orderByIndex = sql.toLowerCase().indexOf("order by");
        if (orderByIndex > 0) {
          buffer.append(sql.substring(orderByIndex));
        }
        buffer.append(") as rownumber_,");
        buffer.append(sql.substring(6));
        buffer.append(" ) as temp_ where rownumber_");
        buffer.append(
            " between " + (rowsPerPage * (pageNo - 1) + 1) + " and " + rowsPerPage * pageNo);
        supportPaging = true;
      }
    }
    if (true) {
      logger.debug(buffer.toString());
    }
    ResultSet resultSet = dbManager.executeQuery(buffer.toString());
    int count = 0;
    if (supportPaging == false && pageNo > 1) {
      dbManager.locate(resultSet, rowsPerPage * (pageNo - 1));
    }

    // 定义返回结果集合
    Collection collection = new ArrayList(rowsPerPage);
    LwTownIndicatorDto lwTownIndicatorDto = null;
    while (resultSet.next()) {
      if (supportPaging == false && pageNo > 0) {
        count++;
        if (count > rowsPerPage) {
          break;
        }
      }

      lwTownIndicatorDto = new LwTownIndicatorDto();
      lwTownIndicatorDto.setUserNo(dbManager.getString(resultSet, "UserNo"));
      lwTownIndicatorDto.setUserName(dbManager.getString(resultSet, "UserName"));
      lwTownIndicatorDto.setAddress(dbManager.getString(resultSet, "Address"));
      lwTownIndicatorDto.setReadDate(dbManager.getString(resultSet, "ReadDate"));
      lwTownIndicatorDto.setStatMonth(dbManager.getString(resultSet, "StatMonth"));
      lwTownIndicatorDto.setThisWorkNum(dbManager.getDouble(resultSet, "ThisWorkNum"));
      lwTownIndicatorDto.setMidWorkNum(dbManager.getDouble(resultSet, "MidWorkNum"));
      lwTownIndicatorDto.setLastWorkNum(dbManager.getDouble(resultSet, "LastWorkNum"));
      lwTownIndicatorDto.setRate(dbManager.getDouble(resultSet, "Rate"));
      lwTownIndicatorDto.setReadQuantity(dbManager.getDouble(resultSet, "ReadQuantity"));
      lwTownIndicatorDto.setExcepQuantity(dbManager.getDouble(resultSet, "ExcepQuantity"));
      lwTownIndicatorDto.setChgAmmeterQuantity(
          dbManager.getDouble(resultSet, "ChgAmmeterQuantity"));
      lwTownIndicatorDto.setCompensateQuantity(
          dbManager.getDouble(resultSet, "CompensateQuantity"));
      lwTownIndicatorDto.setAppendCalQuantity(dbManager.getLong(resultSet, "AppendCalQuantity"));
      lwTownIndicatorDto.setTranferLossQuantity(
          dbManager.getLong(resultSet, "TranferLossQuantity"));
      lwTownIndicatorDto.setPeoplePrice(dbManager.getDouble(resultSet, "PeoplePrice"));
      lwTownIndicatorDto.setNotPeoplePrice(dbManager.getDouble(resultSet, "NotPeoplePrice"));
      lwTownIndicatorDto.setFarmPrice(dbManager.getDouble(resultSet, "FarmPrice"));
      lwTownIndicatorDto.setProducePrice(dbManager.getDouble(resultSet, "ProducePrice"));
      lwTownIndicatorDto.setBusinessPrice(dbManager.getDouble(resultSet, "BusinessPrice"));
      lwTownIndicatorDto.setVoltlevel(dbManager.getInt(resultSet, "Voltlevel"));
      lwTownIndicatorDto.setIndustryPrice(dbManager.getDouble(resultSet, "IndustryPrice"));
      lwTownIndicatorDto.setValidStatus(dbManager.getString(resultSet, "ValidStatus"));
      lwTownIndicatorDto.setFlag(dbManager.getString(resultSet, "Flag"));
      lwTownIndicatorDto.setRemark(dbManager.getString(resultSet, "Remark"));
      lwTownIndicatorDto.setInputDate(dbManager.getString(resultSet, "InputDate"));
      collection.add(lwTownIndicatorDto);
    }
    resultSet.close();
    return collection;
  }
 /**
  * 采用批方式插入多条数据
  *
  * @param collection collection
  * @throws Exception
  */
 public void insertAll(Collection collection) throws Exception {
   StringBuffer buffer = new StringBuffer(200);
   buffer.append("INSERT INTO LwTownIndicator (");
   buffer.append("UserNo,");
   buffer.append("UserName,");
   buffer.append("Address,");
   buffer.append("ReadDate,");
   buffer.append("StatMonth,");
   buffer.append("ThisWorkNum,");
   buffer.append("MidWorkNum,");
   buffer.append("LastWorkNum,");
   buffer.append("Rate,");
   buffer.append("ReadQuantity,");
   buffer.append("ExcepQuantity,");
   buffer.append("ChgAmmeterQuantity,");
   buffer.append("CompensateQuantity,");
   buffer.append("AppendCalQuantity,");
   buffer.append("TranferLossQuantity,");
   buffer.append("PeoplePrice,");
   buffer.append("NotPeoplePrice,");
   buffer.append("FarmPrice,");
   buffer.append("ProducePrice,");
   buffer.append("BusinessPrice,");
   buffer.append("Voltlevel,");
   buffer.append("IndustryPrice,");
   buffer.append("ValidStatus,");
   buffer.append("Flag,");
   buffer.append("Remark,");
   buffer.append("InputDate ");
   buffer.append(") ");
   buffer.append("VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
   if (logger.isDebugEnabled()) {
     logger.debug(buffer.toString());
   }
   dbManager.prepareStatement(buffer.toString());
   for (Iterator i = collection.iterator(); i.hasNext(); ) {
     LwTownIndicatorDto lwTownIndicatorDto = (LwTownIndicatorDto) i.next();
     dbManager.setString(1, lwTownIndicatorDto.getUserNo());
     dbManager.setString(2, lwTownIndicatorDto.getUserName());
     dbManager.setString(3, lwTownIndicatorDto.getAddress());
     dbManager.setString(4, lwTownIndicatorDto.getReadDate());
     dbManager.setString(5, lwTownIndicatorDto.getStatMonth());
     dbManager.setDouble(6, lwTownIndicatorDto.getThisWorkNum());
     dbManager.setDouble(7, lwTownIndicatorDto.getMidWorkNum());
     dbManager.setDouble(8, lwTownIndicatorDto.getLastWorkNum());
     dbManager.setDouble(9, lwTownIndicatorDto.getRate());
     dbManager.setDouble(10, lwTownIndicatorDto.getReadQuantity());
     dbManager.setDouble(11, lwTownIndicatorDto.getExcepQuantity());
     dbManager.setDouble(12, lwTownIndicatorDto.getChgAmmeterQuantity());
     dbManager.setDouble(13, lwTownIndicatorDto.getCompensateQuantity());
     dbManager.setLong(14, lwTownIndicatorDto.getAppendCalQuantity());
     dbManager.setLong(15, lwTownIndicatorDto.getTranferLossQuantity());
     dbManager.setDouble(16, lwTownIndicatorDto.getPeoplePrice());
     dbManager.setDouble(17, lwTownIndicatorDto.getNotPeoplePrice());
     dbManager.setDouble(18, lwTownIndicatorDto.getFarmPrice());
     dbManager.setDouble(19, lwTownIndicatorDto.getProducePrice());
     dbManager.setDouble(20, lwTownIndicatorDto.getBusinessPrice());
     dbManager.setInt(21, lwTownIndicatorDto.getVoltlevel());
     dbManager.setDouble(22, lwTownIndicatorDto.getIndustryPrice());
     dbManager.setString(23, lwTownIndicatorDto.getValidStatus());
     dbManager.setString(24, lwTownIndicatorDto.getFlag());
     dbManager.setString(25, lwTownIndicatorDto.getRemark());
     dbManager.setString(26, lwTownIndicatorDto.getInputDate());
     dbManager.addBatch();
   }
   dbManager.executePreparedUpdateBatch();
 }