*类功能: 公文发送(附件)<br> **************************************************** paper51.com */ paper51.com publicclass Send extends HttpServlet{ paper51.com
private intsign;// 1代表公文已经发送,0代表未发送(也就是用户点击了暂时保存按钮) http://www.paper51.com private intexamine;//1代表处理完成,0代表还未处理(也就是用户点击了以后处理) copyright paper51.com private int id;//发送人id paper51.com private intaccepter;//接受者编号 http://www.paper51.com private intsendter;//发送者编号 内容来自论文无忧网 www.paper51.com private intbumfid;//公文编号 http://www.paper51.com private Stringaxffix;//附件全名 paper51.com private Stringcontent;//公文内容 内容来自论文无忧网 www.paper51.com private Stringtitle;//公文标题 http://www.paper51.com private Stringtime;//发送时间 内容来自www.paper51.com
private Stringsqls;//保存SQL语句 http://www.paper51.com private Stringsqli;//保存SQL语句 http://www.paper51.com private Stringsubmit; 内容来自www.paper51.com private Stringbumf; 内容来自www.paper51.com privateHttpSession session=null; http://www.paper51.com private ResultSetrs=null; copyright paper51.com private Statementstmt=null; paper51.com public voiddoPost(HttpServletRequest request,HttpServletResponse response) throwsServletException, IOException{ 内容来自www.paper51.com request.setCharacterEncoding("gb2312"); http://www.paper51.com response.setContentType("text/html;charset=gb2312"); paper51.com PrintWriterout=response.getWriter(); http://www.paper51.com session=request.getSession(); paper51.com Strstr=new Str(); http://www.paper51.com
Dbdb=new Db(); copyright paper51.com Timetimes=new Time(); http://www.paper51.com
Collectioncoll=new ArrayList(); http://www.paper51.com
paper51.com
try{ paper51.com id=Integer.parseInt((String)session.getAttribute("id"));//获取发送人id,即登陆员工的id号 copyright paper51.com }catch(Exceptione){ http://www.paper51.com e.printStackTrace(); paper51.com } http://www.paper51.com //查看发送人是否有临时公文 copyright paper51.com
sqls="SELECT* FROM bumf WHERE sendter="+id+" AND sign="+0; copyright paper51.com
out.print(sqls+"<br>"); http://www.paper51.com try{ 内容来自论文无忧网 www.paper51.com stmt=db.getStmtread(); http://www.paper51.com rs=stmt.executeQuery(sqls); 内容来自www.paper51.com
//如果没有生成一个临时文件 paper51.com if(!rs.next()){ paper51.com db.close(); http://www.paper51.com sqli="INSERTINTO bumf(sendter,accepter,title,time,content,affix,examine,sign)" paper51.com +"VALUES("+id+","+id+",'','"+times.getYMDHMS()+"','','',1,0)"; 内容来自www.paper51.com stmt=db.getStmt(); 内容来自www.paper51.com stmt.executeUpdate(sqli); http://www.paper51.com } 内容来自www.paper51.com db.close(); copyright paper51.com //调出临时文件 http://www.paper51.com stmt=db.getStmtread(); copyright paper51.com rs=stmt.executeQuery(sqls); http://www.paper51.com if(rs.next()){ http://www.paper51.com bumfid=rs.getInt(1); 内容来自论文无忧网 www.paper51.com sendter=rs.getInt(2); paper51.com accepter=rs.getInt(3); paper51.com title=rs.getString(4); 内容来自论文无忧网 www.paper51.com time=rs.getString(5); copyright paper51.com content=rs.getString(6); paper51.com axffix=rs.getString(7); 内容来自www.paper51.com
examine=rs.getInt(8); paper51.com sign=rs.getInt(9); http://www.paper51.com
content=str.outStr(content); 内容来自www.paper51.com axffix=str.outStr(axffix); 内容来自www.paper51.com
Bumfbumf=new Bumf(); 内容来自www.paper51.com bumf.setId(bumfid); copyright paper51.com bumf.setSendter(sendter); 内容来自www.paper51.com bumf.setAccepter(accepter); paper51.com bumf.setTitle(title); 内容来自www.paper51.com bumf.setTime(time); http://www.paper51.com bumf.setContent(content); 内容来自论文无忧网 www.paper51.com bumf.setExamine(examine); copyright paper51.com bumf.setSign(sign); 内容来自论文无忧网 www.paper51.com bumf.setAffix(axffix); paper51.com
coll.add(bumf); http://www.paper51.com } paper51.com
request.setAttribute("msg",coll); 内容来自论文无忧网 www.paper51.com paper51.com coll=(Collection)request.getAttribute("msg"); http://www.paper51.com if(coll!=null){ paper51.com Iteratorit=coll.iterator(); 内容来自www.paper51.com if(it.hasNext()){ copyright paper51.com
Bumfbumf=(Bumf)it.next(); paper51.com out.print(bumf.getId()); 内容来自www.paper51.com } copyright paper51.com
} http://www.paper51.com }catch(Exceptione){ 内容来自论文无忧网 www.paper51.com e.printStackTrace(); http://www.paper51.com out.print(e); paper51.com }finally{ paper51.com db.close(); 内容来自www.paper51.com RequestDispatcherdispatcher=request.getRequestDispatcher("send.jsp"); paper51.com
dispatcher.forward(request,response); copyright paper51.com } http://www.paper51.com } http://www.paper51.com
public voiddoGet(HttpServletRequest request,HttpServletResponse response) throwsServletException, IOException{ 内容来自论文无忧网 www.paper51.com doPost(request,response); copyright paper51.com
} 内容来自www.paper51.com } http://www.paper51.com
2.接收公文 内容来自论文无忧网 www.paper51.com 当一方用户发送给另一方发送公文后,另一方用户就可以接收到发送给自己的公文。待办公文的数量在接收公文的页面上显示,用户处理完一个公文后该公文则被标记成已办公文,同时下一个未办公文公显示出来,如果用户只是打开接收公文页面没有处理公文,那么此公文仍是未办公文。已办公文只有管理员才能查看其标题列表和附件名称,对于这项功能的实现流程与发送公文类似,在此只给出关键部分代码: http://www.paper51.com /****************************************com.bumf.Accept.java************************************/ 内容来自论文无忧网 www.paper51.com Collectioncoll=new ArrayList(); 内容来自论文无忧网 www.paper51.com //获取发送人id http://www.paper51.com
try{ 内容来自www.paper51.com id=Integer.parseInt((String)session.getAttribute("id")); http://www.paper51.com
}catch(Exceptione){ 内容来自论文无忧网 www.paper51.com // e.printStackTrace(); http://www.paper51.com
request.setAttribute("msg","您的网页已过期请重新登录"); 内容来自论文无忧网 www.paper51.com id=0; copyright paper51.com } paper51.com
//查看接受人是否有新的公文 http://www.paper51.com count=db.getRowCount("bumfWHERE accepter="+id+" AND sign="+1+" AND examine="+0); 内容来自www.paper51.com if(count>0){ paper51.com request.setAttribute("count",newInteger(count).toString()); http://www.paper51.com
} paper51.com sqls="SELECT* FROM bumf WHERE accepter="+id+" AND sign="+1+" ANDexamine="+0+" ORDER BY bumfid"; http://www.paper51.com try{ paper51.com stmt=db.getStmtread(); http://www.paper51.com rs=stmt.executeQuery(sqls); http://www.paper51.com if(rs.next()){ copyright paper51.com bumfid=rs.getInt(1); paper51.com sendter=rs.getInt(2); paper51.com accepter=rs.getInt(3); http://www.paper51.com
title=rs.getString(4); 内容来自论文无忧网 www.paper51.com time=rs.getString(5); 内容来自www.paper51.com
content=rs.getString(6); 内容来自www.paper51.com axffix=rs.getString(7); paper51.com
examine=rs.getInt(8); 内容来自www.paper51.com sign=rs.getInt(9); copyright paper51.com
content=str.outStr(content); copyright paper51.com axffix=str.outStr(axffix); http://www.paper51.com Bumfbumf=new Bumf(); paper51.com
http://www.paper51.com |