package com.vci.server.workflow.server.ExImp; import java.sql.SQLException; import java.util.List; import org.hibernate.SQLQuery; import com.vci.common.log.ServerWithLog4j; import com.vci.server.base.persistence.dao.HibernateSessionFactory; import com.vci.server.workflow.common.resouce.WorkflowProperties; import com.vci.server.workflow.server.interfaces.IWorkflowUserService; public class ExAssginImp { private String processInstansId; private String taskName; private static String userServiceImplClass = WorkflowProperties.getStringProperty("workflow.userService"); private static IWorkflowUserService puService; public ExAssginImp() { } public ExAssginImp(String processInstansId, String taskName) { this.processInstansId = processInstansId; this.taskName = taskName; } /** * @author ld 2013-7-19 通过流程模板、流程数据ID、流程任务名称,获取该流程任务的用户。 * @param deploymentId * @param dataIds * @param taskName * @return * @throws Exception */ public String[] userList(String processInstansId, String taskName) throws Exception { ServerWithLog4j.logger.debug("用户和任务关系类=================="); String sql = "select a.username from JBPM4_TASKANDUSERCONFIGEX a where a.PROCESSINSTANSID = ? and a.taskname = ?"; String userName = ""; String[] res = null; try { HibernateSessionFactory.getSession().flush(); SQLQuery sqlquery = HibernateSessionFactory.getSession().createSQLQuery(sql); sqlquery.setString(0, processInstansId); sqlquery.setString(1, taskName); List list = sqlquery.list(); if (list.size() > 0) { userName = String.valueOf(list.get(list.size() - 1)); } if (userName != null) { String[] users = userName.split(","); // 如果配置了用户选择插件,则执行以下操作 if (userServiceImplClass != null && !"".equals(userServiceImplClass)) { res = getIworkFlowUserServiceInstance().getAllUsers2Task(users, ""); } } } catch (SQLException e) { e.printStackTrace(); ServerWithLog4j.logger.error(e); } return res == null ? new String[] {} : res; } private static IWorkflowUserService getIworkFlowUserServiceInstance() throws InstantiationException, IllegalAccessException, ClassNotFoundException { if (puService == null) { puService = (IWorkflowUserService) (Class.forName(userServiceImplClass).newInstance()); } return puService; } }