Browse Source

动态设置查询结果条数

chenw 6 years ago
parent
commit
c17669b8fa

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

@@ -174,7 +174,7 @@ public interface ShowChartsMapper {
     /*
     查询筛选列信息
      */
-    @Select("select * from (select distinct ${columnName} from ${tableName} )where ${columnName} like '%'||#{keyword,jdbcType=VARCHAR}||'%' and rownum <= 20")
-    List<Object> getScreenData(@Param("columnName") String columnName, @Param("tableName") String tableName, @Param("keyword") String keyword);
+    @Select("select * from (select distinct ${columnName} from ${tableName} )where ${columnName} like '%'||#{keyword,jdbcType=VARCHAR}||'%' and rownum <= #{count, jdbcType=INTEGER}")
+    List<Object> getScreenData(@Param("columnName") String columnName, @Param("tableName") String tableName, @Param("keyword") String keyword, @Param("count") int count);
 
 }

+ 12 - 0
bi-server/src/main/java/com/usoftchina/bi/server/model/vo/configVo/ColumnScreenInfo.java

@@ -4,6 +4,18 @@ public class ColumnScreenInfo {
     private int id;
     private String columnName;
     private String keyword;
+    /**
+     * 需要返回的记录数
+     */
+    private int count = 20;
+
+    public int getCount() {
+        return count;
+    }
+
+    public void setCount(int count) {
+        this.count = count;
+    }
 
     public String getKeyword() {
         return keyword;

+ 12 - 0
bi-server/src/main/java/com/usoftchina/bi/server/model/vo/configVo/HistogramConfigInfo.java

@@ -12,6 +12,18 @@ public class HistogramConfigInfo {
     private Column yAxis;
     private List<String> groups;
     private List<Screen> filters;
+    /**
+     * 需要展示的条数
+     */
+    private int maxCount = 20;
+
+    public int getMaxCount() {
+        return maxCount;
+    }
+
+    public void setMaxCount(int maxCount) {
+        this.maxCount = maxCount;
+    }
 
     public int getId() {
         return id;

+ 12 - 0
bi-server/src/main/java/com/usoftchina/bi/server/model/vo/configVo/LineConfigInfo.java

@@ -12,6 +12,18 @@ public class LineConfigInfo {
     private Column yAxis;
     private List<String> groups;
     private List<Screen> filters;
+    /**
+     * 需要展示的条数
+     */
+    private int maxCount = 1000;
+
+    public int getMaxCount() {
+        return maxCount;
+    }
+
+    public void setMaxCount(int maxCount) {
+        this.maxCount = maxCount;
+    }
 
     public int getId() {
         return id;

+ 12 - 0
bi-server/src/main/java/com/usoftchina/bi/server/model/vo/configVo/PieConfigInfo.java

@@ -11,6 +11,18 @@ public class PieConfigInfo {
     private Column legendData;
     private Column series;
     private List<Screen> filters;
+    /**
+     * 需要展示的条数
+     */
+    private int maxCount = 20;
+
+    public int getMaxCount() {
+        return maxCount;
+    }
+
+    public void setMaxCount(int maxCount) {
+        this.maxCount = maxCount;
+    }
 
     public int getId() {
         return id;

+ 12 - 0
bi-server/src/main/java/com/usoftchina/bi/server/model/vo/configVo/ScatterConfigInfo.java

@@ -12,6 +12,18 @@ public class ScatterConfigInfo {
     private Column yAxis;
     private List<String> groups;
     private List<Screen> filters;
+    /**
+     * 需要展示的条数
+     */
+    private int maxCount = 50;
+
+    public int getMaxCount() {
+        return maxCount;
+    }
+
+    public void setMaxCount(int maxCount) {
+        this.maxCount = maxCount;
+    }
 
     public int getId() {
         return id;

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

@@ -116,16 +116,16 @@ public class ShowHistogramService {
             //X轴
             //判断是否为日期类型
             if ("time".equals(xColumnType)){
-                timeReture = timeConverterUtil.timeConverter(xColumn, tableName, xAxisType, screen, 20);
+                timeReture = timeConverterUtil.timeConverter(xColumn, tableName, xAxisType, screen, histogramConfigInfo.getMaxCount());
                 xAxisData = timeReture.getValues();
                 chartsDataInfo.setTooMany(timeReture.isOverdose());
                 xData = timeConverterUtil.toRespons(xAxisData,xAxisType );
             }else {
                 int count = showChartsMapper.getNumForX(xColumn, tableName);
-                if (count > 20){
+                if (count > histogramConfigInfo.getMaxCount()){
                     chartsDataInfo.setTooMany(true);
                 }
-                xAxisData = showChartsMapper.getXAxis(xColumn, tableName, screen, 20);
+                xAxisData = showChartsMapper.getXAxis(xColumn, tableName, screen, histogramConfigInfo.getMaxCount());
 
             }
             if ("".equals(xAxisData) || xAxisData == null || xAxisData.size() == 0){

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

@@ -156,10 +156,10 @@ public class ShowLineService {
             while (itGroup.hasNext()){
                 String groupByName = (String) itGroup.next();
                 int counts = showChartsMapper.getGroupsCount(groupByName,tableName, screenToColumnS);
-                if (counts > 366){
+                if (counts > lineConfigInfo.getMaxCount()){
                     chartsDataInfo.setTooMany(true);
                 }
-                List<String> groupsData = showChartsMapper.getGroups(groupByName,tableName, screenToColumnS, 366); //查询每个分组系列
+                List<String> groupsData = showChartsMapper.getGroups(groupByName,tableName, screenToColumnS, lineConfigInfo.getMaxCount()); //查询每个分组系列
                 Iterator itGroupsData = groupsData.iterator();
 
                 //每个分组得到得每个系列

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

@@ -108,16 +108,16 @@ public class ShowPieService {
         //X轴
         //判断是否为日期类型
         if ("time".equals(xColumnType)){
-            timeReture = timeConverterUtil.timeConverter(xColumn, tableName, xAxisType, screen, 20);
+            timeReture = timeConverterUtil.timeConverter(xColumn, tableName, xAxisType, screen, pieConfigInfo.getMaxCount());
             xAxisData = timeReture.getValues();
             chartsDataInfo.setTooMany(timeReture.isOverdose());
             xData = timeConverterUtil.toRespons(xAxisData,xAxisType );
         }else {
             int count = showChartsMapper.getNumForX(xColumn, tableName);
-            if (count > 20){
+            if (count > pieConfigInfo.getMaxCount()){
                 chartsDataInfo.setTooMany(true);
             }
-            xAxisData = showChartsMapper.getXAxis(xColumn, tableName, screen, 20);
+            xAxisData = showChartsMapper.getXAxis(xColumn, tableName, screen, pieConfigInfo.getMaxCount());
 
         }
         if ("".equals(xAxisData) || xAxisData == null || xAxisData.size() == 0){

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

@@ -113,16 +113,16 @@ public class ShowScatterService {
         //X轴
         //判断是否为日期类型
         if ("time".equals(xColumnType)){
-            timeReture = timeConverterUtil.timeConverter(xColumn, tableName, xAxisType, screen, 50);
+            timeReture = timeConverterUtil.timeConverter(xColumn, tableName, xAxisType, screen, scatterConfigInfo.getMaxCount());
             xAxisData = timeReture.getValues();
             chartsDataInfo.setTooMany(timeReture.isOverdose());
             xData = timeConverterUtil.toRespons(xAxisData,xAxisType );
         }else {
                 int count = showChartsMapper.getNumForX(xColumn, tableName);
-                if (count > 50){
+                if (count > scatterConfigInfo.getMaxCount()){
                     chartsDataInfo.setTooMany(true);
                 }
-            xAxisData = showChartsMapper.getXAxis(xColumn, tableName, screen, 50);
+            xAxisData = showChartsMapper.getXAxis(xColumn, tableName, screen, scatterConfigInfo.getMaxCount());
 
         }
 

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/ColumnScreenService.java

@@ -51,7 +51,7 @@ public class ColumnScreenService {
                 logger.info("使用数据源:{}", String.valueOf(baseId));
                 DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
             }
-            data =  showChartsMapper.getScreenData(columnScreenInfo.getColumnName(), tableName, columnScreenInfo.getKeyword());
+            data =  showChartsMapper.getScreenData(columnScreenInfo.getColumnName(), tableName, columnScreenInfo.getKeyword(), columnScreenInfo.getCount());
         }catch (Exception e){
             e.printStackTrace();
             logger.error("异常");
@@ -88,7 +88,7 @@ public class ColumnScreenService {
                 logger.info("使用数据源:{}", String.valueOf(baseId));
                 DynamicDataSourceContextHolder.setDataSourceType(String.valueOf(baseId));
             }
-            data =  showChartsMapper.getScreenData(columnScreenInfo.getColumnName(), tableName, columnScreenInfo.getKeyword());
+            data =  showChartsMapper.getScreenData(columnScreenInfo.getColumnName(), tableName, columnScreenInfo.getKeyword(), columnScreenInfo.getCount());
         }catch (Exception e){
             e.printStackTrace();
             logger.error("异常");

+ 0 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataConnectorService.java

@@ -214,7 +214,6 @@ public class DataConnectorService {
     /*
     更新数据源分组
      */
-    @CacheEvict(value = "singleDataConnector", key = "#body.id")
     public RepEntity updateConfigGroup(GroupUpdateId groupUpdateId) {
         int id = groupUpdateId.getId();
         int groupId = groupUpdateId.getGroupId();
@@ -225,7 +224,6 @@ public class DataConnectorService {
     /*
     删除数据源
      */
-    @CacheEvict(value = "singleDataConnector")
     public RepEntity delDataConnector(Long id) {
         int count = dataConnectorMapper.countChartsById(id);
         if (count > 0) {