示例#1
0
 /**
  * 将页面的Form的数据拷内到实体对象
  *
  * @param aWebForm TPubGgl 页面的Form
  * @return editForm 法律法规管理修改的form
  * @throws Exception
  */
 private static TPubFlfggl webForm2PoForm(EditForm aWebForm) throws Exception {
   TPubFlfggl aPoBean = new TPubFlfggl();
   aPoBean.setId(aWebForm.getTPubFlfggl().getId());
   aPoBean.setTitle(aWebForm.getTPubFlfggl().getTitle());
   aPoBean.setClassification(aWebForm.getTPubFlfggl().getClassification());
   aPoBean.setBusinesstype(aWebForm.getTPubFlfggl().getBusinesstype());
   aPoBean.setIssuedate(
       CTools.convertStringToTimestamp(aWebForm.getTPubFlfggl().getIssueTime_str(), "yyyy-MM-dd"));
   aPoBean.setCreatetime(
       CTools.convertStringToTimestamp(
           aWebForm.getTPubFlfggl().getCreateTime_str(), "yyyy-MM-dd"));
   aPoBean.setOrderno(aWebForm.getTPubFlfggl().getOrderno());
   aPoBean.setContent(aWebForm.getTPubFlfggl().getContent());
   aPoBean.setSpare1(aWebForm.getTPubFlfggl().getSpare1());
   aPoBean.setSpare2(aWebForm.getTPubFlfggl().getSpare2());
   aPoBean.setSpare3(aWebForm.getTPubFlfggl().getSpare3());
   aPoBean.setSpare4(aWebForm.getTPubFlfggl().getSpare4());
   return aPoBean;
 }
示例#2
0
 /**
  * 处理增加
  *
  * @param actionForm ActionForm 表单From
  * @param request HttpServletRequest Web请求
  * @param response HttpServletResponse Web结果
  * @throws CDealException 处理异常
  */
 public static long doAdd(
     AddForm pWebForm, HttpServletRequest request, HttpServletResponse response)
     throws CDealException, SQLException {
   long chapterid;
   Connection mconn = null;
   PreparedStatement pstmt = null;
   try {
     CUserBean loginUser =
         (CUserBean) request.getSession().getAttribute(CConstants.USER_BEAN); // 用户BEAN
     /*TPubFlfggl aPoBean = webForm2PoForm(pWebForm);  // 将页面的Form的数据拷内到实体对象
     aPoBean.setId(CTools.getNewNumID());
     aPoBean.setCreateperson(loginUser.getId());  // 用户 ID
     aPoBean.setCreatetime(CTools.getCurrentTimestamp());  // 当前时间
     CHibernateUtil.saveObject(aPoBean);  // 调用 PO 层进行增加 */
     chapterid = CTools.getNewNumID();
     mconn = CDBManager.getConn();
     mconn.setAutoCommit(false); // 将自动提交设置为否
     String sql =
         "insert into t_pub_law (id,createperson,createtime,title,classification,issuedate,orderno,spare1,spare2,spare3,spare4,businesstype,bigcontent) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
     pstmt = mconn.prepareStatement(sql);
     pstmt.setLong(1, chapterid);
     pstmt.setLong(2, loginUser.getId());
     pstmt.setTimestamp(3, CTools.getCurrentTimestamp());
     pstmt.setString(4, pWebForm.getTPubFlfggl().getTitle());
     CLog.println("4====title=" + pWebForm.getTPubFlfggl().getTitle());
     pstmt.setInt(5, pWebForm.getTPubFlfggl().getClassification());
     CLog.println("5====classification=" + pWebForm.getTPubFlfggl().getClassification());
     pstmt.setTimestamp(
         6,
         CTools.convertStringToTimestamp(
             pWebForm.getTPubFlfggl().getIssueTime_str(), "yyyy-mm-dd"));
     pstmt.setLong(7, pWebForm.getTPubFlfggl().getOrderno());
     pstmt.setString(8, pWebForm.getTPubFlfggl().getSpare1());
     pstmt.setString(9, pWebForm.getTPubFlfggl().getSpare2());
     pstmt.setString(10, pWebForm.getTPubFlfggl().getSpare3());
     pstmt.setString(11, pWebForm.getTPubFlfggl().getSpare4());
     pstmt.setInt(12, pWebForm.getTPubFlfggl().getBusinesstype());
     pstmt.setClob(13, CLOB.empty_lob()); // 构造空CLOB对象
     pstmt.executeUpdate();
     pstmt.close();
     // =======================再次从库表中读出,获得CLOB句柄
     pstmt =
         mconn.prepareStatement("select a.bigcontent from t_pub_law a where a.id = ? for update");
     pstmt.setLong(1, chapterid);
     ResultSet rs = pstmt.executeQuery();
     rs.next();
     CLOB textClob = (CLOB) rs.getClob(1);
     textClob.putString(
         1,
         pWebForm
             .getTPubFlfggl()
             .getBigContent_str()
             .replaceAll("\n", "<br>")); // 将页面的法律法规内容写入Clob
     pstmt = mconn.prepareStatement("update t_pub_law set bigcontent=? where id=?");
     pstmt.setClob(1, textClob);
     pstmt.setLong(2, chapterid);
     pstmt.executeUpdate();
     return chapterid;
   } catch (Exception e) {
     throw new CDealException("执行增加" + mModuleName + "时失败。", e);
   } finally {
     if (pstmt != null) {
       pstmt.close();
     }
     mconn.commit();
     if (mconn != null) {
       mconn.close();
     }
   }
 }
