Exemplo n.º 1
0
  /**
   * 查询处理
   *
   * @param actionForm ActionForm 表单From
   * @param request HttpServletRequest Web请求
   * @param response HttpServletResponse Web结果
   * @throws CDealException 处理异常
   */
  public static void doQuery(
      QueryForm pQueryForm, HttpServletRequest request, HttpServletResponse response)
      throws CDealException {
    try {

      // 查询数据SQL语句
      String msSql =
          "select CHENGPIID,COMPLAINEDPERSON,COMPLAINPERSON,COMPLAINVERSION,to_char(a.CREATEDATE,'yyyy-mm-dd')CREATEDATE,COMPLAINUNIT,COMPLAINEDUNIT,SPARE1,SPARE2,SPARE3,SPARE4,t.abbrname,a.XZGCXYFL,a.SUBXZGCXYFL from T_YW_ZDSX_JCJ_TSCHENGPIBIAO a,t_Sys_Department t  WHERE a.STATUS = 1 and SUBMITSTATUS = 1 and t.id=COMPLAINEDUNIT "; // 主查询语句
      String msOrder = "ORDER BY CREATEDATE desc"; // 排序语句

      // 查询子条件
      String msSqlWhere = "";
      String msTemp = pQueryForm.getCHENGPIID(); // 呈批表编号
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and CHENGPIID like '%" + msTemp + "%'";
      }
      msTemp = pQueryForm.getCOMPLAINEDPERSON(); // 呈批表被投诉人姓名
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and COMPLAINEDPERSON like '%" + msTemp + "%'";
      }
      msTemp = pQueryForm.getCOMPLAINUNIT(); // 呈批表问题性质
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and COMPLAINUNIT like '%" + msTemp + "%'";
      }
      msTemp = pQueryForm.getCOMPLAINEDUNIT(); // 呈批表被投诉人单位
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and COMPLAINEDUNIT = '" + msTemp + "'";
      }
      msTemp = pQueryForm.getCOMPLAINPERSON(); // 呈批表投诉人姓名
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and COMPLAINPERSON like '%" + msTemp + "%'";
      }
      msTemp = pQueryForm.getCOMPLAINVERSION(); // 呈批表投诉形式
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and COMPLAINVERSION =" + msTemp;
      }
      msTemp = pQueryForm.getCREATEDATE1(); // 呈批表创建时间,起
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and CREATEDATE >= to_date('" + msTemp + "','yyyy-mm-dd')";
      }
      msTemp = pQueryForm.getCREATEDATE2(); // 呈批表创建时间,止
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and CREATEDATE <= to_date('" + msTemp + "','yyyy-mm-dd')";
      }

      msSql = msSql + msSqlWhere; // 主查询语句 加上 查询子条件

      CDataPage dataPage = new CDataPage(); // 翻页实现类
      dataPage.setQuerySql(msSql); // 设置查询语句
      dataPage.setOrderStr(msOrder); // 设置排序语句
      dataPage.setPageRowCount(CConstants.PAGE_ROW_COUNT); // 每页行数
      dataPage.init(request);
      request.setAttribute(CConstants.DATA_PAGE_OBJECT, dataPage);

      // 初始化页面,初始化投诉形式下拉菜单
      TreeMap COMPLAINVERSIONListName = new TreeMap(); // 取出aWebForm
      COMPLAINVERSIONListName = CCodeMap.getMapByType("行政效能投诉形式");
      pQueryForm.setCOMPLAINVERSIONList(COMPLAINVERSIONListName);
      TreeMap COMPLAINVERSIONListName1 = new TreeMap(); // 取出aWebForm
      COMPLAINVERSIONListName1 = CCodeMap.getMapByType("部门名称列表");
      pQueryForm.setDepartList(COMPLAINVERSIONListName1);

    } catch (Exception e) {
      throw new CDealException("根据输入条件进行查询时失败。", e);
    }
  }