コード例 #1
0
ファイル: ListUser.java プロジェクト: xhm1027/qth
 public void execute(
     @Param(name = "company") String company,
     @Param(name = "page") int page,
     @Param(name = "pageSize") int pageSize,
     @Param(name = "userLevel") String userLevel,
     @Param(name = "status") String status,
     @Param(name = "name") String name,
     Context context) {
   UserQuery userQuery = new UserQuery();
   if (page == 0) {
     page = 1;
   }
   if (pageSize == 0 || pageSize > QueryObject.maxPageSize) {
     pageSize = QueryObject.defaultPageSize;
   }
   userQuery.setStatus(status);
   userQuery.setUserLevel(userLevel);
   userQuery.setCompany(company);
   userQuery.setName(name);
   context.put("userList", userService.queryUser(userQuery, (page - 1) * 20, pageSize));
   context.put("company", company);
   context.put("name", name);
   context.put("status", status);
   context.put("userLevel", userLevel);
   context.put("page", page);
   context.put("pageSize", pageSize);
   int totalCount = userService.queryCount(userQuery);
   context.put("totalCount", totalCount);
   context.put("totalPage", totalCount / pageSize + 1);
 }
コード例 #2
0
ファイル: ListEnterprise.java プロジェクト: xhm1027/qth
  public void execute(
      @Param(name = "company") String company,
      @Param(name = "b") Long[] b,
      @Param(name = "s") Long[] s,
      @Param(name = "order") String order,
      @Param(name = "orderDesc") String orderDesc,
      @Param(name = "page") int page,
      @Param(name = "pageSize") int pageSize,
      @Param(name = "userRole") String userRole,
      Context context) {
    // 如果是第一次请求,全部勾选
    if ((b == null || b.length == 0) && (s == null || s.length == 0)) {
      List<ProductCategory> resourceCategoryList = productCategoryService.getAllResourceCategory();
      List<ProductCategory> materialCategoryList = productCategoryService.getAllMaterialCategory();
      if (UserRole.INNER_USER.equals(userRole)) { // 内部用户b是原材料类别
        b = new Long[materialCategoryList.size()];
        for (int i = 0; i < materialCategoryList.size(); i++) {
          b[i] = materialCategoryList.get(i).getId();
        }
        s = new Long[resourceCategoryList.size()];
        for (int i = 0; i < resourceCategoryList.size(); i++) {
          s[i] = resourceCategoryList.get(i).getId();
        }
      } else {
        s = new Long[materialCategoryList.size()];
        for (int i = 0; i < materialCategoryList.size(); i++) {
          s[i] = materialCategoryList.get(i).getId();
        }
        b = new Long[resourceCategoryList.size()];
        for (int i = 0; i < resourceCategoryList.size(); i++) {
          b[i] = resourceCategoryList.get(i).getId();
        }
      }
    }
    // 分页参数处理
    UserQuery userQuery = new UserQuery();
    if (page == 0) {
      page = 1;
    }
    if (pageSize == 0 || pageSize > QueryObject.maxPageSize) {
      pageSize = QueryObject.defaultPageSize;
    }

    // 企业类型
    if (UserRole.INNER_USER.equalsIgnoreCase(userRole)) {
      userQuery.setRole(UserRole.INNER_USER);
    } else {
      userQuery.setRole(UserRole.OUTER_USER);
    }
    // 公司名
    userQuery.setCompany(company);
    // 采购类别
    List<Long> buyInterestIds = null;
    if (b != null && b.length > 0) {
      buyInterestIds = new ArrayList<Long>();
      for (Long id : b) {
        buyInterestIds.add(id);
      }
      userQuery.setBuyInterestIds(buyInterestIds);
    }
    // 销售类别
    List<Long> saleInterestIds = null;
    if (s != null && s.length > 0) {
      saleInterestIds = new ArrayList<Long>();
      for (Long id : s) {
        saleInterestIds.add(id);
      }
      userQuery.setSaleInterestIds(saleInterestIds);
    }
    // 排序
    if (order != null) {
      userQuery.setOrderModified(true);
      // 排序方式
      if (orderDesc != null && orderDesc.equals(QueryObject.ORDER_DESC)) {
        userQuery.setOrderDesc(true);
      }
      if (orderDesc != null && orderDesc.equals(QueryObject.ORDER_ASC)) {
        userQuery.setOrderAsc(true);
      }
    }
    // 查询结果
    context.put("userList", userService.queryUser(userQuery, (page - 1) * pageSize, pageSize));
    // 查询参数
    context.put("buyInterestIds", b);
    context.put("saleInterestIds", s);
    context.put("company", company);
    context.put("order", order);
    context.put("userRole", userRole);
    context.put("page", page);
    context.put("orderDesc", orderDesc);
    context.put("pageSize", pageSize);
    int totalCount = userService.queryCount(userQuery);
    context.put("totalCount", totalCount);
    context.put("totalPage", (totalCount - 1) / pageSize + 1);

    // 类别信息,作为查询条件用
    CategoryQuery categoryQuery = new CategoryQuery();
    categoryQuery.setIsMaterial(IS.Y);
    context.put(
        "materialCategories",
        wrapProductCategoryVO(
            productCategoryService.query(categoryQuery), saleInterestIds, buyInterestIds));
    categoryQuery.setIsMaterial(IS.N);
    context.put(
        "notMaterialCategories",
        wrapProductCategoryVO(
            productCategoryService.query(categoryQuery), saleInterestIds, buyInterestIds));
  }