Browse Source

增加halfYear

chenw 6 years ago
parent
commit
6abfabf065

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

@@ -299,15 +299,17 @@ public class TimeConverterUtil {
     public static String convertToOracleDateStr(String xColumn, String timeType) {
         if ("year".equals(timeType)){
             return "TO_CHAR(" + xColumn + ", 'YYYY')";
-        }else if("month".equals(timeType)) {
+        } else if("month".equals(timeType)) {
             return "TO_CHAR(" + xColumn + ", 'YYYY-MM')";
-        }else if ("day".equals(timeType)) {
+        } else if ("day".equals(timeType)) {
             return "TO_CHAR(" + xColumn + ", 'YYYY-MM-DD')";
-        }else if ("quarter".equals(timeType)) {
+        } else if ("quarter".equals(timeType)) {
             return "TO_CHAR(" + xColumn + ", 'YYYY-Q')";
-        }else if ("week".equals(timeType)) {
+        } else if ("week".equals(timeType)) {
             return "TO_CHAR(" + xColumn + ", 'YYYY-WW')";
-        }else {
+        } else if ("halfYear".equals(timeType)){
+            return "case when to_char(${xAxisName},'MM')<=6 then to_char(${xAxisName},'YYYY')|| '-H1' else to_char(${xAxisName},'YYYY')||'-H2' end ";
+        } else {
             return "TO_CHAR(" + xColumn + ", 'YYYY-MM-DD')";
         }
     }