Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-devicemonitor
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 f462912d
authored
Aug 31, 2023
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.23.0 添加设备定位和警情查询接口 优化空指针异常处理
1 parent
fdf25b4f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
44 deletions
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/MonitorServiceImpl.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/MonitorServiceImpl.java
View file @
f462912
...
...
@@ -37,6 +37,7 @@ import cn.hutool.core.date.DateUtil;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.nacos.common.utils.CollectionUtils
;
import
com.glsx.plat.common.utils.DateUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.exception.BusinessException
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
...
...
@@ -343,55 +344,64 @@ public class MonitorServiceImpl implements MonitorService {
// 根据设备号和类型查询最后一个位置点
DataGpsLocation
gpsLocation
=
hdaoGpsComponent
.
getDeviceLastGpsInfo
(
sn
,
deviceTypeRelationEnum
);
deviceInformationDTO
.
setLastOneGPSRecord
(
gpsLocation
);
// 获取最后一个GPS位置点的时间
String
gpsTime
=
gpsLocation
.
getDateTime
();
Date
gpsEndTime
=
DateUtils
.
addDateDays
(
DateUtil
.
parseDateTime
(
gpsTime
),
1
);
// 获取结束时间 开始时间向前推一个月
Date
gpsStartTime
=
DateUtils
.
addDateDays
(
gpsEndTime
,
-
30
);
// 查询GPS记录数据 (时间范围为从查询起的一个月)
log
.
info
(
"设备号:"
+
sn
+
";开始时间:"
+
DateUtil
.
formatDateTime
(
gpsStartTime
));
log
.
info
(
"设备号:"
+
sn
+
";结束时间:"
+
DateUtil
.
formatDateTime
(
gpsEndTime
));
List
<
DataGpsLocation
>
gpsHistoryLocationList
=
hdaoGpsComponent
.
getDeviceHistoryLocation
(
sn
,
deviceTypeRelationEnum
,
DateUtil
.
formatDateTime
(
gpsStartTime
),
DateUtil
.
formatDateTime
(
gpsEndTime
));
// 对list进行排序 并获取最近的三条
gpsHistoryLocationList
.
sort
((
o1
,
o2
)
->
{
long
o1Time
=
DateUtil
.
parseDateTime
(
o1
.
getDateTime
()).
getTime
();
long
o2Time
=
DateUtil
.
parseDateTime
(
o2
.
getDateTime
()).
getTime
();
if
(
o1Time
>
o2Time
)
{
return
-
1
;
}
else
{
return
1
;
if
(
Objects
.
nonNull
(
gpsLocation
))
{
// 获取最后一个GPS位置点的时间
String
gpsTime
=
gpsLocation
.
getDateTime
();
if
(
StringUtils
.
isNotEmpty
(
gpsTime
))
{
Date
gpsEndTime
=
DateUtils
.
addDateDays
(
DateUtil
.
parseDateTime
(
gpsTime
),
1
);
// 获取结束时间 开始时间向前推一个月
Date
gpsStartTime
=
DateUtils
.
addDateDays
(
gpsEndTime
,
-
30
);
// 查询GPS记录数据 (时间范围为从查询起的一个月)
log
.
info
(
"设备号:"
+
sn
+
";开始时间:"
+
DateUtil
.
formatDateTime
(
gpsStartTime
));
log
.
info
(
"设备号:"
+
sn
+
";结束时间:"
+
DateUtil
.
formatDateTime
(
gpsEndTime
));
List
<
DataGpsLocation
>
gpsHistoryLocationList
=
hdaoGpsComponent
.
getDeviceHistoryLocation
(
sn
,
deviceTypeRelationEnum
,
DateUtil
.
formatDateTime
(
gpsStartTime
),
DateUtil
.
formatDateTime
(
gpsEndTime
));
// 对list进行排序 并获取最近的三条
gpsHistoryLocationList
.
sort
((
o1
,
o2
)
->
{
long
o1Time
=
DateUtil
.
parseDateTime
(
o1
.
getDateTime
()).
getTime
();
long
o2Time
=
DateUtil
.
parseDateTime
(
o2
.
getDateTime
()).
getTime
();
if
(
o1Time
>
o2Time
)
{
return
-
1
;
}
else
{
return
1
;
}
});
if
(
gpsHistoryLocationList
.
size
()
>
3
)
{
deviceInformationDTO
.
setLastThreeGPSRecord
(
gpsHistoryLocationList
.
subList
(
0
,
3
));
}
else
{
deviceInformationDTO
.
setLastThreeGPSRecord
(
gpsHistoryLocationList
);
}
}
});
if
(
gpsHistoryLocationList
.
size
()
>
3
)
{
deviceInformationDTO
.
setLastThreeGPSRecord
(
gpsHistoryLocationList
.
subList
(
0
,
3
));
}
else
{
deviceInformationDTO
.
setLastThreeGPSRecord
(
gpsHistoryLocationList
);
}
DataBsLocation
deviceLastBsInfo
=
hdaoGpsComponent
.
getDeviceLastBsInfo
(
sn
,
deviceTypeRelationEnum
);
// 获取最后一个基站位置点时间
String
bsTime
=
deviceLastBsInfo
.
getGpsTime
();
Date
bsEndTime
=
DateUtils
.
addDateDays
(
DateUtil
.
parseDateTime
(
bsTime
),
1
);
// 获取结束时间 开始时间向前推一个月
Date
bsStartTime
=
DateUtils
.
addDateDays
(
bsEndTime
,
-
30
);
// 查询基站记录数据 (时间范围为从查询起的一个月)
List
<
BaseStationModel
>
baseStationPointList
=
hdaoGpsComponent
.
getBaseStationPoint
(
sn
,
deviceTypeRelationEnum
.
getDataDeviceType
(),
DateUtil
.
formatDateTime
(
bsStartTime
),
DateUtil
.
formatDateTime
(
bsEndTime
));
// 对list进行排序 并获取最近的三条
baseStationPointList
.
sort
((
o1
,
o2
)
->
{
long
o1Time
=
DateUtil
.
parseDateTime
(
o1
.
getTime
()).
getTime
();
long
o2Time
=
DateUtil
.
parseDateTime
(
o2
.
getTime
()).
getTime
();
if
(
o1Time
>
o2Time
)
{
return
-
1
;
}
else
{
return
1
;
if
(
Objects
.
nonNull
(
deviceLastBsInfo
))
{
// 获取最后一个基站位置点时间
String
bsTime
=
deviceLastBsInfo
.
getGpsTime
();
if
(
StringUtils
.
isNotEmpty
(
bsTime
))
{
Date
bsEndTime
=
DateUtils
.
addDateDays
(
DateUtil
.
parseDateTime
(
bsTime
),
1
);
// 获取结束时间 开始时间向前推一个月
Date
bsStartTime
=
DateUtils
.
addDateDays
(
bsEndTime
,
-
30
);
// 查询基站记录数据 (时间范围为从查询起的一个月)
List
<
BaseStationModel
>
baseStationPointList
=
hdaoGpsComponent
.
getBaseStationPoint
(
sn
,
deviceTypeRelationEnum
.
getDataDeviceType
(),
DateUtil
.
formatDateTime
(
bsStartTime
),
DateUtil
.
formatDateTime
(
bsEndTime
));
// 对list进行排序 并获取最近的三条
baseStationPointList
.
sort
((
o1
,
o2
)
->
{
long
o1Time
=
DateUtil
.
parseDateTime
(
o1
.
getTime
()).
getTime
();
long
o2Time
=
DateUtil
.
parseDateTime
(
o2
.
getTime
()).
getTime
();
if
(
o1Time
>
o2Time
)
{
return
-
1
;
}
else
{
return
1
;
}
});
if
(
baseStationPointList
.
size
()
>
3
)
{
deviceInformationDTO
.
setLastThreeBSRecord
(
baseStationPointList
.
subList
(
0
,
3
));
}
else
{
deviceInformationDTO
.
setLastThreeBSRecord
(
baseStationPointList
);
}
}
});
if
(
baseStationPointList
.
size
()
>
3
)
{
deviceInformationDTO
.
setLastThreeBSRecord
(
baseStationPointList
.
subList
(
0
,
3
));
}
else
{
deviceInformationDTO
.
setLastThreeBSRecord
(
baseStationPointList
);
}
// 获取光感和断电数据
...
...
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