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

1、项目需求:

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

公文流转的流程:

2. 板块功能需求

(1)、页面要求

① 能适应800*600或1024*768分辨率;

② 布局合理、结构清晰、页面完整;

③ 有效页面数在8页以上;

④ 分页与主页风格统一;

⑤ 首页(登录页):用户登录页(共有十位用户帐号,帐号、密码可预设)。不同用户登录后,进入的功能页不相同,要求密码在数据库中加密。

⑥ 部门(不含办公室)功能页:有公文拟制、签收公文、浏览公文(已签收的公文)三个模块

⑦ 办公室功能页:有修改公文、公文流转、删除公文、公文发送等功能。

⑧ 副厂长功能页:有审核公文(修改并签意见)、浏览已发所有公文、查询公文三个模块。

⑨ 厂长功能页:有审签公文(修改并签意见)、浏览已发所有公文、查询公文三个模块。

⑩ 系统管理功能页:有用户管理、角色管理、公文流转流程管理。

(2)、功能设计:

  1. 公文拟制:创建新的电子公文,对创建的电子公文进行上传操作。
  2. 签收公文:当接收方接收公文后,会给发送方发回执信息,确认公文已经收到。
  3. 浏览公文(已签收的公文):

1) 选择日期段。

2) 通过“查询”功能,显示该时间段内已通过审签的正式公文。

3) 点击公文标题,将会显示出该公文的具体信息。

  1. 修改公文:对拟制好的的电子公文进行格式化处理操作,套用公文样例。
  2. 公文流转:按照公文流转流程设定公文接收用户。
  3. 删除公文:如果该公文没有通过审核或审签,需要删除可以利用“删除”功能。确定后,系统提示公文删除成功,删除的公文将在“被删除公文”模块中的显示。
  4. 公文发送:操作员要根据单位管理员选择的公文的流程进行公文的流转发送,实现待发公文和已发送公文的管理
  5. 审核公文(修改并签意见):签署审核意见和修改意见,并将退回办公室。
  6. 有审签公文(修改并签意见):签署审前意见和修改意见,若同意,则生成正式公文并交由办公室转发。
  7. 浏览已发所有公文:按日期查看所有已发公文,点击标题可查看具体信息。
  8. 公文查询:是查询由公文交换系统处理过的公文,并且建立或检查公文详尽的索引信息。可以根据发送机构、接收机构、公文种类和其它开放信息进行公文数据查询。
  9. 系统管理:

