package com.kingdee.eas.custom.workflow;

import java.sql.SQLException;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.fm.common.FMIsqlFacadeFactory;
import com.kingdee.jdbc.rowset.IRowSet;

public class WorkflowFacadeControllerBean extends AbstractWorkflowFacadeControllerBean
{
    private static Logger logger =
        Logger.getLogger("com.kingdee.eas.custom.workflow.WorkflowFacadeControllerBean");
    
    /***
	 *获取公司工作流审批人员ID
	 * */
	protected Object _getWorkFlowPerson(Context ctx, String orgID,String postionNum) throws BOSException {
		Object  personID = null;
		StringBuffer sql =new StringBuffer();
		sql.append("  select en.CFPersonID  as PersonID from CT_WOR_CompanyWorkflow cw ");
		sql.append("  left join CT_WOR_CompanyWorkflowEntry en  on cw.fid =en.fparentid ");
		sql.append("  left join CT_WOR_WorkflowPostion  wp on en.CFPostionID =wp.fid  ");
		sql.append("  where   cw.CFDeparmentID='"+orgID+"' and wp.fnumber='"+postionNum+"'");
		 IRowSet rowset = null;
		try {
			rowset = FMIsqlFacadeFactory.getLocalInstance(ctx).executeQuery(sql.toString(),null);
		} catch (EASBizException e) {
			e.printStackTrace();
		}
		 if(rowset.size()>0){
			  try {
				  while (rowset.next()) {
					  personID =rowset.getObject("PersonID");
				  }
			} catch (SQLException e) {
				e.printStackTrace();
			}
		 }
		return personID;
	}
}