chenw 6 лет назад
Родитель
Сommit
66a20f3803

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

@@ -133,8 +133,8 @@ public interface ShowChartsMapper {
      * @param rule
      * @return
      */
-    @Select("SELECT ${fieldName} FROM ${tableName} WHERE ${condition} ORDER BY ${sort} ${rule}")
+    @Select("SELECT * FROM (SELECT ${fieldName} FROM ${tableName} WHERE ${condition} ORDER BY ${sort} ${rule}) WHERE ROWNUM <= #{threshold}")
     List<Map<String, Object>> getIndicatorValue(@Param("fieldName") String fieldName, @Param("tableName") String tableName, @Param("condition") String condition,
-                                               @Param("sort") String sort, @Param("rule") String rule);
+                                               @Param("sort") String sort, @Param("rule") String rule, @Param("threshold") int threshold);
 
 }

+ 3 - 3
bi-server/src/main/java/com/usoftchina/bi/server/model/vo/configVo/IndicatorConfigInfo.java

@@ -37,13 +37,13 @@ public class IndicatorConfigInfo {
     private String rule;
 
     @ApiModelProperty("阈值")
-    private String threshold;
+    private int threshold;
 
-    public String getThreshold() {
+    public int getThreshold() {
         return threshold;
     }
 
-    public void setThreshold(String threshold) {
+    public void setThreshold(int threshold) {
         this.threshold = threshold;
     }
 

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

@@ -48,8 +48,7 @@ public class ShowIndicatorService {
         String fields = "", otherFields = "";
         String sort = indicatorConfigInfo.getSort();
         String condition = getCondition(filters, indicatorConfigInfo.getxField().getColumnRename(), indicatorConfigInfo.getyField().getColumnRename());
-        condition = condition + (StringUtils.isEmpty(condition) ? "" : " AND") + " ROWNUM <= " + indicatorConfigInfo.getThreshold();
-                String tableName = chartsUtilService.getSqlStr(token, indicatorConfigInfo.getId(), 0);
+        String tableName = chartsUtilService.getSqlStr(token, indicatorConfigInfo.getId(), 0);
         String operate = indicatorConfigInfo.getyField().getShowDataType();
         if (ObjectUtils.isEmpty(indicatorConfigInfo.getxField())) {
             fields += StringUtils.isEmpty(operate) ? indicatorConfigInfo.getyField().getColumnRename() + " as \"value\" " : operate + "(" + indicatorConfigInfo.getyField().getColumnRename() + ") as \"value\" ";
@@ -64,7 +63,7 @@ public class ShowIndicatorService {
             fields += "," + String.join(",", indicatorConfigInfo.getOtherColumn());
             condition += "," + String.join(",", indicatorConfigInfo.getOtherColumn());
         }
-        List<Map<String, Object>> indicatorSeriesMapList = showChartsMapper.getIndicatorValue(fields, tableName, condition, sort, indicatorConfigInfo.getRule());
+        List<Map<String, Object>> indicatorSeriesMapList = showChartsMapper.getIndicatorValue(fields, tableName, condition, sort, indicatorConfigInfo.getRule(), indicatorConfigInfo.getThreshold());
         chartsDataInfo.setChartsColumnConfig(chartsConfigMapper.getChartsColumn(indicatorConfigInfo.getId()));
         chartsDataInfo.setSerieses(indicatorSeriesMapList);
         chartsDataInfo.setStyleConfig(styleConfig);