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