document.java

来自「一个用java编写的功能强大的OA系统」· Java 代码 · 共 1,589 行 · 第 1/4 页

JAVA
1,589
字号
        Conn conn = new Conn(connname);        PreparedStatement pstmt = null;        try {                        pstmt = conn.prepareStatement(SAVE_DOCUMENT);            pstmt.setString(1, title);            pstmt.setInt(2, canComment ? 1 : 0);            pstmt.setBoolean(3, isHome);            pstmt.setInt(4, examine);            pstmt.setString(5, keywords);            pstmt.setInt(6, intisRelateShow);            pstmt.setInt(7, templateId);            pstmt.setString(8, dir_code);            pstmt.setInt(9, isNew);            pstmt.setString(10, author);            pstmt.setString(11, flowTypeCode);            pstmt.setString(12, parentCode);            pstmt.setString(13, color);            pstmt.setInt(14, bold?1:0);            if (expireDate == null)                pstmt.setTimestamp(15, null);            else                pstmt.setTimestamp(15, new Timestamp(expireDate.getTime()));            pstmt.setInt(16, id);            conn.executePreUpdate();                        DocCacheMgr dcm = new DocCacheMgr();            if (oldexamine==examine) {                dcm.refreshUpdate(id);            }            else {                dcm.refreshUpdate(id, class1, parentCode);            }                        if (!dir_code.equals(class1)) {                dcm.refreshChangeDirCode(class1, dir_code);                class1 = dir_code;            }                        DocContent dc = new DocContent();            dc = dc.getDocContent(id, 1);            dc.saveWithoutFile(application, mfu);        } catch (SQLException e) {            logger.error(e.getMessage());            throw new ErrMsgException("服务器内部错!");        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        return true;    }    public synchronized boolean UpdateIsHome(boolean isHome) throws            ErrMsgException {        String sql = "update document set isHome=? where id=?";        Conn conn = new Conn(connname);        PreparedStatement pstmt = null;        try {                        pstmt = conn.prepareStatement(sql);            pstmt.setInt(1, isHome ? 1 : 0);            pstmt.setInt(2, id);            conn.executePreUpdate();                        DocCacheMgr dcm = new DocCacheMgr();            dcm.refreshUpdate(id);        } catch (SQLException e) {            logger.error(e.getMessage());            throw new ErrMsgException("服务器内部错!");        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        return true;    }    public synchronized boolean increaseHit() throws            ErrMsgException {        hit ++;        Conn conn = new Conn(connname);        PreparedStatement pstmt = null;        try {                        pstmt = conn.prepareStatement(SAVE_HIT);            pstmt.setInt(1, hit);            pstmt.setInt(2, id);            conn.executePreUpdate();                        DocCacheMgr dcm = new DocCacheMgr();            dcm.refreshUpdate(id);        } catch (SQLException e) {            logger.error(e.getMessage());            throw new ErrMsgException("服务器内部错!");        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        return true;    }    public synchronized boolean UpdateSummaryWithoutFile(ServletContext application,                                                CMSMultiFileUploadBean mfu) throws            ErrMsgException {        Conn conn = new Conn(connname);        boolean re = true;        try {                        String idstr = StrUtil.getNullString(mfu.getFieldValue("id"));            if (!StrUtil.isNumeric(idstr))                throw new ErrMsgException("标识id=" + idstr + "非法,必须为数字!");            id = Integer.parseInt(idstr);            summary = StrUtil.getNullString(mfu.getFieldValue("htmlcode"));            PreparedStatement pstmt = null;             pstmt = conn.prepareStatement(SAVE_SUMMARY);            pstmt.setString(1, summary);            pstmt.setInt(2, id);            re = conn.executePreUpdate()==1?true:false;                        DocCacheMgr dcm = new DocCacheMgr();            dcm.refreshUpdate(id);        } catch (SQLException e) {            re = false;            logger.error(e.getMessage());        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        return re;    }    public synchronized boolean UpdateSummary(ServletContext application, CMSMultiFileUploadBean mfu) throws            ErrMsgException {        String isuploadfile = StrUtil.getNullString(mfu.getFieldValue(                "isuploadfile"));                if (isuploadfile.equals("false"))            return UpdateSummaryWithoutFile(application, mfu);        String FilePath = StrUtil.getNullString(mfu.getFieldValue("filepath"));        String tempAttachFilePath = application.getRealPath("/") + FilePath +                                    "/";        mfu.setSavePath(tempAttachFilePath);         File f = new File(tempAttachFilePath);        if (!f.isDirectory()) {            f.mkdirs();        }        boolean re = false;        ResultSet rs = null;        Conn conn = new Conn(connname);        try {                        String sql = "select path from cms_images where mainkey=" + id +                         " and kind='document' and subkey=" + 0 + "";            rs = conn.executeQuery(sql);            if (rs != null) {                String fpath = "";                while (rs.next()) {                    fpath = rs.getString(1);                    if (fpath != null) {                        File virtualFile = new File(Global.getRealPath() + fpath);                        virtualFile.delete();                    }                }            }            if (rs != null) {                rs.close();                rs = null;            }                        sql = "delete from cms_images where mainkey=" + id +                  " and kind='document' and subkey=" + 0 + "";            conn.executeUpdate(sql);                        int ret = mfu.getRet();            if (ret == 1) {                mfu.writeFile(false);                Vector files = mfu.getFiles();                                java.util.Enumeration e = files.elements();                String filepath = "";                sql = "";                while (e.hasMoreElements()) {                    FileInfo fi = (FileInfo) e.nextElement();                    filepath = FilePath + "/" + fi.getName();                    sql = "insert into cms_images (path,mainkey,kind,subkey) values (" +                            StrUtil.sqlstr(filepath) + "," + id +                            ",'document'," + 0 + ")";                    conn.executeUpdate(sql);                }            } else                throw new ErrMsgException("上传失败!ret=" + ret);            if (rs != null) {                try {                    rs.close();                } catch (Exception e) {}                rs = null;            }            re = UpdateSummaryWithoutFile(application, mfu);        } catch (Exception e) {            logger.error("UpdateSummary:" + e.getMessage());        } finally {            if (conn != null) {                conn.close();                conn = null;            }        }        return re;    }    public boolean updateOrgAddr() {        String sql = "update document set orgAddr=? where id=?";        Conn conn = new Conn(connname);        boolean re = false;        try {            PreparedStatement pstmt = conn.prepareStatement(sql);            pstmt.setString(1, orgAddr);            pstmt.setInt(2, id);            re = conn.executePreUpdate()==1?true:false;            if (re) {                                DocCacheMgr dcm = new DocCacheMgr();                dcm.refreshUpdate(id);            }        }        catch (SQLException e) {            logger.error(e.getMessage());        }        finally {            if (conn!=null) {                conn.close(); conn = null;            }        }        return re;    }    public synchronized boolean updateTemplateId() {        String sql = "update document set template_id=? where id=?";        Conn conn = new Conn(connname);        boolean re = false;        try {            PreparedStatement pstmt = conn.prepareStatement(sql);            pstmt.setInt(1, templateId);            pstmt.setInt(2, id);            re = conn.executePreUpdate()==1?true:false;            if (re) {                                DocCacheMgr dcm = new DocCacheMgr();                dcm.refreshUpdate(id);            }        }        catch (SQLException e) {            logger.error(e.getMessage());        }        finally {            if (conn!=null) {                conn.close(); conn = null;            }        }        return re;    }    public synchronized boolean Update(ServletContext application,                                       CMSMultiFileUploadBean mfu) throws            ErrMsgException {        String isuploadfile = StrUtil.getNullString(mfu.getFieldValue(                "isuploadfile"));                if (isuploadfile.equals("false"))            return UpdateWithoutFile(application, mfu);                String dir_code = StrUtil.getNullStr(mfu.getFieldValue("dir_code"));        author = StrUtil.getNullString(mfu.getFieldValue("author"));        title = StrUtil.getNullString(mfu.getFieldValue("title"));        String strIsHome = StrUtil.getNullString(mfu.getFieldValue("isHome"));        if (strIsHome.equals(""))            isHome = false;        else if (strIsHome.equals("false"))            isHome = false;        else if (strIsHome.equals("true"))            isHome = true;        else            isHome = false;        String strexamine = mfu.getFieldValue("examine");        int oldexamine = examine;        examine = Integer.parseInt(strexamine);        keywords = StrUtil.getNullStr(mfu.getFieldValue("keywords"));        String strisRelateShow = StrUtil.getNullStr(mfu.getFieldValue("isRelateShow"));        int intisRelateShow = 0;        if (StrUtil.isNumeric(strisRelateShow)) {            intisRelateShow = Integer.parseInt(strisRelateShow);            if (intisRelateShow==1)                isRelateShow = true;        }        String strisnew = StrUtil.getNullStr(mfu.getFieldValue("isNew"));        if (StrUtil.isNumeric(strisnew))            isNew = Integer.parseInt(strisnew);        else            isNew = 0;        String strCanComment = StrUtil.getNullStr(mfu.getFieldValue(                "canComment"));        if (strCanComment.equals(""))            canComment = false;        else if (strCanComment.equals("1"))            canComment = true;        flowTypeCode = StrUtil.getNullStr(mfu.getFieldValue("flowTypeCode"));        color = StrUtil.getNullStr(mfu.getFieldValue("color"));        bold = StrUtil.getNullStr(mfu.getFieldValue("isBold")).equals("true");        expireDate = DateUtil.parse(mfu.getFieldValue("expireDate"), "yyyy-MM-dd");        if (!dir_code.equals(class1)) {            Leaf lf = new Leaf();            lf = lf.getLeaf(dir_code);            parentCode = lf.getParentCode();        }        Conn conn = new Conn(connname);        ResultSet rs = null;        PreparedStatement pstmt = null;        try {                        pstmt = conn.prepareStatement(SAVE_DOCUMENT);            pstmt.setString(1, title);            pstmt.setInt(2, canComment ? 1 : 0);            pstmt.setBoolean(3, isHome);            pstmt.setInt(4, examine);            pstmt.setString(5, keywords);            pstmt.setInt(6, intisRelateShow);            pstmt.setInt(7, templateId);            pstmt.setString(8, dir_code);            pstmt.setInt(9, isNew);            pstmt.setString(10, author);            pstmt.setString(11, flowTypeCode);            pstmt.setString(12, parentCode);            pstmt.setString(13, color);            pstmt.setInt(14, bold?1:0);            if (expireDate==null)                pstmt.setTimestamp(15, null);            else                pstmt.setTimestamp(15, new Timestamp(expireDate.getTime()));            pstmt.setInt(16, id);            conn.executePreUpdate();                        DocCacheMgr dcm = new DocCacheMgr();            if (oldexamine==examine) {                dcm.refreshUpdate(id);            }            else {                dcm.refreshUpdate(id, class1, parentCode);            }                        if (!dir_code.equals(class1)) {                dcm.refreshChangeDirCode(class1, dir_code);                class1 = dir_code;            }                        DocContent dc = new DocContent();            dc = dc.getDocContent(id, 1);            dc.save(application, mfu);        } catch (SQLException e) {            logger.error(e.getMessage());            throw new ErrMsgException("服务器内部错!");        } finally {            if (rs != null) {                try {                    rs.close();                } catch (Exception e) {}                rs = null;            }            if (conn != null) {                conn.close();                conn = null;            }        }        return true;    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?