chenw il y a 6 ans
Parent
commit
62cc24340f

+ 6 - 0
bi-server/src/main/java/com/usoftchina/bi/server/dao/chart/ShowChartsMapper.java

@@ -27,6 +27,12 @@ public interface ShowChartsMapper {
     List<String> getXAxis(@Param("xAxisName") String xAxisName, @Param("tableName") String tableName, @Param("screenToColumn") String screenToColumn, @Param("num") int num);
 
 
+    //XY轴数据
+    @Select("select ${dataType}(${yAxisName}) as \"value\",${xColumn} as \"date\" from ${tableName} where ${screen} group by ${xColumn}")
+    List<LineSeriesMap> getXAndYValues(@Param("yAxisName") String yAxisName, @Param("xColumn") String xColumn,
+                          @Param("tableName") String tableName, @Param("dataType") String dataType,
+                          @Param("screen") String screen);
+
     //x轴数据
     @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xColumn} = #{xdata} ${screen}")
     String getXValue(@Param("yAxisName") String yAxisName, @Param("xColumn") String xColumn,

+ 29 - 21
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowScatterService.java

@@ -12,6 +12,7 @@ import com.usoftchina.bi.core.jdbc.DynamicDataSourceContextHolder;
 import com.usoftchina.bi.server.utils.ScreenUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -132,29 +133,36 @@ public class ShowScatterService {
         }
 
         //无分组时Y值
-        Iterator itX = xAxisData.iterator();
-        while (itX.hasNext()){
-            String xdata = (String)itX.next();
-            double valueOne = 0;
-            String valueOnes = null;
-            if ("time".equals(xColumnType)){
-                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata, screenToColumnS);
-            }else {
-                if (xdata == null || "".equals(xdata)){
-                    valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType, screenToColumnS);
-                }else {
-                    valueOnes = showChartsMapper.getXValue(yColumn, xColumn, tableName, yAxisType, xdata ,screenToColumnS);
-                }
+        if (!"time".equals(xColumnType)) {
+            if (StringUtils.isEmpty(screenToColumnS)) {
+                screenToColumnS = " 1 = 1 ";
             }
-            if (valueOnes == null || "".equals(valueOnes)){
-                valueOne = 0;
-            }else {
-                valueOne = Double.parseDouble(valueOnes);
+            value = showChartsMapper.getXAndYValues(yColumn, xColumn, tableName, yAxisType, screenToColumnS);
+        }else {
+            Iterator itX = xAxisData.iterator();
+            while (itX.hasNext()) {
+                String xdata = (String) itX.next();
+                double valueOne = 0;
+                String valueOnes = null;
+                if ("time".equals(xColumnType)) {
+                    valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata, screenToColumnS);
+                } else {
+                    if (xdata == null || "".equals(xdata)) {
+                        valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType, screenToColumnS);
+                    } else {
+                        valueOnes = showChartsMapper.getXValue(yColumn, xColumn, tableName, yAxisType, xdata, screenToColumnS);
+                    }
+                }
+                if (valueOnes == null || "".equals(valueOnes)) {
+                    valueOne = 0;
+                } else {
+                    valueOne = Double.parseDouble(valueOnes);
+                }
+                LineSeriesMap lineSeriesMap = new LineSeriesMap();
+                lineSeriesMap.setValue(valueOne);
+                lineSeriesMap.setDate(xdata);
+                value.add(lineSeriesMap);
             }
-            LineSeriesMap lineSeriesMap = new LineSeriesMap();
-            lineSeriesMap.setValue(valueOne);
-            lineSeriesMap.setDate(xdata);
-            value.add(lineSeriesMap);
         }
         LineSeries series = new LineSeries();
 //        series.setName(yColumn);