Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 26a2d2e4
authored
May 27, 2022
by
向延琳
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix:常驻地查询取到激活之前的数据
1 parent
9f296cac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
14 deletions
src/main/java/cn/com/glsx/admin/modules/service/VehicleMonitorService.java
src/main/java/cn/com/glsx/admin/modules/utils/DateUtil.java
src/main/java/cn/com/glsx/admin/modules/service/VehicleMonitorService.java
View file @
26a2d2e
...
...
@@ -532,15 +532,14 @@ public class VehicleMonitorService {
//2为无源设备查询基站;1为有源设备查询GPS
Device
device
=
deviceService
.
getDeviceBySn
(
search
.
getSn
());
Date
deviceActivateTime
=
Optional
.
ofNullable
(
device
)
.
map
(
Device:
:
getActivateTime
)
VehicleDevice
vehicleDevice
=
vehicleDeviceService
.
getByBindSn
(
search
.
getSn
());
boolean
isGps
=
Objects
.
isNull
(
device
)
||
Objects
.
equals
(
device
.
getSource
(),
1
);
int
lacType
=
isGps
?
1
:
2
;
Date
deviceActivateTime
=
Optional
.
ofNullable
(
vehicleDevice
)
.
map
(
VehicleDevice:
:
getCreatedDate
)
.
orElse
(
new
Date
());
int
lacType
;
if
(
Objects
.
isNull
(
device
)
||
Objects
.
equals
(
device
.
getSource
(),
1
))
{
lacType
=
1
;
}
else
{
lacType
=
2
;
}
//转换前端时间
ImmutablePair
<
String
,
String
>
timeImmutablePair
=
convertTime
(
search
,
deviceActivateTime
);
...
...
@@ -550,30 +549,37 @@ public class VehicleMonitorService {
/**
* 转换开始结束时间
* @return 开始时间只取设备激活时间之后
*/
public
ImmutablePair
<
String
,
String
>
convertTime
(
ResidentSearch
search
,
Date
device
Cre
ateTime
)
{
public
ImmutablePair
<
String
,
String
>
convertTime
(
ResidentSearch
search
,
Date
device
Activ
ateTime
)
{
Date
now
=
new
Date
();
String
startDate
=
""
;
String
endDate
=
DateUtil
.
getNowDateTimeFormat
();
String
deviceActivateTimeStr
=
DateUtil
.
formatDate
(
deviceActivateTime
);
switch
(
search
.
getTimeRange
())
{
//前一个月
case
ConstantsVehicle
.
RESIDENT_TYPE_ONE
:
startDate
=
DateUtil
.
formatDate
(
DateUtil
.
getDayBefore
(
30
,
now
));
String
afterOneMonth
=
DateUtil
.
formatDate
(
DateUtil
.
getDayBefore
(
30
,
now
));
startDate
=
DateUtil
.
getAfterDateTimeStr
(
afterOneMonth
,
deviceActivateTimeStr
);
break
;
//前三个月
case
ConstantsVehicle
.
RESIDENT_TYPE_THREE
:
startDate
=
DateUtil
.
formatDate
(
DateUtil
.
getDayBefore
(
90
,
now
));
String
afterThreeMonth
=
DateUtil
.
formatDate
(
DateUtil
.
getDayBefore
(
90
,
now
));
startDate
=
DateUtil
.
getAfterDateTimeStr
(
afterThreeMonth
,
deviceActivateTimeStr
);
break
;
//前半年
case
ConstantsVehicle
.
RESIDENT_TYPE_SIX
:
startDate
=
DateUtil
.
formatDate
(
DateUtil
.
getDayBefore
(
180
,
now
));
String
afterSixMonth
=
DateUtil
.
formatDate
(
DateUtil
.
getDayBefore
(
180
,
now
));
startDate
=
DateUtil
.
getAfterDateTimeStr
(
afterSixMonth
,
deviceActivateTimeStr
);
break
;
case
ConstantsVehicle
.
RESIDENT_TYPE_PRESENT
:
startDate
=
DateUtil
.
formatDate
(
deviceCreateTime
)
;
startDate
=
deviceActivateTimeStr
;
break
;
//自定义
case
ConstantsVehicle
.
RESIDENT_TYPE_CUSTOM
:
startDate
=
search
.
getStartTime
(
);
startDate
=
DateUtil
.
getAfterDateTimeStr
(
search
.
getStartTime
(),
deviceActivateTimeStr
);
endDate
=
search
.
getEndTime
();
break
;
default
:
...
...
src/main/java/cn/com/glsx/admin/modules/utils/DateUtil.java
View file @
26a2d2e
...
...
@@ -1543,6 +1543,30 @@ public class DateUtil extends org.apache.commons.lang.time.DateUtils {
return
datetime
.
toInstant
(
ZoneOffset
.
ofHours
(
8
)).
toEpochMilli
();
}
/**
* 获取之后的时间
* @param dateTime1 yyyy-MM-dd HH:mm:ss
* @param dateTime2 yyyy-MM-dd HH:mm:ss
* @return yyyy-MM-dd HH:mm:ss
*/
public
static
String
getAfterDateTimeStr
(
String
dateTime1
,
String
dateTime2
)
{
if
(
StringUtils
.
isEmpty
(
dateTime1
)
&&
StringUtils
.
isEmpty
(
dateTime1
))
{
return
""
;
}
if
(
StringUtils
.
isEmpty
(
dateTime1
)
)
{
return
dateTime2
;
}
if
(
StringUtils
.
isEmpty
(
dateTime2
)
)
{
return
dateTime1
;
}
LocalDateTime
localDateTime1
=
LocalDateTime
.
parse
(
dateTime1
,
DateTimeFormatter
.
ofPattern
(
YMDHMS
));
LocalDateTime
localDateTime2
=
LocalDateTime
.
parse
(
dateTime2
,
DateTimeFormatter
.
ofPattern
(
YMDHMS
));
if
(
localDateTime1
.
isAfter
(
localDateTime2
))
{
return
dateTime1
;
}
return
dateTime2
;
}
public
static
void
main
(
String
[]
args
)
{
// System.out.println(formatDate(getStartDateOfCurrentDay(new Date())));
System
.
out
.
println
(
getMaxDayOfCurrentMonth
());
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment