Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
syncData
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenzy
syncData
Commits
37fc7968
Commit
37fc7968
authored
Apr 24, 2025
by
chenzy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改】抽取数据过滤,分页处理
parent
9aef130e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
DataSyncActor.java
...main/java/com/keymobile/syncdata/actor/DataSyncActor.java
+8
-5
SyncDataController.java
...n/java/com/keymobile/syncdata/api/SyncDataController.java
+8
-4
No files found.
src/main/java/com/keymobile/syncdata/actor/DataSyncActor.java
View file @
37fc7968
...
...
@@ -9,7 +9,6 @@ import com.keymobile.syncdata.util.SpringUtil;
import
lombok.extern.slf4j.Slf4j
;
import
org.bson.Document
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
java.io.IOException
;
...
...
@@ -39,7 +38,6 @@ public class DataSyncActor extends AbstractActor {
}
public
void
syncData
(
SyncDataMessage
syncDataMessage
)
{
handleUserData
();
// 抽取所有数据
...
...
@@ -112,20 +110,25 @@ public class DataSyncActor extends AbstractActor {
Map
<
String
,
Object
>
map
=
null
;
try
{
map
=
objectMapper
.
readValue
(
rows
.
toString
(),
Map
.
class
);
String
deptid
=
(
String
)
map
.
get
(
"DEPTID"
);
String
username
=
(
String
)
map
.
get
(
"NAME"
);
String
hr_status
=
(
String
)
map
.
getOrDefault
(
"HR_STATUS"
,
"I"
);
String
eff_status
=
(
String
)
map
.
getOrDefault
(
"EFF_STATUS"
,
"I"
);
if
(
"A"
.
equals
(
hr_status
)
||
"A"
.
equals
(
eff_status
))
{
String
deptid
=
(
String
)
map
.
get
(
"DEPTID"
);
String
username
=
(
String
)
map
.
get
(
"NAME"
);
String
userId
=
String
.
valueOf
(
map
.
get
(
"USER_ID"
));
String
deptName
=
orgMapIdAndName
.
get
(
deptid
);
String
oaAccount
=
(
String
)
map
.
get
(
"OA_ACCOUNT"
);
map
.
put
(
"DEPT_NAME"
,
deptName
);
map
.
put
(
"search"
,
oaAccount
+
":"
+
userId
+
":"
+
username
+
":"
+
":"
+
deptName
+
":"
+
deptid
);
urlList
.
add
(
map
);
}
}
catch
(
JsonProcessingException
e
)
{
throw
new
RuntimeException
(
e
);
}
});
}
}
// 处理用户数据,根据机构编号,查机构名称DEPT_NAME
private
void
handleUserData
()
{
Query
query
=
new
Query
();
...
...
@@ -137,7 +140,7 @@ public class DataSyncActor extends AbstractActor {
log
.
info
(
"机构数据未同步,为空"
);
return
;
}
orgMapIdAndName
=
documentList
.
stream
().
collect
(
Collectors
.
toMap
(
each
->(
String
)
each
.
get
(
"DEPT_ID"
),
each
->(
String
)
each
.
get
(
"DEPT_DESC"
),(
key1
,
key2
)->
key1
));
orgMapIdAndName
=
documentList
.
stream
().
collect
(
Collectors
.
toMap
(
each
->
(
String
)
each
.
get
(
"DEPT_ID"
),
each
->
(
String
)
each
.
get
(
"DEPT_DESC"
),
(
key1
,
key2
)
->
key1
));
}
}
src/main/java/com/keymobile/syncdata/api/SyncDataController.java
View file @
37fc7968
...
...
@@ -75,8 +75,9 @@ public class SyncDataController {
String
deptId
=
(
String
)
map
.
get
(
"DEPT_ID"
);
String
partDeptId
=
(
String
)
map
.
get
(
"PART_DEPT_ID"
);
String
deptDesc
=
(
String
)
map
.
get
(
"DEPT_DESC"
);
String
order_num
=
String
.
valueOf
(
map
.
get
(
"ORDER_NUM"
));
TreeNode
<
String
>
longTreeNode
=
new
TreeNode
<>(
deptId
,
partDeptId
,
deptDesc
,
0
);
TreeNode
<
String
>
longTreeNode
=
new
TreeNode
<>(
deptId
,
partDeptId
,
deptDesc
,
order_num
);
HashMap
<
String
,
Object
>
hashMap
=
new
HashMap
<>();
longTreeNode
.
setExtra
(
hashMap
);
nodeList
.
add
(
longTreeNode
);
...
...
@@ -92,13 +93,16 @@ public class SyncDataController {
tree
.
setId
((
String
)
treeNode
.
getId
());
tree
.
setParentId
((
String
)
treeNode
.
getParentId
());
tree
.
setName
(
treeNode
.
getName
());
Comparable
weight
=
treeNode
.
getWeight
();
tree
.
setWeight
(
weight
);
tree
.
putAll
(
treeNode
.
getExtra
());
});
return
build
;
}
@GetMapping
(
"/getUserByOrgId"
)
public
Page
<
Document
>
getUserByOrgId
(
@RequestParam
String
orgId
,
@RequestParam
(
defaultValue
=
"0"
)
Integer
pageNum
ber
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
pageSize
)
{
public
Page
<
Document
>
getUserByOrgId
(
@RequestParam
String
orgId
,
@RequestParam
(
defaultValue
=
"0"
)
Integer
pageNum
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
pageSize
)
{
// 查询orgID及其子节点
Queue
<
String
>
queue
=
new
LinkedList
<>();
List
<
String
>
list
=
new
ArrayList
<>();
...
...
@@ -114,7 +118,7 @@ public class SyncDataController {
query
.
fields
().
exclude
(
"_id"
);
query
.
with
(
org
.
springframework
.
data
.
domain
.
Sort
.
by
(
org
.
springframework
.
data
.
domain
.
Sort
.
Direction
.
ASC
,
"DEPT_ID"
));
Long
total
=
mongoTemplate
.
count
(
query
,
Document
.
class
,
"sync_user_data"
);
Pageable
pageable
=
PageRequest
.
of
(
pageNum
ber
,
pageSize
);
Pageable
pageable
=
PageRequest
.
of
(
pageNum
-
1
,
pageSize
);
query
.
with
(
pageable
);
List
<
Document
>
documents
=
mongoTemplate
.
find
(
query
,
Document
.
class
,
"sync_user_data"
);
...
...
@@ -130,7 +134,7 @@ public class SyncDataController {
query
.
addCriteria
(
Criteria
.
where
(
"search"
).
regex
(
search
));
}
Long
total
=
mongoTemplate
.
count
(
query
,
Document
.
class
,
"sync_user_data"
);
Pageable
pageable
=
PageRequest
.
of
(
pageNumber
,
pageSize
);
Pageable
pageable
=
PageRequest
.
of
(
pageNumber
-
1
,
pageSize
);
query
.
with
(
pageable
);
List
<
Document
>
documents
=
mongoTemplate
.
find
(
query
,
Document
.
class
,
"sync_user_data"
);
return
PageableExecutionUtils
.
getPage
(
documents
,
pageable
,
()
->
total
);
...
...
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