示例#3
0
  /**
   * 处理修改
   *
   * @param actionForm ActionForm 表单From
   * @param request HttpServletRequest Web请求
   * @param response HttpServletResponse Web结果
   * @throws CDealException 处理异常
   */
  public static void doEdit(
      EditForm pWebForm, HttpServletRequest request, HttpServletResponse response)
      throws CDealException, SQLException {
    CUserBean loginUser =
        (CUserBean) request.getSession().getAttribute(CConstants.USER_BEAN); // 用户BEAN
    long chapterid = pWebForm.getTPubFlfggl().getId();
    Connection mconn = null;
    PreparedStatement pstmt = null;
    try {
      /*TPubFlfggl aPoBean = webForm2PoForm(pWebForm);  // 将页面的Form的数据拷内到实体对象
      aPoBean.setModperson(loginUser.getId());  // 用户 ID
      aPoBean.setModtime(CTools.getCurrentTimestamp());  // 当前时间
      CHibernateUtil.updateObject(aPoBean);  // 调用 PO 层进行修改 */
      mconn = CDBManager.getConn();
      mconn.setAutoCommit(false); // 将自动提交设置为否
      String sql =
          "update t_pub_law a set a.modperson=?,a.modtime=?,a.title=?,a.classification=?,a.businesstype=?,a.issuedate=?,a.orderno=?,a.bigcontent = ? where a.id = ? ";
      pstmt = mconn.prepareStatement(sql);
      pstmt.setLong(1, loginUser.getId());
      pstmt.setTimestamp(2, CTools.getCurrentTimestamp());
      pstmt.setString(3, pWebForm.getTPubFlfggl().getTitle());
      pstmt.setInt(4, pWebForm.getTPubFlfggl().getClassification());
      pstmt.setInt(5, pWebForm.getTPubFlfggl().getBusinesstype());
      pstmt.setTimestamp(
          6,
          CTools.convertStringToTimestamp(
              pWebForm.getTPubFlfggl().getIssueTime_str(), "yyyy-MM-dd"));
      pstmt.setLong(7, pWebForm.getTPubFlfggl().getOrderno());
      pstmt.setClob(8, CLOB.empty_lob());
      pstmt.setLong(9, chapterid);
      pstmt.executeUpdate();
      pstmt.close();

      // =======================再次从库表中读出,获得CLOB句柄
      pstmt =
          mconn.prepareStatement("select a.bigcontent from t_pub_law a where a.id = ? for update");
      pstmt.setLong(1, chapterid);
      ResultSet rs = pstmt.executeQuery();
      rs.next();
      CLOB textClob = (CLOB) rs.getClob(1);
      if (textClob == null) {
        CLog.println("340========textClob is null");
      }
      if (pWebForm.getTPubFlfggl().getBigContent_str() == null) {
        CLog.println("343========BigContent_str is null");
      }
      textClob.putString(
          1,
          pWebForm
              .getTPubFlfggl()
              .getBigContent_str()
              .replaceAll("\n", "<br>")); // 将页面的法律法规内容写入Clob
      pstmt = mconn.prepareStatement("update t_pub_law set bigcontent=? where id=?");
      pstmt.setClob(1, textClob);
      pstmt.setLong(2, chapterid);
      pstmt.executeUpdate();
    } catch (Exception e) {
      throw new CDealException("执行修改" + mModuleName + "时失败。", e);
    } finally {
      if (pstmt != null) {
        pstmt.close();
      }
      mconn.commit();
      if (mconn != null) {
        mconn.close();
      }
    }
  }