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

2. 板块功能需求
(1)、页面要求
① 能适应800*600或1024*768分辨率;
② 布局合理、结构清晰、页面完整;
③ 有效页面数在8页以上;
④ 分页与主页风格统一;
⑤ 首页(登录页):用户登录页(共有十位用户帐号,帐号、密码可预设)。不同用户登录后,进入的功能页不相同,要求密码在数据库中加密。
⑥ 部门(不含办公室)功能页:有公文拟制、签收公文、浏览公文(已签收的公文)三个模块
⑦ 办公室功能页:有修改公文、公文流转、删除公文、公文发送等功能。
⑧ 副厂长功能页:有审核公文(修改并签意见)、浏览已发所有公文、查询公文三个模块。
⑨ 厂长功能页:有审签公文(修改并签意见)、浏览已发所有公文、查询公文三个模块。
⑩ 系统管理功能页:有用户管理、角色管理、公文流转流程管理。
(2)、功能设计:
- 公文拟制:创建新的电子公文,对创建的电子公文进行上传操作。
- 签收公文:当接收方接收公文后,会给发送方发回执信息,确认公文已经收到。
- 浏览公文(已签收的公文):
1) 选择日期段。
2) 通过“查询”功能,显示该时间段内已通过审签的正式公文。
3) 点击公文标题,将会显示出该公文的具体信息。
- 修改公文:对拟制好的的电子公文进行格式化处理操作,套用公文样例。
- 公文流转:按照公文流转流程设定公文接收用户。
- 删除公文:如果该公文没有通过审核或审签,需要删除可以利用“删除”功能。确定后,系统提示公文删除成功,删除的公文将在“被删除公文”模块中的显示。
- 公文发送:操作员要根据单位管理员选择的公文的流程进行公文的流转发送,实现待发公文和已发送公文的管理
- 审核公文(修改并签意见):签署审核意见和修改意见,并将退回办公室。
- 有审签公文(修改并签意见):签署审前意见和修改意见,若同意,则生成正式公文并交由办公室转发。
- 浏览已发所有公文:按日期查看所有已发公文,点击标题可查看具体信息。
- 公文查询:是查询由公文交换系统处理过的公文,并且建立或检查公文详尽的索引信息。可以根据发送机构、接收机构、公文种类和其它开放信息进行公文数据查询。
- 系统管理:
a) 角色配置管理
- 用户权限维护功能:实现对用户的角色管理。
- 角色维护功能:实现对角色权限的管理,主要有编辑、增加和删除操作。
b) 用户管理:查看用户、新开用户、暂停用户、用户信息修改、删除用户
c) 单位管理员设置功能:每个单位的操作员实现修改密码、修改个人信息。
(3). 公文样例

