Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-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
赵啸非
device-new-platform
Commits
9c2ee29c
Commit
9c2ee29c
authored
May 27, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加智慧办公回调信息
parent
31f22b7c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
4 deletions
+46
-4
device-manager/src/main/java/com/mortals/xhx/daemon/task/SyncUserTaskImpl.java
...in/java/com/mortals/xhx/daemon/task/SyncUserTaskImpl.java
+46
-4
No files found.
device-manager/src/main/java/com/mortals/xhx/daemon/task/SyncUserTaskImpl.java
View file @
9c2ee29c
package
com.mortals.xhx.daemon.task
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ITask
;
...
...
@@ -19,7 +18,10 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 同步用户,唯一标识为用户名。
...
...
@@ -41,10 +43,50 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
userPdu
.
setPage
(
1
);
userPdu
.
setSize
(-
1
);
Rest
<
RespData
<
List
<
UserPdu
>>>
resp
=
userFeign
.
list
(
userPdu
);
if
(
resp
.
getCode
()
==
YesNoEnum
.
YES
.
getValue
())
{
List
<
UserPdu
>
userPduList
=
resp
.
getData
().
getData
();
log
.
info
(
"用户总数量:{}"
,
userPduList
.
size
());
if
(!
ObjectUtils
.
isEmpty
(
userPduList
))
{
List
<
UserEntity
>
newUserList
=
userPduList
.
stream
().
map
(
newUser
->
{
UserEntity
userEntity
=
new
UserEntity
();
userEntity
.
initAttrValue
();
BeanUtils
.
copyProperties
(
newUser
,
userEntity
,
new
String
[]{
"id"
,
"lastLoginTime"
,
"lastLoginAddress"
});
return
userEntity
;
}).
collect
(
Collectors
.
toList
());
List
<
UserEntity
>
oldUserList
=
userService
.
find
(
new
UserQuery
());
log
.
info
(
" oldUserList size:{}"
,
oldUserList
.
size
());
Map
<
String
,
UserEntity
>
oldUserMap
=
oldUserList
.
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getLoginName
(),
y
->
y
,
(
o
,
n
)
->
n
));
Map
<
String
,
UserEntity
>
newUserMap
=
newUserList
.
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getLoginName
(),
y
->
y
,
(
o
,
n
)
->
n
));
List
<
UserEntity
>
saveUserList
=
newUserList
.
stream
().
map
(
item
->
{
if
(!
oldUserMap
.
containsKey
(
item
.
getLoginName
()))
{
item
.
setCreateUserId
(
1L
);
item
.
setCreateUserName
(
"系统管理员"
);
item
.
setCreateTime
(
new
Date
());
return
item
;
}
return
null
;
}).
filter
(
f
->
f
!=
null
).
collect
(
Collectors
.
toList
());
if
(!
ObjectUtils
.
isEmpty
(
saveUserList
))
{
log
.
info
(
"用户新增,size:{}"
,
saveUserList
.
size
());
saveUserList
.
stream
().
forEach
(
item
->{
userService
.
getUserDao
().
insert
(
item
);
});
//userService.save(saveUserList);
}
}
//查找新增 与更新
//同步更新用户,以loginname为唯一标识,密码默认与用户相同
resp
.
getData
().
getData
().
forEach
(
user
->
{
/*
resp.getData().getData().forEach(user -> {
log.info("loginName:{}", user.getLoginName());
UserEntity tempEntity = userService.selectOne(new UserQuery().loginName(user.getLoginName()));
if (ObjectUtils.isEmpty(tempEntity)) {
...
...
@@ -59,7 +101,7 @@ public class SyncUserTaskImpl implements ITaskExcuteService {
log.info("更新:{}", JSON.toJSONString(userEntity));
userService.getUserDao().update(userEntity);
}
});
});
*/
}
// log.info("syncUserResp:{}", JSON.toJSONString(resp));
...
...
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