Browse Source

处理Y轴为日期类型的报错

chenw 6 years ago
parent
commit
6e183b8432

+ 9 - 0
bi-server/pom.xml

@@ -50,6 +50,15 @@
       <artifactId>poi</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-cache</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>net.sf.ehcache</groupId>
+      <artifactId>ehcache</artifactId>
+    </dependency>
     <!--<dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-tomcat</artifactId>

+ 4 - 0
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowHistogramService.java

@@ -49,6 +49,7 @@ public class ShowHistogramService {
                yColumn = histogramConfigInfo.getyAxis().getColumnRename(),
                yType = histogramConfigInfo.getyAxis().getShowDataType(),
                xColumnType = histogramConfigInfo.getxAxis().getColumnType(),
+               yColumnType = histogramConfigInfo.getyAxis().getColumnType(),
                yAxisType = CalculationJudgeUtil.Judge(yType),
                xAxisType = histogramConfigInfo.getxAxis().getShowDataType(),
                sort = StringUtils.isEmpty(histogramConfigInfo.getSort()) ? xColumn : histogramConfigInfo.getSort(),
@@ -124,6 +125,9 @@ public class ShowHistogramService {
                 fieldName = fieldName.replace("distinct", "");
                 condition += "," + yColumn;
             }
+            if ("time".equals(yColumnType)) {
+                fieldName = yAxisType + "(" + yColumn + ") as value," + ("scale".equals(xColumnType) ? "nvl(" + xColumn + ",0)" : "nvl(" + xColumn + ",'空')") + " as name ";
+            }
             if (CollectionUtils.isEmpty(groupBy)) {
                 List<HistogramData> histogramList = showChartsMapper.getHistogramValueWithoutGroup(fieldName, tableName, condition, sort, rule);
                 if (histogramList.size() > histogramConfigInfo.getMaxCount()) {

+ 4 - 0
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowLineService.java

@@ -42,6 +42,7 @@ public class ShowLineService {
         ChartsDataInfo chartsDataInfo = new ChartsDataInfo();
         String xColumn = lineConfigInfo.getxAxis().getColumnRename(),
                yColumn = lineConfigInfo.getyAxis().getColumnRename(),
+               yColumnType = lineConfigInfo.getyAxis().getColumnType(),
                yType = lineConfigInfo.getyAxis().getShowDataType(),
                yAxisType = CalculationJudgeUtil.Judge(yType),
                xAxisType = lineConfigInfo.getxAxis().getShowDataType();
@@ -91,6 +92,9 @@ public class ShowLineService {
             }
             xColumn = TimeConverterUtil.convertToOracleDateStr(xColumn, xAxisType);         //X轴 -> 折线图X轴只能为日期类型
             String fieldName = yAxisType + "(nvl(" + yColumn + ",0)) as value,nvl(" + xColumn + ",'空') as name ";
+            if ("time".equals(yColumnType)) {
+                fieldName = yAxisType + "(" + yColumn + ")) as value,nvl(" + xColumn + ",'空') as name ";
+            }
             String condition = screenToColumnS + " GROUP BY " + xColumn;
             if (yAxisType.contains("distinct")) {
                 fieldName = fieldName.replace("distinct", "");

+ 4 - 0
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowPieService.java

@@ -43,6 +43,7 @@ public class ShowPieService {
         String xColumn = pieConfigInfo.getLegendData().getColumnRename(),
                yColumn = pieConfigInfo.getSeries().getColumnRename(),
                xColumnType = pieConfigInfo.getLegendData().getColumnType(),
+               yColumnType = pieConfigInfo.getSeries().getColumnType(),
                xAxisType = pieConfigInfo.getLegendData().getShowDataType(),
                yType = pieConfigInfo.getSeries().getShowDataType(),
                yAxisType = CalculationJudgeUtil.Judge(yType);
@@ -101,6 +102,9 @@ public class ShowPieService {
                     + "(nvl(" + yColumn + ",0)) as value,"
                     + ("scale".equals(xColumnType) ? "nvl(" + xColumn + ",0)" : "nvl(" + xColumn + ",'空')")
                     + " as name ";
+            if ("time".equals(yColumnType)) {
+                fieldName = yAxisType + "(" + yColumn + ") as value," + ("scale".equals(xColumnType) ? "nvl(" + xColumn + ",0)" : "nvl(" + xColumn + ",'空')") + " as name ";
+            }
             String condition = screenToColumnS + " GROUP BY " + xColumn;
             if (yAxisType.contains("distinct")) {
                 fieldName = fieldName.replace("distinct", "");

+ 5 - 4
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowScatterService.java

@@ -46,6 +46,7 @@ public class ShowScatterService {
         String xColumn = scatterConfigInfo.getxAxis().getColumnRename(),
                yColumn = scatterConfigInfo.getyAxis().getColumnRename(),
                xColumnType = scatterConfigInfo.getxAxis().getColumnType(),
+               yColumnType = scatterConfigInfo.getyAxis().getColumnType(),
                yType = scatterConfigInfo.getyAxis().getShowDataType(),
                yAxisType = CalculationJudgeUtil.Judge(yType),
                xAxisType = scatterConfigInfo.getxAxis().getShowDataType();
@@ -98,10 +99,10 @@ public class ShowScatterService {
             if ("time".equals(xColumnType)){
                 xColumn = TimeConverterUtil.convertToOracleDateStr(xColumn, xAxisType);         //X轴
             }
-            String fieldName = yAxisType
-                    + "(" + yColumn + ") as value,"
-                    + ("scale".equals(xColumnType) ? "nvl(" + xColumn + ",0)" : "nvl(" + xColumn + ",'空')")
-                    + " as \"date\" ";
+            String fieldName = yAxisType + "(nvl(" + yColumn + ",0)) as value," + ("scale".equals(xColumnType) ? "nvl(" + xColumn + ",0)" : "nvl(" + xColumn + ",'空')") + " as \"date\" ";
+            if ("time".equals(yColumnType)) {
+                fieldName = yAxisType + "(" + yColumn + ") as value," + ("scale".equals(xColumnType) ? "nvl(" + xColumn + ",0)" : "nvl(" + xColumn + ",'空')") + " as name ";
+            }
             String condition = screenToColumnS + " GROUP BY " + xColumn;
             if (yAxisType.contains("distinct")) {
                 fieldName = fieldName.replace("distinct", "");