预警性能 不使用转列改为使用正则

This commit is contained in:
zhaokaiyao@91isoft.com
2021-12-24 15:22:37 +08:00
parent 2bd9e7f323
commit d9996eeac2
6 changed files with 147 additions and 56 deletions
@@ -4,15 +4,19 @@ import com.alibaba.druid.sql.visitor.functions.Char;
import com.sun.org.apache.bcel.internal.generic.NEW;
import lombok.Data;
import lombok.experimental.Accessors;
import net.bytebuddy.asm.Advice;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.format.annotation.DateTimeFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.*;
@Data
@Accessors(chain = true)
@@ -26,11 +30,15 @@ public class TermDTO {
private String endDate;
// private String str;
private String termStr;
private List<String> termList;
public TermDTO() {
LocalDate starDate = LocalDate.now();//系统当前日期
LocalDate endDate = LocalDate.now().plusMonths(3);//系统当前日期3个月后
//系统当前日期
LocalDate starDate = LocalDate.now();
//系统当前日期3个月后
LocalDate endDate = LocalDate.now().plusMonths(3);
convertToStr(starDate,endDate);
}
@@ -49,7 +57,9 @@ public class TermDTO {
int compareEnd = dateString.compareTo(startDate);
if (compareStart >= 0 && compareEnd <=0) {
return true;
} else return false;
} else {
return false;
}
}
@@ -61,7 +71,7 @@ public class TermDTO {
* @param startDate
* @param endDate
*/
public void convertToStr(LocalDate startDate,LocalDate endDate){
private void convertToStr(LocalDate startDate,LocalDate endDate){
/**
* 使用DateTimeFormatter线程安全,但不晓得怎么支持Date类型转换为字符串 ¯\_(ツ)_/¯
@@ -72,5 +82,38 @@ public class TermDTO {
this.startDate =formatter.format(startDate);
this.endDate=formatter.format(endDate);
this.termList= forDate();
this.termStr= StringUtils.join(this.termList,"|");
}
private List<String> forDate() {
// 日期格式化
LinkedList<String> termList = new LinkedList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
// 起始日期
Date d1 = sdf.parse(this.startDate);
// 结束日期
Date d2 = sdf.parse(this.endDate);
Date tmp = d1;
Calendar dd = Calendar.getInstance();
dd.setTime(d1);
// 循环之间的每一天
while (tmp.getTime() < d2.getTime()) {
tmp = dd.getTime();
termList.add(sdf.format(tmp));
// 天数加上1
dd.add(Calendar.DAY_OF_MONTH, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
return termList;
}
}