完成情况:完成了表的构建,bean层, dao层,util、sevlet层刚开始,主页面完成剩下页面没有完成
代码如下:
bean层:
公文信息类
package bean;
public class InfoBean {
private int id;
private String title;
private String owner;
private String time;
private String receiver;
private int status;
private int result;
private String place;
private String viceplace;
private String primaryplace;
private int deletestatus;
private int callback;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
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;
}
public String getViceplace() {
return viceplace;
}
public void setViceplace(String viceplace) {
this.viceplace = viceplace;
}
public String getPrimaryplace() {
return primaryplace;
}
public void setPrimaryplace(String primaryplace) {
this.primaryplace = primaryplace;
}
public int getDeletestatus() {
return deletestatus;
}
public void setDeletestatus(int deletestatus) {
this.deletestatus = deletestatus;
}
public int getCallback() {
return callback;
}
public void setCallback(int callback) {
this.callback = callback;
}
public InfoBean(int id, String title, String owner, String time, String receiver, int status, int result,
String place, String viceplace, String primaryplace, int deletestatus, int callback) {
super();
this.id = id;
this.title = title;
this.owner = owner;
this.time = time;
this.receiver = receiver;
this.status = status;
this.result = result;
this.place = place;
this.viceplace = viceplace;
this.primaryplace = primaryplace;
this.deletestatus = deletestatus;
this.callback = callback;
}
public InfoBean() {
// TODO Auto-generated constructor stub
}
}
权限
package bean;
public class authority {
private int id;
private int authority;;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getAuthority() {
return authority;
}
public void setAuthority(int authority) {
this.authority = authority;
}
public authority() {
// TODO Auto-generated constructor stub
}
}
user类:
package bean;
public class user {
private int id;
private String username;
private String password;
private int permissionId;
private int status;
private String job;
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
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 int getPermissionId() {
return permissionId;
}
public void setPermissionId(int permissionId) {
this.permissionId = permissionId;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public user() {
// TODO Auto-generated constructor stub
}
}
dao层,对于每个功能的实现:
package dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import bean.InfoBean;
import bean.authority;
import bean.user;
import util.DBUtil; public class dao {
public static ArrayList<InfoBean> getInfos(String str) {
Connection conn = null;
PreparedStatement pst = null;
ResultSet rs = null;
conn = DBUtil.getConnection();
String sql;
if (str.equals("receive"))
sql = "select * from infobean where status=0 or status=2 or status=3 or status=4 or status=5 or status=6 or status=7 or status=-1 and deletestatus=0";
if (str.equals("send"))
sql = "select * from infobean where status=1 or status=4 or status=5 or status=8 or status=9 or status=10 and deletestatus=0";
if (str.equals("delete"))
sql = "select * from infobean where deletestatus=1";
else
sql = "select * from infobean";
try { PreparedStatement prepareStatement = conn.prepareStatement(sql);
rs = prepareStatement.executeQuery();
ArrayList<InfoBean> list = new ArrayList<>();
while (rs.next()) {
InfoBean ib = new InfoBean();
ib.setId(rs.getInt("id"));
ib.setTitle(rs.getString("title"));
ib.setOwner(rs.getString("owner"));
ib.setTime(rs.getString("time"));
ib.setReceiver(rs.getString("receive"));
ib.setStatus(rs.getInt("status"));
ib.setResult(rs.getInt("reslut"));
ib.setPlace(rs.getString("place"));
ib.setDeletestatus(rs.getInt("deletestatus"));
list.add(ib); }
return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DBUtil.close(rs, pst, conn);
}
return null;
} public static boolean userExits(user user) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
con = DBUtil.getConnection();
String sql = "select * from user where username ='" + user.getUsername() + "'and password='"
+ user.getPassword() + "'and status !=0";
try {
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next() == false)
return false;
else
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
DBUtil.close(rs, pstmt, con);
}
return false;
} public static boolean addInfo(InfoBean ib) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DBUtil.getConnection();
String sql = "insert into infobean(title,owner,receiver,time,status,result,place,deletestatus,callback) values(?,?,?,?,?,?,?,?,?)";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, ib.getTitle());
pstmt.setString(2, ib.getOwner());
pstmt.setString(3, ib.getReceiver());
pstmt.setString(4, ib.getTime());
pstmt.setInt(5, ib.getStatus());
pstmt.setInt(6, ib.getResult());
pstmt.setString(7, ib.getPlace());
pstmt.setInt(8, 0);
pstmt.setInt(9, 0);
pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, pstmt, con);
}
return false; } public static boolean delete_user(user u) {
Connection con = null;
PreparedStatement pstmt = null; try {
con = DBUtil.getConnection();
String sql = "delete from user where id=" + u.getId();
System.out.println(sql);
pstmt = con.prepareStatement(sql);
pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(pstmt, con);
}
return false;
} public static boolean update_user_status(user user) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DBUtil.getConnection();
String sql = "update user set status = ? where id = ?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, user.getStatus());
pstmt.setInt(2, user.getId());
pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(pstmt, con);
}
return false;
} public static boolean update_user(user user) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DBUtil.getConnection();
String sql = "update user set username=?,password=?,job=? where id = " + user.getId();
pstmt = con.prepareStatement(sql);
pstmt.setString(1, user.getUsername());
pstmt.setString(2, user.getPassword());
pstmt.setString(3, user.getJob());
pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(pstmt, con);
}
return false;
} @SuppressWarnings("resource")
public static boolean sendDoc(int id) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int status = -1;
int newstatus = -1;
String receiver = "";
try {
con = DBUtil.getConnection();
String sql = "select * from infobean where id=" + id;
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next()) {
status = rs.getInt("status");
}
switch (status) {
case 0:
newstatus = 1;
receiver = "副厂长";
break;
case 2:
newstatus = 5;
receiver = "厂长";
break;
case 3:
newstatus = 4;
receiver = "部门";
break;
case 6:
newstatus = 8;
receiver = "部门和副厂长";
break;
case 7:
newstatus = 9;
receiver = "部门和副厂长";
break;
case 8:
newstatus = 10;
receiver = "部门";
break;
default:
System.out.println("公文状态有误!");
break;
}
String sql_update = "update infobean set status = ? where id = ?";
pstmt = con.prepareStatement(sql_update);
pstmt.setInt(1, newstatus);
pstmt.setInt(2, id);
pstmt.executeUpdate();
return true;
} catch (SQLException e) {
System.out.println("数据库信息更新失败");
e.printStackTrace();
} finally {
DBUtil.close(pstmt, con);
}
return false;
} public static ArrayList<InfoBean> getInfoBychoose(String type, String value) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "";
System.out.println(type);
if (type.equals("title")) {
sql = "select * from infobean where title='" + value + "'";
} else if (type.equals("owner")) {
sql = "select * from infobean where owner='" + value + "'";
} else if (type.equals("receiver")) {
sql = "select * from infobean where receiver='" + value + "'";
} else if (type.equals("result")) {
sql = "select * from infobean where result='" + value + "'";
}
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
ArrayList<InfoBean> list = new ArrayList<>();
while (rs.next()) {
InfoBean ib = new InfoBean();
ib.setId(rs.getInt("id"));
ib.setTitle(rs.getString("title"));
ib.setOwner(rs.getString("owner"));
ib.setTime(rs.getString("time"));
ib.setReceiver(rs.getString("receiver"));
ib.setStatus(rs.getInt("status"));
ib.setResult(rs.getInt("result"));
ib.setPlace(rs.getString("place"));
list.add(ib);
}
return list;
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static ArrayList<InfoBean> getCheckedOrNotInfo(String type) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "";
if (type.equals("checked")) {
sql = "select * from infobean where status=6 or status=7";
} else {
sql = "select * from infobean where status=5";
}
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
ArrayList<InfoBean> list = new ArrayList<>();
while (rs.next()) {
InfoBean ib = new InfoBean();
ib.setId(rs.getInt("id"));
ib.setTitle(rs.getString("title"));
ib.setOwner(rs.getString("owner"));
ib.setTime(rs.getString("time"));
ib.setReceiver(rs.getString("receiver"));
ib.setStatus(rs.getInt("status"));
ib.setResult(rs.getInt("result"));
ib.setPlace(rs.getString("place"));
list.add(ib);
}
return list;
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static ArrayList<InfoBean> getCheckedorNot(String str) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "";
System.out.println(str);
if (str.equals("notchecked")) {
sql = "select * from infobean where status=1";
} else {
sql = "select * from infobean where status!=1 and status!=0 and status!=-1";
}
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
ArrayList<InfoBean> list = new ArrayList<>();
while (rs.next()) {
InfoBean ib = new InfoBean();
ib.setId(rs.getInt("id"));
ib.setTitle(rs.getString("title"));
ib.setOwner(rs.getString("owner"));
ib.setTime(rs.getString("time"));
ib.setReceiver(rs.getString("receiver"));
ib.setStatus(rs.getInt("status"));
ib.setResult(rs.getInt("result"));
ib.setPlace(rs.getString("place"));
list.add(ib);
}
return list;
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static ArrayList<InfoBean> getReceivedInfoByUser(String type, user user) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "";
if (type.equals("received")) {
sql = "select * from infobean where owner=? and status=10";
} else {
sql = "select * from infobean where owner=? and status!=10";
}
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, user.getUsername());
rs = preparedStatement.executeQuery();
ArrayList<InfoBean> list = new ArrayList<>();
while (rs.next()) {
InfoBean doc = new InfoBean();
doc.setId(rs.getInt("id"));
doc.setTitle(rs.getString("title"));
doc.setTime(rs.getString("time"));
doc.setStatus(rs.getInt("status"));
doc.setResult(rs.getInt("result"));
list.add(doc);
}
return list;
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static InfoBean getInfoById(InfoBean ib) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "select * from infobean where id=" + ib.getId();
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
if (rs.next()) {
ib.setTitle(rs.getString("title"));
ib.setOwner(rs.getString("owner"));
ib.setTime(rs.getString("time"));
ib.setReceiver(rs.getString("receiver"));
ib.setStatus(rs.getInt("status"));
ib.setResult(rs.getInt("result"));
ib.setPlace(rs.getString("place"));
ib.setViceplace(rs.getString("viceplace"));
ib.setPrimaryplace(rs.getString("primaryplace"));
return ib;
}
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static boolean checked_change(InfoBean ib) {
Connection connection = null;
PreparedStatement preparedStatement = null;
String sql = "update infobean set status = ?,result = ?,receiver = ?,viceplace = ? where id = ?";
try {
connection = DBUtil.getConnection();
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setInt(1, ib.getStatus());
preparedStatement.setInt(2, ib.getResult());
preparedStatement.setString(3, ib.getReceiver());
preparedStatement.setString(4, ib.getViceplace());
preparedStatement.setInt(5, ib.getId());
preparedStatement.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(preparedStatement, connection);
}
return false;
} public static boolean unchecked_change(InfoBean ib) {
Connection connection = null;
PreparedStatement preparedStatement = null;
String sql = "update infobean set status = ?,result = ?,receiver = ?,viceplace = ? where id = ?";
try {
connection = DBUtil.getConnection();
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setInt(1, ib.getStatus());
preparedStatement.setInt(2, ib.getResult());
preparedStatement.setString(3, ib.getReceiver());
preparedStatement.setString(4, ib.getViceplace());
preparedStatement.setInt(5, ib.getId());
preparedStatement.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(preparedStatement, connection);
}
return false;
} public static boolean formatDoc(InfoBean ib) {
Connection connection = null;
PreparedStatement preparedStatement = null;
String sql_update = "update infobean set status = ? where id = ?";
try {
connection = DBUtil.getConnection();
preparedStatement = connection.prepareStatement(sql_update);
preparedStatement.setInt(1, ib.getStatus());
preparedStatement.setInt(2, ib.getId());
preparedStatement.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(preparedStatement, connection);
}
return false;
} public static boolean ReceiveInfo(InfoBean ib) {
Connection connection = null;
PreparedStatement preparedStatement = null;
String sql = "update infobean set status = ?,callback = 1 where id = ?";
try {
connection = DBUtil.getConnection();
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setInt(1, 10);
preparedStatement.setInt(2, ib.getId());
preparedStatement.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(preparedStatement, connection);
}
return false;
} public static ArrayList<InfoBean> getInfoByTime(InfoBean ib1, InfoBean ib2) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from infobean where time between ? and ?";
try {
connection = DBUtil.getConnection();
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, ib1.getTime());
preparedStatement.setString(2, ib2.getTime());
rs = preparedStatement.executeQuery();
ArrayList<InfoBean> list = new ArrayList<>();
while (rs.next()) {
InfoBean doc = new InfoBean();
doc.setId(rs.getInt("id"));
doc.setTitle(rs.getString("title"));
doc.setTime(rs.getString("time"));
doc.setOwner(rs.getString("owner"));
list.add(doc);
}
return list;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static ArrayList<InfoBean> getAllInfos() {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from infobean";
try {
connection = DBUtil.getConnection();
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
ArrayList<InfoBean> list = new ArrayList<>();
while (rs.next()) {
InfoBean ib = new InfoBean();
ib.setId(rs.getInt("id"));
ib.setTitle(rs.getString("title"));
ib.setTime(rs.getString("time"));
ib.setOwner(rs.getString("owner"));
list.add(ib);
}
return list;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static ArrayList<user> getAllUser() {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from user";
try {
connection = DBUtil.getConnection();
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
ArrayList<user> list = new ArrayList<>();
while (rs.next()) {
user user = new user();
user.setId(rs.getInt("id"));
user.setUsername(rs.getString("username"));
user.setPassword(rs.getString("password"));
user.setPermissionId(rs.getInt("permissionId"));
user.setJob(rs.getString("job"));
user.setStatus(rs.getInt("status"));
list.add(user);
}
return list;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static user getUserById(user user) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from user where id=" + user.getId();
try {
connection = DBUtil.getConnection();
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
user user1 = new user();
if (rs.next()) {
user1.setId(rs.getInt("id"));
user1.setUsername(rs.getString("username"));
user1.setPassword(rs.getString("password"));
user1.setPermissionId(rs.getInt("permissionId"));
user1.setStatus(rs.getInt("status"));
user1.setJob(rs.getString("job"));
}
return user1;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(preparedStatement, connection);
}
return null;
} public static ArrayList<authority> getAuthority(authority at) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from permission where id=" + at.getId();
try {
connection = DBUtil.getConnection();
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
ArrayList<authority> list = new ArrayList<>();
while (rs.next()) {
authority at1 = new authority();
at1.setId(rs.getInt("id"));
at1.setAuthority(rs.getInt("authority"));
list.add(at1);
}
return list;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static boolean deleteAuthority(authority at) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DBUtil.getConnection();
String sql = "delete from permission where id=" + at.getId();
pstmt = con.prepareStatement(sql);
pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(pstmt, con);
}
return false;
} public static boolean updateAuthority(authority at1, authority at2) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DBUtil.getConnection();
String sql = "update permission set permission = ? where id = ? and permission = ?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, at2.getAuthority());
pstmt.setInt(2, at1.getId());
pstmt.setInt(3, at1.getAuthority());
pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(pstmt, con);
}
return false;
} public dao() {
// TODO Auto-generated constructor stub
} public static boolean updatePwd(user user) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DBUtil.getConnection();
String sql = "update users set password = ? where username = ?";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, user.getPassword());
pstmt.setString(2, user.getUsername());
pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(pstmt, con);
}
return false;
} public static user getUserByUsername(user user) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
String sql = "select * from user where username='" + user.getUsername() + "'";
try {
connection = DBUtil.getConnection();
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
user user1 = new user();
if (rs.next()) {
user1.setId(rs.getInt("id"));
user1.setPermissionId(rs.getInt("permissionId"));
System.out.println(user1.getPermissionId());
}
return user1;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static boolean deleteInfo(InfoBean ib) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DBUtil.getConnection();
String sql = "update infobean set deletestatus = ? where id = ?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, ib.getDeletestatus());
pstmt.setInt(2, ib.getId());
pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(pstmt, con);
}
return false;
} public static ArrayList<InfoBean> getCall() {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet rs = null;
try {
connection = DBUtil.getConnection();
String sql = "select * from infobean where callback=1";
preparedStatement = connection.prepareStatement(sql);
rs = preparedStatement.executeQuery();
ArrayList<InfoBean> list = new ArrayList<>();
while (rs.next()) {
InfoBean ib = new InfoBean();
ib.setId(rs.getInt("id"));
ib.setTitle(rs.getString("title"));
ib.setOwner(rs.getString("owner"));
ib.setTime(rs.getString("time"));
ib.setReceiver(rs.getString("receiver"));
ib.setStatus(rs.getInt("status"));
ib.setResult(rs.getInt("result"));
ib.setPlace(rs.getString("place"));
ib.setDeletestatus(rs.getInt("deletestatus"));
ib.setCallback(rs.getInt("callback"));
list.add(ib);
}
return list;
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
} finally {
DBUtil.close(rs, preparedStatement, connection);
}
return null;
} public static boolean setCallOver(InfoBean ib) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DBUtil.getConnection();
String sql = "update infobean set callback = ? where id = ?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, 0);
pstmt.setInt(2, ib.getId());
pstmt.executeUpdate();
return true;
} catch (SQLException e) {
e.printStackTrace();
} finally {
DBUtil.close(pstmt, con);
}
return false;
} }
DBUtil对于数据库的操作封装:
package util; import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement; public class DBUtil {
private static String url = "jdbc:mysql://localhost:3306/doc_system?useUnicode=true&characterEncoding=utf8";
private static String user = "root";
private static String password = "root";
private static String jdbcName="com.mysql.jdbc.Driver";
private Connection con=null;
public static Connection getConnection() {
Connection con=null;
try {
Class.forName(jdbcName);
con=DriverManager.getConnection(url, user, password);
System.out.println("数据库连接成功");
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("数据库连接失败");
e.printStackTrace();
}
return con; }
public static void close(Connection con) {
if(con!=null)
try {
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
public static void close(Statement state, Connection conn) {
if(state!=null) {
try {
state.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(conn!=null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
} public static void close(ResultSet rs, Statement state, Connection conn) {
if(rs!=null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(state!=null) {
try {
state.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(conn!=null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
servlet对于公文的接受:
package servlet; import java.io.IOException;
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 bean.InfoBean;
import dao.dao; /**
* Servlet implementation class receive
*/
@WebServlet("/receive")
public class receive extends HttpServlet {
private static final long serialVersionUID = 1L; /**
* @see HttpServlet#HttpServlet()
*/
public receive() {
super();
// TODO Auto-generated constructor stub
} /**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
int id=Integer.parseInt(request.getParameter("id"));
InfoBean ib=new InfoBean();
ib.setId(id);
if(dao.setCallOver(ib)) response.getWriter().write("yes");
else response.getWriter().write("no");
} /**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
} }
其他的servlet还没写完
表结构:




其他页面尚未完成
体会:当遇到很多很多的代码的时候发现了封装成类有多么简便 ,这样频繁的调用要比写要简单的多。这种大项目主要是业务流程的分析,只有清楚每个流程,分析到位,你才能知道这些到底应该怎么做,应该怎么封装。但是dao层的任务量实在是太大了 有两小时在写dao层,别的更没有时间。因此还要加强增删改查的基本操作,越来越熟悉,写的速度也越快,只有这样才能在规定的时间内完成任务。另外在自己编程的过程中要总结方法,总结到底怎么做才能简化代码量,提高自己的效率。老师一让计时,这才发现自己写代码速度到底有多慢,因此还需要加强自己的薄弱项目。重在实践,多动手。多分析业务流程,对业务流程在脑中有一个清楚的认识,这样才能快速的编程。而且拿到题目的时候,不是直接去写,而是去分析流程,分析结构,分析自己应该用什么方法,怎么做。每次做题的时候都要去分析。你写出正确的代码的前提是你了解业务流程。这样写起代码来才会得心应手。要寻找一些方法中的共同点,然后简化代码。
Java web 公文流转系统 完成结果的更多相关文章
- “公文流转系统 v1.0”
1.项目需求: 河北金力集团是我省机械加工的龙头企业,主要从事矿山机械制造及各种机械零部件加工.企业有3个厂区,主厂区位于省高新技术开发区,3个分厂分别在保定.邢台和唐山.为增加企业的核心竞争力和加强 ...
- YbSoftwareFactory 代码生成插件【二十三】:集成强大的公文流转系统
今天有空更新博客才发现快一年没有写博客了,不得不感叹时间过得真快.过去的一年确实也挺忙的,在此祝各位博友们新的一年工作顺利.权限模型在过去一年进行了不少的升级,主要集成了公文流转系统.多家手机短信接口 ...
- 公文流转系统v0.1
河北金力集团公文流转系统 1.项目需求: 河北金力集团是我省机械加工的龙头企业,主要从事矿山机械制造及各种机械零部件加工.企业有3个厂区,主厂区位于省高新技术开发区,3个分厂分别在保定.邢台和唐山.为 ...
- OA公文流转系统(未完成)
基本页面比较多,所以就不贴出来了,具体的页面可以自行浏览. 点我进入OA系统浏览界面(未做响应式布局,需电脑端打开) 账号密码: 部门:bumen------bumen 办公室:bangongshi- ...
- javaweb 公文流转系统制作
该系统主要的要求就是实现公文的流转审核,用户有多重类型,在不同用户登录的时候要进入不同的页面,并能执行他们的权限. 用户分四种,普通部门(可以草拟公文并提交),办公室(接受普通部门的公文并编辑,最后提 ...
- 2019.12.9java公文流转系统
自己来写这个系统真是没有什么思路.就弄了个登陆界面,在数据库建了个表,其它的代码一直有错误,登陆不进去.
- java web 程序---投票系统
1.这里会连接数据库--JDBC的学习实例 一共有3个页面. 2.第一个页面是一个form表单,第二个页面是处理数据,第三个页面是显示页面 vote.jsp <body bgcolor=&quo ...
- 零基础如何系统学习Java Web
零基础如何系统学习Java Web? 我来给你说一说 你要下决心,我要转行做开发,这样你才能学成. 你要会打字,我公司原来有一个程序员,打字都是两个手一指禅,身为程序员你一指禅怎么写出的代码,半个 ...
- 使用Java编写一个简单的Web的监控系统cpu利用率,cpu温度,总内存大小
原文:http://www.jb51.net/article/75002.htm 这篇文章主要介绍了使用Java编写一个简单的Web的监控系统的例子,并且将重要信息转为XML通过网页前端显示,非常之实 ...
随机推荐
- Laravel save部分字段失效的bug问题解决
问题描述:今天在编写api的更新部分,发现有部分字段怎么更新都更新不上去. 问题排查: 经过多次测试,发现每次提交只能更新部分字段,字段分别为:id,user_id,device_room_id,na ...
- js之数据类型(原始类型)
JavaScript的数据类型分为两类:原始类型和对象类型.本文讨论的是原始类型.原始类型包括数字,字符串,和布尔值.但在JavaScript中有两个特殊的原始值null(空)和undefined(未 ...
- 【Git的基本操作五】比较文件差异
比较文件差异 1. git diff [文件名] 将工作区中的文件和暂存区对应文件进行比较 例:git diff test.txt 2. git diff [本地库中文件历史记录(指针)] [文件名] ...
- 数组去重-----js 判断字符串中是否包含某个字符串indexOf
判断obj对象是否在arr数组里面,是返回true const dealArray = (arr, obj) => { Array.prototype.S = String.fromCharCo ...
- mysql的锁机制,以及乐观锁,悲观锁,以及热点账户余额问题
mysql的简单锁机制. myisam 1.只支持表级锁,所以经常更新的表结构不适宜用. 2.select也会产生锁表 innodb 1.支持事务,行级锁,表级锁,执行行级锁的前提是sql语句的索引有 ...
- Java并发与多线程
1. 并发与并行 并发是指某个时间段内,多任务交替处理的能力:并行是指同时处理多任务的能力,多核CPU可以实现并行任务. 并发执行的特点: (1)并发程序间相互制约:程序执行结果的相互依赖以及共享资源 ...
- 性能测试分析工具nmon文件分析时报错解决办法
1.使用nmon analyzer V334.xml分析数据时,如果文件过大,可以修改Analyser页签中的INTERVALS的最大值: 2.查找生成的nmon文件中包含的nan,删掉这些数据(需要 ...
- thinkphp5 二维码生成 composer
进入extend文件夹 composer require endroid/qrcode 2.将二维码生成封装为服务 QrcodeServer.php代码如下: <?php /** * Creat ...
- Linux下kafka集群搭建
环境准备 zookeeper集群环境 kafka是依赖于zookeeper注册中心的一款分布式消息对列,所以需要有zookeeper单机或者集群环境. 三台服务器: 172.16.18.198 k8s ...
- postman 接口测试(一)
一.postman 应用场景 开发接口快速的调用接口,以便调试 方便的调用接口,通过不同的参数去测试接口的输出 这些接口调用时需要保存下来的反复运行的 在运行中如果有断言(检查点 <预期 和现实 ...