Просмотр исходного кода

钻取功能逻辑代码添加

hy 6 лет назад
Родитель
Сommit
ab21fd0d81

+ 5 - 0
bi-server/src/main/java/com/usoftchina/bi/server/model/bo/Screen.java

@@ -7,6 +7,11 @@ public class Screen {
     private String symbolLabel;
     private String symbol;
     private String value;
+    private String type; //如果是钻取的过滤条件 会把钻取类型加入到type 过滤栏的条件则这个属性为空
+
+    public String getType() { return type; }
+
+    public void setType(String type) { this.type = type; }
 
     public String getColumnLabel() {
         return columnLabel;

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

@@ -155,7 +155,7 @@ public class ShowHistogramService {
                 chartsDataInfo.setxAxis(xAxisData);
                 /* 数据处理 */
                 List<String> groupList = histogramGroupList.stream().map(HistogramGroupData::getGroupName).distinct().limit(5).collect(Collectors.toList());
-                Map<String, List<HistogramGroupData>> histogramNameMap = histogramGroupList.stream().collect(Collectors.groupingBy(HistogramGroupData::getName));
+                Map<String, List<HistogramGroupData>> histogramNameMap = histogramGroupList.stream().collect(Collectors.groupingBy( histogramGroupData ->  StringUtils.isEmpty(histogramGroupData.getName())?"空":histogramGroupData.getName() ));
                 Set<String> keyset = histogramNameMap.keySet();
                 Iterator<String> keyIt= keyset.iterator();
                 List<HistogramGroupData> histogramGroupListAfterHandle = new ArrayList<>();
@@ -168,6 +168,11 @@ public class ShowHistogramService {
                             histogramGroupDataList.add(new HistogramGroupData(key, null, groupName));
                         }
                     });
+                    histogramGroupDataList.forEach(histogramGroupData -> {
+                        if(StringUtils.isEmpty(histogramGroupData.getName()) ){
+                            histogramGroupData.setName("空");
+                        }
+                    });
                     histogramGroupListAfterHandle.addAll(histogramGroupDataList);
                 }
                 /* 返回数据对象组装 */

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

@@ -151,8 +151,9 @@ public class ShowLineService {
                 }
                 chartsDataInfo.setxAxis(xAxisData);
                 /* 数据处理 */
+                //limit(5) 是分组显示数 现在是最大是5
                 List<String> groupList = histogramGroupList.stream().map(HistogramGroupData::getGroupName).distinct().limit(5).collect(Collectors.toList());
-                Map<String, List<HistogramGroupData>> histogramNameMap = histogramGroupList.stream().collect(Collectors.groupingBy(HistogramGroupData::getName));
+                Map<String, List<HistogramGroupData>> histogramNameMap = histogramGroupList.stream().collect(Collectors.groupingBy( histogramGroupData -> StringUtils.isEmpty(histogramGroupData.getName())?"空":histogramGroupData.getName() ));
                 Set<String> keyset = histogramNameMap.keySet();
                 Iterator<String> keyIt= keyset.iterator();
                 List<HistogramGroupData> histogramGroupListAfterHandle = new ArrayList<>();
@@ -165,6 +166,11 @@ public class ShowLineService {
                             histogramGroupDataList.add(new HistogramGroupData(key, null, groupName));
                         }
                     });
+                    histogramGroupDataList.forEach( histogramGroupData -> {
+                        if( StringUtils.isEmpty(histogramGroupData.getName()) ){
+                            histogramGroupData.setName("空");
+                        }
+                    });
                     histogramGroupListAfterHandle.addAll(histogramGroupDataList);
                 }
                 /* 返回数据对象组装 */
@@ -179,7 +185,7 @@ public class ShowLineService {
                     value = histogramGroupDataList.stream().map(HistogramGroupData::getValue).collect(Collectors.toList()).subList(0, xAxisData.size());
                     Series series = new Series(key, value, groupBy.get(0));
                     serieses.add(series);
-                }while (it.hasNext() && i <= 20);
+                }while (it.hasNext() && i <= xAxisData.size());
             }
             chartsDataInfo.setStyleConfig(styleConfig);
             chartsDataInfo.setChartsColumnConfig(chartsColumn);

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

