Esempio n. 1
0
 /** CLOB을 그냥 select해서 넣으면 안들어간다. 이거 한번 돌리고 쓰자. */
 public static List<? extends Object[]> convertClob(List<? extends Object[]> items) {
   List<Object[]> newItems = Lists.newArrayList();
   for (Object[] item : items) {
     Object[] newItem = new Object[item.length];
     for (int i = 0; i < item.length; i++) {
       Object columnValue = item[i];
       if (columnValue instanceof CLOB) {
         CLOB clob = (CLOB) columnValue;
         try {
           columnValue = IOUtils.toString(clob.getCharacterStream());
         } catch (Exception e) {
           Throwables.propagate(e);
         }
       }
       newItem[i] = columnValue;
     }
     newItems.add(newItem);
   }
   return newItems;
 }
Esempio n. 2
0
  /**
   * 设置进入修改页面的初始值
   *
   * @param actionForm ActionForm 表单From
   * @param request HttpServletRequest Web请求
   * @param response HttpServletResponse Web结果
   * @throws CDealException 处理异常
   */
  public static void setEditDefault(
      EditForm pWebForm, HttpServletRequest request, HttpServletResponse response)
      throws CDealException {
    try {

      // 初始化页面,初始化法律类别下拉菜单
      TreeMap classificationList = new TreeMap();
      classificationList = CCodeMap.getMapByType("法律类别");
      pWebForm.setClassificationList(classificationList);
      CLog.println("\n111111111法律类别");
      // 初始化页面,初始化业务类别下拉菜单
      TreeMap businesstypeList = new TreeMap();
      businesstypeList = CCodeMap.getMapByType("法律法规业务类别");
      pWebForm.setBusinesstypeList(businesstypeList);
      CLog.println("\n业务类别");

      // UploadForm aUploadForm = new UploadForm();
      // aUploadForm.setType("重大事项");
      // aUploadForm.setBid(pWebForm.getTPubFlfggl().getId());
      // CLog.println("\n公共管理333333");
      // com.tjsoft.system.upload.CDeal.setUploadDefault(aUploadForm, request, response);
      // CLog.println("\n公共管理55555555");
      // pWebForm.setUploadedFile(aUploadForm.getUploadedFile());
      // CLog.println("\n111111111hhhhhhhrrrr");

      Connection mConn = null;
      PreparedStatement pstmt = null;
      String content_str = "";
      try {
        mConn = CDBManager.getConn(); // 创建数据库连接
        // String mSQL = "SELECT
        // t.title,t.classification,t.businesstype,to_char(t.Issuedate,'yyyy-mm-dd'),t.orderno,t.content,spare1,spare2,spare3,spare4,to_char(t.createtime,'yyyy-mm-dd') FROM t_pub_law t WHERE t.id=?";
        String mSQL =
            "SELECT t.title,t.classification,t.businesstype,to_char(t.Issuedate,'yyyy-mm-dd'),t.orderno,t.content,spare1,spare2,spare3,spare4,to_char(t.createtime,'yyyy-mm-dd'),t.bigcontent FROM t_pub_law t WHERE t.id=?";
        pstmt = mConn.prepareStatement(mSQL);
        pstmt.setLong(1, pWebForm.getTPubFlfggl().getId()); // 主键
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
          // pWebForm.getTPubFlfggl().setId(rs.getLong(1));
          pWebForm.getTPubFlfggl().setTitle(rs.getString(1)); // 标题
          pWebForm.getTPubFlfggl().setClassification(rs.getInt(2)); // 类别
          pWebForm.getTPubFlfggl().setBusinesstype(rs.getInt(3)); // 业务类别
          pWebForm.getTPubFlfggl().setIssueTime_str(rs.getString(4)); // 颁布日期
          pWebForm.getTPubFlfggl().setOrderno(rs.getLong(5)); // 排序号
          pWebForm.getTPubFlfggl().setContent(rs.getString(6)); // 内容
          pWebForm.getTPubFlfggl().setSpare1(rs.getString(7)); // 备用字段
          pWebForm.getTPubFlfggl().setSpare2(rs.getString(8)); // 备用字段
          pWebForm.getTPubFlfggl().setSpare3(rs.getString(9)); // 备用字段
          pWebForm.getTPubFlfggl().setSpare4(rs.getString(10)); // 备用字段
          pWebForm.getTPubFlfggl().setCreateTime_str(rs.getString(11)); // 录入时间
          // pWebForm.getTPubFlfggl().setBigContent(rs.getClob(12));
          CLOB content = (CLOB) rs.getClob(12);
          if (content != null) {
            Reader is = content.getCharacterStream();
            BufferedReader br = new BufferedReader(is);
            String s = br.readLine();
            while (s != null) {
              content_str += s;
              s = br.readLine();
            }
          }
          pWebForm.getTPubFlfggl().setBigContent_str(content_str.replaceAll("<br>", "\n"));
        } else {
          throw new CDealException(
              "使用编号 " + pWebForm.getTPubFlfggl().getId() + "未能找到数据。", new Exception("查询数据失败。"));
        }
      } catch (Exception e) {
        throw e;
      }

    } catch (Exception e) {
      throw new CDealException("进入修改" + mModuleName + "时失败。", e);
    }
  }