标准预警,判断标准在产车实施日期和新车型实施日期是否在预警期限内
This commit is contained in:
@@ -55,8 +55,8 @@ public class ScheduledJob {
|
||||
|
||||
|
||||
|
||||
// @Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
|
||||
@Scheduled(cron="*/5 * * * * ?")
|
||||
@Scheduled(cron = "0 0 0 * * ?") //每天的凌晨0点执行
|
||||
// @Scheduled(cron="*/5 * * * * ?")
|
||||
@Async
|
||||
public void WarningSchedulingTasks() {
|
||||
|
||||
@@ -123,9 +123,12 @@ public class ScheduledJob {
|
||||
.setItemsId("-1")
|
||||
.setPower("1")
|
||||
.setMark("3")
|
||||
.setPutTime(warningEO.getXCXSSRQ())
|
||||
.setStandCode(warningEO.getStandSort()+" "+ warningEO.getStandNum()+"-"+ warningEO.getStandYear());
|
||||
|
||||
//实施日期达到预警时间,但新车型实施日期不在时间内
|
||||
if (term.isTerm(warningEO.getXCXSSRQ())){
|
||||
warningEO.setPutTime(warningEO.getXCXSSRQ());
|
||||
}
|
||||
|
||||
}
|
||||
warningList.addAll(standInfoXCXSSRQ);
|
||||
@@ -141,8 +144,11 @@ public class ScheduledJob {
|
||||
.setItemsId("-1")
|
||||
.setPower("1")
|
||||
.setMark("4")
|
||||
.setPutTime(warningEO.getZCCSSRQ())
|
||||
.setStandCode(warningEO.getStandSort()+" "+ warningEO.getStandNum()+"-"+ warningEO.getStandYear());
|
||||
//实施日期达到预警时间,但在产车实施日期不在时间内
|
||||
if (term.isTerm(warningEO.getZCCSSRQ())){
|
||||
warningEO.setPutTime(warningEO.getZCCSSRQ());
|
||||
}
|
||||
}
|
||||
warningList.addAll(standInfoZCCSSRQ);
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
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;
|
||||
|
||||
@@ -19,36 +21,56 @@ public class DataDTO {
|
||||
* 预警的期限为系统日期的次日至3个月后
|
||||
*/
|
||||
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
private LocalDate startDate;
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
private LocalDate endDate;
|
||||
|
||||
private String startDate;
|
||||
|
||||
private String endDate;
|
||||
|
||||
// private String str;
|
||||
|
||||
public DataDTO() {
|
||||
this.startDate =LocalDate.now().plusDays(1); //系统当前日期
|
||||
this.endDate = LocalDate.now().plusMonths(3);//系统当前日期3个月后
|
||||
LocalDate starDate = LocalDate.now();//系统当前日期
|
||||
LocalDate endDate = LocalDate.now().plusMonths(3);//系统当前日期3个月后
|
||||
|
||||
convertToStr(starDate,endDate);
|
||||
}
|
||||
|
||||
public DataDTO(LocalDate startDate,LocalDate endDate){
|
||||
this.startDate=startDate;
|
||||
this.endDate=endDate;
|
||||
convertToStr(startDate,endDate);
|
||||
}
|
||||
|
||||
//
|
||||
// public boolean isTerm(T date){
|
||||
//
|
||||
// if (date.getClass().equals(Date.class)){
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//线程不安全
|
||||
//
|
||||
// DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
// String dataStr= dtf.format(LocalDate.now());
|
||||
// LocalDate localDateTime = LocalDate.parse(dataStr, dtf);
|
||||
// return
|
||||
// }
|
||||
//判断日期是否在期限内
|
||||
public boolean isTerm(Date date) {
|
||||
|
||||
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String dateString = formatter.format(date);
|
||||
int compareStart = dateString.compareTo(startDate);
|
||||
int compareEnd = dateString.compareTo(startDate);
|
||||
if (compareStart >= 0 && compareEnd <=0) {
|
||||
return true;
|
||||
} else return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 此时的mybatis-plus对localDate类型没有完全支持,则转换为字符串使用
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
*/
|
||||
public void convertToStr(LocalDate startDate,LocalDate endDate){
|
||||
|
||||
/**
|
||||
* 使用DateTimeFormatter线程安全,但不晓得怎么支持Date类型转换为字符串 ¯\_(ツ)_/¯
|
||||
*/
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");//线程不安全且不支持LocalDate
|
||||
|
||||
this.startDate =formatter.format(startDate);
|
||||
this.endDate=formatter.format(endDate);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user