Browse Source

1.Y轴排序支持 2.修复由于X轴类型导致的SQL错误

chenw 6 years ago
parent
commit
23c6cbe0d8

+ 8 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowHistogramService.java

@@ -110,9 +110,15 @@ public class ShowHistogramService {
             if ("time".equals(xColumnType)) {
                 xColumn = TimeConverterUtil.convertToOracleDateStr(xColumn, xAxisType);
             }
-            String fieldName = yAxisType + "(" + yColumn + ") as value,nvl(" + xColumn + ",'空') as name ";
+            //Y轴排序
+            if (sort.equals(yColumn)) {
+                sort = yAxisType + "(" + yColumn + ")";
+            }
+            String fieldName = yAxisType
+                    + "(" + yColumn + ") as value,"
+                    + ("scale".equals(xColumnType) ? "nvl(" + xColumn + ",0)" : "nvl(" + xColumn + ",'空')")
+                    + " as name ";
             String condition = screenToColumnS + " GROUP BY " + xColumn;
-            sort = xColumn;
             if (CollectionUtils.isEmpty(groupBy)) {
                 List<HistogramData> histogramList = showChartsMapper.getHistogramValueWithoutGroup(fieldName, tableName, condition, sort, rule);
                 if (histogramList.size() > histogramConfigInfo.getMaxCount()) {