📄 wffuncinfodao.java
字号:
package cn.com.iaspec.workflow.privilege.dao;
import java.sql.*;
import java.util.*;
import org.apache.log4j.*;
import cn.com.iaspec.workflow.db.*;
import cn.com.iaspec.workflow.*;
import cn.com.iaspec.workflow.vo.db.*;
/**
*
* <p>Title:功能信息表DAO </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: IASPEC Technologies</p>
* @author xiesonglin
* @version 1.0
*/
public class WfFuncInfoDAO{
private static Logger logger=Logger.getLogger(WfFuncInfoDAO.class);
public WfFuncInfoDAO(){
}
/**
* 查询
* @param func LaFuncInfo
* @throws SQLException
* @return List
*/
public List query(WfFuncInfo func)
throws SQLException{
Connection conn=null;
Statement stm=null;
try{
conn=WorkflowDBConnectionManager.getInstance().getConnection();
stm=conn.createStatement();
String sql=" select * from wf_func_info ";
StringBuffer sbWhere=getQueryString(func);
sql=sql+sbWhere.toString();
logger.info("......query sql:"+sql);
ResultSet rs=stm.executeQuery(sql);
List list=resultsetToVO(rs);
return list;
}
finally{
WorkflowDBConnectionManager.getInstance().close(stm,false);
WorkflowDBConnectionManager.getInstance().close(conn);
}
}
/**
* 取得当前用户有权限办理的一级菜单功能
* @param userId String
* @return List
*/
public List getFirstFuncInfoByUserId(String userId)
throws SQLException{
Connection conn=null;
Statement stm=null;
try{
conn=WorkflowDBConnectionManager.getInstance().getConnection();
stm=conn.createStatement();
String sql=" select * from wf_func_info "+
"Where func_id In (Select Distinct func_id From wf_role_func "+
"Where role_id In (Select Distinct role_id From wf_org_user_role "+
"Where user_id = '"+userId+
"')) And up_func_id = '0' order by func_order ";
logger.info("......query sql:"+sql);
ResultSet rs=stm.executeQuery(sql);
List list=resultsetToVO(rs);
return list;
}
finally{
WorkflowDBConnectionManager.getInstance().close(stm,false);
WorkflowDBConnectionManager.getInstance().close(conn);
}
}
/**
* 取得指定用户、指定菜单下用户有权限办理的功能菜单
* @param userId String
* @param funcId String
* @throws SQLException
* @return List
*/
public List getSubFuncInfoByParentId(String userId,String funcId)
throws SQLException{
Connection conn=null;
List list=new ArrayList();
CallableStatement callStm=null;
Statement stm=null;
try{
//取得有权限的功能接点id
conn=WorkflowDBConnectionManager.getInstance().getConnection();
String sql="{?=call func_get_subfuncid_byprarentid(?,?)}";
logger.info("......query sql:"+sql+":userId:"+userId+":funcId:"+funcId);
callStm=conn.prepareCall(sql);
callStm.registerOutParameter(1,java.sql.Types.VARCHAR);
callStm.setString(2,userId);
callStm.setString(3,funcId);
callStm.execute();
String tempId=callStm.getString(1);
callStm.close();
if(tempId==null&&tempId.equals("")){
return list;
}
//String[] ids=tempId.split(",");
String[] ids=tempId.split(",");
String sTemp="";
for(int i=0;i<ids.length;i++){
sTemp=sTemp+",'"+ids[i]+"'";
}
if(sTemp!=null&&!sTemp.equals("")){
//去掉最后一个','
sTemp=sTemp.substring(1,sTemp.length());
}
else{
return list;
}
//取得有权限功能的菜单信息
stm=conn.createStatement();
sql=" select * from wf_func_info where func_id in ("+sTemp+
") order by func_order ";
logger.info("......query sql:"+sql);
ResultSet rs=stm.executeQuery(sql);
list=resultsetToVO(rs);
rs.close();
//处理功能节点信息,将非直属子功能删除
return this.processSubFuncInfo(list,funcId);
}
catch(Exception ex){
ex.printStackTrace();
}
finally{
WorkflowDBConnectionManager.getInstance().close(conn);
}
return null;
}
/**
* 处理功能节点信息,将非直属子功能删除
* @param list List 已经取得的功能信息
* @param funcId String 功能id
* @return LaFuncInfo
*/
private List processSubFuncInfo(List list,String funcId){
List subList=new ArrayList();
List returnList=new ArrayList();
//取得各节点直属子功能信息
for(int i=0;i<list.size();i++){
WfFuncInfo funcTemp=(WfFuncInfo)list.get(i);
WfFuncInfo func=getSubFuncInfo(list,funcTemp.getFuncId());
subList.add(func);
}
//将直属功能加入returnList
for(int j=0;j<subList.size();j++){
WfFuncInfo funcTemp=(WfFuncInfo)subList.get(j);
if(funcTemp.getUpFuncId().equals(funcId)&&
!funcTemp.getFuncId().equals(funcId)){
returnList.add(funcTemp);
}
}
return returnList;
}
/**
* 取得指定接点的信息,包括子节点信息
* @param list List 已经取得的功能信息
* @param funcId String 功能id
* @return LaFuncInfo
*/
private WfFuncInfo getSubFuncInfo(List list,String funcId){
WfFuncInfo func=new WfFuncInfo();
List subList=new ArrayList();
for(int i=0;i<list.size();i++){
WfFuncInfo funcTemp=(WfFuncInfo)list.get(i);
//取得当前节点信息
if(funcTemp.getFuncId().equals(funcId)){
func=funcTemp;
}
//取得子功能信息
if(funcTemp.getUpFuncId().equals(funcId)&&
!funcTemp.getFuncId().equals(funcId)){
WfFuncInfo subFunc=getSubFuncInfo(list,funcTemp.getFuncId());
subList.add(subFunc);
}
func.setSubFuncList(subList);
}
return func;
}
/**
* 取得查询条件
* @param user LaUser
* @return StringBuffer
*/
private StringBuffer getQueryString(WfFuncInfo func){
StringBuffer sb=new StringBuffer();
if(func!=null){
if(func.getActivityId()!=null&&!func.getActivityId().equals("")){
sb.append(" activityid = '"+func.getActivityId()+"' ");
sb.append(" and ");
}
if(func.getFireFlag()!=null&&!func.getFireFlag().equals("")){
sb.append(" fireflag = '"+func.getFireFlag()+"' ");
sb.append(" and ");
}
if(func.getFuncId()!=null&&!func.getFuncId().equals("")){
sb.append(" func_id = '"+func.getFuncId()+"' ");
sb.append(" and ");
}
if(func.getFuncImage()!=null&&!func.getFuncImage().equals("")){
sb.append(" func_image = '"+func.getFuncImage()+"' ");
sb.append(" and ");
}
if(func.getFuncName()!=null&&!func.getFuncName().equals("")){
sb.append(" func_name = '"+func.getFuncName()+"' ");
sb.append(" and ");
}
if(func.getFuncOrder()!=WorkflowConstant.LONG_INIT_VALUE){
sb.append(" func_order = "+func.getFuncOrder()+" ");
sb.append(" and ");
}
if(func.getFunDesc()!=null&&!func.getFunDesc().equals("")){
sb.append(" fun_desc = '"+func.getFunDesc()+"' ");
sb.append(" and ");
}
if(func.getPageName()!=null&&!func.getPageName().equals("")){
sb.append(" page_name = '"+func.getPageName()+"' ");
sb.append(" and ");
}
if(func.getUpFuncId()!=null&&!func.getUpFuncId().equals("")){
sb.append(" up_func_id = '"+func.getUpFuncId()+"' ");
sb.append(" and ");
}
if(func.getOpenType()!=null&&!func.getOpenType().equals("")){
sb.append(" open_type = '"+func.getOpenType()+"' ");
sb.append(" and ");
}
if(func.getWindowHeight()!=WorkflowConstant.LONG_INIT_VALUE){
sb.append(" window_height = "+func.getWindowHeight()+" ");
sb.append(" and ");
}
if(func.getWindowWidth()!=WorkflowConstant.LONG_INIT_VALUE){
sb.append(" window_width = "+func.getWindowWidth()+" ");
sb.append(" and ");
}
}
if(sb.length()>0){
//增加查询条件关键字
sb.insert(0," where ");
//去除最后一个" AND "操作符
sb.delete(sb.length()-5,sb.length());
}
return sb;
}
private List resultsetToVO(ResultSet rs)
throws SQLException{
List list=new ArrayList();
while(rs.next()){
WfFuncInfo func=new WfFuncInfo();
///func.setActivityId(rs.getString("acivityid"));
func.setActivityId(rs.getString("activityid"));
func.setFireFlag(rs.getString("fireflag"));
func.setFuncId(rs.getString("func_id"));
func.setFuncImage(rs.getString("func_image"));
func.setFuncName(rs.getString("func_name"));
func.setFuncOrder(rs.getLong("func_order"));
func.setFunDesc(rs.getString("fun_desc"));
func.setPageName(rs.getString("page_name"));
func.setUpFuncId(rs.getString("up_func_id"));
func.setOpenType(rs.getString("open_type"));
func.setWindowHeight(rs.getLong("window_height"));
func.setWindowWidth(rs.getLong("window_width"));
list.add(func);
}
return list;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -