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 aaf141e5
authored
Dec 23, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加用户组织判断
1 parent
fb0a1297
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
12 deletions
src/main/java/cn/com/glsx/admin/modules/controller/HomeController.java
src/main/java/cn/com/glsx/admin/modules/service/HomeService.java
src/main/java/cn/com/glsx/admin/modules/controller/HomeController.java
View file @
aaf141e
...
@@ -40,6 +40,13 @@ public class HomeController {
...
@@ -40,6 +40,13 @@ public class HomeController {
@Autowired
@Autowired
private
HomeService
homeService
;
private
HomeService
homeService
;
@GetMapping
(
"/authuserorg"
)
@ApiOperation
(
value
=
"用户组织鉴权"
)
public
R
<
Map
<
String
,
Boolean
>>
authUserOrg
()
{
Map
<
String
,
Boolean
>
authUserOrgMap
=
homeService
.
authUserOrg
();
return
R
.
ok
().
data
(
authUserOrgMap
);
}
@GetMapping
(
"/getdevicenumber"
)
@GetMapping
(
"/getdevicenumber"
)
@ApiOperation
(
value
=
"查询首页统计数据"
)
@ApiOperation
(
value
=
"查询首页统计数据"
)
public
R
<
Map
<
String
,
Object
>>
getDeviceNumber
()
{
public
R
<
Map
<
String
,
Object
>>
getDeviceNumber
()
{
...
...
src/main/java/cn/com/glsx/admin/modules/service/HomeService.java
View file @
aaf141e
...
@@ -15,6 +15,7 @@ import com.glsx.plat.common.utils.DateUtils;
...
@@ -15,6 +15,7 @@ import com.glsx.plat.common.utils.DateUtils;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.context.utils.PropertiesUtils
;
import
com.glsx.plat.context.utils.PropertiesUtils
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -50,6 +51,16 @@ public class HomeService {
...
@@ -50,6 +51,16 @@ public class HomeService {
private
static
final
String
PARSE_PATTERN
=
"yyyy-MM-dd"
;
private
static
final
String
PARSE_PATTERN
=
"yyyy-MM-dd"
;
public
Map
<
String
,
Boolean
>
authUserOrg
()
{
Map
<
String
,
Boolean
>
authUserOrgMap
=
Maps
.
newHashMap
();
// 判断用户是否是仲利组织
String
zhongLiTenantId
=
PropertiesUtils
.
getProperty
(
"zhongli.tenant.id"
);
if
(
StringUtils
.
isNotEmpty
(
zhongLiTenantId
)
&&
ShieldContextHolder
.
getTenantId
()
==
Long
.
parseLong
(
zhongLiTenantId
))
{
authUserOrgMap
.
put
(
"isZhongLi"
,
true
);
}
return
authUserOrgMap
;
}
public
Map
<
String
,
Object
>
getDeviceNumber
()
{
public
Map
<
String
,
Object
>
getDeviceNumber
()
{
Map
<
String
,
Object
>
returnMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
returnMap
=
new
HashMap
<>();
...
@@ -69,16 +80,8 @@ public class HomeService {
...
@@ -69,16 +80,8 @@ public class HomeService {
int
bindNumForToday
=
bindNumMap
.
get
(
"bindNumForToday"
).
intValue
();
int
bindNumForToday
=
bindNumMap
.
get
(
"bindNumForToday"
).
intValue
();
returnMap
.
put
(
"bindNumForToday"
,
bindNumForToday
);
returnMap
.
put
(
"bindNumForToday"
,
bindNumForToday
);
String
userIdStr
=
PropertiesUtils
.
getProperty
(
"guangqi.userId"
);
// 设备离线计算时间
List
<
String
>
userIds
=
new
ArrayList
<>(
Arrays
.
asList
(
userIdStr
.
split
(
","
)));
long
offlineTime
=
Constants
.
OFFLINE_TIME_OTHER
;
Long
loginUserId
=
ShieldContextHolder
.
getUserId
();
// 广汽的离线和绑定单独计算
long
offlineTime
=
0L
;
if
(
userIds
.
contains
(
String
.
valueOf
(
loginUserId
)))
{
offlineTime
=
Constants
.
OFFLINE_TIME_GQ
;
}
else
{
offlineTime
=
Constants
.
OFFLINE_TIME_OTHER
;
}
//设备离线数 获取该账户权限下 所以设备号集合
//设备离线数 获取该账户权限下 所以设备号集合
List
<
String
>
sns
=
vehicleMapper
.
getAllDeviceSnByAuth
();
List
<
String
>
sns
=
vehicleMapper
.
getAllDeviceSnByAuth
();
...
@@ -88,6 +91,12 @@ public class HomeService {
...
@@ -88,6 +91,12 @@ public class HomeService {
List
<
String
>
offlineSnList
=
Arrays
.
asList
(
offlineSnStr
.
split
(
","
));
List
<
String
>
offlineSnList
=
Arrays
.
asList
(
offlineSnStr
.
split
(
","
));
// 从所有设备列表中 去掉不计算离线的设备列表
// 从所有设备列表中 去掉不计算离线的设备列表
sns
.
removeAll
(
offlineSnList
);
sns
.
removeAll
(
offlineSnList
);
// 仲利组织下显示白名单车辆数量
String
zhongLiTenantId
=
PropertiesUtils
.
getProperty
(
"zhongli.tenant.id"
);
if
(
StringUtils
.
isNotEmpty
(
zhongLiTenantId
)
&&
ShieldContextHolder
.
getTenantId
()
==
Long
.
parseLong
(
zhongLiTenantId
))
{
// 仲利用户显示不计算设备离线数
returnMap
.
put
(
"offlineSnNum"
,
offlineSnList
.
size
());
}
}
}
// 调用警情微服务查询老E盾库中设备离线数量
// 调用警情微服务查询老E盾库中设备离线数量
...
@@ -104,8 +113,6 @@ public class HomeService {
...
@@ -104,8 +113,6 @@ public class HomeService {
String
offlineRate
=
numberFormat
.
format
((
float
)
offlineNumber
/
(
float
)
allActiveNumber
*
100
);
String
offlineRate
=
numberFormat
.
format
((
float
)
offlineNumber
/
(
float
)
allActiveNumber
*
100
);
returnMap
.
put
(
"onlineRate"
,
onlineRate
);
returnMap
.
put
(
"onlineRate"
,
onlineRate
);
returnMap
.
put
(
"offlineRate"
,
offlineRate
);
returnMap
.
put
(
"offlineRate"
,
offlineRate
);
// 仲利用户显示不计算设备离线数
returnMap
.
put
(
"offlineSnNum"
,
0
);
return
returnMap
;
return
returnMap
;
}
}
...
...
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