Selaa lähdekoodia

根据维度编码查询维度 类型

jkzlzhoujie 6 vuotta sitten
vanhempi
commit
3b19222cf1

+ 31 - 0
src/main/java/com/yihu/quota/etl/formula/FuncHelper.java

@ -0,0 +1,31 @@
package com.yihu.quota.etl.formula;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
/**
 * @author janseny
 * @date 2018/10/9
 * 函数计算转换器
 */
@Component
@Scope("prototype")
public class FuncHelper {
    public Object function(String classPackage,Object... args) throws Exception {
        Object data = null;
        String clazz = classPackage;
        if (!StringUtils.isEmpty(classPackage)) {
            //反射出对象并且调用execute方法去 计算对应的值
            Object obj = Class.forName(clazz).newInstance();
            Method method = obj.getClass().getMethod("execute", Object.class);
            data = (List<Map<String, Object>>) method.invoke(obj, args);
        }
        return data;
    }
}

+ 25 - 5
src/main/java/com/yihu/quota/service/cube/ElasticSearchDataProcessService.java

@ -8,6 +8,7 @@ import com.yihu.ehr.util.datetime.DateUtil;
import com.yihu.quota.etl.formula.AgeGroupFunc;
import com.yihu.quota.etl.formula.DictFunc;
import com.yihu.quota.etl.formula.DivisionFunc;
import com.yihu.quota.etl.formula.FuncHelper;
import com.yihu.quota.model.cube.Cube;
import com.yihu.quota.model.cube.CubeMemberMapping;
import com.yihu.quota.util.ElasticSearchHandler;
@ -170,20 +171,29 @@ public class ElasticSearchDataProcessService {
     * @param dataType
     * @param dict
     * @param algorithm
     * @param algorithmParm
     * @param algorithmParm 格式如 维度值,如果需要后端获取后代替用value,每个参数直接用逗号分隔,像第一个和第二个参数用逗号,分开,如: value,2,3
     * @return
     */
    public Map<String,Object> dimensionDataExtendToMap(String cloumnValue,String cloumnCode,String dataType ,String dict,String algorithm,String algorithmParm ){
    public Map<String,Object> dimensionDataExtendToMap(String cloumnValue,String cloumnCode,String dataType ,
                                                       String dict,String algorithm,String algorithmParm ) throws Exception {
        Map<String, Object> source  = new HashMap<>();
        //字典扩展
        if(StringUtils.isNotEmpty(dict) && StringUtils.isEmpty(algorithm)){
            source = extendDictData(source,cloumnCode,dict,cloumnValue);
        }else if(StringUtils.isNotEmpty(algorithm)){
//            //通过 反射方式进行  后续开放 暂时字典redis不通
//            FuncHelper funcHelper = new FuncHelper();
//            algorithmParm = algorithmParm.replace("value",cloumnCode);
//            Object data = funcHelper.function(algorithm, algorithmParm.split(","));
//            if(StringUtils.isNotEmpty(dict)){
//                source = extendDictData(source,cloumnCode,dict,data.toString());
//            }else{
//                source.put(cloumnCode,data);
//            }
            //年龄段
            if(algorithm.equals("AgeGroupFunc")){
            if(algorithm.contains("AgeGroupFunc")){
                source = extendAgeGroupData(source,cloumnCode,dict,cloumnValue);
            }
            //其他算法 --
        }else {
            source.put(cloumnCode,dataConver(dataType,cloumnValue));
        }
@ -214,8 +224,18 @@ public class ElasticSearchDataProcessService {
                objChildMap = extendDictData(objChildMap,cloumnCode,dict,cloumnValue);
                source.put(parentCode,objChildMap);
            }else if(StringUtils.isNotEmpty(algorithm)){
//                //通过 反射方式进行  后续开放 暂时字典redis不通
//                FuncHelper funcHelper = new FuncHelper();
//                algorithmParm = algorithmParm.replace("value",cloumnCode);
//                Object data = funcHelper.function(algorithm, algorithmParm.split(","));
//                if(StringUtils.isNotEmpty(dict)){
//                    objChildMap = extendDictData(objChildMap,cloumnCode,dict,data.toString());
//                }else{
//                    objChildMap.put(cloumnCode,data);
//                }
                //区域算法
                if(algorithm.equals("DivisionFunc") && StringUtils.isNotEmpty(algorithmParm)){
                if(algorithm.contains("DivisionFunc") && StringUtils.isNotEmpty(algorithmParm)){
                    objChildMap = extendDivisionData(objChildMap, cloumnCode, algorithmParm, cloumnValue);
                }
                source.put(parentCode,objChildMap);