|
|
@@ -8,6 +8,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.time.DayOfWeek;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Iterator;
|
|
|
import java.util.List;
|
|
|
@@ -123,16 +127,22 @@ public class ScreenUtil {
|
|
|
private String getTimeSymbAndVal(String symbol, String value) {
|
|
|
String values = "" + value;
|
|
|
String tar = "";
|
|
|
- if ("null".equals(symbol)) {
|
|
|
- tar = "is null";
|
|
|
- } else if ("notNull".equals(symbol)) {
|
|
|
- tar = "is not null";
|
|
|
- } else if ("between".equals(symbol)) {
|
|
|
+ if ("between".equals(symbol)) {
|
|
|
tar = "";
|
|
|
String[] str = value.split(",");
|
|
|
String str1 = str[0];
|
|
|
String str2 = str[1];
|
|
|
tar = "between '" + str1 + "' and '" + str2 + "'";
|
|
|
+ } else if ("=".equals(symbol)) {
|
|
|
+ values = TimeFormat(value);
|
|
|
+ if (values.contains(",")) {
|
|
|
+ String[] str = values.split(",");
|
|
|
+ String str1 = str[0];
|
|
|
+ String str2 = str[1];
|
|
|
+ tar = "between '" + str1 + "' and '" + str2 + "'";
|
|
|
+ } else {
|
|
|
+ tar = symbol + " '" + values + "'";
|
|
|
+ }
|
|
|
} else {
|
|
|
tar = symbol + " '" + values + "'";
|
|
|
}
|
|
|
@@ -157,4 +167,77 @@ public class ScreenUtil {
|
|
|
valueString = valueString.replaceFirst(",", "(") + ")";
|
|
|
return valueString;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String TimeFormat(String value){
|
|
|
+ String formatValue = "";
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ switch (value) {
|
|
|
+ case "today" :
|
|
|
+ formatValue = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ break;
|
|
|
+ case "yesterday" :
|
|
|
+ formatValue = localDate.plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ break;
|
|
|
+ case "week" :
|
|
|
+ formatValue = localDate.plusWeeks(0).with(DayOfWeek.MONDAY).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
|
|
|
+ + localDate.plusWeeks(0).with(DayOfWeek.SUNDAY).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ break;
|
|
|
+ case "lastweek" :
|
|
|
+ formatValue = localDate.plusWeeks(-1).with(DayOfWeek.MONDAY).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
|
|
|
+ + localDate.plusWeeks(-1).with(DayOfWeek.SUNDAY).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ break;
|
|
|
+ case "month" :
|
|
|
+ formatValue = localDate.plusMonths(0).with(TemporalAdjusters.firstDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
|
|
|
+ + localDate.plusWeeks(0).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ break;
|
|
|
+ case "lastmonth" :
|
|
|
+ formatValue = localDate.plusWeeks(-1).with(TemporalAdjusters.firstDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
|
|
|
+ + localDate.plusWeeks(-1).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ break;
|
|
|
+ case "quarter" :
|
|
|
+ formatValue = quarterStart(0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
|
|
|
+ + quarterStart(0).plusMonths(2).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ break;
|
|
|
+ case "lastquarter" :
|
|
|
+ formatValue = quarterStart(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
|
|
|
+ + quarterStart(-1).plusMonths(2).with(TemporalAdjusters.lastDayOfMonth()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ formatValue = "";
|
|
|
+ break;
|
|
|
+ case "year" :
|
|
|
+ formatValue = localDate.plusYears(0).with(TemporalAdjusters.firstDayOfYear()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
|
|
|
+ + localDate.plusWeeks(0).with(TemporalAdjusters.firstDayOfYear()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ break;
|
|
|
+ case "lastyear" :
|
|
|
+ formatValue = localDate.plusYears(-1).with(TemporalAdjusters.firstDayOfYear()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ","
|
|
|
+ + localDate.plusWeeks(-1).with(TemporalAdjusters.firstDayOfYear()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ formatValue = value;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return formatValue;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static LocalDate quarterStart(int offset) {
|
|
|
+ final LocalDate date = LocalDate.now().plusMonths(offset * 3);
|
|
|
+ int month = date.getMonth().getValue();//当月
|
|
|
+ int start = 0;
|
|
|
+ if (month >= 1 && month <= 3) {//第一季度
|
|
|
+ start = 1;
|
|
|
+ } else if (month >= 4 && month <= 6) {//第二季度
|
|
|
+ start = 4;
|
|
|
+ } else if (month >= 7 && month <= 9) {//第三季度
|
|
|
+ start = 7;
|
|
|
+ } else if ((month >= 10 && month <= 12)) {//第四季度
|
|
|
+ start = 10;
|
|
|
+ } else if (month == 12) {//第四季度
|
|
|
+ start = 12;
|
|
|
+ month = 14;
|
|
|
+ }
|
|
|
+ return date.plusMonths(start - month).with(TemporalAdjusters.firstDayOfMonth());
|
|
|
+ }
|
|
|
}
|