哈哈哈哈哈啊
							parent
							
								
									e051922d51
								
							
						
					
					
						commit
						d582384b44
					
				| 
						 | 
					@ -41,6 +41,7 @@ import java.text.DateFormat;
 | 
				
			||||||
import java.text.SimpleDateFormat;
 | 
					import java.text.SimpleDateFormat;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.Collection;
 | 
					import java.util.Collection;
 | 
				
			||||||
 | 
					import java.util.Collections;
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
import java.util.HashSet;
 | 
					import java.util.HashSet;
 | 
				
			||||||
import java.util.Iterator;
 | 
					import java.util.Iterator;
 | 
				
			||||||
| 
						 | 
					@ -53,6 +54,8 @@ import net.mlw.vlh.ValueList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.apache.commons.lang.StringUtils;
 | 
					import org.apache.commons.lang.StringUtils;
 | 
				
			||||||
import org.apache.log4j.Logger;
 | 
					import org.apache.log4j.Logger;
 | 
				
			||||||
 | 
					import org.hibernate.engine.SessionFactoryImplementor;
 | 
				
			||||||
 | 
					import org.hibernate.hql.ast.QueryTranslatorImpl;
 | 
				
			||||||
import org.springframework.beans.BeansException;
 | 
					import org.springframework.beans.BeansException;
 | 
				
			||||||
import org.springframework.context.ApplicationContext;
 | 
					import org.springframework.context.ApplicationContext;
 | 
				
			||||||
import org.springframework.context.ApplicationContextAware;
 | 
					import org.springframework.context.ApplicationContextAware;
 | 
				
			||||||
