* @param queryLocation
* @return
*/
public static String getTableSelect(String tableId,QueryLocation queryLocation){
ProcessEngineConfigurationImpl processEngineConfigurationImpl = ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration();
DataBaseTable dataBaseTable = processEngineConfigurationImpl.getDataBaseTable(tableId);
if(dataBaseTable == null){
throw new FixFlowException("未找到id为"+tableId+"的table配置");
}
if(!StringUtil.getBoolean(processEngineConfigurationImpl.getPigeonholeConfig().getIsEnable())){
return dataBaseTable.getTableValue();
}
String tableName = "";
if(QueryLocation.HIS.equals(queryLocation)){
tableName = dataBaseTable.getArchiveTable();
}else if(QueryLocation.RUN_HIS.equals(queryLocation)){
StringBuilder sbColumn = new StringBuilder();
for(Column column :dataBaseTable.getColumn()){
sbColumn.append(column.getColumn());
sbColumn.append(",");
}
String columnString = sbColumn.toString().substring(0,sbColumn.toString().length()-1);
tableName = dataBaseTable.getTableValue();
String hisTableName = dataBaseTable.getArchiveTable();
tableName = "(select "+columnString+" from "+tableName+" union all select "+columnString+" from "+hisTableName+")";
}else{
tableName = dataBaseTable.getTableValue();
}
return tableName;
}