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
      // t.BUSIINDEXID,t.ITEMID,t.ITEMTITLE,t.FROMCOMPANY,t.ITEMTYPE,t.DEPARTMENT, " +
      //                     "t.LIMITFOREWARN,t.LIMITYELLOW,t.LIMITRED,c.abbrname from
      // T_JC_ZDSX_DCK_BUSIINDEX t" +
      //                     ",t_Yw_Dck_Jcj_Taskbreak b,t_sys_department c where t.itemid = b.itemid
      // and b.firstflag = 1 and b.transactdepartment = c.id ";
      String msSql =
          "select t.BUSIINDEXID,t.ITEMID,t.ITEMTITLE,t.FROMCOMPANY,t.ITEMTYPE,t.DEPARTMENT, "
              + "t.LIMITFOREWARN,t.LIMITYELLOW,t.LIMITRED from T_JC_ZDSX_DCK_BUSIINDEX t,t_yw_dck_jcj_resister p where t.itemid = p.itemid and (t.spare1=0 or t.spare1 is null)  ";
      String msOrder =
          "order by t.LIMITRED desc,T.LIMITYELLOW desc,T.LIMITFOREWARN desc, BUSIINDEXID desc"; // 排序语句

      // 查询子条件
      String msSqlWhere = "";
      String msTemp = pQueryForm.getItemid(); // 编号
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and t.itemid like '%" + msTemp + "%'";
      }
      msTemp = pQueryForm.getFromcompany(); // 来文单位
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and t.fromcompany like '%" + msTemp + "%'";
      }
      msTemp = pQueryForm.getItemtitle(); // 督办标题
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and t.itemtitle like '%" + msTemp + "%'";
      }
      msTemp = pQueryForm.getItemtype(); // 类别
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and t.itemtype =" + msTemp;
      }
      msTemp = pQueryForm.getItemstatus(); // 重大事项状态类别
      if (msTemp != null && msTemp.length() > 0 && msTemp.equals("1")) {
        msSqlWhere += " and p.ITEMSTATUS =1";
      }
      if (msTemp != null && msTemp.length() > 0 && msTemp.equals("2")) {
        msSqlWhere += " and p.ITEMSTATUS =2";
      }
      if (msTemp != null && msTemp.length() > 0 && msTemp.equals("3")) {
        msSqlWhere += " and p.ITEMSTATUS =3";
      }
      if (msTemp != null
          && msTemp.length() > 0
          && (msTemp.equals("4")
              || msTemp.equals("5")
              || msTemp.equals("6")
              || msTemp.equals("7"))) {
        msSqlWhere += " and p.ITEMSTATUS =4";
      }
      if (msTemp != null && msTemp.length() > 0 && msTemp.equals("8")) {
        msSqlWhere += " and p.ITEMSTATUS =7";
      }
      msTemp = pQueryForm.getDepartment(); // 来源分类
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and t.department =" + msTemp;
      }
      msTemp = pQueryForm.getFromdate1(); // 收文日期,起
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and t.INITIALDATE >= to_date('" + msTemp + "','yyyy-mm-dd')";
      }
      msTemp = pQueryForm.getFromdate2(); // 收文日期,止
      if (msTemp != null && msTemp.length() > 0) {
        msSqlWhere += " and t.INITIALDATE <= to_date('" + msTemp + "','yyyy-mm-dd')";
      }

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

      CDataPage dataPage = new CDataPage(); // 翻页实现类
      dataPage.setQuerySql(msSql); // 设置查询语句
      dataPage.setOrderStr(msOrder); // 设置排序语句
      dataPage.setQueryFormOrderColumn(pQueryForm.getQueryFormOrderColumn()); // 查询页面排序的字段
      dataPage.setPageRowCount(CConstants.PAGE_ROW_COUNT); // 每页行数
      dataPage.setFormName("forms[0]");
      dataPage.init(request);
      request.setAttribute(CConstants.DATA_PAGE_OBJECT, dataPage);
    } catch (Exception e) {
      throw new CDealException("根据输入条件进行查询时失败。", e);
    }
  }