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 ef47dac0
authored
Dec 24, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化设备离线的查询方式
1 parent
d1ab5ee9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
8 deletions
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleMapper.java
src/main/java/cn/com/glsx/admin/modules/service/HomeService.java
src/main/resources/mapper/VehicleMapper.xml
src/main/java/cn/com/glsx/admin/modules/mapper/VehicleMapper.java
View file @
ef47dac
...
...
@@ -191,4 +191,14 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
*/
@DataPerm
(
showSql
=
true
)
List
<
DeviceBindVo
>
getBindDeviceInfoWithAuth
(
@Param
(
"appendSql"
)
String
appendSql
);
/**
* 统计设备离线数
*
* @param
* @param offlineSnList 不计算离线的设备集合
* @param offlineTime 离线时间
* @return
*/
Integer
getOfflineNumber
(
@Param
(
"offlineSnList"
)
List
<
String
>
offlineSnList
,
@Param
(
"offlineTime"
)
long
offlineTime
);
}
\ No newline at end of file
src/main/java/cn/com/glsx/admin/modules/service/HomeService.java
View file @
ef47dac
...
...
@@ -12,7 +12,6 @@ import cn.com.glsx.admin.modules.remote.RemoteDeviceLoginService;
import
cn.com.glsx.admin.modules.remote.RemoteStuJudgeAlarmService
;
import
cn.com.glsx.admin.modules.utils.DateUtil
;
import
cn.com.glsx.auth.utils.ShieldContextHolder
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.glsx.plat.common.utils.DateUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.context.utils.PropertiesUtils
;
...
...
@@ -87,14 +86,11 @@ public class HomeService {
// 设备离线计算时间
long
offlineTime
=
Constants
.
OFFLINE_TIME_OTHER
;
//设备离线数 获取该账户权限下 所以设备号集合
List
<
String
>
sns
=
vehicleMapper
.
getAllDeviceSnByAuth
();
// 获取不计算离线的设备列表(并同时将该设备计算为在线设备数量) by 杨林龙
String
offlineSnStr
=
PropertiesUtils
.
getProperty
(
"uncalculated.offline.device.sns"
);
if
(
CollectionUtil
.
isNotEmpty
(
sns
)
&&
StringUtils
.
isNotEmpty
(
offlineSnStr
))
{
List
<
String
>
offlineSnList
=
Arrays
.
asList
(
offlineSnStr
.
split
(
","
));
// 从所有设备列表中 去掉不计算离线的设备列表
sns
.
removeAll
(
offlineSnList
);
List
<
String
>
offlineSnList
=
Lists
.
newArrayList
();
if
(
StringUtils
.
isNotEmpty
(
offlineSnStr
))
{
offlineSnList
=
Arrays
.
asList
(
offlineSnStr
.
split
(
","
));
// 仲利组织下显示白名单车辆数量
String
zhongLiTenantId
=
PropertiesUtils
.
getProperty
(
"zhongli.tenant.id"
);
if
(
StringUtils
.
isNotEmpty
(
zhongLiTenantId
)
&&
ShieldContextHolder
.
getTenantId
()
==
Long
.
parseLong
(
zhongLiTenantId
))
{
...
...
@@ -104,7 +100,7 @@ public class HomeService {
}
// 调用警情微服务查询老E盾库中设备离线数量
Integer
offlineNumber
=
remoteDeviceLoginService
.
getOfflineNumber
(
sns
,
offlineTime
);
Integer
offlineNumber
=
vehicleMapper
.
getOfflineNumber
(
offlineSnList
,
offlineTime
);
returnMap
.
put
(
"offlineNumber"
,
offlineNumber
);
//设备在线数
int
onlineNumber
=
allActiveNumber
-
offlineNumber
;
...
...
src/main/resources/mapper/VehicleMapper.xml
View file @
ef47dac
...
...
@@ -745,4 +745,25 @@
) temp
GROUP BY DATE_FORMAT(temp.created_date, '%Y-%m-%d')
</select>
<select
id=
"getOfflineNumber"
>
select COUNT(1) offlineNumber
from t_vehicle tv
left join t_vehicle_device tvd on tvd.vehicle_id = tv.id
left join t_device td on td.sn = tvd.sn
left join t_device_location tdl on tdl.sn = td.sn
WHERE
and (
(timestampdiff(SECOND, tdl.last_gps_time, now())
>
#{offlineTime}
and timestampdiff(SECOND, tdl.last_bs_time, now())
>
#{offlineTime} and td.source = 1)
or
(timestampdiff(SECOND, tdl.last_bs_time, now())
>
#{offlineTime} and td.source = 0)
)
<if
test=
"offlineSnList!=null and offlineSnList.size()>0"
>
and tvd.sn not in
<foreach
collection=
"offlineSnList"
item=
"sn"
open=
"("
separator=
","
close=
")"
>
#{sn}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
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