公文流转

Posted 20183544-wangzhengshuai

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了公文流转相关的知识,希望对你有一定的参考价值。

公文流转

一、数据库设计:

技术图片

 

 

 1、id - tid :权限id 子权限tid

 2、statu 用户状态

 3、uid 用户唯一标识 uid

技术图片

 

 1、id与 user 表中的 权限id相对应 。

 2、quan :表示 有此权限的用户的具体权限内容。

 3、address:是相应权限的功能实现地址。

技术图片

 

 1、id 公文的唯一标识。

 2、status 公文状态。

 3、deletestatus 标志公文是我删除

 4、firstcheck 副厂长审核结果

 5、secondcheck 厂长审核结果

二、功能之不同用户登入显示不同功能界面

设计思路:

1、将登入用户封装进一个实体,存进 session 域中。

2、登入成功后根据用户的权限 id ,从 quan (权限表) 获取此用户的功能权限,以及实现权限功能的地址。

3、在页面就可以动态的实现显示不同功能。

 登入界面:index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>登入</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<style type="text/css">
#container {
    width: 440px;
    border: 1px solid #E7E7E7;
    padding: 20px 0 20px 30px;
    border-radius: 5px;
    margin-top: 60px;
    background: #fff;
}

#submit {
    background: url(‘./images/login.gif‘) no-repeat scroll 0 0 rgba(0, 0, 0, 0);
    height: 35px;
    width: 100px;
    color: white;
}
</style>

</head>
<body>
    <div id="container" class="container">
        <form class="form-horizontal" action="user?method=login" method="post">
            <div class="form-group">
                <label for="username" class="col-sm-2 control-label">用户名</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" id="username"
                        name="username" placeholder="请输入用户名">
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-sm-2 control-label">密码</label>
                <div class="col-sm-6">
                    <input type="password" class="form-control" id="password"
                        name="password" placeholder="请输入密码">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input type="submit" width="100" value="登录" name="submit"
                        id="submit" >
                </div>
            </div>
        </form>
    </div>
</body>
</html>

各个用户功能界面 function.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>功能</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>

<style type="text/css">
table {
    position: relative;
    top: 10px; left : 5px;
    bgcolor: #FFFFFF;
    left: 5px;
}

#right {
    height: 800px;
    background-color: ghostwhite;
    float: left;
}



#left {
    height: 900px;
    background-color: #28A4C9;
}

#who {
    position: relative;
    top: 30px;
    left: 5px;
}
</style>

</head>
<body>
    <div class="row" style="background-color: silver; height: 100px">

        <div class="col-md-3">
            <h3 id="who">用户:${who.job }</h3>
        </div>
        <div class="col-md-9" style="align-content: center;">
            <h1>河北金力集团公文流转系统</h1>
        </div>
        <hr />
    </div>
    <div class="row">
        <div class="col-md-2" id="left">
            <table class="table">
                <c:forEach items="${quan_list}" var="item">
                    <tr>
                        <td style="background-color: white"><h2 align="center">
                                <a href="${item.address }" target="right">${item.quan}</a>
                            </h2></td>
                    </tr>
                </c:forEach>
            </table>
        </div>
        <div id="right" class="col-md-10">
            <iframe name="right" src="" width="100%" height="100%"></iframe>
        </div>
    </div>
</body>
</html>

 用户servlet :UserServlet.java

package com.me.servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.me.dao.UserDao;
import com.me.domain.Quan;
import com.me.domain.User;

@WebServlet("/user")
public class UserServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
       
    public UserServlet() {
        super();
    }
    UserDao userdao =new UserDao();
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        request.setCharacterEncoding("UTF-8");
        String method = request.getParameter("method");
        if(method.equals("login")) {
            try {
                login(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        } else if(method.equals("function")) {
            try {
                function(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    private void function(HttpServletRequest request, HttpServletResponse response) throws  SQLException, ServletException, IOException{
        User user = (User) request.getSession().getAttribute("who");
        List<Quan> quan_list = userdao.function(user);
        request.setAttribute("quan_list", quan_list);
        if(!quan_list.isEmpty()) {
            System.out.println(quan_list.isEmpty());
            request.getRequestDispatcher("function.jsp").forward(request, response);;
        }else {
            request.getRequestDispatcher("function.jsp").forward(request, response);;
            
        }
    }

    private void login(HttpServletRequest request, HttpServletResponse response) throws IOException, SQLException, ServletException {
        User user= new User();
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        user.setUsername(username);
        user.setPassword(password);
        user=userdao.login(user);
        
        request.getSession().setAttribute("who", user);
        if(user!=null) {
            System.out.println(user.toString());
            request.getRequestDispatcher("user?method=function").forward(request, response);;
        }else {
            request.getRequestDispatcher("index.jsp").forward(request, response);;
        }
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }

}

用户实体 User.java

package com.me.domain;

public class User {
    private int id;
    private int uid;
    private int tid;
    private int statu;
    private String username;
    private String password;
    private String job;

    public int getUid() {
        return uid;
    }

    public void setUid(int uid) {
        this.uid = uid;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getTid() {
        return tid;
    }

    public void setTid(int tid) {
        this.tid = tid;
    }

    public int getStatu() {
        return statu;
    }

    public void setStatu(int statu) {
        this.statu = statu;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    @Override
    public String toString() {
        return "User [id=" + id + ", tid=" + tid + ", statu=" + statu + ", username=" + username + ", password="
                + password + ", job=" + job + "]";
    }

}

权限实体 Quan.java

package com.me.domain;

public class Quan {
    private String quan; 
    private int id; 
    private String address;
    public String getQuan() {
        return quan;
    }
    public void setQuan(String quan) {
        this.quan = quan;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    @Override
    public String toString() {
        return "Quan [quan=" + quan + ", id=" + id + ", address=" + address + "]";
    } 
    
}

 

三、公文流转过程(只实现的,公文畅通无阻,全部通过!!)

设计思路:

1、公文状态分析:

status(状态)      含义               status(状态)
   0             刚拟好
   1           办公室(修改)
  2           副厂长    /不同意        8
  3           办公室流转    
  4           厂长    /不同意         9
  5           办公室流转
  10          副厂长看
  11          办公室流转
  6           发到部门
  7           签收过

(注:因为没写完,稍后补上,详细的设计思路,敬请谅解)

公文拟制:create_doc.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<style type="text/css">
#title {
    width: 300px;
    height: 50px;
}
#ti{
    position: relative;
    top: 30px;

}

</style>
<script type="text/javascript">
function sent(){
    var title=$("#title").val();
    if(title==null){
        alert("请输入标题");
    }
    var content=$("#content").val();
    if(content==null){
        alert("请输入正文内容");
    }
    $.ajax({
        "async":true,
        "url":"docflow?method=to_office",
        "data":{"title":title,"content":content},
        "type":"POST",
        "dataType":"json",
        "success":function(data){
            var f = data.f;
            if(f){
                alert("发送成功");
            }else{
                alert("发送失败");
                
            }
        }
    });
    return true;
}
</script>
</head>
<body>
    <form  onsubmit="return sent()">
        <br />
        <table class="table">
            <tr>
                <td>
                    <font size="4" id="ti">标题</font>
                </td>
                <td>
                    <h3>
                        <input type="text" name="title" id="title">
                    </h3>
                </td>
            </tr>
            <tr>
                <td colspan="2"><font size="4">内容</font></td>
            </tr>
            <tr>
                <td colspan="2"><textarea name="content" id="content"
                        cols="120" rows="18">
                        河北金力集团文件
                        
                        
                        
                        
                        
                        
                        
                        
                        
                                                部门:${who.job }
                                                起草人:${who.username }
                    </textarea><br /></td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" value="发送"
                    style="color: blue; background: orange;"><br /></td>
            </tr>
        </table>
    </form>
</body>
</html>

办公室流转公文: docflow_office.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
function sent(status,id,i){
    var owner = $("#owner"+i).text();
    if(status==1||status==3||status==5){
    }else {
        alert("该公文已流转到相应部门,不具备发送权限!");
    }
    $.ajax({
        "async":true,
        "url":"docflow?method=to_next",
        "data":{"id":id,"owner":owner,"status":status},
        "type":"POST",
        "dataType":"json",
        "success":function(data){
            var f = data.f;
            if(f){
                //$("#status"+i).attr("value",status+1);
                alert("发送成功");
                window.location="docflow?method=officelist";
            }else{
                alert("发送失败");
                
            }
        }
    });
}
function deletedoc(status,id,deletestatus){
    if(deletestatus==1){
        alert("该公文已删除");
        return ;
    }else {
        var msg = "确定删除?";
        if(confirm(msg)==true){
            if(status==8||status==9){
                $.ajax({
                    "async":true,
                    "url":"docflow?method=deletedoc",
                    "data":{"id":id},
                    "type":"POST",
                    "dataType":"json",
                    "success":function(data){
                        var f = data.f;
                        if(f){
                            //$("#status"+i).attr("value",status+1);
                            alert("删除成功");
                            window.location="docflow?method=officelist";
                        }else{
                            alert("删除失败");
                        }
                    }
                });
            }
            else if(status!=7){
                alert("该公文还为被有关部门签收,不能删除!");
                return ;
            }else{
                alert("该公文审核或审签已通过,不能删除!");
                return ;
            }
        }else{
            alert("操作取消!");
        }
        
    }
    

}
</script>
</head>
<body>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>公文编号</th>
                <th>公文标题</th>
                <th>公文来源</th>
                <th>公文状态</th>
                <th>流转状态</th>
                <th>创建时间</th>
                <th colspan="2">操作</th>
            </tr>
        </thead>
        <tbody>
            <c:forEach  var="item"  items="${doclist}" varStatus="i">
                <tr>
                    <td >${item.id}</td>
                    <td > <a  href="docflow?method=docinfo&id=${item.id}" target="right">${item.title}</a> </td>
                    <td id="owner${i.index+1 }">${item.owner}</td>
                    <td id="status${i.index+1 }">${item.status}</td>
                    <td >${item.current}</td>
                    <td >${item.time}</td>
                    <td ><a  onclick="sent(${item.status},${item.id},${i.index+1})">发送</a></td>
                    <td ><a onclick="deletedoc(${item.status},${item.id},${item.deletestatus})" >删除</a></td>
                </tr>
            </c:forEach>
        </tbody>
    </table>
</body>
</html>

副厂长审核 :firstcheck.jsp  & firstcheck2.jsp  

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
function firstcheck(status,id){
    if(status!=2){
        alert("无权限!");
        return;
    }
    window.location="docflow?method=firstcheck2&id="+id;
}
function sent(status,id){
    alert(status);
    if(status!=10){
        alert("无权限");
        return;
    }
    $.ajax({
        "async":true,
        "url":"docflow?method=sent_to_down",
        //"url":"docflow?method=to_fu",
        "data":{"id":id},
        "type":"POST",
        "dataType":"json",
        "success":function(data){
            var f = data.f;
            if(f){
                alert("发送成功");
                window.location="docflow?method=firstcheck";
            }else{
                alert("发送失败");
            }
        }
    });
}
</script>
<style type="text/css">
.ab{
    position: relative;
    top: 40px; 
    left : 35px;
    right: 30px;
}
</style>
</head>
<body>

    <div class="row" style="background-color: rosybrown; height: 100px">
        <font size="5"><a class="ab" href="docflow?method=unaudit">未审核的公文</a></font>&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;<font size="5"><a class="ab"
            href="docflow?method=audit">已审核的公文</a></font>
    </div>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>公文编号</th>
                <th>公文标题</th>
                <th>公文来源</th>
                <th>公文状态</th>
                <th>流转状态</th>
                <th>创建时间</th>
                <th colspan="2">操作</th>
            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${doclist}" varStatus="i">
                <tr>
                    <td>${item.id}</td>
                    <td > <a  href="docflow?method=docinfo&id=${item.id}" target="right">${item.title}</a> </td>
                    <td id="owner${i.index+1 }">${item.owner}</td>
                    <td id="status${i.index+1 }">${item.status}</td>
                    <td>${item.current}</td>
                    <td>${item.time}</td>
                    <td><a onclick="firstcheck(${item.status},${item.id})">审核</a></td>
                    <td><a onclick="sent(${item.status},${item.id})">发送</a></td>
                </tr>
            </c:forEach>
        </tbody>
    </table>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<style type="text/css">
#title {
    width: 300px;
    height: 50px;
}
#ti{
    position: relative;
    top: 30px;

}

</style>
<script type="text/javascript">
function sent(id){
    var firstcheck=$("#firstcheck").val();
    var val=$(input:radio[name="check"]:checked).val();
    if(val==null){
        alert("请勾选是否同意该公文选项!");
        return false;
    }else{
        //alert("操作成功!");
    $.ajax({
        "async":true,
        "url":"docflow?method=firstcheck3",
        //"url":"docflow?method=to_fu",
        "data":{"firstcheck":firstcheck,"id":id,"check":val},
        "type":"POST",
        "dataType":"json",
        "success":function(data){
            var f = data.f;
            if(f){
                alert("审核修改成功");
                return true;
            }else{
                alert("操作失败");
                return false;
                
            }
        }
    });
    }
    
}
</script>
</head>
<body>
    
        <br />
        <table class="table">
            <tr>
                <td>
                    <font size="4" id="ti">标题</font>
                </td>
                <td>
                    <h3>
                        <input type="text" name="title" id="title" value="${doc.title }">
                    </h3>
                </td>
            </tr>
            <tr>
                <td colspan="2"><font size="4">内容</font></td>
            </tr>
            <tr>
                <td colspan="2"><textarea name="content" id="content"
                        cols="120" rows="18">
                    
                        
                ${doc.content }        
                        
                        
                        
                        
                        
                        
                        
                                                
                    </textarea><br /></td>
            </tr>
            <tr>
                <td colspan="2"><font size="4">审核修改的意见或建议:</font></td>
            </tr>
            <tr>
                <td colspan="2"><textarea name="firstcheck" id="firstcheck"
                        cols="120" rows="12">
                        
                        
                        
                        
                        
                        
                    </textarea><br /></td>
            </tr>
            <tr>
                <td colspan="2"><font size="4">是否同意该公文:</font>
                    <font size="4">
                    <input type="radio" name="check" value="yes">同意
                    <input type="radio" name="check" value="no">不同意
                    </font>
                </td>
            </tr>
            <tr>
                <td colspan="2"><input type="button" value="修改"
                    style="color: blue; background: orange;" onclick="return sent(${doc.id})"><br /></td>
            </tr>
        </table>
</body>
</html>

厂长审核 secondcheck.jsp & secondcheck2.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript">
function firstcheck(status,id){
    if(status!=4){
        alert("无权限!");
        return;
    }
    window.location="docflow?method=secondcheck2&id="+id;
}
</script>
<style type="text/css">
.ab{
    position: relative;
    top: 40px; 
    left : 35px;
    right: 30px;
}
</style>
</head>
<body>

    <div class="row" style="background-color: rosybrown; height: 100px">
        <font size="5"><a class="ab" href="docflow?method=unaudit2">未审核的公文</a></font>&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;<font size="5"><a class="ab"
            href="docflow?method=audit2">已审核的公文</a></font>
    </div>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>公文编号</th>
                <th>公文标题</th>
                <th>公文来源</th>
                <th>公文状态</th>
                <th>流转状态</th>
                <th>创建时间</th>
                <th >操作</th>
            </tr>
        </thead>
        <tbody>
            <c:forEach  var="item"  items="${doclist}" varStatus="i">
                <tr>
                    <td >${item.id}</td>
                    <td > <a  href="docflow?method=docinfo&id=${item.id}" target="right">${item.title}</a> </td>
                    <td id="owner${i.index+1 }">${item.owner}</td>
                    <td id="status${i.index+1 }">${item.status}</td>
                    <td >${item.current}</td>
                    <td >${item.time}</td>
                    <td ><a onclick="firstcheck(${item.status},${item.id})" >审核</a></td>
                </tr>
            </c:forEach>
        </tbody>
    </table>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<style type="text/css">
#title {
    width: 300px;
    height: 50px;
}
#ti{
    position: relative;
    top: 30px;

}

</style>
<script type="text/javascript">
function sent(id){
    var secondcheck=$("#secondcheck").val();
    var val=$(input:radio[name="check"]:checked).val();
    if(val==null){
        alert("请勾选是否同意该公文选项!");
        return false;
    }else{
        
    $.ajax({
        "async":true,
        "url":"docflow?method=secondcheck3",
        "data":{"secondcheck":secondcheck,"id":id,"check":val},
        "type":"POST",
        "dataType":"json",
        "success":function(data){
            var f = data.f;
            if(f){
                alert("审核修改成功");
                return true;
            }else{
                alert("操作失败");
                return false;
                
            }
        }
    });
    }
    
}
</script>
</head>
<body>
    
        <br />
        <table class="table">
            <tr>
                <td>
                    <font size="4" id="ti">标题</font>
                </td>
                <td>
                    <h3>
                        <input type="text" name="title" id="title" value="${doc.title }">
                    </h3>
                </td>
            </tr>
            <tr>
                <td colspan="2"><font size="4">内容</font></td>
            </tr>
            <tr>
                <td colspan="2"><textarea name="content" id="content"
                        cols="120" rows="18">
                    
                        
                ${doc.content }        
                        
                        
                        
                        
                        
                        
                        
                                                
                    </textarea><br /></td>
            </tr>
            <tr>
                <td colspan="2"><font size="4">副厂长审核修改的意见或建议:</font></td>
            </tr>
            <tr>
                <td colspan="2"><textarea name="firstcheck" id="firstcheck"
                        cols="120" rows="12">
                        
                        
                        ${doc.firstcheck }
                        
                        
                        
                    </textarea><br /></td>
            </tr>
            
            <tr>
                <td colspan="2"><font size="4">审核修改的意见或建议:</font></td>
            </tr>
            <tr>
                <td colspan="2"><textarea name="secondcheck" id="secondcheck"
                        cols="120" rows="12">
                        
                        
                        
                        
                        
                        
                    </textarea><br /></td>
            </tr>
            <tr>
                <td colspan="2"><font size="4">是否同意该公文:</font>
                    <font size="4">
                    <input type="radio" name="check" value="yes">同意
                    <input type="radio" name="check" value="no">不同意
                    </font>
                </td>
            </tr>
            <tr>
                <td colspan="2"><input type="button" value="修改"
                    style="color: blue; background: orange;" onclick="return sent(${doc.id})"><br /></td>
            </tr>
        </table>
</body>
</html>

部门签收 :department.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<style type="text/css">
.ab{
    position: relative;
    top: 40px; 
    left : 35px;
    right: 30px;
}
</style>
</head>
<body>
    <div class="row" style="background-color: rosybrown; height: 100px">
        <font size="5"><a class="ab" href="docflow?method=unsign"  >未签收的公文</a></font>&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;<font size="5"><a class="ab" href="docflow?method=sign" >已签收的公文</a></font>
    </div>
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>公文编号</th>
                <th>公文标题</th>
                <th>公文来源</th>
                <th>公文状态</th>
                <th>流转状态</th>
                <th>创建时间</th>
                <th >操作</th>
            </tr>
        </thead>
        <tbody>
            <c:forEach  var="item"  items="${doclist}" varStatus="i">
                <tr>
                    <td >${item.id}</td>
                    <td > <a  href="docflow?method=docinfo&id=${item.id}" target="right">${item.title}</a> </td>
                    <td id="owner${i.index+1 }">${item.owner}</td>
                    <td id="status${i.index+1 }">${item.status}</td>
                    <td >${item.current}</td>
                    <td >${item.time}</td>
                    <td ><a onclick="sign(${item.status},${item.id})">签收</a></td>
                </tr>
            </c:forEach>
        </tbody>
    </table>
</body>
</html>

 

公文实体:Doc.java

package com.me.domain;


public class Doc {
    private int id;
    private int status;
    private int deletestatus;
    private String title;
    private String current;
    private String owner;
    private String content;
    private String time;
    private String firstcheck;
    private String secondcheck;
    public String getFirstcheck() {
        return firstcheck;
    }
    public void setFirstcheck(String firstcheck) {
        this.firstcheck = firstcheck;
    }
    public String getSecondcheck() {
        return secondcheck;
    }
    public void setSecondcheck(String secondcheck) {
        this.secondcheck = secondcheck;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public int getStatus() {
        return status;
    }
    public void setStatus(int status) {
        this.status = status;
    }
    public int getDeletestatus() {
        return deletestatus;
    }
    public void setDeletestatus(int deletestatus) {
        this.deletestatus = deletestatus;
    }
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        this.title = title;
    }
    public String getCurrent() {
        return current;
    }
    public void setCurrent(String current) {
        this.current = current;
    }
    public String getOwner() {
        return owner;
    }
    public void setOwner(String owner) {
        this.owner = owner;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getTime() {
        return time;
    }
    public void setTime(String time) {
        this.time = time;
    }
    @Override
    public String toString() {
        return "Doc [id=" + id + ", status=" + status + ", deletestatus=" + deletestatus + ", title=" + title
                + ", current=" + current + ", owner=" + owner + ", content=" + content + ", time=" + time
                + ", firstcheck=" + firstcheck + ", secondcheck=" + secondcheck + "]";
    }
    
    
}

公文 servlet :DocServlet.java

package com.me.servlet;

import java.io.IOException;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.me.dao.DocDao;
import com.me.domain.Doc;
import com.me.domain.User;

@WebServlet("/docflow")
public class DocFlowServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public DocFlowServlet() {
        super();
    }
    DocDao docdao =new DocDao();
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        String method = request.getParameter("method");
        System.out.println(method);
        if(method.equals("to_office")) {
            try {
                to_office(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("officelist")) {
            try {
                officelist(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("to_next")) {
            try {
                to_next(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("deletedoc")) {
            try {
                deletedoc(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("firstcheck")) {
            try {
                firstcheck(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("firstcheck2")) {
            try {
                firstcheck2(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("firstcheck3")) {
            try {
                firstcheck3(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("secondcheck")) {
            try {
                secondcheck(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("secondcheck2")) {
            try {
                secondcheck2(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("secondcheck3")) {
            try {
                secondcheck3(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("docinfo")) {
            try {
                docinfo(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("sent_to_down")) {
            try {
                sent_to_down(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("sign")) {
            try {
                sign(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("unsign")) {
            try {
                unsign(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("audit")) {
            try {
                audit(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("unaudit")) {
            try {
                unaudit(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("audit2")) {
            try {
                audit2(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }else  if(method.equals("unaudit2")) {
            try {
                unaudit2(request,response);
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
    
    private void unaudit2(HttpServletRequest request, HttpServletResponse response) throws SQLException, ServletException, IOException {
        List<Doc> doclist =docdao.unaudit2();
        request.setAttribute("doclist", doclist);
        System.out.println(doclist.isEmpty());
        if(!doclist.isEmpty()) {
            request.getRequestDispatcher("firstcheck.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("firstcheck.jsp").forward(request, response);
        }
    }

    private void audit2(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        List<Doc> doclist =docdao.audit2();
        request.setAttribute("doclist", doclist);
        System.out.println(doclist.isEmpty());
        if(!doclist.isEmpty()) {
            request.getRequestDispatcher("firstcheck.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("firstcheck.jsp").forward(request, response);
        }
    }

    private void unaudit(HttpServletRequest request, HttpServletResponse response) throws SQLException, ServletException, IOException {
        List<Doc> doclist =docdao.unaudit();
        request.setAttribute("doclist", doclist);
        System.out.println(doclist.isEmpty());
        if(!doclist.isEmpty()) {
            request.getRequestDispatcher("firstcheck.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("firstcheck.jsp").forward(request, response);
        }
    }

    private void audit(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        List<Doc> doclist =docdao.audit();
        request.setAttribute("doclist", doclist);
        System.out.println(doclist.isEmpty());
        if(!doclist.isEmpty()) {
            request.getRequestDispatcher("firstcheck.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("firstcheck.jsp").forward(request, response);
        }
    }

    private void unsign(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        User user = (User) request.getSession().getAttribute("who");
        String job = user.getJob();
        List<Doc> doclist = docdao.unsign(job);
        request.setAttribute("doclist", doclist);
        if(!doclist.isEmpty()) {
            request.getRequestDispatcher("department.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("department.jsp").forward(request, response);
        }
    }
    private void sign(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        User user = (User) request.getSession().getAttribute("who");
        String job = user.getJob();
        List<Doc> doclist = docdao.sign(job);
        request.setAttribute("doclist", doclist);
        if(!doclist.isEmpty()) {
            request.getRequestDispatcher("department.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("department.jsp").forward(request, response);
        }
    }

    private void sent_to_down(HttpServletRequest request, HttpServletResponse response) throws  SQLException, ServletException, IOException {
        String id_str = request.getParameter("id");
        int id=Integer.parseInt(id_str);
        boolean f=docdao.sent_to_down(id);
        response.getWriter().write("{"f":"+f+"}");
    }

    private void docinfo(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        String id_str = request.getParameter("id");
        int id=Integer.parseInt(id_str);
        Doc doc=docdao.docinfo(id);
        request.setAttribute("doc", doc);
        if(doc!=null) {
            request.getRequestDispatcher("docinfo.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("docinfo.jsp").forward(request, response);
        }
    }

    private void secondcheck3(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        String id_str = request.getParameter("id");
        int id=Integer.parseInt(id_str);
        String secondcheck = request.getParameter("secondcheck");
        String check = request.getParameter("check");
        boolean f=false;
        if(check.equals("yes")) {
            f=docdao.secondcheck3(id,secondcheck);
        }else {
            f=docdao.secondcheck4(id,secondcheck);
        }
        //System.out.println(f+"123");
        response.getWriter().write("{"f":"+f+"}");
        
    }

    private void secondcheck2(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        String id_str = request.getParameter("id");
        int id=Integer.parseInt(id_str);
        Doc doc=docdao.secondcheck2(id);
        request.setAttribute("doc", doc);
        if(doc!=null) {
            request.getRequestDispatcher("secondcheck2.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("secondcheck2.jsp").forward(request, response);
        }
        
    }

    private void secondcheck(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        List<Doc> doclist =docdao.secondcheck();
        request.setAttribute("doclist", doclist);
        System.out.println(doclist.isEmpty());
        if(!doclist.isEmpty()) {
            request.getRequestDispatcher("secondcheck.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("secondcheck.jsp").forward(request, response);
        }
    }

    private void firstcheck3(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        System.out.println(123456);
        String id_str = request.getParameter("id");
        int id=Integer.parseInt(id_str);
        String firstcheck = request.getParameter("firstcheck");
        String check = request.getParameter("check");
        boolean f=false;
        if(check.equals("yes")) {
            f=docdao.firstcheck3(id,firstcheck);
        }else {
            f=docdao.firstcheck4(id,firstcheck);
        }
        System.out.println(f+"123");
        response.getWriter().write("{"f":"+f+"}");
    }

    private void firstcheck2(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        String id_str = request.getParameter("id");
        int id=Integer.parseInt(id_str);
        Doc doc=docdao.firstcheck2(id);
        request.setAttribute("doc", doc);
        if(doc!=null) {
            request.getRequestDispatcher("firstcheck2.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("firstcheck2.jsp").forward(request, response);
        }
    }

    private void firstcheck(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        List<Doc> doclist =docdao.firstchenk();
        request.setAttribute("doclist", doclist);
        System.out.println(doclist.isEmpty());
        if(!doclist.isEmpty()) {
            request.getRequestDispatcher("firstcheck.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("firstcheck.jsp").forward(request, response);
        }
    }

    private void deletedoc(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        String id_str = request.getParameter("id");
        int id=Integer.parseInt(id_str);
        boolean f=docdao.deletedoc(id);
        response.getWriter().write("{"f":"+f+"}");
    }

    private void to_next(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        String status_str = request.getParameter("status");
        int status= Integer.parseInt(status_str);
        int status_t=0;
        String id_str = request.getParameter("id");
        int id=Integer.parseInt(id_str);
        String owner = request.getParameter("owner");
        String current="";
        switch (status) {
        case 1:
            if (owner.equals("销售部门")) {
                current="销售副厂长";
            } else if (owner.equals("财务部门")) {
                current="财务副厂长";
            } else {
                current="生产副厂长";
            }
            status_t=2;
            break;
        case 3:
            current="厂长";
            status_t=4;
            break;
        case 5:
            if (owner.equals("销售部门")) {
                current="销售副厂长";
            } else if (owner.equals("财务部门")) {
                current="财务副厂长";
            } else {
                current="生产副厂长";
            }
            status_t=10;
            break;
        case 11:
            current=owner;
            status_t=6;
            break;
        }
        boolean f= docdao.to_fu(id,current,status_t);
        response.getWriter().write("{"f":"+f+"}");

    }

    private void officelist(HttpServletRequest request, HttpServletResponse response)throws  SQLException, ServletException, IOException {
        List<Doc> doclist =docdao.officelist();
        request.setAttribute("doclist", doclist);
        if(!doclist.isEmpty()) {
            request.getRequestDispatcher("docflow_office.jsp").forward(request, response);
        }else {
            request.getRequestDispatcher("docflow_office.jsp").forward(request, response);
        }
    }

    private void to_office(HttpServletRequest request, HttpServletResponse response)throws  SQLException, IOException {
        Doc doc=new Doc();
        String current="办公室";
        User user = (User) request.getSession().getAttribute("who");
        String title = request.getParameter("title");
        String content = request.getParameter("content");
        Date date = new Date();
        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String time=dateFormat.format(date).toString();
        doc.setContent(content);
        doc.setTitle(title);
        doc.setTime(time);
        doc.setCurrent(current);
        doc.setStatus(1);
        doc.setOwner(user.getJob());
        doc.setDeletestatus(0);
        boolean f = docdao.create(doc);
        response.getWriter().write("{"f":"+f+"}");
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }

}

 

 

今天下午就写了这么点 。 。 。 。

 

 

以上是关于公文流转的主要内容,如果未能解决你的问题,请参考以下文章

公文流转,实验完成,下面是一些收获以及实验的相关内容

基于mysql+php065企业公文流转系统

公文流转系统

公文流转系统

公文流转系统

河北金力集团公文流转系统