| 
						 | 
					@ -134,6 +137,7 @@ public class QueryAction extends AbstractAction implements ApplicationContextAwa
 | 
				
			||||||
            return StringUtils.isEmpty(value) ? "-" : value;
 | 
					            return StringUtils.isEmpty(value) ? "-" : value;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private String convertGlobalParamToHql(String hql, Map params) {
 | 
					    private String convertGlobalParamToHql(String hql, Map params) {
 | 
				
			||||||
    	//log.info("开始查询: " + hql);
 | 
					    	//log.info("开始查询: " + hql);
 | 
				
			||||||
| 
						 | 
					@ -290,11 +294,10 @@ public class QueryAction extends AbstractAction implements ApplicationContextAwa
 | 
				
			||||||
        Assert.notNull(hql, String.valueOf(tableConfig.getPageId()) + "'s hql is null!");
 | 
					        Assert.notNull(hql, String.valueOf(tableConfig.getPageId()) + "'s hql is null!");
 | 
				
			||||||
        String hql2 = removeHqlWithNullParam(convertGlobalParamToHql(appendHql(hql, params), params), params);
 | 
					        String hql2 = removeHqlWithNullParam(convertGlobalParamToHql(appendHql(hql, params), params), params);
 | 
				
			||||||
        TableConfig result = null;
 | 
					        TableConfig result = null;
 | 
				
			||||||
        if (this.logger.isDebugEnabled()) {
 | 
					
 | 
				
			||||||
            this.logger.debug("buildGrid with hql[" + hql2 + "] and params[" + params + "]");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
     
 | 
					 | 
				
			||||||
        String hql3 = formateHql(hql2);
 | 
					        String hql3 = formateHql(hql2);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
        if (tableConfig.getDataSourceType().equals(DataSource.HQL_TYPE)) {
 | 
					        if (tableConfig.getDataSourceType().equals(DataSource.HQL_TYPE)) {
 | 
				
			||||||
            int index = containOrderBy(hql3);
 | 
					            int index = containOrderBy(hql3);
 | 
				
			||||||
            if (index == -1) {
 | 
					            if (index == -1) {
 | 
				
			||||||
| 
						 | 
					@ -305,6 +308,9 @@ public class QueryAction extends AbstractAction implements ApplicationContextAwa
 | 
				
			||||||
            result = buildHqlGrid(tableConfig, hql3, params);
 | 
					            result = buildHqlGrid(tableConfig, hql3, params);
 | 
				
			||||||
        } else if (tableConfig.getDataSourceType().equals(DataSource.JAVA_TYPE)) {
 | 
					        } else if (tableConfig.getDataSourceType().equals(DataSource.JAVA_TYPE)) {
 | 
				
			||||||
            result = buildJavaGrid(tableConfig, hql3, params);
 | 
					            result = buildJavaGrid(tableConfig, hql3, params);
 | 
				
			||||||
 | 
					        }else{
 | 
				
			||||||
 | 
					        	   result = buildSqlGrid(tableConfig, hql3, params);
 | 
				
			||||||
 | 
					        	
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        params.clear();
 | 
					        params.clear();
 | 
				
			||||||
        return result;
 | 
					        return result;
 | 
				
			||||||
| 
						 | 
					@ -387,6 +393,25 @@ public class QueryAction extends AbstractAction implements ApplicationContextAwa
 | 
				
			||||||
        tableConfig.setTableRows(list);
 | 
					        tableConfig.setTableRows(list);
 | 
				
			||||||
        return tableConfig;
 | 
					        return tableConfig;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    protected TableConfig buildSqlGrid(TableConfig tableConfig, String hql, Map params) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            ValueList valueList = this.valueListQueryManager.queryBySqlValueList(hql, params);
 | 
				
			||||||
 | 
					            Assert.notNull(valueList, "valueList is null by hql [" + hql + "]");
 | 
				
			||||||
 | 
					            if (valueList == null) {
 | 
				
			||||||
 | 
					                throw new EnergyServerRuntimeException("Cann't query datas from DataBase! ");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            initGridInfo(tableConfig, valueList);
 | 
				
			||||||
 | 
					            return tableConfig;
 | 
				
			||||||
 | 
					        } catch (Exception e) {
 | 
				
			||||||
 | 
					            if (this.logger.isErrorEnabled()) {
 | 
				
			||||||
 | 
					                this.logger.error(e);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            String mess = LocalizedMessage.getLocalizedMessage("build.exception.message", this.referenceModel, this.localeName);
 | 
				
			||||||
 | 
					            throw new BaseException(mess);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected TableConfig buildHqlGrid(TableConfig tableConfig, String hql, Map params) {
 | 
					    protected TableConfig buildHqlGrid(TableConfig tableConfig, String hql, Map params) {
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,18 @@
 | 
				
			||||||
 | 
					package com.dev.energy.server.service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					import net.mlw.vlh.ValueList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* loaded from: high-server-1.1.3.jar:com/dev/energy/server/service/ValueListQueryManager.class */
 | 
				
			||||||
 | 
					public interface ValueListQueryManager {
 | 
				
			||||||
 | 
					    ValueList queryByValueList(String str, Map map);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ValueList queryValueList(String str, Map map);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    ValueList queryBySqlValueList(String str, Map map);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    ValueList scrollableQuery(String str, Map map, Map map2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List query(String str, Map map);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,64 @@
 | 
				
			||||||
 | 
					package com.dev.energy.server.service.pojo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.dev.energy.server.dao.CommonDao;
 | 
				
			||||||
 | 
					import com.dev.energy.server.service.ValueListQueryManager;
 | 
				
			||||||
 | 
					import com.dev.energy.server.valuelist.adapter.hib3.ValueListAdapter;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					import net.mlw.vlh.ValueList;
 | 
				
			||||||
 | 
					import net.mlw.vlh.ValueListInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* loaded from: high-server-1.1.3.jar:com/dev/energy/server/service/pojo/DefaultValueListQueryManager.class */
 | 
				
			||||||
 | 
					public class DefaultValueListQueryManager implements ValueListQueryManager {
 | 
				
			||||||
 | 
					    protected CommonDao commonDao;
 | 
				
			||||||
 | 
					    protected ValueListAdapter valueListAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public DefaultValueListQueryManager(CommonDao commonDao, ValueListAdapter valueListAdapter) {
 | 
				
			||||||
 | 
					        this.commonDao = commonDao;
 | 
				
			||||||
 | 
					        this.valueListAdapter = valueListAdapter;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override // com.dev.energy.server.service.ValueListQueryManager
 | 
				
			||||||
 | 
					    public ValueList queryByValueList(String hql, Map pageParams) {
 | 
				
			||||||
 | 
					        ValueListInfo info = new ValueListInfo(pageParams);
 | 
				
			||||||
 | 
					        return this.valueListAdapter.getValueList(hql, info);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override // com.dev.energy.server.service.ValueListQueryManager
 | 
				
			||||||
 | 
					    public ValueList scrollableQuery(String hql, Map params, Map queryParams) {
 | 
				
			||||||
 | 
					        ValueListInfo info = new ValueListInfo(params);
 | 
				
			||||||
 | 
					        return this.valueListAdapter.scrollableQuery(hql, info, queryParams);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override // com.dev.energy.server.service.ValueListQueryManager
 | 
				
			||||||
 | 
					    public List query(String hql, Map params) {
 | 
				
			||||||
 | 
					        String[] parameters = new String[params.size()];
 | 
				
			||||||
 | 
					        Object[] values = new Object[params.size()];
 | 
				
			||||||
 | 
					        int index = 0;
 | 
				
			||||||
 | 
					        for (Object obj : params.entrySet()) {
 | 
				
			||||||
 | 
					            Map.Entry entry = (Map.Entry) obj;
 | 
				
			||||||
 | 
					            parameters[index] = (String) entry.getKey();
 | 
				
			||||||
 | 
					            values[index] = entry.getValue();
 | 
				
			||||||
 | 
					            index++;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return this.commonDao.findByQuery(hql, parameters, values);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override // com.dev.energy.server.service.ValueListQueryManager
 | 
				
			||||||
 | 
					    public ValueList queryValueList(String hql, Map pageParams) {
 | 
				
			||||||
 | 
					        ValueListInfo info = new ValueListInfo(pageParams);
 | 
				
			||||||
 | 
					        return this.valueListAdapter.getValueListNoCount(hql, info);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override // com.dev.energy.server.service.ValueListQueryManager
 | 
				
			||||||
 | 
					    public ValueList queryBySqlValueList(String hql, Map pageParams) {
 | 
				
			||||||
 | 
					        ValueListInfo info = new ValueListInfo(pageParams);
 | 
				
			||||||
 | 
					        return this.valueListAdapter.getValueListBySQL(hql, info);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
					@ -0,0 +1,30 @@
 | 
				
			||||||
 | 
					package com.dev.energy.server.valuelist.adapter.hib3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import net.mlw.vlh.ValueList;
 | 
				
			||||||
 | 
					import net.mlw.vlh.ValueListInfo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * @author  dev
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public interface ValueListAdapter
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					   /** The name that should be used to bind this service to
 | 
				
			||||||
 | 
					    * a JNDI tree or the like **/
 | 
				
			||||||
 | 
					   static String DEFAULT_SERVICE_NAME = "valueListHandler";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   /** Gets a ValueList with the given name.
 | 
				
			||||||
 | 
					    * 
 | 
				
			||||||
 | 
					    * @param valuelistHql The hql statment clause
 | 
				
			||||||
 | 
					    * @param info The <CODE>ValueListInfo</CODE> information.
 | 
				
			||||||
 | 
					    * @return The <CODE>ValueList</CODE>.
 | 
				
			||||||
 | 
					    */
 | 
				
			||||||
 | 
					   ValueList getValueListNoCount(String hql , ValueListInfo info);
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					   ValueList getValueList(String valuelistHql, ValueListInfo info);
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					   ValueList getValueListBySQL(String valuelistHql, ValueListInfo info);
 | 
				
			||||||
 | 
					   
 | 
				
			||||||
 | 
					   ValueList scrollableQuery(String hql, ValueListInfo info, Map queryParams);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue