Ejemplo n.º 1
0
  /**
   * 设置进入查询处理的初始值
   *
   * @param actionForm ActionForm 表单From
   * @param request HttpServletRequest Web请求
   * @param response HttpServletResponse Web结果
   * @throws CDealException 处理异常
   */
  public static void setQueryDefault(
      QueryForm aWebForm, HttpServletRequest request, HttpServletResponse response)
      throws CDealException {
    QueryForm aWebForm1 = (QueryForm) aWebForm;
    Connection mConn = null;
    PreparedStatement pstmt = null;
    String str = ""; // 要返回的 string
    String sKey = ""; // 取出的TREEMAP的KEY
    String sValue = ""; // 取出的TREEMAP的value
    TreeMap permission;
    try {
      CUserBean loginUser =
          (CUserBean) request.getSession().getAttribute(CConstants.USER_BEAN); // 用户BEAN
      // 第一次进入需要初始许可事项和部门列表
      if (!loginUser.getAttach().containsKey(Common.JCPermissionIDList)) {
        Common.setDepartAndPermissionList(loginUser);
      }
      // 得到许可实施机关列表
      TreeMap tmDepartmentList = (TreeMap) loginUser.getAttach().get(Common.JCDepartmentList);
      // 得到许可事项列表
      TreeMap tmPermissionList = (TreeMap) loginUser.getAttach().get(Common.JCPermissionList);
      // 添加许可实施机关到一个数组里面去.然后统一输出到页面
      Iterator it = tmDepartmentList.keySet().iterator();
      str = "var department=new Array('','全部'";
      int k = 0;
      while (it.hasNext()) {
        k++;
        sKey = (String) it.next();
        str += ",'" + sKey + "',"; // 取出的TREEMAP的KEY
        sValue = (String) tmDepartmentList.get(sKey);
        str += "'" + sValue + "'\n"; // 取出的TREEMAP的value
      }
      str += ");\n";
      str += " var permissionitem = new Array (" + k + ");\n";
      str += "permissionitem[0]=new Array('','全部');\n";

      // 添加许可事项列表
      Iterator itt = tmPermissionList.keySet().iterator();
      int j = 1;
      while (itt.hasNext()) {
        sKey = (String) itt.next();
        permission = (TreeMap) tmPermissionList.get(sKey);
        Iterator itt2 = permission.keySet().iterator();
        // 添加每个部门对应的许可事项
        str += "permissionitem[" + j + "]=new Array('','全部'";
        while (itt2.hasNext()) {
          sKey = (String) itt2.next();
          str += ",'" + sKey + "',"; // 取出的TREEMAP的KEY
          sValue = (String) permission.get(sKey);
          str += "'" + sValue + "'\n"; // 取出的TREEMAP的value
        }
        str += ");\n";
        j++;
      }
      // 设置业务范围的选项
      aWebForm1.setPrint_busi_str(Common.getBusiArea(aWebForm.getBusi_area()));
      // 把部门数组和许可事项输出到页面上
      aWebForm1.setPrintSql(str);
    } catch (Exception e) {
      throw new CDealException("设置进入时限监察查询处理的初始值时失败。", e);
    } finally {
      if (pstmt != null)
        try {
          pstmt.close();
        } catch (Exception e) {
        }
      ;
      if (mConn != null)
        try {
          mConn.close();
        } catch (Exception e) {
        }
      ;
    }
  }