Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
self-service
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
廖旭伟
self-service
Commits
4f4fefd8
Commit
4f4fefd8
authored
Jan 17, 2024
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加门户用户同步任务
parent
3d4c5398
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
108 additions
and
0 deletions
+108
-0
sst-manager/db/add_db.sql
sst-manager/db/add_db.sql
+5
-0
sst-manager/src/main/java/com/mortals/xhx/daemon/task/SyncPortalUserTaskImpl.java
...a/com/mortals/xhx/daemon/task/SyncPortalUserTaskImpl.java
+103
-0
No files found.
sst-manager/db/add_db.sql
View file @
4f4fefd8
...
...
@@ -311,3 +311,8 @@ PRIMARY KEY (`id`)
INSERT
INTO
`mortals_xhx_param`
(
`name`
,
`firstOrganize`
,
`secondOrganize`
,
`paramKey`
,
`paramValue`
,
`validStatus`
,
`modStatus`
,
`displayType`
,
`remark`
,
`createTime`
,
`createUserId`
,
`createUserName`
)
VALUES
(
'综窗服务器http'
,
NULL
,
NULL
,
'server_cws_http_url'
,
'http://192.168.0.252:21086'
,
'1'
,
'4'
,
'0'
,
NULL
,
NULL
,
NULL
,
NULL
);
-- ----------
-- 门户用户同步(2024-01-17)
-- ----------
INSERT
INTO
`mortals_xhx_task`
(
`name`
,
`taskKey`
,
`status`
,
`excuteService`
,
`excuteParam`
,
`excuteHost`
,
`excuteStrategy`
,
`excuteDate`
,
`excuteTime`
,
`remark`
,
`lastExcuteHost`
,
`lastExcuteTime`
,
`interimExcuteStatus`
,
`createTime`
,
`createUserId`
,
`createUserName`
)
VALUES
(
'同步门户用户'
,
'SyncPortalUserTask'
,
'0'
,
'SyncPortalUserTask'
,
NULL
,
NULL
,
'1'
,
'0'
,
'22:01'
,
NULL
,
'172.17.0.1'
,
'2024-01-16 22:01:01'
,
'0'
,
'2023-08-24 22:29:18'
,
'1'
,
'系统管理员'
);
sst-manager/src/main/java/com/mortals/xhx/daemon/task/SyncPortalUserTaskImpl.java
0 → 100644
View file @
4f4fefd8
package
com.mortals.xhx.daemon.task
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.ITask
;
import
com.mortals.framework.service.ITaskExcuteService
;
import
com.mortals.xhx.base.system.user.model.UserEntity
;
import
com.mortals.xhx.base.system.user.model.UserQuery
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.pdu.RespData
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
;
/**
* 同步门户用户
*/
@Slf4j
@Service
(
"SyncPortalUserTask"
)
public
class
SyncPortalUserTaskImpl
implements
ITaskExcuteService
{
@Autowired
private
IUserFeign
userFeign
;
@Autowired
private
UserService
userService
;
@Override
public
void
excuteTask
(
ITask
task
)
throws
AppException
{
try
{
log
.
info
(
"同步门户用户"
);
syncPersons
();
}
catch
(
Exception
e
)
{
log
.
error
(
"同步门户异常"
,
e
);
}
}
private
void
syncPersons
()
{
UserPdu
userPdu
=
new
UserPdu
();
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
Map
<
String
,
UserEntity
>
oldUserMap
=
oldUserList
.
parallelStream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getLoginName
(),
y
->
y
,
(
o
,
n
)
->
n
));
//门户用户map
// 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
);
});
}
}
//查找新增 与更新
}
}
@Override
public
void
stopTask
(
ITask
task
)
throws
AppException
{
}
}
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