@@ -119,6 +119,8 @@ public class ShowPieService {
             if (xAxisData.size() > pieConfigInfo.getMaxCount()) {
                 xAxisData = new ArrayList<>(xAxisData.subList(0, pieConfigInfo.getMaxCount()));
                 xAxisData.add("其它");
+                //有其他的时候 tooMany 为 true
+                chartsDataInfo.setTooMany(true);
                 value = new ArrayList<>(value.stream().sorted((p1, p2) -> p2.getValue().compareTo(p1.getValue())).collect(Collectors.toList()).subList(0, pieConfigInfo.getMaxCount()));
                 Optional<Double> part = value.stream().map(PieSeriesMap::getValue).reduce(Double::sum);
                 if (total.isPresent() && part.isPresent()) {

+ 1 - 1
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/TimeConverterUtil.java

@@ -27,7 +27,7 @@ public class TimeConverterUtil {
         } else if ("week".equals(timeType)) {
             return "TO_CHAR(" + xColumn + ", 'YYYY-WW')";
         } else if ("halfYear".equals(timeType)){
-            return "case when to_char(" + xColumn + ",'MM')<=6 then to_char(" + xColumn + ",'YYYY')|| '-H1' else to_char(" + xColumn + ",'YYYY')||'-H2' end ";
+            return "case when to_char(" + xColumn + ",'MM')<=6 then to_char(" + xColumn + ",'YYYY')|| '-H1' when to_char(" + xColumn + ",'MM')>6 then to_char(" + xColumn + ",'YYYY')||'-H2' else "+ xColumn +"||'' end ";
         } else {
             return "TO_CHAR(" + xColumn + ", 'YYYY-MM-DD')";
         }

+ 12 - 14
bi-server/src/main/java/com/usoftchina/bi/server/utils/ScreenUtil.java

@@ -6,6 +6,7 @@ import com.usoftchina.bi.server.model.bo.Screen;
 import com.usoftchina.bi.server.model.bo.ScreenStr;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
 
 import java.io.IOException;
 import java.time.DayOfWeek;
@@ -41,23 +42,20 @@ public class ScreenUtil {
             String columnType = screen.getColumnType();
             String symbol = screen.getSymbol();
             String value = screen.getValue();
+            String type = screen.getType();//钻取过滤条件的类型 可能和x轴的类型不同
+            String nowType = StringUtils.hasText(type)?type:xColumnType;//钻取的类型优先 没有则使用x轴的类型
 
-            if (columnType != "time" && !("time".equals(columnType))) {
+            if( "isNull".equals(symbol) ){//字段值为null
+                ret = ret + " and " + columnName + " is null ";
+            }else if( "isNotNull".equals(symbol) ){//字段值不为null
+                ret = ret + " and " + columnName + " is not null ";
+            }else if (columnType != "time" && !("time".equals(columnType))) {
                 String symbVal = getSymbAndVal(symbol, value, columnType);
-                if (xColumn.equals(columnName)) {
-                    withColumnRet = ret + " and " + columnName + " " + symbVal;
-                } else {
-                    ret = ret + " and " + columnName + " " + symbVal;
-                }
-            }
-            if (columnType == "time" || "time".equals(columnType)) {
+                ret = ret + " and " + columnName + " " + symbVal;
+            }else if (columnType == "time" || "time".equals(columnType)) {
                 String symbVal = getTimeSymbAndVal(symbol, value);
-                String column = getTimeColumn(columnName, xColumnType);
-                if (xColumn.equals(columnName)) {
-                    withColumnRet = ret + " and " + column + " " + symbVal;
-                } else {
-                    ret = ret + " and " + column + " " + symbVal;
-                }
+                String column = getTimeColumn(columnName, nowType);
+                ret = ret + " and " + column + " " + symbVal;
             }
         }
         screenStr.setRet(ret);