Quellcode durchsuchen

调整代码。

zhangjinjun vor 6 Jahren
Ursprung
Commit
eb037ca41c
1 geänderte Dateien mit 16 neuen und 10 gelöschten Zeilen
  1. 16 10
      src/main/java/com/yihu/quota/controller/ViewController.java

+ 16 - 10
src/main/java/com/yihu/quota/controller/ViewController.java

@ -5,6 +5,7 @@ import com.github.abel533.echarts.Option;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.ehr.controller.EnvelopRestEndPoint;
import com.yihu.ehr.exception.ApiException;
import com.yihu.ehr.util.rest.Envelop;
import com.yihu.quota.model.cube.Cube;
import com.yihu.quota.model.view.View;
@ -111,34 +112,36 @@ public class ViewController extends EnvelopRestEndPoint {
            @ApiParam(name = "sort", value = "排序JSON字符串,排序字段从可排序的维度中挑选,如:'{\"field\":\"event_date\",\"type\":\"asc\"}'")
            @RequestParam(value = "sort", required = false) String sort,
            @ApiParam(name = "drillDimension", value = "钻取维度编码,如:'{\"field\":\"event_date\"}'")
            @RequestParam(value = "drillDimension", required = false) String drillDimension) {
            @RequestParam(value = "drillDimension", required = false) String drillDimension) throws Exception {
        Envelop envelop = new Envelop();
        envelop.setSuccessFlg(true);
        try {
            View view = viewService.findByCode(viewCode);
            if (view == null) {
                throw new ApiException("视图不存在。");
            }
            // 根据视图规则,获取统计结果
            List<ViewQuotaFilterModel> filterModelList = new ArrayList<>();
            if (StringUtils.isNotEmpty(filters)) {
                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);
            if(view.getDisplayType().equals("1")){
            // 转换统计结果数据格式
            if (view.getDisplayType().equals("1")) {
                //数值型
                Map<String, Object> resultMap = aggregationBuildHandler.numericalDataParsing(view, aggregations.getAsMap());
                envelop.setObj(resultMap);
            }else if(view.getDisplayType().equals("2")){
            } 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")){
            } else if (view.getDisplayType().equals("3")) {
                //树形表格
            }else {
            } else {
                //图表
                Option option = aggregationBuildHandler.ehartDataParsing(view, aggregations.getAsMap());
                String echartJson = option.toString();
@ -147,7 +150,10 @@ public class ViewController extends EnvelopRestEndPoint {
        } catch (Exception e) {
            e.printStackTrace();
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg(e.getMessage());
            throw new Exception(e);
        }
        return envelop;
    }