Esempio n. 1
0
  @Override
  public List<Goods> findAllGoods(Long uid) throws SQLException {
    String sql =
        "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where s_name in(select s_name from store where u_id=?)";
    //		String sql = "select
    // g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq
    // from goods where s_name="+"\"门店1\"";
    //		String sql = "select
    // g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq
    // from goods";
    // String sql = "select * from goods where s_name=? and c_name=? and su_name=?";
    List<Object[]> list = qr.query(sql, new ArrayListHandler(), uid);
    List<Goods> goodsList = new ArrayList<Goods>();
    for (Object[] obj : list) {
      Goods goods = new Goods();
      if (obj[0] != null) {
        goods.setGName(obj[0].toString());
      }
      if (obj[1] != null) {
        goods.setSName(obj[1].toString());
      }
      if (obj[2] != null) {
        goods.setCName(obj[2].toString());
      }
      if (obj[3] != null) {
        goods.setSuName(obj[3].toString());
      }
      if (obj[4] != null) {
        goods.setGBarcode(obj[4].toString());
      }
      if (obj[5] != null) {
        goods.setGStockNum(obj[5].toString());
      }
      if (obj[6] != null) {
        goods.setGStockMax(obj[6].toString());
      }
      if (obj[7] != null) {
        goods.setGStockMin(obj[7].toString());
      }
      if (obj[8] != null) {
        goods.setGProdDate(obj[8].toString());
      }
      if (obj[9] != null) {
        goods.setGGiq(obj[9].toString());
      }
      goodsList.add(goods);
    }

    return goodsList;
  }
