123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578 |
- package com.sinosoft.am.systemFile.dao;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import net.sf.json.JSONArray;
- import org.apache.log4j.Logger;
- import com.formaction.Parameter;
- import com.formaction.vo.Msg;
- import com.persistence.DbConnection;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.am.systemFile.vo.SystemFile;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- public class SystemFileDao{
- private Logger log = Logger.getLogger(this.getClass());
-
- /**
- * 上报文件 上级单位可看
- * @throws ClassNotFoundException
- */
- public Msg appear(String comp_id,String fd_id) throws ClassNotFoundException{
- Msg m=new Msg();
- String []arr=fd_id.split(",");
- String sql="UPDATE ECM_AM_FILE_MANAGEMENT SET FILE_STATUS='1',REPORT_COMP_ID=? where fd_objectid=?";
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<arr.length;i++){
- st.setString(1, comp_id);
- st.setString(2, arr[i]);
- st.executeUpdate();
- num++;
- }
- if(num==arr.length){
- log.info("删除----num===="+num);
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- conn.commit();
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- conn.rollback();
- return m;
- }
- }catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 删除消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- }
-
- /**
- * 发布文件 使所有级别都可以看到
- * @throws ClassNotFoundException
- */
- public Msg issue(String comp_id,String fd_id) throws ClassNotFoundException{
- Msg m=new Msg();
- String []arr=fd_id.split(",");
- String sql="UPDATE ECM_AM_FILE_MANAGEMENT SET FILE_STATUS='2',PUBLISH_COMP_ID=? where fd_objectid=?";
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<arr.length;i++){
- st.setString(1, comp_id);
- st.setString(2, arr[i]);
- st.executeUpdate();
- num++;
- }
- if(num==arr.length){
- log.info("删除----num===="+num);
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- conn.commit();
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- conn.rollback();
- return m;
- }
- }catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 删除消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- }
-
- /**
- * 撤回文件 更改文件状态,上级无法查看,只能本人查看
- * @throws ClassNotFoundException
- */
- public Msg callBack(String fd_id) throws ClassNotFoundException{
- Msg m=new Msg();
- String []arr=fd_id.split(",");
- String sql="UPDATE ECM_AM_FILE_MANAGEMENT SET FILE_STATUS='0' where fd_objectid=?";
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<arr.length;i++){
- st.setString(1, arr[i]);
- st.executeUpdate();
- num++;
- }
- if(num==arr.length){
- log.info("删除----num===="+num);
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- conn.commit();
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- conn.rollback();
- return m;
- }
- }catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 删除消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- }
-
- /**
- * 上传文件
- */
- public void importFile(String fileName){
-
- }
-
- //查询上报的文件
- //上报公司为查询用户的子公司且状态为上报状态‘1’
- public List<Map<String, String>> queryAppearFileList(String userId,String conditon) throws ClassNotFoundException{
- String sql="select FD_OBJECTID,FILE_TITLE,FILE_CLASSIFY,FILE_CONTENT,FILE_ADD_DATE,PIGEONHOLE_MAN_ID,PIGEONHOLE_DATE,CHANGE_DETAIL,CHANGE_TYPE,PUBLISH_COMP_ID,REPORT_COMP_ID,FILE_STATUS,IS_DEL,ELECTRONIC_FILE,UPDATEDATE,VERSION_ID from ECM_AM_FILE_MANAGEMENT WHERE REPORT_COMP_ID in(select id from sys_department_0827 where parent_id='"+userId+"') and FILE_STATUS='1' ";
- if(!"".equals(conditon)){
- sql+=conditon;
- }
- log.info("queryAppearFileList.sql==="+sql);
- List<Map<String, String>> list = null;
- try {
- list = PersistenceFactory.getInstance( ModelFactory.getSysmodel()).getSearchResultToMap(99, sql);
- } catch (PersistenceException e) {
- log.error(e.getMessage());
- }
- log.info("获取已接收消息条数===="+list.size());
- // String result = "{\"rows\":" + JSONArray.fromObject(list).toString() + "}";
- return list;
- }
-
- //查询发布的文件
- //状态为2 且发布部门为当前用户部门
- public List<Map<String, String>> queryIssueFileList(String userId,String conditon) throws ClassNotFoundException{
- String sql="select FD_OBJECTID,FILE_TITLE,FILE_CLASSIFY,FILE_CONTENT,FILE_ADD_DATE,PIGEONHOLE_MAN_ID,PIGEONHOLE_DATE,CHANGE_DETAIL,CHANGE_TYPE,PUBLISH_COMP_ID,REPORT_COMP_ID,FILE_STATUS,IS_DEL,ELECTRONIC_FILE,UPDATEDATE,VERSION_ID from ECM_AM_FILE_MANAGEMENT WHERE FILE_STATUS='2' AND PUBLISH_COMP_ID='"+userId+"' ";
- if(!"".equals(conditon)){
- sql+=conditon;
- }
- log.info("queryIssueFileList.sql==="+sql);
- List<Map<String, String>> list = null;
- try {
- list = PersistenceFactory.getInstance( ModelFactory.getSysmodel()).getSearchResultToMap(99, sql);
- } catch (PersistenceException e) {
- log.error(e.getMessage());
- }
- log.info("获取已接收消息条数===="+list.size());
- // String result = "{\"rows\":" + JSONArray.fromObject(list).toString() + "}";
- return list;
- }
-
- //查询上传的文件
- //上传用户为登录用户且文件状态为上传状态‘0’
- public List<Map<String, String>> queryUploadFileList(String userId,String conditon) throws ClassNotFoundException{
- String sql="select FD_OBJECTID,FILE_TITLE,FILE_CLASSIFY,FILE_CONTENT,FILE_ADD_DATE,PIGEONHOLE_MAN_ID,PIGEONHOLE_DATE,CHANGE_DETAIL,CHANGE_TYPE,PUBLISH_COMP_ID,REPORT_COMP_ID,FILE_STATUS,IS_DEL,ELECTRONIC_FILE,UPDATEDATE,VERSION_ID from ECM_AM_FILE_MANAGEMENT WHERE FILE_STATUS in('0','1') AND PIGEONHOLE_MAN_ID='"+userId+"' ";
- if(!"".equals(conditon)){
- sql+=conditon;
- }
- log.info("queryUploadFileList.sql==="+sql);
- List<Map<String, String>> list = null;
- try {
- list = PersistenceFactory.getInstance( ModelFactory.getSysmodel()).getSearchResultToMap(99, sql);
- } catch (PersistenceException e) {
- log.error(e.getMessage());
- }
- log.info("获取已接收消息条数===="+list.size());
- // String result = "{\"rows\":" + JSONArray.fromObject(list).toString() + "}";
- return list;
- }
-
- /**
- * 初始化和查询文件
- * @throws ClassNotFoundException
- */
- public String queryFileList(String userId,String comp_id,String condition,int pageNo,int pageSize) throws ClassNotFoundException{
- if(!"".equals(condition)){
- condition+=" ";
- }
- /*String sql1="select FD_OBJECTID,FILE_TITLE,FILE_CLASSIFY,FILE_CONTENT,FILE_ADD_DATE,PIGEONHOLE_MAN_ID,PIGEONHOLE_DATE,CHANGE_DETAIL,CHANGE_TYPE,PUBLISH_COMP_ID,REPORT_COMP_ID,FILE_STATUS,IS_DEL,ELECTRONIC_FILE,UPDATEDATE,VERSION_ID from ECM_AM_FILE_MANAGEMENT WHERE REPORT_COMP_ID in(select id from sys_department_0827 where parent_id='"+userId+"') and FILE_STATUS='1' ";
- String sql2="select FD_OBJECTID,FILE_TITLE,FILE_CLASSIFY,FILE_CONTENT,FILE_ADD_DATE,PIGEONHOLE_MAN_ID,PIGEONHOLE_DATE,CHANGE_DETAIL,CHANGE_TYPE,PUBLISH_COMP_ID,REPORT_COMP_ID,FILE_STATUS,IS_DEL,ELECTRONIC_FILE,UPDATEDATE,VERSION_ID from ECM_AM_FILE_MANAGEMENT WHERE FILE_STATUS='2' AND PUBLISH_COMP_ID='"+userId+"' ";
- String sql3="select FD_OBJECTID,FILE_TITLE,FILE_CLASSIFY,FILE_CONTENT,FILE_ADD_DATE,PIGEONHOLE_MAN_ID,PIGEONHOLE_DATE,CHANGE_DETAIL,CHANGE_TYPE,PUBLISH_COMP_ID,REPORT_COMP_ID,FILE_STATUS,IS_DEL,ELECTRONIC_FILE,UPDATEDATE,VERSION_ID from ECM_AM_FILE_MANAGEMENT WHERE FILE_STATUS in('0','1') AND PIGEONHOLE_MAN_ID='"+userId+"' ";*/
- String sql="";
- String sqlR="";
-
- if(!"".equals(condition)){
- sql+="select FD_OBJECTID,FILE_TITLE,FILE_CLASSIFY,FILE_CONTENT,FILE_ADD_DATE,PIGEONHOLE_MAN_ID,PIGEONHOLE_DATE,CHANGE_DETAIL,CHANGE_TYPE,PUBLISH_COMP_ID,REPORT_COMP_ID,FILE_STATUS,IS_DEL,ELECTRONIC_FILE,UPDATEDATE,VERSION_ID from ECM_AM_FILE_MANAGEMENT "
- + "WHERE (REPORT_COMP_ID in(select id from sys_department_0827 where parent_id='"+userId+"') and FILE_STATUS='1' "+condition+")or (FILE_STATUS='2' AND PUBLISH_COMP_ID='"+userId+"' "+condition+") or(FILE_STATUS in('0','1') AND PIGEONHOLE_MAN_ID='"+userId+"' "+condition+") ";
- sqlR+="select top "+(pageNo-1)*pageSize+","+pageSize+" FD_OBJECTID,FILE_TITLE,FILE_CLASSIFY,FILE_CONTENT,FILE_ADD_DATE,PIGEONHOLE_MAN_ID,PIGEONHOLE_DATE,CHANGE_DETAIL,CHANGE_TYPE,PUBLISH_COMP_ID,REPORT_COMP_ID,FILE_STATUS,IS_DEL,ELECTRONIC_FILE,UPDATEDATE,VERSION_ID from ECM_AM_FILE_MANAGEMENT "
- + "WHERE (REPORT_COMP_ID in(select id from sys_department_0827 where parent_id='"+userId+"') and FILE_STATUS='1' "+condition+")or (FILE_STATUS='2' AND PUBLISH_COMP_ID='"+userId+"' "+condition+") or(FILE_STATUS in('0','1') AND PIGEONHOLE_MAN_ID='"+userId+"' "+condition+") ";
- /*sql+=condition;
- sqlR+=condition;*/
- }
- List<Map<String, String>> list = null;
- List<Map<String, String>> listR = null;
- try {
- list = PersistenceFactory.getInstance( ModelFactory.getSysmodel()).getSearchResultToMap(99, sql);
- listR = PersistenceFactory.getInstance( ModelFactory.getSysmodel()).getSearchResultToMap(99, sqlR);
- } catch (PersistenceException e) {
- log.error(e.getMessage());
- }
- log.info("sqlR===="+sqlR);
- log.info("sql===="+sql);
- log.info("获取已接收消息条数===="+list.size());
-
- /*List<Map<String, String>>list1=queryAppearFileList(comp_id,condition);
- List<Map<String, String>>list2=queryIssueFileList(comp_id,condition);
- List<Map<String, String>>list3=queryUploadFileList(userId,condition);*/
- /*for(int i=0;i<list1.size();i++){
- list.add(list1.get(i));
- // list.add(list1.get(i));
- // list.add(list1.get(i));
- // list.add(list1.get(i));
- // list.add(list1.get(i));
- // list.add(list1.get(i));
- // list.add(list1.get(i));
- // list.add(list1.get(i));
- }*/
- /*for(int i=0;i<list2.size();i++){
- list.add(list2.get(i));
- // list.add(list2.get(i));
- // list.add(list2.get(i));
- // list.add(list2.get(i));
- // list.add(list2.get(i));
- // list.add(list2.get(i));
- // list.add(list2.get(i));
- // list.add(list2.get(i));
-
- }*/
- /*for(int i=0;i<list3.size();i++){
- list.add(list3.get(i));
- // list.add(list3.get(i));
- // list.add(list3.get(i));
- // list.add(list3.get(i));
- // list.add(list3.get(i));
- // list.add(list3.get(i));
- // list.add(list3.get(i));
- // list.add(list3.get(i));
-
- }*/
-
- log.info("获取已接收消息条数===="+list.size());
- String result = "{\"pager.pageNo\":"+pageNo+",\"pager.totalRows\":"+list.size()+",\"rows\":" + JSONArray.fromObject(listR).toString() + "}";
- log.info("result==="+result);
- return result;
- }
-
-
- /**
- * 查看文件明细和修改文件查看
- */
- public String getFileInfo(String fd_id){
- String sql="select * from ECM_AM_FILE_MANAGEMENT where fd_objectid='"+fd_id+"'";
- List list = null;
- try {
- list = PersistenceFactory.getInstance( ModelFactory.getSysmodel()).getSearchResultToMap(99, sql);
- } catch (PersistenceException e) {
- log.error(e.getMessage());
- }
- String result = "{\"rows\":" + JSONArray.fromObject(list).toString() + "}";
- log.info("获取制度文件信息==="+result);
- return result;
- }
-
- /**
- * 修改文件--纯修改文件基本信息
- * @throws ClassNotFoundException
- */
- public Msg updateFile(SystemFile sf) throws ClassNotFoundException{
- Msg m=new Msg();
- String sql="update ECM_AM_FILE_MANAGEMENT SET FILE_TITLE=?,FILE_CLASSIFY=?,FILE_CONTENT=?,CHANGE_DETAIL=?,CHANGE_TYPE=?,UPDATEDATE=?,FILE_ADD_DATE=? WHERE FD_OBJECTID=?";
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- st.setString(1, sf.getFILE_TITLE());
- st.setString(2, sf.getFILE_CLASSIFY());
- st.setString(3, sf.getFILE_CONTENT());
- st.setString(4, sf.getCHANGE_DETAIL());
- st.setString(5, sf.getCHANGE_TYPE());
- st.setString(6,formatDate(new Date()));
- st.setString(7, sf.getFILE_ADD_DATE());
- st.setString(8, sf.getFD_OBJECTID());
- st.executeUpdate();
- num++;
- if(num==1){
- log.info("删除----num===="+num);
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.UPDATE_SUCSESS);
- conn.commit();
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.UPDATE_FAILURE);
- conn.rollback();
- return m;
- }
- }catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 删除消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- }
-
- /**
- * 归档--修改时如果附件栏有变动,则视为归档
- * @throws ClassNotFoundException
- */
- public Msg placeFile(SystemFile sf) throws ClassNotFoundException{
- Msg m=new Msg();
- // String version_id=getVersionId(sf.getFD_OBJECTID());
- sf.setVERSION_ID(sf.getVERSION_ID());
-
- m=createFile(sf);
-
- m=deleteFile(sf.getFD_OBJECTID());
- return m;
- }
-
- // public String getVersionId(String id) throws ClassNotFoundException{
- // String sql="SELECT version_id FROM WHERE fd_objectid='"+id+"'";
- // String fd_id="";
- // Connection conn = null;
- // Statement stat = null;
- // ResultSet rs = null;
- // DbConnection db = new DbConnection();
- // try {
- // conn = db.getConnection();
- // stat = conn.createStatement();
- // rs = stat.executeQuery(sql);
- // List<String> list = new ArrayList<String>();
- // while (rs.next()) {
- // list.add(rs.getString("FD_OBJECTID"));
- // }
- // if(list.size()==1){
- // fd_id=list.get(0);
- // }
- // } catch (SQLException e) {
- // this.log.error(e.getMessage(), e);
- // throw new ClassNotFoundException("DAO Layou: 获得数据库消息ID集合"
- // + sql, e);
- // } finally {
- // db.close(rs);
- // db.close(stat);
- // db.close(conn);
- // }
- // return fd_id;
- // }
-
- //查看历史版本,表格显示 版次-变更说明-状态
- public String showHis(String version_id){
- String sql="SELECT * FROM ECM_AM_FILE_MANAGEMENT WHERE version_id='"+version_id+"'";
- List list = null;
- try {
- list = PersistenceFactory.getInstance( ModelFactory.getSysmodel()).getSearchResultToMap(99, sql);
- } catch (PersistenceException e) {
- log.error(e.getMessage());
- }
- log.info("获取已接收消息条数===="+list.size());
- String result = JSONArray.fromObject(list).toString();
- return result;
- }
-
- /**
- * 删除文件
- * @throws ClassNotFoundException
- */
- public Msg deleteFile(String fd_id) throws ClassNotFoundException{
- Msg m=new Msg();
- String []arr=fd_id.split(";");
- String sql="UPDATE ECM_AM_FILE_MANAGEMENT SET IS_DEL='1' WHERE FD_OBJECTID=?" ;
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- for(int i=0;i<arr.length;i++){
- st.setString(1, arr[i]);
- st.executeUpdate();
- num++;
- }
- if(num==arr.length){
- log.info("删除----num===="+num);
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- conn.commit();
- return m;
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- conn.rollback();
- return m;
- }
- }catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 删除消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- }
-
- /**
- * 增加文件
- * @throws ClassNotFoundException
- */
- public Msg createFile(SystemFile sf) throws ClassNotFoundException{
- Msg m=new Msg();
- // String fileName=sf.getELECTRONIC_FILE();
- // String newFileName=uploadFile(fileName);
- String sql="INSERT INTO ECM_AM_FILE_MANAGEMENT(FD_OBJECTID,FILE_TITLE,FILE_CLASSIFY,FILE_CONTENT,FILE_ADD_DATE,PIGEONHOLE_MAN_ID,PIGEONHOLE_DATE,CHANGE_DETAIL,CHANGE_TYPE,PUBLISH_COMP_ID,REPORT_COMP_ID,FILE_STATUS,IS_DEL,ELECTRONIC_FILE,UPDATEDATE,VERSION_ID) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
- Connection conn = null;
- PreparedStatement st = null;
- int num=0;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- conn.setAutoCommit(false);
- st = conn.prepareStatement(sql);
- String fd_id=createMsgId(getMsgId());
- st.setString(1,fd_id );
- st.setString(2, sf.getFILE_TITLE());
- st.setString(3, sf.getFILE_CLASSIFY());
- st.setString(4, sf.getFILE_CONTENT());
- st.setString(5, sf.getFILE_ADD_DATE());
- st.setString(6, sf.getPIGEONHOLE_MAN_ID());
- st.setString(7, formatDate(new Date()));
- st.setString(8, sf.getCHANGE_DETAIL());
- st.setString(9, "新增");
- st.setString(10,"");//发布单位
- st.setString(11, "");//上报单位
- st.setString(12, "0");//发布、上传、上报状态
- st.setString(13,"0");
- st.setString(14, sf.getELECTRONIC_FILE());
- st.setString(15, formatDate(new Date()));
- st.setString(16, fd_id);
- st.executeUpdate();
- num++;
- if(num==1){
- log.info("删除----num===="+num);
- m.setSucsess(new Boolean(true).toString());
- m.setInfo(Parameter.DELETE_SUCSESS);
- conn.commit();
- }else{
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- conn.rollback();
- }
- }catch (SQLException e) {
- m.setSucsess(new Boolean(false).toString());
- m.setInfo(Parameter.DELETE_FAILURE);
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 删除消息"
- + sql, e);
- } finally {
- db.close(st);
- db.close(conn);
- }
- return m;
- }
-
- public String formatDate(Date d) {
- SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String date = sd.format(d);
- return date;
- }
-
- public List<String> getMsgId() throws ClassNotFoundException {
- String sql = "SELECT FD_OBJECTID FROM ECM_AM_FILE_MANAGEMENT";
- Connection conn = null;
- Statement stat = null;
- ResultSet rs = null;
- DbConnection db = new DbConnection();
- try {
- conn = db.getConnection();
- stat = conn.createStatement();
- rs = stat.executeQuery(sql);
- List<String> list = new ArrayList();
- while (rs.next()) {
- list.add(rs.getString("FD_OBJECTID"));
- }
- return list;
- } catch (SQLException e) {
- this.log.error(e.getMessage(), e);
- throw new ClassNotFoundException("DAO Layou: 获得数据库消息ID集合"
- + sql, e);
- } finally {
- db.close(rs);
- db.close(stat);
- db.close(conn);
- }
- }
-
- public String createMsgId(List<String> list) throws ClassNotFoundException{
- long l=(long) ((Math.random()+1)*1000000000);
- String msgId=l+"";
- if(list.contains(msgId)){
- return createMsgId(list);
- }
- else{
- log.info("FD_OBJECTID==="+msgId);
- return msgId;
- }
- }
-
- //上传文件,参数为本地文件路径+文件名
- //返回文件上传后在服务器中的地址加文件名
- public String uploadFile(String fileName){
- return null;
- }
-
- public void downLoadFile(String fd_id){
-
- }
- }
|