Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
smart_gov_platform
Commits
5397242e
Commit
5397242e
authored
Jun 21, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加应用分类列表
parent
ed321a24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
4 deletions
+72
-4
base-manager/src/main/java/com/mortals/xhx/base/system/user/service/impl/UserServiceImpl.java
...ls/xhx/base/system/user/service/impl/UserServiceImpl.java
+53
-2
base-manager/src/main/java/com/mortals/xhx/common/utils/SyncTreeSiteThread.java
...java/com/mortals/xhx/common/utils/SyncTreeSiteThread.java
+19
-2
No files found.
base-manager/src/main/java/com/mortals/xhx/base/system/user/service/impl/UserServiceImpl.java
View file @
5397242e
...
...
@@ -296,8 +296,59 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
@Override
public
void
updateUserList
(
List
<
UserPdu
>
list
)
{
//更新本地用户信息,并且更新用户站点树
//更新本地用户信息,并且更新用户站点树 //todo 将站点分组后 分组同步更新
List
<
String
>
loginNames
=
list
.
parallelStream
().
map
(
user
->
user
.
getLoginName
()).
collect
(
Collectors
.
toList
());
UserQuery
userQuery
=
new
UserQuery
();
userQuery
.
setLoginNameList
(
loginNames
);
List
<
UserEntity
>
existUsers
=
this
.
find
(
userQuery
);
Map
<
String
,
UserEntity
>
existUserMap
=
existUsers
.
parallelStream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getLoginName
(),
y
->
y
,
(
o
,
n
)
->
n
));
//分组查找存在的与不存在的用户
Map
<
Boolean
,
List
<
UserPdu
>>
collect
=
list
.
parallelStream
().
collect
(
Collectors
.
partitioningBy
(
x
->
existUserMap
.
containsKey
(
x
.
getLoginName
())));
List
<
UserPdu
>
userPdusUpdate
=
collect
.
get
(
true
);
//更新
List
<
UserEntity
>
userEntityUpdate
=
new
ArrayList
<>();
List
<
UserPdu
>
userPdusSave
=
collect
.
get
(
false
);
//新增
List
<
UserEntity
>
userEntitySave
=
new
ArrayList
<>();
for
(
UserPdu
user
:
userPdusSave
)
{
//新增
UserEntity
entity
=
new
UserEntity
();
entity
.
initAttrValue
();
BeanUtils
.
copyProperties
(
user
,
entity
,
BeanUtil
.
getNullPropertyNames
(
user
));
this
.
save
(
entity
);
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getSiteIds
()))
{
userEntitySave
.
add
(
entity
);
}
}
for
(
UserPdu
user
:
userPdusUpdate
)
{
//更新
UserEntity
userEntity
=
new
UserEntity
();
BeanUtils
.
copyProperties
(
user
,
userEntity
,
new
String
[]{
"loginPwd"
,
"loginName"
,
"userType"
,
"status"
,
"lastLoginTime"
,
"lastLoginAddress"
});
userEntity
.
setId
(
existUserMap
.
get
(
user
.
getLoginName
()).
getId
());
this
.
updateWidthDao
(
userEntity
);
if
(!
ObjectUtils
.
isEmpty
(
userEntity
.
getSiteIds
()))
{
userEntitySave
.
add
(
userEntity
);
}
}
//分组刷新节点 新增
Map
<
String
,
List
<
UserEntity
>>
saveSitesCollect
=
userEntitySave
.
stream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getSiteIds
()));
// Map<String, List<UserEntity>> updateSitesCollect = userEntityUpdate.stream().collect(Collectors.groupingBy(x -> x.getSiteIds()));
saveSitesCollect
.
entrySet
().
stream
().
forEach
(
item
->
{
String
siteIds
=
item
.
getKey
();
List
<
UserEntity
>
userEntities
=
item
.
getValue
();
if
(!
ObjectUtils
.
isEmpty
(
userEntities
))
{
Context
context
=
new
Context
();
context
.
setUser
(
userEntities
.
get
(
0
));
ThreadPool
.
getInstance
().
execute
(
new
SyncTreeSiteThread
(
context
,
userEntities
));
}
});
/*
//如果用户未有所属站点 则不更新
for (UserPdu user : list) {
UserEntity tempUser = this.selectOne(new UserQuery().loginName(user.getLoginName()));
...
...
@@ -324,7 +375,7 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
ThreadPool.getInstance().execute(new SyncTreeSiteThread(context));
}
}
}
}
*/
}
...
...
base-manager/src/main/java/com/mortals/xhx/common/utils/SyncTreeSiteThread.java
View file @
5397242e
...
...
@@ -2,10 +2,13 @@ package com.mortals.xhx.common.utils;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.model.Context
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.module.site.model.SiteTreeSelect
;
import
com.mortals.xhx.module.site.service.SiteService
;
import
com.mortals.xhx.utils.SpringUtils
;
import
lombok.AllArgsConstructor
;
import
lombok.NonNull
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.apachecommons.CommonsLog
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.util.ObjectUtils
;
...
...
@@ -18,16 +21,30 @@ import java.util.List;
* @description:
**/
@AllArgsConstructor
@RequiredArgsConstructor
@Slf4j
public
class
SyncTreeSiteThread
implements
Runnable
{
@NonNull
private
Context
context
;
private
List
<
UserEntity
>
userEntities
;
@Override
public
void
run
()
{
SiteService
siteService
=
SpringUtils
.
getBean
(
SiteService
.
class
);
List
<
SiteTreeSelect
>
siteTreeSelects
=
siteService
.
siteTree
(
context
);
siteService
.
setSiteTree
(
siteTreeSelects
,
context
);
if
(
ObjectUtils
.
isEmpty
(
userEntities
)){
siteService
.
setSiteTree
(
siteTreeSelects
,
context
);
}
else
{
for
(
UserEntity
userEntity
:
userEntities
)
{
Context
contextTemp
=
new
Context
();
contextTemp
.
setUser
(
userEntity
);
siteService
.
setSiteTree
(
siteTreeSelects
,
contextTemp
);
}
}
// log.info("刷新用户站点树=》userID:{} siteIds:{} siteTree:{}",context.getUser().getId(),context.getUser().getSiteIds(), JSON.toJSONString(siteService.getSiteTree(context)));
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment