优化代码位于/BIZ/SA/task/logic/code/dsrc/TaskUtils.java的getExecutorCondition
本次优化将like换成了=,充分利用SA_TASK_SEXECUTORFID索引提升待办任务的查询效率
后面如果使用过程中再次出现性能下降,只要检查一下SA_TASK_SEXECUTORFID的索引碎片,优化一下就会好了
5.2.7版本中修改如下:
public static String getExecutorCondition(String alias, Collection<PersonMember> pms, boolean useAgentProcess){ /* String result = ""; List<String> items = new ArrayList<String>(); for (PersonMember pm : pms){ String item = "'" + pm.getFID() + "' like concat(" + alias + ".sExecutorFID, '%')"; if (useAgentProcess){ String agentProcess = pm.getAgentProcess(); if (Utils.isNotEmptyString(agentProcess)){ String agentProcessCondition = getAgentProcessCondition(alias, agentProcess); item = appendCondition(item, "and", agentProcessCondition); } } items.add(item); } if (items.isEmpty()){ result = "1<>1"; }else{ for (String item : items){ if (result.equals("")){ result = item; }else{ result = result + " or " + item; } } result = appendCondition(result, "and", alias + ".sExecutorFID like '/%'"); } return result; */ String result = ""; for (PersonMember pm : pms) { com.justep.system.opm.OrgNode org = pm; String psmFilter = ""; while (org != null) { if (psmFilter.length() > 0) { psmFilter = psmFilter + " OR "; } psmFilter = psmFilter + "(" + alias + ".sExecutorFID = '" + org.getFID() + "')"; org = org.getParent(); } if (useAgentProcess){ String agentProcess = pm.getAgentProcess(); if (Utils.isNotEmptyString(agentProcess)){ String agentProcessCondition = getAgentProcessCondition(alias, agentProcess); psmFilter = "(" + psmFilter + ") AND (" + agentProcessCondition + ")"; } } if (result.length() > 0) { result = result + " OR "; } result = result + "(" + psmFilter + ")"; } if (result.length() == 0) { result = "1=1"; } result = "(" + result + ")"; }
5.3.8版本(5.3版本中都是通用的)中修改如下:
public static String getExecutorCondition(String alias, Collection<PersonMember> pms, boolean useAgentProcess, Map<String, Object> vars){ /* if (taskExecutorOnlyPerson()){ return getExecutorConditionWithPerson(alias, pms, useAgentProcess, vars); } String result = ""; List<String> items = new ArrayList<String>(); int i = 0; for (PersonMember pm : pms){ String var = "_efid" + i++; vars.put(var, pm.getFID()); String item = ":" + var + " like concat(" + alias + ".sExecutorFID, '%')"; if (useAgentProcess){ String agentProcess = pm.getAgentProcess(); if (Utils.isNotEmptyString(agentProcess)){ String agentProcessCondition = getAgentProcessCondition(alias, agentProcess, vars); item += " and " + agentProcessCondition; } } items.add(item); } if (items.isEmpty()){ result = "1<>1"; }else{ for (String item : items){ if (result.equals("")){ result = item; }else{ result = result + " or " + item; } } result = "(" + result + ") and " + alias + ".sExecutorFID like '/%' "; } return result; */ if (taskExecutorOnlyPerson()){ return getExecutorConditionWithPerson(alias, pms, useAgentProcess, vars); } String result = ""; for (PersonMember pm : pms) { com.justep.system.opm.OrgNode org = pm; String psmFilter = ""; while (org != null) { if (psmFilter.length() > 0) { psmFilter = psmFilter + " OR "; } psmFilter = psmFilter + "(" + alias + ".sExecutorFID = '" + org.getFID() + "')"; org = org.getParent(); } if (useAgentProcess){ String agentProcess = pm.getAgentProcess(); if (Utils.isNotEmptyString(agentProcess)){ String agentProcessCondition = getAgentProcessCondition(alias, agentProcess, vars); psmFilter = "(" + psmFilter + ") AND (" + agentProcessCondition + ")"; } } if (result.length() > 0) { result = result + " OR "; } result = result + "(" + psmFilter + ")"; } if (result.length() == 0) { result = "1=1"; } result = "(" + result + ")"; return result; }
评一波