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

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. CA机构及SSL证书

    互联网安全形势日趋严峻,企业重视自身互联网安全已成必然,SSL认证成大势所趋.要部署SSL证书最首先就是选好CA机构!其次选择适合自己的SSL证书!今天就来介绍一下如何选择CA机构及SSL证书! 首先 ...

  2. IntelliJ IDEA Spring boot devtools 实现热部署

    一.spring-boot-devtools是一个为开发者服务的一个模块,其中最重要的功能就是自动部署新代码. 二.原理 使用了两个ClassLoader,一个ClassLoader用来加载那些不会变 ...

  3. PLSQL Developer 12 汉化包下载

    下载地址: https://www.allroundautomations.com/plsqldevlang/120/index.html

  4. iptables防火墙操作-查看、配置、重启、关闭

    查看iptables端口配置 iptables -L -n --line-number iptables端口配置(不开通3389无法远程连接,不开通icmp无法ping) iptables -A IN ...

  5. WinForm - 不用自绘实现仿QQ2013

    素材啥的都是一手整理的,绝对的原创.这是13年做的,虽然是个老项目了,可里面涉及的winform技术不会过时,所以就拿出来重温探讨下技术要点. 没使用任何自绘命令,可以说是非常容易理解与学习的. 效果 ...

  6. Java十进制转二进制

    闲着没事写了个简单的十进制转二进制的算法,很简单,个人记录一下,不妥之处请指正. public static String toBinaryString(int j) { if (j < 0) ...

  7. 开源you-get项目爬虫,以及基于python+selenium的自动测试利器

    写在前面 爬虫和自动测试,对于python来说是最合适不过也是最擅长的. 开源的项目也很多,例如you-get项目https://github.com/soimort/you-get.盗链和爬虫神器. ...

  8. NORDIC GATT事件

    假设有两个服务,每个服务注册相应事件 注册的事件为ble_dev_cfg_on_ble_evt.ble_lora_cfg_on_ble_evt 当在任何一个服务中发生GATT特征读或写的时候,注册的这 ...

  9. shell脚本基础和grep文本处理工具企业应用1

      bash特性及bash脚本编程初步: 用户要跟计算机交互就需要有终端,比如:显示器.键鼠等,在终端有附着的接口程序 GUI:KDE.GNome.Xfce CLI:/etc/shells bash ...

  10. Linux系统组成和获取命令帮助2

    基于cobbler进行网络安装:    https://cobbler.github.io/ 终端:terminal        无论是系统的图形界面还是文字界面,都可以叫做控制台,终端       ...