Esempio n. 2
0
  @Override
  public PageBean<Goods> findByCombination(
      String sName, String cName, String suName, String inventoryStatus, Long uid, int pc)
      throws SQLException {
    /*
     * 1.得到ps
     * 2.得到tr
     * 3.得到beanList
     * 4.创建PageBean,返回
     */

    // 1.得到ps
    int ps = PageConstants.GOODS_PAGE_SIZE;

    // 2.得到tr
    String sql = "";
    Number number = null;
    int tr = 0;

    // -----------------------------------------------------------------------------------
    // -----------------------------------------------------------------------------------
    // -----------------------------------------------------------------------------------

    if (sName.equals("全部门店")) {
      if (cName.equals("全部分类")) {
        if (suName.equals("全部供货商")) {
          // 1 1 1
          if (inventoryStatus.equals("库存不足")) { // g_stock_num库存量 g_stock_min库存下限 g_stock_max库存上限
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and s_name in(select s_name from store where u_id=?)";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and s_name in(select s_name from store where u_id=?)";
          } else {
            sql =
                "select count(*) from goods where s_name in(select s_name from store where u_id=?)";
          }
          number = (Number) qr.query(sql, new ScalarHandler(), uid);
          tr = number.intValue();
          //					System.out.println("库存不足的总记录条数:"+tr);

          //					sql = "select count(*) from goods where s_name in(select s_name from store where
          // u_id=?)";
          //					number = (Number) qr.query(sql, new ScalarHandler(), uid);
          //					tr = number.intValue();
        } else {
          // 1 1 0
          if (inventoryStatus.equals("库存不足")) { // g_stock_num库存量 g_stock_min库存下限 g_stock_max库存上限
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and su_name=? and s_name in(select s_name from store where u_id=?)";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and su_name=? and s_name in(select s_name from store where u_id=?)";

          } else {
            sql =
                "select count(*) from goods where su_name=? and s_name in(select s_name from store where u_id=?)";
          }
          number = (Number) qr.query(sql, new ScalarHandler(), suName, uid);
          tr = number.intValue();
        }
      } else {
        if (suName.equals("全部供货商")) {
          // 1 0 1
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and c_name=? and s_name in(select s_name from store where u_id=?)";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and c_name=? and s_name in(select s_name from store where u_id=?)";
          } else {
            sql =
                "select count(*) from goods where c_name=? and s_name in(select s_name from store where u_id=?)";
          }

          number = (Number) qr.query(sql, new ScalarHandler(), cName, uid);
          tr = number.intValue();
        } else {
          // 1 0 0
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and c_name=? and su_name=? and s_name in(select s_name from store where u_id=?)";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and c_name=? and su_name=? and s_name in(select s_name from store where u_id=?)";
          } else {
            sql =
                "select count(*) from goods where c_name=? and su_name=? and s_name in(select s_name from store where u_id=?)";
          }
          number = (Number) qr.query(sql, new ScalarHandler(), cName, suName, uid);
          tr = number.intValue();
        }
      }
    } else {
      if (cName.equals("全部分类")) {
        if (suName.equals("全部供货商")) {
          // 0 1 1
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and s_name=? and s_name in(select s_name from store where u_id=?)";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and s_name=? and s_name in(select s_name from store where u_id=?)";
          } else {
            sql =
                "select count(*) from goods where s_name=? and s_name in(select s_name from store where u_id=?)";
          }
          number = (Number) qr.query(sql, new ScalarHandler(), sName, uid);
          tr = number.intValue();
          System.out.println("tr: " + tr);
          System.out.println(sql);
        } else {
          // 0 1 0
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and s_name=? and su_name=? and s_name in(select s_name from store where u_id=?)";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and s_name=? and su_name=? and s_name in(select s_name from store where u_id=?)";
          } else {
            sql =
                "select count(*) from goods where s_name=? and su_name=? and s_name in(select s_name from store where u_id=?)";
          }
          number = (Number) qr.query(sql, new ScalarHandler(), sName, suName, uid);
          tr = number.intValue();
        }
      } else {
        if (suName.equals("全部供货商")) {
          // 0 0 1
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and s_name=? and c_name=? and s_name in(select s_name from store where u_id=?)";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and s_name=? and c_name=? and s_name in(select s_name from store where u_id=?)";
          } else {
            sql =
                "select count(*) from goods where s_name=? and c_name=? and s_name in(select s_name from store where u_id=?)";
          }
          number = (Number) qr.query(sql, new ScalarHandler(), sName, cName, uid);
          tr = number.intValue();
        } else {
          // 0 0 0
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) s_name=? and c_name=? and su_name=? and s_name in(select s_name from store where u_id=?)";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select count(*) from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and s_name=? and c_name=? and su_name=? and s_name in(select s_name from store where u_id=?)";
          } else {
            sql =
                "select count(*) from goods where s_name=? and c_name=? and su_name=? and s_name in(select s_name from store where u_id=?)";
          }
          number = (Number) qr.query(sql, new ScalarHandler(), sName, cName, suName, uid);
          tr = number.intValue();
        }
      }
    }

    // -----------------------------------------------------------------------------------
    // -----------------------------------------------------------------------------------
    // -----------------------------------------------------------------------------------

    // 3.得到beanList,即当前页记录
    List<Object[]> list = null;

    if (sName.equals("全部门店")) {
      if (cName.equals("全部分类")) {
        if (suName.equals("全部供货商")) {
          // 1 1 1
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where s_name in (select s_name from store where u_id=?) limit ?,?";
          }
          list = qr.query(sql, new ArrayListHandler(), uid, (pc - 1) * ps, ps);
        } else {
          // 1 1 0
          // -----------------------------------------------------------------------------
          // -----------------------------------------------------------------------------
          // -----------------------------------------------------------------------------
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          }
          list = qr.query(sql, new ArrayListHandler(), suName, uid, (pc - 1) * ps, ps);
        }
      } else {
        if (suName.equals("全部供货商")) {
          // 1 0 1
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and c_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and c_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where c_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          }
          list = qr.query(sql, new ArrayListHandler(), cName, uid, (pc - 1) * ps, ps);
        } else {
          // 1 0 0
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and c_name=? and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and c_name=? and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where c_name=? and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          }
          list = qr.query(sql, new ArrayListHandler(), cName, suName, uid, (pc - 1) * ps, ps);
        }
      }
    } else {
      if (cName.equals("全部分类")) {
        if (suName.equals("全部供货商")) {
          // 0 1 1
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and s_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and s_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where s_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          }
          list = qr.query(sql, new ArrayListHandler(), sName, uid, (pc - 1) * ps, ps);
          System.out.println(sql);
        } else {
          // 0 1 0
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and s_name=? and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and s_name=? and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where s_name=? and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          }
          list = qr.query(sql, new ArrayListHandler(), sName, suName, uid, (pc - 1) * ps, ps);
        }
      } else {
        if (suName.equals("全部供货商")) {
          // 0 0 1
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and s_name=? and c_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and s_name=? and c_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where s_name=? and c_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          }
          list = qr.query(sql, new ArrayListHandler(), sName, cName, uid, (pc - 1) * ps, ps);
        } else {
          // 0 0 0
          if (inventoryStatus.equals("库存不足")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)<=CAST(g_stock_min AS DECIMAL) and s_name=? and c_name=? and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else if (inventoryStatus.equals("库存过剩")) {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where CAST(g_stock_num AS DECIMAL)>=CAST(g_stock_max AS DECIMAL) and s_name=? and c_name=? and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          } else {
            sql =
                "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where s_name=? and c_name=? and su_name=? and s_name in (select s_name from store where u_id=?) limit ?,?";
          }
          list =
              qr.query(sql, new ArrayListHandler(), sName, cName, suName, uid, (pc - 1) * ps, ps);
        }
      }
    }

    List<Goods> goodsList = new ArrayList<Goods>();
    for (Object[] obj : list) {
      Goods goods = new Goods();

      if (obj[0] != null) {
        goods.setGName(obj[0].toString());
      }
      if (obj[1] != null) {
        goods.setSName(obj[1].toString());
      }
      if (obj[2] != null) {
        goods.setCName(obj[2].toString());
      }
      if (obj[3] != null) {
        goods.setSuName(obj[3].toString());
      }
      if (obj[4] != null) {
        goods.setGBarcode(obj[4].toString());
      }
      if (obj[5] != null) {
        goods.setGStockNum(obj[5].toString());
      }
      if (obj[6] != null) {
        goods.setGStockMax(obj[6].toString());
      }
      if (obj[7] != null) {
        goods.setGStockMin(obj[7].toString());
      }
      if (obj[8] != null) {
        goods.setGProdDate(obj[8].toString());
      }
      if (obj[9] != null) {
        goods.setGGiq(obj[9].toString());
      }
      goodsList.add(goods);
    }

    // 4.创建PageBean,返回
    PageBean<Goods> pb = new PageBean<Goods>();
    pb.setBeanList(goodsList);
    pb.setPc(pc);
    pb.setPs(ps);
    pb.setTr(tr);

    return pb;
  }
Esempio n. 3
0
  @Override
  public PageBean<Goods> findByUid(Long uid, int pc) throws SQLException {
    /*
     * 1.得到ps
     * 2.得到tr
     * 3.得到beanList
     * 4.创建PageBean,返回
     */

    // 1.得到ps
    int ps = PageConstants.GOODS_PAGE_SIZE;
    // 2.得到tr
    //		String sql = "select count(*) from goods";
    String sql =
        "select count(*) from goods where s_name in(select s_name from store where u_id=?)";
    //		Number number = (Number) qr.query(sql, new ScalarHandler());
    Number number = (Number) qr.query(sql, new ScalarHandler(), uid);
    int tr = number.intValue();
    // 3.得到beanList,即当前页记录
    //		sql = "select
    // g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq
    // from goods limit ?,?";
    sql =
        "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods where s_name in (select s_name from store where u_id=?) limit ?,?";
    //		sql = "select
    // g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq
    // from goods where s_name in(select s_name from store where u_id=?) limit ?,?";
    //		List<Object[]> list = qr.query(sql, new ArrayListHandler(), (pc-1)*ps, ps);
    List<Object[]> list = qr.query(sql, new ArrayListHandler(), uid, (pc - 1) * ps, ps);
    List<Goods> goodsList = new ArrayList<Goods>();
    for (Object[] obj : list) {
      Goods goods = new Goods();
      if (obj[0] != null) {
        goods.setGName(obj[0].toString());
      }
      if (obj[1] != null) {
        goods.setSName(obj[1].toString());
      }
      if (obj[2] != null) {
        goods.setCName(obj[2].toString());
      }
      if (obj[3] != null) {
        goods.setSuName(obj[3].toString());
      }
      if (obj[4] != null) {
        goods.setGBarcode(obj[4].toString());
      }
      if (obj[5] != null) {
        goods.setGStockNum(obj[5].toString());
      }
      if (obj[6] != null) {
        goods.setGStockMax(obj[6].toString());
      }
      if (obj[7] != null) {
        goods.setGStockMin(obj[7].toString());
      }
      if (obj[8] != null) {
        goods.setGProdDate(obj[8].toString());
      }
      if (obj[9] != null) {
        goods.setGGiq(obj[9].toString());
      }
      goodsList.add(goods);
    }

    // 4.创建PageBean,返回
    PageBean<Goods> pb = new PageBean<Goods>();
    pb.setBeanList(goodsList);
    pb.setPc(pc);
    pb.setPs(ps);
    pb.setTr(tr);

    return pb;
  }
Esempio n. 4
0
  /** 通用的查询方法(重载),以分页的方式 */
  @Override
  public PageBean<Goods> findByCriteria(List<Expression> exprList, int pc) throws SQLException {
    /*
     * 1.得到ps
     * 2.得到tr
     * 3.得到beanList
     * 4.创建PageBean,返回
     */
    int ps = PageConstants.GOODS_PAGE_SIZE;

    // 2.通过exprList来生成where子句
    StringBuilder whereSql = new StringBuilder(" where 1=1");
    List<Object> params = new ArrayList<Object>();
    for (Expression expr : exprList) {
      whereSql
          .append(" and ")
          .append(expr.getName())
          .append(" ")
          .append(expr.getOperator())
          .append(" ");
      if (!expr.getOperator().equals("is null")) {
        whereSql.append("?");
        params.add(expr.getValue());
      }
    }
    System.out.println(whereSql);
    // 3.得到tr
    String sql = "select count(*) from goods" + whereSql;
    Number number = (Number) qr.query(sql, new ArrayListHandler(), params.toArray());
    int tr = number.intValue();
    // 4.得到beanList,即当前页记录
    sql =
        "select g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq from goods"
            + whereSql
            + " limit ?,?";
    //		sql = "select
    // g_name,s_name,c_name,su_name,g_barcode,g_stock_num,g_stock_max,g_stock_min,g_prod_date,g_giq
    // from goods where s_name in(select s_name from store where u_id=?) limit ?,?";
    params.add((pc - 1) * ps);
    params.add(ps);
    List<Object[]> list = qr.query(sql, new ArrayListHandler(), params.toArray());
    List<Goods> goodsList = new ArrayList<Goods>();
    for (Object[] obj : list) {
      Goods goods = new Goods();
      if (obj[0] != null) {
        goods.setGName(obj[0].toString());
      }
      if (obj[1] != null) {
        goods.setSName(obj[1].toString());
      }
      if (obj[2] != null) {
        goods.setCName(obj[2].toString());
      }
      if (obj[3] != null) {
        goods.setSuName(obj[3].toString());
      }
      if (obj[4] != null) {
        goods.setGBarcode(obj[4].toString());
      }
      if (obj[5] != null) {
        goods.setGStockNum(obj[5].toString());
      }
      if (obj[6] != null) {
        goods.setGStockMax(obj[6].toString());
      }
      if (obj[7] != null) {
        goods.setGStockMin(obj[7].toString());
      }
      if (obj[8] != null) {
        goods.setGProdDate(obj[8].toString());
      }
      if (obj[9] != null) {
        goods.setGGiq(obj[9].toString());
      }
      goodsList.add(goods);
    }

    // 5.创建PageBean,返回
    PageBean<Goods> pb = new PageBean<Goods>();
    pb.setBeanList(goodsList);
    pb.setPc(pc);
    pb.setPs(ps);
    pb.setTr(tr);

    return pb;
  }