public String index() {
    StringBuffer hql = new StringBuffer(" from AddressBookType a where 1 = 1");
    List<Object> args = new ArrayList<Object>();

    if (StringUtils.isNotBlank(getModel().getName())) {
      hql.append(" and a.name like ? ");
      args.add(MatchMode.ANYWHERE.toMatchString(getModel().getName()));
    }

    page = PageUtil.getPage(getPageNo(), getPageSize());
    page = getManager().pageQuery(page, hql.toString(), args.toArray());
    restorePageData(page);

    return INDEX;
  }
Exemple #2
0
  /* 入库单查询 */
  public String indexDraw() {
    page = PageUtil.getPage(getPageNo(), getPageSize());
    StringBuffer sql = new StringBuffer("from InStock i where 1=1");
    List<Object> args = new ArrayList<Object>();

    if (StringUtils.isNotBlank(getModel().getStockNo())) { // 按单号查询
      sql.append(" and i.stockNo = ?");
      args.add(getModel().getStockNo());
    }

    if (getModel().getGoods() != null
        && StringUtils.isNotBlank(getModel().getGoods().getName())) { // 按物品名称查询
      sql.append(" and i.goods.name like ?");
      args.add(MatchMode.ANYWHERE.toMatchString(getModel().getGoods().getName()));
    }

    if (StringUtils.isNotBlank(cDate)) { // 按入库日期查询
      sql.append(" and i.inDate = ?");
      try {
        args.add(DateUtil.firstSecondOfDate(DateUtil.convertStringToDate("yyyy-MM-dd", cDate)));
      } catch (ParseException e) {
      }
    }

    sql.append(" order by i.inDate desc");
    page = getManager().pageQuery(page, sql.toString(), args.toArray());
    restorePageData(page);

    List<InStock> list = page.getData();
    if (list != null && list.size() > 0) {
      // 统计总入库数量
      int totalInCounts = 0;
      // 统计总价钱
      double totalAmount = 0;
      for (InStock i : list) {
        // 入库数
        Integer inCounts = i.getInCounts() == null ? 0 : i.getInCounts();
        // 此单库存价钱
        Double amount = i.getAmount() == null ? 0d : i.getAmount();
        totalInCounts += inCounts;
        totalAmount += amount;
      }
      getRequest().setAttribute("totalAmount", totalAmount);
      getRequest().setAttribute("totalInCounts", totalInCounts);
    }

    return "indexDraw";
  }