1.项目需求

河北金力集团是我省机械加工的龙头企业,主要从事矿山机械制造及各种机械零部件加工。企业有3个厂区,主厂区位于省高新技术开发区,3个分厂分别在保定、邢台和唐山。为增加企业的核心竞争力和加强管理的科学程度,近期企业将在全集团实行ERP管理,建立网页版公文流转系统。具体部门:主厂区、一分厂、二分厂、三分厂、销售部门、财务部门、办公室;领导:三位副厂长(分别管理生产、销售、财务)、一位厂长。

流转流程:

数据库:

(1)根据用户的角色及相应权限设计用户表 Doc.java

用于储存公文信息

字段:

Id:公文编号

Title:公文标题

Owner:发送公文的机构

Time:公文发送时间

Receiver:接收公文的机构

Status:公文流转状态

Result:公文审核结果

Place:公文储存位置

Tipplace:副厂长审核意见位置

Ftipplace:厂长审签意见位置

Deletestatus:公文的删除状态

Callback:该公文回执信息的接收状态

(2) 用户父权限ID建立用户权限表Permission.java

用于储存用户权限信息

字段:

Id:角色权限编号

Permission:角色权限代码

(3) 公文流转状态建立公文数据表Users.java

用于储存用户信息

字段:

Id:用户编号

Username:用户名

Password:密码

permissionId:角色权限编号

Status:标记用户是否被暂停使用

界面

(1)登录界面:

index.jsp

</style>
</head>
<body>
	<div class="header"><h2>河北金力集团公文流转系统</h2></div>

	<div class="container">
		<div class="login">
			<h2 class="logtip">登录</h2>
			<form action="login_do" method="post">
				<div class="form-group">
					<label for="username">用户名</label>
					<input type="text" class="form-control" id="username" name="username">
				</div>
				<div class="form-group">
					<label for="password">密码</label>
					<input type="password" class="form-control" id="password" name="password">
				</div>
				<div class="btnbag">
					<input type="button" class="btn btn-primary logbtn" onclick="login()" value="登录">
					<input type="button" class="btn btn-primary mangbtn" onclick="entermang()" value="进入管理">
				</div>
			</form>
		</div>
	</div>

	<div class="footer"></div>
</body>
<script>
	function login()
	{
		var username=$("#username").val();
		var password=$("#password").val();
		if(username==""||password=="")
			alert("请将信息填写完整!");
		else
		{
			$.post(
				"login_do",
				{username:username,
					password:password},
				function(data){
					if(data=="yes")
					{
						alert("成功登陆!");
						window.location="mainpage.jsp";
					}
					else
						alert("用户名或密码错误!或用户已被暂停使用!");
				},
				"text"
			);
		}
	}
	function entermang()
	{
		var username=$("#username").val();
		var password=$("#password").val();
		if(username==""||password=="")
			alert("请将信息填写完整!");
		else
		{
			$.post(
				"login_do",
				{username:username,
					password:password},
				function(data){
					if(data=="yes")
					{
						alert("成功登陆!");
						window.location="backmainpage.jsp";
					}
					else
						alert("用户名或密码错误!或用户已被暂停使用!");
				},
				"text"
			);
		}
	}
</script>
</html>

(2)主界面

backmainpage.jsp

</style>
<script>
function onload()
{
    <%
    Cookie[] cookies=request.getCookies();
    String value="";
    if(cookies!=null){
        System.out.println("cookie的长度为:"+cookies.length);
        for(int i=0;i<cookies.length;i++)
        {
            if(cookies[i].getName().equals("username"))
            {
                value=cookies[i].getValue();
                break;
            }
        }
    }
    %>
    $("#informationshow").text("当前登录账户:"+"<%=value%>");
}
function exitlog(event)
{
    var msg = "您确定要注销吗?";
    if (confirm(msg)==true){
        event.href="http://localhost:8080/official-document/index.jsp";
    }
    else{
        alert("操作取消!");
    }
}
</script>
</head>
<body onload="onload()">
    <div class="header">
        <h2>河北金力集团后台管理系统</h2>
        <div class="loginfoshow" id="userinfor">
            <p id="informationshow"></p>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="" onclick="exitlog(this)">[注销]</a>
        </div>
    </div>
    <div class="contain">
        <div class="list-group">
            <%if(value.equals("admit")){ %>
            <a id="1" href="getAllUser" class="list-group-item list-group-item-aciton" target="operation">用户管理</a>
            <%} %>
            <a id="2" href="" class="list-group-item list-group-item-aciton" onclick="updatepwd()">修改密码</a>

        </div>
        <div class="operation">
            <iframe name="operation" src="" width="100%" height="100%" style="background-color: gray;"></iframe>
        </div>
    </div>
    <div class="footer"></div>
