pqc任务查询方法修改
This commit is contained in:
parent
01b86c2621
commit
41809a8b53
|
|
@ -2,7 +2,10 @@ package com.nflg.wms.common.pojo.qo;
|
|||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* PQC任务列表查询参数
|
||||
|
|
@ -45,6 +48,16 @@ public class QmsPqcTaskRecordSearchQO {
|
|||
*/
|
||||
private LocalDateTime createEndTime;
|
||||
|
||||
/**
|
||||
* 兼容前端传参:创建开始时间
|
||||
*/
|
||||
private String createTimeStart;
|
||||
|
||||
/**
|
||||
* 兼容前端传参:创建结束时间
|
||||
*/
|
||||
private String createTimeEnd;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
|
|
@ -54,4 +67,46 @@ public class QmsPqcTaskRecordSearchQO {
|
|||
* 每页条数
|
||||
*/
|
||||
private Integer pageSize = 10;
|
||||
|
||||
public LocalDateTime getCreateStartTime() {
|
||||
if (createStartTime != null) {
|
||||
return createStartTime;
|
||||
}
|
||||
return parseDateTime(createTimeStart, false);
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateEndTime() {
|
||||
if (createEndTime != null) {
|
||||
return createEndTime;
|
||||
}
|
||||
return parseDateTime(createTimeEnd, true);
|
||||
}
|
||||
|
||||
private LocalDateTime parseDateTime(String text, boolean endOfDay) {
|
||||
if (text == null || text.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
if (text.endsWith("Z") || text.contains("+")) {
|
||||
return OffsetDateTime.parse(text).toLocalDateTime();
|
||||
}
|
||||
if (text.contains("/")) {
|
||||
if (text.length() == 10) {
|
||||
LocalDate date = LocalDate.parse(text, DateTimeFormatter.ofPattern("yyyy/MM/dd"));
|
||||
return endOfDay ? date.atTime(23, 59, 59) : date.atStartOfDay();
|
||||
}
|
||||
return LocalDateTime.parse(text, DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));
|
||||
}
|
||||
if (text.length() == 10) {
|
||||
LocalDate date = LocalDate.parse(text, DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
return endOfDay ? date.atTime(23, 59, 59) : date.atStartOfDay();
|
||||
}
|
||||
if (text.length() == 19 && text.contains(" ")) {
|
||||
return LocalDateTime.parse(text, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
return LocalDateTime.parse(text);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue