Browse Source

Merge branch 'dev-1.13.0' of http://192.168.1.220:10080/EHR/svr-quota into dev-1.13.0

zhangjinjun 6 years ago
parent
commit
c39936b551

+ 10 - 3
src/main/java/com/yihu/quota/controller/CubeController.java

@ -81,12 +81,19 @@ public class CubeController  extends BaseController {
                rowKeyFieldInfo.setField("rowkey");
                rowKeyFieldInfo.setField("rowkey");
                rowKeyFieldInfo.setDataType("String");
                rowKeyFieldInfo.setDataType("String");
                fieldInfoList.add(rowKeyFieldInfo);
                fieldInfoList.add(rowKeyFieldInfo);
                //extra_total 默认添加字段用于统计聚合使用
                FieldInfo totalFieldInfo =  new FieldInfo();
                totalFieldInfo.setField("extra_total");
                totalFieldInfo.setDataType("String");
                fieldInfoList.add(totalFieldInfo);
                for(CubeMappingModel cubeMappingModel : cubeMappingModels){
                for(CubeMappingModel cubeMappingModel : cubeMappingModels){
                    String fieldCode = cubeMappingModel.getDimensionCode();
                    String fieldCode = cubeMappingModel.getDimensionCode();
                    //数据字典名称作为一个属性 扩展
                    //数据字典名称作为一个属性 扩展
                    if(StringUtils.isNotEmpty(cubeMappingModel.getDict())){
                    if(StringUtils.isNotEmpty(cubeMappingModel.getDict())){
                        FieldInfo dictFieldName =  new FieldInfo();
                        FieldInfo dictFieldName =  new FieldInfo();
                        dictFieldName.setField(fieldCode + "Name");
                        dictFieldName.setField(fieldCode + "_name");
                        dictFieldName.setDataType("String");
                        dictFieldName.setDataType("String");
                        fieldInfoList.add(dictFieldName);
                        fieldInfoList.add(dictFieldName);
                    }
                    }
@ -113,7 +120,7 @@ public class CubeController  extends BaseController {
                            //数据字典名称作为一个子属性 扩展
                            //数据字典名称作为一个子属性 扩展
                            if(StringUtils.isNotEmpty(cubeMemberMappingModel.getDict())){
                            if(StringUtils.isNotEmpty(cubeMemberMappingModel.getDict())){
                                FieldInfo dictFieldName =  new FieldInfo();
                                FieldInfo dictFieldName =  new FieldInfo();
                                dictFieldName.setField(fieldCode + "Name");
                                dictFieldName.setField(fieldCode + "_name");
                                dictFieldName.setDataType("String");
                                dictFieldName.setDataType("String");
                                childFieldiList.add(dictFieldName);
                                childFieldiList.add(dictFieldName);
                            }
                            }
@ -125,7 +132,7 @@ public class CubeController  extends BaseController {
                    fieldInfoList.add(fieldInfo);
                    fieldInfoList.add(fieldInfo);
                }
                }
                FieldInfo updateDateFieldInfo =  new FieldInfo();
                FieldInfo updateDateFieldInfo =  new FieldInfo();
                updateDateFieldInfo.setField("updateDate");
                updateDateFieldInfo.setField("update_date");
                updateDateFieldInfo.setDataType("Date");
                updateDateFieldInfo.setDataType("Date");
                fieldInfoList.add(updateDateFieldInfo);
                fieldInfoList.add(updateDateFieldInfo);
                esHandler.createIndexAndCreateMapping(index, type, fieldInfoList, esHandler.getTransportClient());
                esHandler.createIndexAndCreateMapping(index, type, fieldInfoList, esHandler.getTransportClient());

+ 35 - 7
src/main/java/com/yihu/quota/controller/ViewController.java

@ -1,6 +1,7 @@
package com.yihu.quota.controller;
package com.yihu.quota.controller;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.core.type.TypeReference;
import com.github.abel533.echarts.Option;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
@ -11,13 +12,22 @@ import com.yihu.quota.service.cube.CubeService;
import com.yihu.quota.service.view.ViewDimensionService;
import com.yihu.quota.service.view.ViewDimensionService;
import com.yihu.quota.service.view.ViewQuotaService;
import com.yihu.quota.service.view.ViewQuotaService;
import com.yihu.quota.service.view.ViewService;
import com.yihu.quota.service.view.ViewService;
import com.yihu.quota.util.AggregationBuildHandler;
import com.yihu.quota.util.ElasticSearchHandler;
import com.yihu.quota.util.ElasticSearchHandler;
import com.yihu.quota.util.ReportOption;
import com.yihu.quota.vo.ViewQuotaFilterModel;
import com.yihu.quota.vo.ViewQuotaFilterModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
import org.elasticsearch.search.aggregations.Aggregation;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMethod;
@ -25,7 +35,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.List;
import java.util.Map;
/**
/**
 * @author janseny
 * @author janseny
@ -41,11 +53,8 @@ public class ViewController extends EnvelopRestEndPoint {
    @Autowired
    @Autowired
    private CubeService cubeService;
    private CubeService cubeService;
    @Autowired
    @Autowired
    private ViewDimensionService viewDimensionService;
    @Autowired
    private ViewQuotaService viewQuotaService;
    @Autowired
    private ElasticSearchHandler elasticSearchHandler;
    private AggregationBuildHandler aggregationBuildHandler;
    @ApiOperation(value = "添加视图")
    @ApiOperation(value = "添加视图")
    @RequestMapping(value = ServiceApi.StatisticView.View.Add, method = RequestMethod.GET)
    @RequestMapping(value = ServiceApi.StatisticView.View.Add, method = RequestMethod.GET)
@ -112,10 +121,29 @@ public class ViewController extends EnvelopRestEndPoint {
                filterModelList = objectMapper.readValue(filters, new TypeReference<List<ViewQuotaFilterModel>>() {
                filterModelList = objectMapper.readValue(filters, new TypeReference<List<ViewQuotaFilterModel>>() {
                });
                });
            }
            }
            View view = viewService.findByCode(viewCode);
            if(view == null){
                logger.debug("视图不存在");
                return null;
            }
            Aggregations aggregations = viewService.statViewResult(viewCode, filterModelList);
            Aggregations aggregations = viewService.statViewResult(viewCode, filterModelList);
            if(view.getDisplayType().equals("1")){
                //数值型
                Map<String, Object> resultMap = aggregationBuildHandler.numericalDataParsing(view, aggregations.getAsMap());
                envelop.setObj(resultMap);
            }else if(view.getDisplayType().equals("2")){
                //普通表格
                List<Map<String, Object>> resultList = aggregationBuildHandler.tableDataParsing(view, aggregations.getAsMap());
                envelop.setObj(resultList);
            }else if(view.getDisplayType().equals("3")){
                //树形表格
            // TODO 将统计结果转换成展示的数据格式
            }else {
                //图表
                Option option = aggregationBuildHandler.ehartDataParsing(view, aggregations.getAsMap());
                String echartJson = option.toString();
                envelop.setObj(echartJson);
            }
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            envelop.setSuccessFlg(false);
            envelop.setSuccessFlg(false);

+ 3 - 2
src/main/java/com/yihu/quota/service/cube/ElasticSearchDataProcessService.java

@ -315,7 +315,7 @@ public class ElasticSearchDataProcessService {
//      value = dictFunc.execute(param);
//      value = dictFunc.execute(param);
        value =  cloumnCode + "测试值";
        value =  cloumnCode + "测试值";
        source.put(cloumnCode,code);
        source.put(cloumnCode,code);
        source.put(cloumnCode + "Name",value);
        source.put(cloumnCode + "_name",value);
        return source;
        return source;
    }
    }
@ -356,7 +356,7 @@ public class ElasticSearchDataProcessService {
        String divisionVal = "";
        String divisionVal = "";
        if(cloumnCode.toLowerCase().equals("town")){
        if(cloumnCode.toLowerCase().equals("town")){
            level = "1";
            level = "1";
            divisionVal = "鄱阳县";
            divisionVal = "婺源县";
        }else if(cloumnCode.toLowerCase().equals("city")){
        }else if(cloumnCode.toLowerCase().equals("city")){
            level = "2";
            level = "2";
            divisionVal = "上饶市";
            divisionVal = "上饶市";
@ -384,6 +384,7 @@ public class ElasticSearchDataProcessService {
        if(data != null){
        if(data != null){
            elasticSearchUtil.update(index, type,rowKey,source);
            elasticSearchUtil.update(index, type,rowKey,source);
        }else {
        }else {
            source.put("extra_total","1");
            elasticSearchUtil.index(index, type,source);
            elasticSearchUtil.index(index, type,source);
        }
        }
    }
    }

+ 4 - 0
src/main/java/com/yihu/quota/service/view/ViewService.java

@ -86,6 +86,10 @@ public class ViewService extends BaseJpaService<View, ViewDao> {
        return viewDao.findOne(id);
        return viewDao.findOne(id);
    }
    }
    public View findByCode(String viewCode){
        return viewDao.findByCode(viewCode);
    }
    /**
    /**
     * 获取视图完整规则
     * 获取视图完整规则
     *
     *

+ 98 - 128
src/main/java/com/yihu/quota/util/AggregationBuildHandler.java

@ -53,94 +53,94 @@ public class AggregationBuildHandler {
    @Autowired
    @Autowired
    private CubeService cubeService;
    private CubeService cubeService;
    /**
     * 简单聚合
     * @param aggType 聚合类型
     * @param aggName 聚合名称
     * @param fieldName 聚合字段
     * @return
     */
    public AbstractAggregationBuilder addAggregationBuilder(String aggType,String aggName, String fieldName){
        AbstractAggregationBuilder builder = null;
        if(aggType.equals("sum")){
            builder = AggregationBuilders.sum(aggName).field(fieldName);
        }else if(aggType.equals("count")){
            builder = AggregationBuilders.count(aggName).field(fieldName);
        }else if(aggType.equals("avg")){
            builder = AggregationBuilders.avg(aggName).field(fieldName);
        }else if(aggType.equals("max")){
            builder = AggregationBuilders.max(aggName).field(fieldName);
        }else if(aggType.equals("min")){
            builder = AggregationBuilders.min(aggName).field(fieldName);
        }
        return  builder;
    }
    /**
     * 分组后,简单聚合
     * @param aggType 聚合类型
     * @param aggName 聚合名称
     * @param fieldName 聚合字段
     * @return
     */
    public AbstractAggregationBuilder addTermAggregationBuilder(String termName, String termFieldName,String aggType,String aggName, String fieldName){
        AbstractAggregationBuilder builder = null;
        TermsBuilder termsBuilder = addTermsBuilder(termName,termFieldName);
        if(aggType.equals("sum")){
            builder = termsBuilder.subAggregation(AggregationBuilders.sum(aggName).field(fieldName));
        }else if(aggType.equals("count")){
            builder = termsBuilder.subAggregation(AggregationBuilders.count(aggName).field(fieldName));
        }else if(aggType.equals("avg")){
            builder = termsBuilder.subAggregation(AggregationBuilders.avg(aggName).field(fieldName));
        }else if(aggType.equals("max")){
            builder = termsBuilder.subAggregation(AggregationBuilders.max(aggName).field(fieldName));
        }else if(aggType.equals("min")){
            builder = termsBuilder.subAggregation(AggregationBuilders.min(aggName).field(fieldName));
        }
        return  builder;
    }
    /**
     * 添加分组
     * @param termName
     * @param fieldName
     * @return
     */
    public TermsBuilder addTermsBuilder(String termName, String fieldName){
        TermsBuilder termBuilder = AggregationBuilders.terms(termName).field(fieldName);
        return termBuilder;
    }
    /**
     *
     * @param client
     * @param boolQueryBuilder  查询的过滤条件
     * @param aggBuilderList  聚合组
     *  聚合组中成员是 单个的聚合查询,其中单个的聚合查询可以嵌套子聚合查询 如:
     *  单个聚合 查询 :TermsBuilder firstAgg= AggregationBuilders.terms("player_count ").field("team");
     *  带有子聚合的聚合查询 :
     *    TermsBuilder secondAgg= AggregationBuilders.terms("pos_count").field("position")
     *      .subAggregation(
     *          AggregationBuilders.dateHistogram("by_year").field("dateOfBirth").interval((DateHistogramInterval.YEAR))
     *              .subAggregation(
     *                  AggregationBuilders.avg("avg_children").field("children")
     *              )
     *          );
     * @return 聚合结果集
     */
    public Map<String, Aggregation> structAggregationQuery(TransportClient client,String index,String type,
                                                            BoolQueryBuilder boolQueryBuilder,
                                                            LinkedList<AbstractAggregationBuilder> aggBuilderList){
        SearchRequestBuilder searchRequestBuilder = client.prepareSearch(index).setTypes(type).setQuery(boolQueryBuilder);
        for(AbstractAggregationBuilder aggBuilder : aggBuilderList){
            searchRequestBuilder.addAggregation(aggBuilder);
        }
        SearchResponse response = searchRequestBuilder.execute().actionGet();
        Map<String, Aggregation> map = response.getAggregations().getAsMap();
        client.close();
        return map;
    }
//    /**
//     * 简单聚合
//     * @param aggType 聚合类型
//     * @param aggName 聚合名称
//     * @param fieldName 聚合字段
//     * @return
//     */
//    public AbstractAggregationBuilder addAggregationBuilder(String aggType,String aggName, String fieldName){
//        AbstractAggregationBuilder builder = null;
//        if(aggType.equals("sum")){
//            builder = AggregationBuilders.sum(aggName).field(fieldName);
//        }else if(aggType.equals("count")){
//            builder = AggregationBuilders.count(aggName).field(fieldName);
//        }else if(aggType.equals("avg")){
//            builder = AggregationBuilders.avg(aggName).field(fieldName);
//        }else if(aggType.equals("max")){
//            builder = AggregationBuilders.max(aggName).field(fieldName);
//        }else if(aggType.equals("min")){
//            builder = AggregationBuilders.min(aggName).field(fieldName);
//        }
//        return  builder;
//    }
//    /**
//     * 分组后,简单聚合
//     * @param aggType 聚合类型
//     * @param aggName 聚合名称
//     * @param fieldName 聚合字段
//     * @return
//     */
//    public AbstractAggregationBuilder addTermAggregationBuilder(String termName, String termFieldName,String aggType,String aggName, String fieldName){
//        AbstractAggregationBuilder builder = null;
//        TermsBuilder termsBuilder = addTermsBuilder(termName,termFieldName);
//        if(aggType.equals("sum")){
//            builder = termsBuilder.subAggregation(AggregationBuilders.sum(aggName).field(fieldName));
//        }else if(aggType.equals("count")){
//            builder = termsBuilder.subAggregation(AggregationBuilders.count(aggName).field(fieldName));
//        }else if(aggType.equals("avg")){
//            builder = termsBuilder.subAggregation(AggregationBuilders.avg(aggName).field(fieldName));
//        }else if(aggType.equals("max")){
//            builder = termsBuilder.subAggregation(AggregationBuilders.max(aggName).field(fieldName));
//        }else if(aggType.equals("min")){
//            builder = termsBuilder.subAggregation(AggregationBuilders.min(aggName).field(fieldName));
//        }
//        return  builder;
//    }
//    /**
//     * 添加分组
//     * @param termName
//     * @param fieldName
//     * @return
//     */
//    public TermsBuilder addTermsBuilder(String termName, String fieldName){
//        TermsBuilder termBuilder = AggregationBuilders.terms(termName).field(fieldName);
//        return termBuilder;
//    }
//    /**
//     *
//     * @param client
//     * @param boolQueryBuilder  查询的过滤条件
//     * @param aggBuilderList  聚合组
//     *  聚合组中成员是 单个的聚合查询,其中单个的聚合查询可以嵌套子聚合查询 如:
//     *  单个聚合 查询 :TermsBuilder firstAgg= AggregationBuilders.terms("player_count ").field("team");
//     *  带有子聚合的聚合查询 :
//     *    TermsBuilder secondAgg= AggregationBuilders.terms("pos_count").field("position")
//     *      .subAggregation(
//     *          AggregationBuilders.dateHistogram("by_year").field("dateOfBirth").interval((DateHistogramInterval.YEAR))
//     *              .subAggregation(
//     *                  AggregationBuilders.avg("avg_children").field("children")
//     *              )
//     *          );
//     * @return 聚合结果集
//     */
//    public Map<String, Aggregation> structAggregationQuery(TransportClient client,String index,String type,
//                                                            BoolQueryBuilder boolQueryBuilder,
//                                                            LinkedList<AbstractAggregationBuilder> aggBuilderList){
//        SearchRequestBuilder searchRequestBuilder = client.prepareSearch(index).setTypes(type).setQuery(boolQueryBuilder);
//        for(AbstractAggregationBuilder aggBuilder : aggBuilderList){
//            searchRequestBuilder.addAggregation(aggBuilder);
//        }
//        SearchResponse response = searchRequestBuilder.execute().actionGet();
//        Map<String, Aggregation> map = response.getAggregations().getAsMap();
//        client.close();
//        return map;
//    }
    /**
    /**
     * 表格型 - 数据结果解析
     * 表格型 - 数据结果解析
@ -148,24 +148,10 @@ public class AggregationBuildHandler {
     * @param map 聚合查询结果
     * @param map 聚合查询结果
     * @return
     * @return
     */
     */
    public List<Map<String, Object>> tableDataParsing(String viewCode ,Map<String, Aggregation> map){
//        List<String> rowList = new LinkedList<>();
//        rowList.add("town_terms");
//        rowList.add("total");
//        List<String> cloumnList = new ArrayList<>();
//        cloumnList.add("total_count_result");
//        cloumnList.add("sex_terms");
        View view = viewDao.findByCode(viewCode);
        if(view == null){
            logger.debug("视图不存在");
            return null;
        }
    public List<Map<String, Object>> tableDataParsing(View view,Map<String, Aggregation> map){
        List<String> rowList = getRowDimensionList(view.getId());
        List<String> rowList = getRowDimensionList(view.getId());
        List<String> cloumnList = getColumnDimensionList(view.getId());
        List<String> cloumnList = getColumnDimensionList(view.getId());
        List<ViewQuota> viewQuotas = viewQuotaDao.findByViewId(view.getId());
        List<ViewQuota> viewQuotas = viewQuotaDao.findByViewId(view.getId());
//        List<ViewQuotaFilter> viewFilters = viewQuotaFilterDao.findByRelationId(view.getId());
        Map<String, Object> quotaMap = new HashMap<>();
        Map<String, Object> quotaMap = new HashMap<>();
        for(ViewQuota viewQuota :viewQuotas){
        for(ViewQuota viewQuota :viewQuotas){
            List<ViewQuotaFilter> viewQuotaFilters = viewQuotaFilterDao.findByRelationId(viewQuota.getId());
            List<ViewQuotaFilter> viewQuotaFilters = viewQuotaFilterDao.findByRelationId(viewQuota.getId());
@ -254,13 +240,8 @@ public class AggregationBuildHandler {
     * @param map 聚合查询结果
     * @param map 聚合查询结果
     * @return
     * @return
     */
     */
    public Map<String, Object> numericalDataParsing(String viewCode ,Map<String, Aggregation> map){
    public Map<String, Object> numericalDataParsing(View view,Map<String, Aggregation> map){
        Map<String, Object> resultMap = new HashMap<>();
        Map<String, Object> resultMap = new HashMap<>();
        View view = viewDao.findByCode(viewCode);
        if(view == null){
            logger.debug("视图不存在");
            return null;
        }
        List<ViewQuota> viewQuotas = viewQuotaDao.findByViewId(view.getId());
        List<ViewQuota> viewQuotas = viewQuotaDao.findByViewId(view.getId());
        Map<String, Object> quotaMap = new HashMap<>();
        Map<String, Object> quotaMap = new HashMap<>();
        for(ViewQuota viewQuota :viewQuotas){
        for(ViewQuota viewQuota :viewQuotas){
@ -294,33 +275,22 @@ public class AggregationBuildHandler {
     * @param map 聚合查询结果
     * @param map 聚合查询结果
     * @return
     * @return
     */
     */
    public Option ehartDataParsing(String viewCode ,Map<String, Aggregation> map){
    public Option ehartDataParsing(View view,Map<String, Aggregation> map) throws  Exception{
        Option option = null;
        Option option = null;
        ReportOption reportOption = new ReportOption();
        ReportOption reportOption = new ReportOption();
        List<String> xDataList = new LinkedList<>();
        List<String> xDataList = new LinkedList<>();
        List<String> charTypes = new LinkedList<>();
        List<String> charTypes = new LinkedList<>();
        List<String> lineNames = new LinkedList<>();
        List<String> lineNames = new LinkedList<>();
        List<List<Object>> lineDataList = new LinkedList<>();
        List<List<Object>> lineDataList = new LinkedList<>();
        List<String> rowList = new LinkedList<>();
        rowList.add("town_terms");
        View view = viewDao.findByCode(viewCode);
//        rowList = getRowDimensionList(view.getId());
        List<String> rowList = getRowDimensionList(view.getId());
        Map<String,List<Object>> quotasDataMap = new LinkedHashMap<>();
        if(rowList.size() != 1){
        if(rowList.size() != 1){
            logger.debug("图表型指标维度配置有误");
            logger.debug("图表型指标维度配置有误");
            return null;
            throw new Exception("图表型指标维度配置有误");
        }
        }
        String rowAggCode = rowList.get(0);
        String rowAggCode = rowList.get(0);
        List<String> quotaList = new LinkedList<>();
        List<String> quotaList = new LinkedList<>();
        Map<String,List<Object>> quotasDataMap = new LinkedHashMap<>();
        List<ViewQuota> viewQuotas = new ArrayList<>();
        ViewQuota vq = new ViewQuota();
        vq.setChartType("1");
        vq.setCode("total");
        vq.setName("各区县总人数");
        viewQuotas.add(vq);
//        viewQuotas = viewQuotaDao.findByViewId(view.getId());
        List<ViewQuota> viewQuotas = viewQuotaDao.findByViewId(view.getId());
        for(ViewQuota viewQuota :viewQuotas){
        for(ViewQuota viewQuota :viewQuotas){
            quotaList.add(viewQuota.getCode());
            quotaList.add(viewQuota.getCode());
            charTypes.add(viewQuota.getChartType());
            charTypes.add(viewQuota.getChartType());
@ -331,14 +301,14 @@ public class AggregationBuildHandler {
            Terms terms = (Terms)aggregation;
            Terms terms = (Terms)aggregation;
            String key = "";
            String key = "";
            List<Terms.Bucket> buckets =  terms.getBuckets();
            List<Terms.Bucket> buckets =  terms.getBuckets();
            for(String quotaCode: quotaList){
            for(ViewQuota viewQuota: viewQuotas){
                List<Object> quotaData = new ArrayList<>();
                List<Object> quotaData = new ArrayList<>();
                for(Terms.Bucket bucket : buckets){
                for(Terms.Bucket bucket : buckets){
                    key = bucket.getKeyAsString() != null ? bucket.getKeyAsString() : bucket.getKey().toString();
                    key = bucket.getKeyAsString() != null ? bucket.getKeyAsString() : bucket.getKey().toString();
                    xDataList.add(key);
                    xDataList.add(key);
                    List<Aggregation> aggregationList = bucket.getAggregations().asList();
                    List<Aggregation> aggregationList = bucket.getAggregations().asList();
                    for(Aggregation subAgg : aggregationList){
                    for(Aggregation subAgg : aggregationList){
                        if(subAgg.getName().contains(quotaCode)){
                        if(subAgg.getName().contains(viewQuota.getBasicFormulaType())){
                            Map<String, Object> subDataMap = getInternalAggValue(subAgg.getName(),subAgg);
                            Map<String, Object> subDataMap = getInternalAggValue(subAgg.getName(),subAgg);
                            if(subDataMap != null || subDataMap.size() > 0){
                            if(subDataMap != null || subDataMap.size() > 0){
                                quotaData.add(subDataMap.get(subAgg.getName()));
                                quotaData.add(subDataMap.get(subAgg.getName()));
@ -346,7 +316,7 @@ public class AggregationBuildHandler {
                        }
                        }
                    }
                    }
                }
                }
                quotasDataMap.put(quotaCode, quotaData);
                quotasDataMap.put(viewQuota.getCode(), quotaData);
            }
            }
        }
        }
        for (Map.Entry<String,List<Object>> entry : quotasDataMap.entrySet()) {
        for (Map.Entry<String,List<Object>> entry : quotasDataMap.entrySet()) {