</body>
<script>
    function updatepwd()
    {
        var username="<%=value%>";
        var password=prompt("请输入修改后的密码:");
        if(password!=""&&password!=null)
        {
            $.post(
                    "updateSelf",
                    {
                        username:username,
                        password:password
                    },
                    function(data)
                    {
                        if(data=="yes")
                            alert("修改成功!");
                        else
                            alert("修改失败!");
                    },
                    "text"
                );
        }
    }
</script>
</html>

mainpage.jsp

</style>
<script>
function onload()
{
	<%
	Cookie[] cookies=request.getCookies();
	String value="";
	ArrayList<Permission> list=new ArrayList<>();
	if(cookies!=null){
		System.out.println("cookie的长度为:"+cookies.length);
		for(int i=0;i<cookies.length;i++)
		{
			if(cookies[i].getName().equals("username"))
			{
				value=cookies[i].getValue();
			}
			if(cookies[i].getName().equals("pid"))
			{
				Permission permission=new Permission();
				permission.setId(Integer.parseInt(cookies[i].getValue()));
				list=DBUtil.getPermission(permission);
			}
		}
	}
	%>
	$("#informationshow").text("当前登录账户:<%=value %>");
}
function exitlog(event)
{
	var msg = "您确定要注销吗?";
	if (confirm(msg)==true){
		event.href="http://localhost:8080/official-document/index.jsp";
	}
	else{
		alert("操作取消!");
	}
}
</script>
</head>
<body onload="onload()">
	<div class="header">
		<h2>河北金力集团公文流转系统</h2>
		<div class="loginfoshow" id="userinfor">
			<p id="informationshow"></p>
			      
			<a href="" onclick="exitlog(this)">[注销]</a>
		</div>
	</div>
	<div class="contain">
		<div class="list-group">
			<%for(Permission s:list)
			{
			if(s.getPermission()==1){%>
			<a id="1" href="writedoc.jsp?user=<%=value %>" class="list-group-item list-group-item-aciton" target="operation">公文拟制</a>
			<%}else if(s.getPermission()==2){ %>
			<a id="2" href="getReceivedorNot?user=<%=value %>&type=received" class="list-group-item list-group-item-aciton" target="operation">签收公文</a>
			<%}else if(s.getPermission()==3){  %>
			<a id="3" href="showAll" class="list-group-item list-group-item-aciton" target="operation">浏览公文</a>
			<%}else if(s.getPermission()==5){  %>
			<a id="5" href="getDoc?type=receive" class="list-group-item list-group-item-aciton" target="operation">公文流转</a>
			<%}else if(s.getPermission()==6){  %>
			<a id="6" href="queryDoc?type=all" class="list-group-item list-group-item-aciton" target="operation">公文查询</a>
			<%}else if(s.getPermission()==7){  %>
			<a id="7" href="checkDoc?type=notchecked" class="list-group-item list-group-item-aciton" target="operation">审核公文</a>
			<%}else if(s.getPermission()==8){  %>
			<a id="8" href="fcheckDoc?type=notchecked" class="list-group-item list-group-item-aciton" target="operation">审签公文</a>
			<%}} %>
		</div>
		<div class="operation">
            <iframe name="operation" src="" width="100%" height="100%" style="background-color: gray;"></iframe>
		</div>
	</div>
	<div class="footer"></div>
</body>
</html>

  (3)公文流转

writecheck.jsp

