示例#1
0
  /**
   * 设置进入查看详细信息页面的初始值 setEditDefault
   *
   * @param aWebForm EditForm
   * @param request HttpServletRequest
   * @param response HttpServletResponse
   */
  public static void setEditDefault(
      EditForm pWebForm, HttpServletRequest request, HttpServletResponse response)
      throws CDealException {
    try {
      // 初始化页面,初始化投诉形式下拉菜单
      int type = 0;
      Connection mConn = null;
      PreparedStatement pstmt = null;

      try {
        mConn = CDBManager.getConn(); // 创建数据库连接
        // 设置进入修改页面的初始值SQL
        String mSQL =
            "select A.CHENGPIID,A.COMPLAINEDPERSON,A.COMPLAINPERSON, A.COMPLAINEDUNIT, A.COMPLAINUNIT, A.COMPLAINEDDUTY, A.COMPLAINDUTY, A.QUESTIONKIND, A.COMPLAINVERSION, "
                + "  A.CONTENTABSTRACT,   A.SUGGESTION,   A.SIGN1,  to_char(A.DATE1, 'yyyy-mm-dd') DATE1,A.LEADERCONFIRM, A.SIGN2,   to_char(A.DATE2, 'yyyy-mm-dd') DATE2, A.REMARK,   A.BUSINESSID, "
                + " decode(A.BUSINESSTYPE,'1','建设工程','2','行政许可','3','政府采购','4','重大事项','5','行政执法','6','财政预算','7','信访','8','应急预案') BUSINESSTYPE,"
                + "   t.abbrname,A.COMPLAINEDGRADE,A.XZGCXYFL,A.SUBXZGCXYFL,A.XZGLFL,A.XZGCBXXS from T_YW_ZDSX_JCJ_TSCHENGPIBIAO A,t_Sys_Department t where  A.COMPLAINEDUNIT = t.id  and A.CHENGPIID = ?";
        pstmt = mConn.prepareStatement(mSQL);
        pstmt.setString(1, pWebForm.getCHENGPIID()); // 主键
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
          pWebForm.getTTsChengpibiao().setCHENGPIID(rs.getString(1)); // 呈批表编号
          pWebForm.getTTsChengpibiao().setCOMPLAINEDPERSON(rs.getString(2)); // 呈批表被投诉人姓名
          pWebForm.getTTsChengpibiao().setCOMPLAINPERSON(rs.getString(3)); // 呈批表投诉人姓名
          pWebForm.getTTsChengpibiao().setCOMPLAINEDUNIT(rs.getString(4)); // 呈批表被投诉人单位
          pWebForm.getTTsChengpibiao().setCOMPLAINUNIT(rs.getString(5)); // 呈批表投诉人单位
          pWebForm.getTTsChengpibiao().setCOMPLAINEDDUTY(rs.getString(6)); // 呈批表被投诉人职务
          pWebForm.getTTsChengpibiao().setCOMPLAINDUTY(rs.getString(7)); // 呈批表投诉人职务
          pWebForm.getTTsChengpibiao().setQUESTIONKIND(rs.getString(8)); // 呈批表问题性质
          pWebForm.getTTsChengpibiao().setCOMPLAINVERSION(rs.getInt(9)); // 呈批表投诉形式
          type = rs.getInt(9);
          pWebForm.getTTsChengpibiao().setCONTENTABSTRACT(rs.getString(10)); // 呈批表内容摘要
          pWebForm.getTTsChengpibiao().setSUGGESTION(rs.getString(11)); // 呈批表拟办意见
          pWebForm.getTTsChengpibiao().setSIGN1(rs.getString(12)); // 呈批表拟办人签字
          pWebForm.getTTsChengpibiao().setDATE1_STR(rs.getString(13)); // 呈批表拟办人签字日期
          pWebForm.getTTsChengpibiao().setLEADERCONFIRM(rs.getString(14)); // 呈批表局领导批示
          pWebForm.getTTsChengpibiao().setSIGN2(rs.getString(15)); // 呈批表局领导签字
          pWebForm.getTTsChengpibiao().setDATE2_STR(rs.getString(16)); // 呈批表局领导签字日期
          pWebForm.getTTsChengpibiao().setREMARK(rs.getString(17)); // 呈批表备注
          pWebForm.getTTsChengpibiao().setBUSINESSID(rs.getString(18));
          pWebForm.setTypename(rs.getString(19));
          pWebForm.setDepartmentname(rs.getString(20));
          pWebForm.getTTsChengpibiao().setCOMPLAINEDGRADE(rs.getInt(21));
          pWebForm.getTTsChengpibiao().setXZGCXYFL(rs.getInt(22));
          pWebForm.getTTsChengpibiao().setSUBXZGCXYFL(rs.getInt(23));
          pWebForm.getTTsChengpibiao().setXZGLFL(rs.getInt(24));
          pWebForm.getTTsChengpibiao().setXZGCBXXS(rs.getInt(25));

        } else {
          throw new CDealException(
              "使用编号 " + pWebForm.getCHENGPIID() + "未能找到数据。", new Exception("查询数据失败。"));
        }
        TreeMap COMPLAINVERSIONList = new TreeMap();
        CCodeMap aCodeMap = new CCodeMap();
        COMPLAINVERSIONList = aCodeMap.getMapByType("行政效能投诉形式");
        String busitypename = (String) COMPLAINVERSIONList.get("" + type);
        pWebForm.setTsxingshu(busitypename);
        // 处理附件
        UploadForm aUploadForm = new UploadForm();
        aUploadForm.setType("行政效能");
        aUploadForm.setBid2("办理呈批表");
        aUploadForm.setBid(Long.parseLong(pWebForm.getTTsChengpibiao().getCHENGPIID()));
        com.tjsoft.system.upload.CDeal.setUploadDefault(aUploadForm, request, response);
        pWebForm.setUploadedFile(aUploadForm.getUploadedFile());
      } catch (Exception e) {
        throw e;
      } finally {
        if (pstmt != null)
          try {
            pstmt.close();
          } catch (Exception e) {
          }
        ;
        if (mConn != null)
          try {
            mConn.close();
          } catch (Exception e) {
          }
        ;
      }
    } catch (Exception e) {
      throw new CDealException("进入修改" + mModuleName + "时失败。", e);
    }
  }
  private void initPK(ConnectionProvider cp, String shortTableName)
      throws SQLException, DBException {
    ResultSet rs;

    IndexElement[] iearr = getIndexes();
    if (iearr != null) {
      for (int i = 0; i < iearr.length; i++)
        if (iearr[i].isUnique()) {
          UniqueKeyElementImpl ukei =
              new UniqueKeyElementImpl(
                  iearr[i].getName().getName(),
                  false); // false = not primary key (primary flag is setted later)
          UniqueKeyElement uke = new UniqueKeyElement(ukei, (TableElement) element, iearr[i]);
          uke.setColumns(iearr[i].getColumns());
          changeKeys(new UniqueKeyElement[] {uke}, DBElement.Impl.ADD);
        }

      UniqueKeyElement[] ukes = ((TableElement) element).getUniqueKeys();

      rs =
          cp.getDatabaseMetaData()
              .getPrimaryKeys(cp.getConnection().getCatalog(), cp.getSchema(), shortTableName);

      TreeMap cols = new TreeMap();
      Object keySeq;
      String colName;
      if (rs != null) {
        HashMap rset = new HashMap();
        while (rs.next()) {
          keySeq = rs.getObject("KEY_SEQ"); // NOI18N
          colName = rs.getString("COLUMN_NAME").trim(); // NOI18N

          cols.put(keySeq, colName); // NOI18N
        }
        rs.close();
      }

      boolean primary = false;
      if (cols != null && cols.size() > 0) primary = true;

      if (primary) {
        if (ukes == null || ukes.length == 0) {
          // issue 56492: no index defined for the primary key
          // generate a UniqueKeyElement and an IndexElement for it

          String indexName = "primary_key_index"; // NOI18N
          int i = 1;
          while (((TableElement) element).getIndex(DBIdentifier.create(indexName)) != null) {
            indexName = indexName + i;
            i++;
          }

          LinkedList idxs = new LinkedList();
          for (Iterator it = cols.values().iterator(); it.hasNext(); ) {
            // non-unique = false, thus the index is unique -- see initIndexes()
            idxs.add(indexName + "." + it.next() + ".false"); // NOI18N
          }

          IndexElementImpl iei = new IndexElementImpl(this, indexName, true);
          IndexElement ie = new IndexElement(iei, (TableElement) element);
          iei.initColumns(idxs);
          changeIndexes(new IndexElement[] {ie}, DBElement.Impl.ADD);

          UniqueKeyElementImpl ukei = new UniqueKeyElementImpl(ie.getName().getName(), true);
          UniqueKeyElement uke = new UniqueKeyElement(ukei, (TableElement) element, ie);
          uke.setColumns(ie.getColumns());
          changeKeys(new UniqueKeyElement[] {uke}, DBElement.Impl.ADD);
        } else if (ukes.length == 1) ukes[0].setPrimaryKey(primary);
        else {
          ColumnElement[] ces;
          Object[] o = cols.values().toArray();
          boolean equals;
          for (int i = 0; i < ukes.length; i++) {
            ces = ukes[i].getColumns();
            if (ces.length != o.length) continue;
            else {
              equals = true;
              for (int j = 0; j < ces.length; j++)
                if (!o[j].toString().equals(ces[j].getName().getName())) {
                  equals = false;
                  break;
                }
              if (equals) {
                ukes[i].setPrimaryKey(primary);
                break;
              }
            }
          }
        }
      }
    }
  }