a)  角色配置管理

  1. 用户权限维护功能:实现对用户的角色管理。
  2. 角色维护功能:实现对角色权限的管理,主要有编辑、增加和删除操作。

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 公文流转系统 完成结果的更多相关文章

  1. “公文流转系统 v1.0”

    1.项目需求: 河北金力集团是我省机械加工的龙头企业,主要从事矿山机械制造及各种机械零部件加工.企业有3个厂区,主厂区位于省高新技术开发区,3个分厂分别在保定.邢台和唐山.为增加企业的核心竞争力和加强 ...

  2. YbSoftwareFactory 代码生成插件【二十三】:集成强大的公文流转系统

    今天有空更新博客才发现快一年没有写博客了,不得不感叹时间过得真快.过去的一年确实也挺忙的,在此祝各位博友们新的一年工作顺利.权限模型在过去一年进行了不少的升级,主要集成了公文流转系统.多家手机短信接口 ...

  3. 公文流转系统v0.1

    河北金力集团公文流转系统 1.项目需求: 河北金力集团是我省机械加工的龙头企业,主要从事矿山机械制造及各种机械零部件加工.企业有3个厂区,主厂区位于省高新技术开发区,3个分厂分别在保定.邢台和唐山.为 ...

  4. OA公文流转系统(未完成)

    基本页面比较多,所以就不贴出来了,具体的页面可以自行浏览. 点我进入OA系统浏览界面(未做响应式布局,需电脑端打开) 账号密码: 部门:bumen------bumen 办公室:bangongshi- ...

  5. javaweb 公文流转系统制作

    该系统主要的要求就是实现公文的流转审核,用户有多重类型,在不同用户登录的时候要进入不同的页面,并能执行他们的权限. 用户分四种,普通部门(可以草拟公文并提交),办公室(接受普通部门的公文并编辑,最后提 ...

  6. 2019.12.9java公文流转系统

    自己来写这个系统真是没有什么思路.就弄了个登陆界面,在数据库建了个表,其它的代码一直有错误,登陆不进去.

  7. java web 程序---投票系统

    1.这里会连接数据库--JDBC的学习实例 一共有3个页面. 2.第一个页面是一个form表单,第二个页面是处理数据,第三个页面是显示页面 vote.jsp <body bgcolor=&quo ...

  8. 零基础如何系统学习Java Web

    零基础如何系统学习Java Web?   我来给你说一说 你要下决心,我要转行做开发,这样你才能学成. 你要会打字,我公司原来有一个程序员,打字都是两个手一指禅,身为程序员你一指禅怎么写出的代码,半个 ...

  9. 使用Java编写一个简单的Web的监控系统cpu利用率,cpu温度,总内存大小

    原文:http://www.jb51.net/article/75002.htm 这篇文章主要介绍了使用Java编写一个简单的Web的监控系统的例子,并且将重要信息转为XML通过网页前端显示,非常之实 ...

随机推荐

  1. Katu Puzzle POJ - 3678 (2 - sat)

    有N个变量X1X1~XNXN,每个变量的可能取值为0或1. 给定M个算式,每个算式形如 XaopXb=cXaopXb=c,其中 a,b 是变量编号,c 是数字0或1,op 是 and,or,xor 三 ...

  2. 《深入理解 Java 虚拟机》学习笔记 -- 内存区域

    <深入理解 Java 虚拟机>学习笔记 -- 内存区域 运行时数据区域 主要分为 6 部分: 程序计数器 虚拟机栈 本地方法栈 Java 堆 方法区 如图所示: 1. 程序计数器(线程私有 ...

  3. linux查询cpu过高原因--java

    1. 查询java pid top -c 2. 查询java进程下,线程情况 top -Hp pid(threadIdList) 3. 将10进制线程id转为16进制 printf "%x ...

  4. [C#.net]使用Thread.Sleep界面卡死的问题解决方法

    很多初学者在写C#程序的时候,需要程序等待某个时间,但是又不想用比较繁琐的线程等操作,因此用Thread.Sleep()函数,但是这个函数在等待过程中会操作界面的卡死,那么,如何能保证既不卡死又能达到 ...

  5. 【原创】大数据基础之Logstash(6)mongo input

    logstash input插件之mongodb是第三方的,配置如下: input { mongodb { uri => 'mongodb://mongo_server:27017/db' pl ...

  6. CentOS/RHEL 安装EPEL第三方软件源

    EPEL源简介 EPEL(Extra Packages for Enterprise Linux) 是由 FedORA 社区打造,为 RHEL 及衍生发行版如 CentOS等提供高质量软件包的项目.装 ...

  7. Python学习笔记:利用爬虫自动保存图片

    兴趣才是第一生产驱动力. Part 1 起先,源于对某些网站图片浏览只能一张一张的翻页,心生不满.某夜,冒出一个想法,为什么我不能利用爬虫技术把想看的图片给爬下来,然后在本地看个够. 由此经过一番初尝 ...

  8. 13 Django之中间件

    一.什么是中间件 中间件顾名思义,是介于request与response处理之间的一道处理过程,相对比较轻量级,并且在全局上改变django的输入与输出.因为改变的是全局,所以需要谨慎实用,用不好会影 ...

  9. vue编程式导航,命名路由

    //使用 window.location.href 的形式,叫做 编程式导航 绑定事件的形式 <template> <div class="goods-item" ...

  10. git 多账户添加ssh秘钥

    生成秘钥的步骤: ssh-keygen -t rsa -C "xxxx@qq.com" 添加秘钥 在不同的域中添加相同的秘钥是没有问题的,比如 github.com / code. ...