package com.vci.client.workflow.user;
|
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import com.vci.client.common.objects.UserEntityObject;
|
import com.vci.client.portal.utility.TableDataUtil;
|
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
|
import com.vci.corba.workflow.data.FlowInstanceInfo;
|
|
public class VciWorkflowUserImpl implements WorkflowUserInterface {
|
|
enum UserExpression{
|
all("all", 0, "所有人"),
|
creator("creator", 1, "拟稿人"),
|
creatordept("creator.dept", 2, "拟稿人所在部门"),
|
ownerdept("owner.dept", 3, "当前处理人所在部门"),
|
allleader("allleader", 4, "所有领导"),
|
allsecretary("allsecretary", 5, "所有秘书"),
|
creatordeptleader("creator.dept.leader", 6, "拟稿人所在部门领导"),
|
ownerdeptleader("owner.dept.leader", 7, "当前处理人所在部门领导"),
|
owner("owner", 8, "当前节点处理人"),
|
onenodealluser("onenode.alluser", 9 , "某一级别的所有人"),
|
onenodemanager("onenode.manager", 10 , "某一节点处理人"),
|
chooseByForm("chooseByForm", 11 , "从业务表单中选择"),
|
ownerchilddept("owner.childdept", 12, "当前处理人的一级部门"),
|
ownercustomorg("owner.customorg", 13, "当前人的自定义组"),//暂不处理
|
custom("custom", 14, "反射类");
|
|
private String value;
|
private String explain;
|
|
private UserExpression(String value, int index, String explain){
|
this.value = value;
|
this.explain = explain;
|
}
|
}
|
|
private static VciWorkflowUserImpl instance = null;
|
|
public static VciWorkflowUserImpl getInstance() {
|
if(instance == null) {
|
instance = new VciWorkflowUserImpl();
|
}
|
return instance;
|
}
|
|
private TableDataUtil util = new TableDataUtil();
|
private String id = "";
|
private UserEntityObject userObj = null;
|
|
public List<String[]> getUserByExp(String exp, String executionId, UserEntityObject userObj) {
|
if(exp == null | exp.length() == 0 | userObj == null) {
|
return new ArrayList<String[]>();
|
}
|
this.userObj = userObj;
|
this.id = executionId;
|
for(UserExpression ue : UserExpression.values()) {
|
if(exp.equals(ue.value)) {
|
try {
|
return getUser(ue);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
return new ArrayList<String[]>();
|
}
|
|
private List<String[]> getUser(UserExpression ue) throws Exception {
|
List<Map<String, String>> list = null;
|
List<String[]> nullList = new ArrayList<String[]>();
|
Map<String, String> conditionMap = new HashMap<String, String>();
|
System.out.println(ue.explain);
|
switch(ue) {
|
case all:
|
list = queryDate("personTemplete", null, "person");
|
return turnIDList(list, "id");
|
case creator:
|
list = queryUser();
|
return turnIDList(list, "id");
|
case creatordept:
|
list = queryDept();
|
return turnIDList(list, "oid");
|
case ownerdept:
|
id = null;
|
list = queryDept();
|
return turnIDList(list, "oid");
|
case allleader:
|
conditionMap.put("islead", "1");
|
list = queryDate("personTemplete", conditionMap, "person");
|
return turnIDList(list, "id");
|
case allsecretary:
|
conditionMap.put("issecretary", "1");
|
list = queryDate("personTemplete", conditionMap, "person");
|
return turnIDList(list, "oid");
|
case creatordeptleader:
|
list = queryDeptLeader();
|
return turnIDList(list, "oid");
|
case ownerdeptleader:
|
id = null;
|
list = queryDeptLeader();
|
return turnIDList(list, "oid");
|
case owner:
|
id = null;
|
list = queryUser();
|
return turnIDList(list, "oid");
|
case onenodealluser:
|
break;
|
case onenodemanager:
|
break;
|
case chooseByForm:
|
break;
|
case ownerchilddept:
|
id = null;
|
list = queryDept();
|
if(list == null) {
|
return nullList;
|
}
|
String oid = list.get(0).get("oid");
|
conditionMap.put("parentdept", oid);
|
list = queryDate("DepartmentQueryTemplate", conditionMap, "department");
|
return turnIDList(list, "oid");
|
case ownercustomorg:
|
break;
|
case custom:
|
if(id != null && id.length() > 0) {
|
WorkflowUserInterface inter = (WorkflowUserInterface) (Class
|
.forName(id).newInstance());
|
return inter.getUserByExp(null, null, this.userObj);
|
}
|
|
break;
|
}
|
return nullList;
|
}
|
|
/**
|
* 返回长度为4的数组,第一个为id(user时)或oid(其他情况),第二个是name,其他为空
|
* @param list
|
* @param key
|
* @return
|
*/
|
private List<String[]> turnIDList(List<Map<String, String>> list, String key) {
|
List<String[]> idList = new ArrayList<String[]>();
|
if(list != null) {
|
for(Map<String, String> map : list) {
|
String[] strs = new String[4];
|
strs[0] = map.get(key);
|
strs[1] = map.get("name");
|
idList.add(strs);
|
}
|
}
|
return idList;
|
}
|
|
private List<Map<String, String>> queryDeptLeader() throws Exception{
|
List<Map<String, String>> list = queryDept();
|
if(list == null) {
|
return new ArrayList<Map<String, String>>();
|
}
|
Map<String, String> conditionMap = new HashMap<String, String>();
|
conditionMap = new HashMap<String, String>();
|
conditionMap.put("f_oid", list.get(0).get("oid"));
|
conditionMap.put("isparttime", "0");
|
list = queryDate("deptPersonTemplate", conditionMap, "deptperson");
|
List<Map<String, String>> index = new ArrayList<Map<String, String>>();
|
for(Map<String, String> map : list) {
|
if("1".equals(map.get("islead"))) {
|
index.add(map);
|
}
|
}
|
return index;
|
}
|
|
private List<Map<String, String>> queryDept() throws Exception{
|
List<Map<String, String>> list = queryUser();
|
if(list.size() != 1) {
|
return new ArrayList<Map<String, String>>();
|
}
|
String t_oid = list.get(0).get("oid");
|
Map<String, String> conditionMap = new HashMap<String, String>();
|
conditionMap.put("t_oid", t_oid);
|
conditionMap.put("isparttime", "0");
|
return queryDate("queryDeptTemplate", conditionMap, "deptperson");
|
}
|
|
private List<Map<String, String>> queryUser() throws Exception{
|
String userName = "";
|
if(id == null || id.length() == 0) {
|
userName = userObj.getUserName();
|
} else {
|
ProcessCustomClientDelegate pccd = new ProcessCustomClientDelegate(userObj);
|
FlowInstanceInfo fii = pccd.getFlowInstanceInfo(id);
|
userName = fii.creator;
|
}
|
Map<String, String> conditionMap = new HashMap<String, String>();
|
conditionMap.put("id", userName);
|
return queryDate("personTemplete", conditionMap, "person");
|
}
|
|
private List<Map<String, String>> queryDate(String qtName, Map<String, String> conditionMap, String type) {
|
List<Map<String, String>> dataModel = null;
|
Map<String, String> queryColumnsMap = new HashMap<String, String>();
|
queryColumnsMap.put("*", "标题");
|
try {
|
dataModel = util.getObjectDataList(qtName, null,
|
conditionMap , null, null, type,
|
queryColumnsMap, null, null);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
if(dataModel == null) {
|
dataModel = new ArrayList<Map<String, String>>();
|
}
|
return dataModel;
|
}
|
|
public String getAttrbuteByCondition(Map<String, String> items,
|
String attr) {
|
String str = items.get(attr) == null ? "" : items.get(attr);
|
return str;
|
}
|
|
}
|