.get("userId"));
String whereSql = " 1=1 ";
String leftJoinStr = "";
QueryExpandTo queryExpandTo = new QueryExpandTo();
try {
TaskQuery tq = engine.getTaskService().createTaskQuery();
tq.taskAssignee(StringUtil.getString(filter.get("userId")));
tq.taskCandidateUser(StringUtil.getString(filter.get("userId")));
// tq.processDefinitionKey(StringUtil.getString(filter.get("pdkey")));
String descritpion = StringUtil.getString(filter.get("title"));
if(StringUtil.isNotEmpty(descritpion))
tq.taskDescriptionLike(descritpion);
String initor = StringUtil.getString(filter.get("initor"));
if(StringUtil.isNotEmpty(initor))
tq.initiator(initor);
//发起人模糊匹配
String initorName = StringUtil.getString(filter.get("initorName"));
if (StringUtil.isNotEmpty(initorName)) {
initorName = initorName.replace("'", "");
ProcessEngine processEngine = ProcessEngineManagement
.getDefaultProcessEngine();
AllUserInfo userInfoConfig = processEngine
.getProcessEngineConfiguration().getUserDefinition()
.getUserInfoConfig();
leftJoinStr += " LEFT JOIN (" + userInfoConfig.getSqlText()
+ ") UT on UT." + userInfoConfig.getUserIdField()
+ " = P.INITIATOR ";
whereSql += " and (UT." + userInfoConfig.getUserNameField()
+ " LIKE '%" + initorName + "%' or UT."
+ userInfoConfig.getUserIdField() + " = '"
+ initorName + "')";
}
String bizKey = StringUtil.getString(filter.get("bizKey"));
if(StringUtil.isNotEmpty(bizKey))
tq.businessKeyLike(bizKey);
String processDefinitionName = StringUtil.getString(filter.get("processDefinitionName"));
if(StringUtil.isNotEmpty(processDefinitionName))
tq.processDefinitionNameLike(processDefinitionName);
Date dates = null;
Date datee = null;
String dss = StringUtil.getString(filter.get("arrivalTimeS"));
String dse = StringUtil.getString(filter.get("arrivalTimeE"));
if(StringUtil.isNotEmpty(dss)){
dates = DateUtil.stringToDate(dss,"yyyy-MM-dd");
}
if(StringUtil.isNotEmpty(dse)){
String endTime = "235959999";
dse += endTime;
datee = DateUtil.stringToDate(dse,"yyyy-MM-ddHHmmssSSS");
}
if(dates!=null)
tq.taskCreatedAfter(datee);
if(datee!=null)
tq.taskCreatedBefore(dates);
String pageI = StringUtil.getString(filter.get("pageIndex"));
String rowI = StringUtil.getString(filter.get("pageSize"));
int pageIndex=1;
int rowNum =15;
if(StringUtil.isNotEmpty(pageI)){
pageIndex = Integer.valueOf(pageI);
}
if(StringUtil.isNotEmpty(rowI)){
rowNum = Integer.valueOf(rowI);
}
if(filter.get("ended")==null)
tq.taskNotEnd();
if(StringUtil.isNotEmpty(StringUtil.getString(filter.get("agentUserId")))){
tq.isAgent(true);
if(filter.get("agentType").equals("1")){
tq.taskAssignee(StringUtil.getString(filter.get("userId")));
tq.taskCandidateUser(StringUtil.getString(filter.get("userId")));
tq.agentId(StringUtil.getString(filter.get("agentUserId")));
}else{
tq.taskAssignee(StringUtil.getString(filter.get("agentUserId")));
tq.taskCandidateUser(StringUtil.getString(filter.get("agentUserId")));
tq.agentId(StringUtil.getString(filter.get("userId")));
}
}else{
tq.taskAssignee(StringUtil.getString(filter.get("userId")));
tq.taskCandidateUser(StringUtil.getString(filter.get("userId")));
}
if (StringUtil.isNotEmpty(leftJoinStr)) {
queryExpandTo.setLeftJoinSql(leftJoinStr);
}
queryExpandTo.setWhereSql(whereSql);
tq.queryExpandTo(queryExpandTo);
List<TaskInstance> lts = tq.orderByTaskCreateTime().desc().listPagination(pageIndex, rowNum);
Long count = tq.count();
List<Map<String,Object>> instanceMaps = new ArrayList<Map<String,Object>>();