Bläddra i källkod

ES 添加mapping 是增加 extra_total 字段,保存是默认为1

jkzlzhoujie 6 år sedan
förälder
incheckning
d9bf6cc109

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

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

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

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

+ 3 - 16
src/main/java/com/yihu/quota/util/AggregationBuildHandler.java

@ -148,24 +148,17 @@ public class AggregationBuildHandler {
     * @param map 聚合查询结果
     * @return
     */
    public List<Map<String, Object>> tableDataParsing(String viewCode ,Map<String, Aggregation> map){
    public List<Map<String, Object>> tableDataParsing(View view,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;
        }
        List<String> rowList = getRowDimensionList(view.getId());
        List<String> cloumnList = getColumnDimensionList(view.getId());
        List<ViewQuota> viewQuotas = viewQuotaDao.findByViewId(view.getId());
//        List<ViewQuotaFilter> viewFilters = viewQuotaFilterDao.findByRelationId(view.getId());
        Map<String, Object> quotaMap = new HashMap<>();
        for(ViewQuota viewQuota :viewQuotas){
            List<ViewQuotaFilter> viewQuotaFilters = viewQuotaFilterDao.findByRelationId(viewQuota.getId());
@ -254,13 +247,8 @@ public class AggregationBuildHandler {
     * @param map 聚合查询结果
     * @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<>();
        View view = viewDao.findByCode(viewCode);
        if(view == null){
            logger.debug("视图不存在");
            return null;
        }
        List<ViewQuota> viewQuotas = viewQuotaDao.findByViewId(view.getId());
        Map<String, Object> quotaMap = new HashMap<>();
        for(ViewQuota viewQuota :viewQuotas){
@ -294,7 +282,7 @@ public class AggregationBuildHandler {
     * @param map 聚合查询结果
     * @return
     */
    public Option ehartDataParsing(String viewCode ,Map<String, Aggregation> map){
    public Option ehartDataParsing(View view,Map<String, Aggregation> map){
        Option option = null;
        ReportOption reportOption = new ReportOption();
        List<String> xDataList = new LinkedList<>();
@ -304,7 +292,6 @@ public class AggregationBuildHandler {
        List<String> rowList = new LinkedList<>();
        rowList.add("town_terms");
        View view = viewDao.findByCode(viewCode);
//        rowList = getRowDimensionList(view.getId());
        if(rowList.size() != 1){
            logger.debug("图表型指标维度配置有误");