</style>
</head>
<body>
	<%Doc doc=(Doc)request.getAttribute("doc"); %>
	<div>公文来源:<%=doc.getOwner() %>    发送日期:<%=doc.getTime() %></div>
	<div class="contain">
		<div class="title"><h2>河北金立集团文件</h2></div>
		<%if(doc.getOwner().equals("salespart")){ %>
		<div class="tip">厂[售] [2019] *号</div>
		<%}else if(doc.getOwner().equals("financepart")){ %>
		<div class="tip">厂[财] [2019] *号</div>
		<%}else{ %>
		<div class="tip">厂[产] [2019] *号</div>
		<%}
		FileInputStream fileInputStream;
		String text="";
		try {
			fileInputStream = new FileInputStream(doc.getPlace());
			BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream));
	        String line = null;
	        try {
				while ((line = bufferedReader.readLine()) != null) {
					text+=line;
				}
			} catch (IOException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}

	        fileInputStream.close();
		} catch (FileNotFoundException e1) {
			// TODO 自动生成的 catch 块
			e1.printStackTrace();
		} catch (IOException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		if(text.equals("")!=true){
		%>
		<div class="underline">-------------------------------------------------</div>
		<div class="doctitle"><%=doc.getTitle() %></div>
		<div class="content"><%=text %></div>
		<%}else{ %>
		<div class="underline">-------------------------------------------------</div>
		<div class="doctitle"><%=doc.getTitle() %></div>
		<div class="content">公文内容读取失败!</div>
		<%}
		String time=doc.getTime();
		String[] date=time.split("-");
		%>
		<div class="time"><%=date[0] %>年<%=date[1] %>月<%=date[2] %>日</div>
	</div>
	<div class="writesuggest">
		<div><h4>请在下方输入审核意见和修改意见:</h4></div>
		<textarea rows="20" cols="20" class="suggestion" id="suggestion"></textarea>
		<div class="radio">
			<label>是否同意该公文:</label>
			<label class="radio-inline"><input type="radio" name="result" value="1">同意</label>
			<label class="radio-inline"><input type="radio" name="result" value="0">不同意</label>
		</div>
		<input type="button" value="确认修改" class="btn" onclick="writesug()">
	</div>
</body>
<script>
		function writesug()
		{
			var val=$('input:radio[name="result"]:checked').val();
			var id=<%=doc.getId()%>;
			var tip=$("#suggestion").val();
			if(val==null)
			{
				alert("请勾选是否同意该公文选项!");
			}
			else{
				$.post(
					"checked_change",
					{
						id:id,
						result:val,
						tip:tip
					},
					function(data)
					{
						if(data=="yes")
						{
							alert("操作成功!");
							window.location="checkDoc?type=notchecked";
						}
						else
							alert("操作失败!");

					},
					"text"
				);
			}
		}
</script>
</html>




writedoc.jsp

</style>
</head>
<body>
	<h4>请输入公文标题:</h4>
	<div><input type="text" class="form-control" id="title"></div>
	<h4>请在下方书写正文:</h4>
	<div>
		<textarea id="doc" rows="20" cols="40"></textarea>
	</div>
	<div class="btnbag">
		<input type="button" class="btn" value="提交" onclick="submit()">
	</div>
</body>
<script type="text/javascript">
	function GetQueryString(name) {
		  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		  var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
		  var context = "";
		  if (r != null)
		     context = r[2];
		  reg = null;
		  r = null;
		  return context == null || context == "" || context == "undefined" ? "" : context;
	}


	function submit()
	{
		var text=$("#doc").val();
		var user=GetQueryString("user");
		var title=$("#title").val();
		if(text==""||title=="")
		{
			alert("包含空内容!请填写完整!");
		}
		else
		{
			$.post(
				"writedoc_do",
				{text:text,
					user:user,
					title:title},
				function(data){
					if(data=="yes"){
						alert("发送成功");
						$("#title").val("");
						$("#doc").val("");
					}
					else{
						alert("发送失败");
					}
				},
				"text"
			);
		}
	}
</script>
</html>





writefcheck.jsp


</style>
</head>
<body>
	<%Doc doc=(Doc)request.getAttribute("doc"); %>
	<div>公文来源:<%=doc.getOwner() %>    发送日期:<%=doc.getTime() %></div>
	<div class="contain">
		<div class="title"><h2>河北金立集团文件</h2></div>
		<%if(doc.getOwner().equals("salespart")){ %>
		<div class="tip">厂[售] [2019] *号</div>
		<%}else if(doc.getOwner().equals("financepart")){ %>
		<div class="tip">厂[财] [2019] *号</div>
		<%}else{ %>
		<div class="tip">厂[产] [2019] *号</div>
		<%}
		FileInputStream fileInputStream;
		String text="";
		try {
			fileInputStream = new FileInputStream(doc.getPlace());
			BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream));
	        String line = null;
	        try {
				while ((line = bufferedReader.readLine()) != null) {
					text+=line;
				}
			} catch (IOException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}

	        fileInputStream.close();
		} catch (FileNotFoundException e1) {
			// TODO 自动生成的 catch 块
			e1.printStackTrace();
		} catch (IOException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		if(text.equals("")!=true){
		%>
		<div class="underline">-------------------------------------------------</div>
		<div class="doctitle"><%=doc.getTitle() %></div>
		<div class="content"><%=text %></div>
		<%}else{ %>
		<div class="underline">-------------------------------------------------</div>
		<div class="doctitle"><%=doc.getTitle() %></div>
		<div class="content">公文内容读取失败!</div>
		<%}
		String time=doc.getTime();
		String[] date=time.split("-");
		%>
		<div class="time"><%=date[0] %>年<%=date[1] %>月<%=date[2] %>日</div>
	</div>
	<div class="writesuggest">
		<div><h4>请在下方输入审签意见和修改意见:</h4></div>
		<textarea rows="20" cols="20" class="suggestion" id="suggestion"></textarea>
		<div class="radio">
			<label>是否同意该公文:</label>
			<label class="radio-inline"><input type="radio" name="result" value="1">同意</label>
			<label class="radio-inline"><input type="radio" name="result" value="0">不同意</label>
		</div>
		<input type="button" value="确认修改" class="btn" onclick="writesug()">
	</div>
</body>
<script>
		function writesug()
		{
			var val=$('input:radio[name="result"]:checked').val();
			var id=<%=doc.getId()%>;
			var tip=$("#suggestion").val();
			if(val==null)
			{
				alert("请勾选是否同意该公文选项!");
			}
			else{
				$.post(
					"fchecked_change",
					{
						id:id,
						result:val,
						tip:tip
					},
					function(data)
					{
						if(data=="yes")
						{
							alert("操作成功!");
							window.location="fcheckDoc?type=notchecked";
						}
						else
							alert("操作失败!");

					},
					"text"
				);
			}
		}
</script>
</html>

(4)公文的签收  

doc层
package com.official.bean;

public class Doc {
	private int id;
	private String tipplace;
	private String ftipplace;
	private int deletestatus;
	private int callback;
	public int getCallback() {
		return callback;
	}
	public void setCallback(int callback) {
		this.callback = callback;
	}
	public int getDeletestatus() {
		return deletestatus;
	}
	public void setDeletestatus(int deletestatus) {
		this.deletestatus = deletestatus;
	}
	public String getFtipplace() {
		return ftipplace;
	}
	public void setFtipplace(String ftipplace) {
		this.ftipplace = ftipplace;
	}
	public String getTipplace() {
		return tipplace;
	}
	public void setTipplace(String tipplace) {
		this.tipplace = tipplace;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	private String title;
	private String owner;
	private String time;
	private String receiver;
	private int status;
	private int result;
	private String place;
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getOwner() {
		return owner;
	}
	public void setOwner(String owner) {
		this.owner = owner;
	}
	public String getTime() {
		return time;
	}
	public void setTime(String time) {
		this.time = time;
	}
	public String getReceiver() {
		return receiver;
	}
	public void setReceiver(String receiver) {
		this.receiver = receiver;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public int getResult() {
		return result;
	}
	public void setResult(int result) {
		this.result = result;
	}
	public String getPlace() {
		return place;
	}
	public void setPlace(String place) {
		this.place = place;
	}
}

  

12-25 02:23