📄 logbo.java
字号:
package com.log.bo;
import com.log.util.Constant;
import com.log.util.DateUtil;
import com.lzc.util.db.DBManager;
public class LogBo {
private static LogBo instance = null;
public static LogBo getInstance() {
if (instance == null) {
synchronized (new Object()) {
if (instance == null) {
instance = new LogBo();
}
}
}
return instance;
}
public static void main(String[] args) throws Exception {
LogBo bo = LogBo.getInstance();
bo.searchStaff("11", "", "22", "33");
}
public String searchStaff(String workno, String name, String phone,
String department) throws Exception {
String sql = "select* from staffinfo";
try {
if (!workno.equals("") || !name.equals("") || !phone.equals("")
|| !department.equals("")) {
sql += " where ";
int i = 0;
if (!workno.equals("")) {
i++;
sql += " workno like '%" + workno + "%'";
}
if (!name.equals("")) {
if (i > 0) {
sql += " and ";
}
i++;
sql += " name like '%" + name + "%'";
}
if (!phone.equals("")) {
if (i > 0) {
sql += " and ";
}
i++;
sql += " phone like '%" + phone + "%'";
}
if (!department.equals("")) {
if (i > 0) {
sql += " and ";
}
i++;
sql += " department like '%" + department + "%'";
}
}
// System.out.println("sql:" + sql);
} catch (Exception e) {
System.out.println("Error in searchStaff:" + e);
}
return sql;
}
public boolean delStaffInfo(String[] paramVal) throws Exception {
boolean flag = false;
try {
String sql = "delete from staffinfo where id=?";
flag = DBManager.getNewInstance("szhtp").update(sql, paramVal);
} catch (Exception e) {
flag = false;
System.out.println("Error in delStaffInfo:" + e);
}
return flag;
}
public boolean editStaffInfo(String[] paramVal) throws Exception {
boolean flag = false;
try {
String sql = "update staffinfo set workno=?,name=?,phone=?,idcard=?,sex=?,department=? where id=?";
flag = DBManager.getNewInstance("szhtp").update(sql, paramVal);
} catch (Exception e) {
flag = false;
System.out.println("Error in editStaffInfo:" + e);
}
return flag;
}
public String[][] getStaffinfoByID(String id) throws Exception {
String[][] data = null;
try {
String sql = "select * from staffinfo where id=" + id;
data = DBManager.getNewInstance("szhtp").query(sql, -1, 1);
} catch (Exception e) {
System.out.println("Error in getStaffinfoByID:" + e);
}
return data;
}
public String[][] getStaffinfoByID(String id, String workno)
throws Exception {
String[][] data = null;
try {
String sql = "select * from staffinfo where id <>" + id
+ " and workno=" + workno;
data = DBManager.getNewInstance("szhtp").query(sql, 10, 1);
} catch (Exception e) {
System.out.println("Error in getStaffinfoByID:" + e);
}
return data;
}
public String[][] getStaffinfoByNo(String workno) throws Exception {
String[][] data = null;
try {
String sql = "select * from staffinfo where workno=" + workno;
data = DBManager.getNewInstance("szhtp").query(sql, 10, 1);
} catch (Exception e) {
System.out.println("Error in getStaffinfoByNo:" + e);
}
return data;
}
public boolean addStaffInfo(String[] paramVal) throws Exception {
boolean flag = false;
try {
String sql = "insert into staffinfo(workno,name,phone,idcard,sex,department)values(?,?,?,?,?,?)";
flag = DBManager.getNewInstance("szhtp").update(sql, paramVal);
} catch (Exception e) {
flag = false;
System.out.println("Error in addStaffInfo:" + e);
}
return flag;
}
public String[][] getSysTypeByCode(String sysCode) throws Exception {
String[][] data = null;
try {
String sql = "select * from SystemType where syscode='" + sysCode
+ "'";
data = DBManager.getNewInstance("szhtp").query(sql, -1, 1);
} catch (Exception e) {
System.out.println("Error in getSysTypeByCode:" + e);
}
return data;
}
public String[][] getSysTypeList() throws Exception {
String[][] data = null;
try {
String sql = "select * from SystemType";
data = DBManager.getNewInstance("szhtp").query(sql, -1, 1);
} catch (Exception e) {
System.out.println("Error in getSysTypeList:" + e);
}
return data;
}
public void addSysType(String[] paramVal) throws Exception {
try {
String sql = "insert into SystemType(syscode,name)values(?,?)";
DBManager.getNewInstance("szhtp").update(sql, paramVal);
} catch (Exception e) {
System.out.println("Error in addSysType:" + e);
}
}
public void editSysType(String[] paramVal) throws Exception {
try {
String sql = "update SystemType set name=? where syscode=?";
DBManager.getNewInstance("szhtp").update(sql, paramVal);
} catch (Exception e) {
System.out.println("Error in editSysType:" + e);
}
}
public void delSysType(String[] paramVal) throws Exception {
try {
String sql = "delete from SystemType where syscode=?";
DBManager.getNewInstance("szhtp").update(sql, paramVal);
} catch (Exception e) {
System.out.println("Error in delSysType:" + e);
}
}
public String[][] getLogTypeByCode(String code) throws Exception {
String[][] data = null;
try {
String sql = "select * from logtype where code='" + code + "'";
data = DBManager.getNewInstance("szhtp").query(sql, -1, 1);
} catch (Exception e) {
System.out.println("Error in getLogTypeByCode:" + e);
}
return data;
}
public String[][] getLogTypeList() throws Exception {
String[][] data = null;
try {
String sql = "select * from logtype ";
data = DBManager.getNewInstance("szhtp").query(sql, -1, 1);
} catch (Exception e) {
System.out.println("Error in getLogTypeList:" + e);
return null;
}
return data;
}
public void addLogType(String[] paramVal) throws Exception {
try {
String sql = "insert into logtype(code,name,syscode)values(?,?,?)";
DBManager.getNewInstance("szhtp").update(sql, paramVal);
} catch (Exception e) {
System.out.println("Error in addLogType:" + e);
}
}
public void editLogType(String[] paramVal) throws Exception {
try {
String sql = "update logtype set name=?,syscode=? where code=?";
DBManager.getNewInstance("szhtp").update(sql, paramVal);
} catch (Exception e) {
System.out.println("Error in editLogType:" + e);
}
}
public void delLogType(String[] paramVal) throws Exception {
try {
String sql = "delete from logtype where code=?";
DBManager.getNewInstance("szhtp").update(sql, paramVal);
} catch (Exception e) {
System.out.println("Error in delLogType:" + e);
}
}
public void getLogInfoList(String logType, String logUser) throws Exception {
try {
String sql = "select * from SysLogInfo";
if ((null != logType && !"".equals(logType))
|| (null != logUser && !"".equals(logUser))) {
sql += " where ";
if (null != logType && !"".equals(logType)) {
sql += " logtype like '%" + logType + "%'";
}
if (null != logUser && !"".equals(logUser)) {
sql += " and logUser like '%" + logUser + "%'";
}
}
} catch (Exception e) {
System.out.println("Error in getLogInfoList:" + e);
}
}
public boolean addLogInfo(String[] paramVal) throws Exception {
boolean flag = false;
try {
// System.out.println("paramVal:"+paramVal);
// for(int i=0;i<paramVal.length;i++){
// System.out.println(":::::"+paramVal[i]);
// }
String sql = "insert into SysLogInfo(logtype,logcontent,loguser)values(?,?,?)";
flag = DBManager.getNewInstance("szhtp").update(sql, paramVal);
} catch (Exception e) {
System.out.println("Error in addLogInfo:" + e);
}
return flag;
}
public boolean addLogInfo(String logType, String content, String logUser)
throws Exception {
boolean flag = false;
try {
// System.out.println("paramVal:"+paramVal);
// for(int i=0;i<paramVal.length;i++){
// System.out.println(":::::"+paramVal[i]);
// }
// String sql = "insert into
// SysLogInfo(logtype,logcontent,loguser)values(?,?,?)";
String sql = "exec sp_InsertSysLogInfo '" + logType + "','"
+ content + "','" + logUser + "'";
flag = DBManager.getNewInstance("szhtp").update(sql);
} catch (Exception e) {
System.out.println("Error in addLogInfo:" + e);
}
return flag;
}
public boolean addLogInfoEx(String logType, String content, String logUser,String ipAdd,String macAdd)
throws Exception {
boolean flag = false;
try {
String sql = "exec sp_InsertSysLogInfoEx '" + logType + "','"
+ content + "','" + logUser + "','"+ipAdd+"','"+macAdd+"'";
flag = DBManager.getNewInstance("szhtp").update(sql);
} catch (Exception e) {
System.out.println("Error in addLogInfoEx:" + e);
}
return flag;
}
public boolean addLevel(String serial_no, String phone_nbr,
String staff_id, int state) throws Exception {
boolean flag = false;
try {
String sql = "exec sp_InsertSatisfyLevel '" + serial_no + "','"
+ phone_nbr + "','" + staff_id + "'," + state;
// System.out.println("sql:"+sql);
flag = DBManager.getNewInstance("szhtp").update(sql);
} catch (Exception e) {
System.out.println("Error in addLevel:" + e);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -