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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
16 deletions
+23
-16
DataSyncActor.java
...main/java/com/keymobile/syncdata/actor/DataSyncActor.java
+14
-11
SyncDataController.java
...n/java/com/keymobile/syncdata/api/SyncDataController.java
+9
-5
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;
...
@@ -9,7 +9,6 @@ import com.keymobile.syncdata.util.SpringUtil;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.bson.Document
;
import
org.bson.Document
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Query
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -39,7 +38,6 @@ public class DataSyncActor extends AbstractActor {
...
@@ -39,7 +38,6 @@ public class DataSyncActor extends AbstractActor {
}
}
public
void
syncData
(
SyncDataMessage
syncDataMessage
)
{
public
void
syncData
(
SyncDataMessage
syncDataMessage
)
{
handleUserData
();
handleUserData
();
// 抽取所有数据
// 抽取所有数据
...
@@ -112,20 +110,25 @@ public class DataSyncActor extends AbstractActor {
...
@@ -112,20 +110,25 @@ public class DataSyncActor extends AbstractActor {
Map
<
String
,
Object
>
map
=
null
;
Map
<
String
,
Object
>
map
=
null
;
try
{
try
{
map
=
objectMapper
.
readValue
(
rows
.
toString
(),
Map
.
class
);
map
=
objectMapper
.
readValue
(
rows
.
toString
(),
Map
.
class
);
String
deptid
=
(
String
)
map
.
get
(
"DEPTID"
);
String
hr_status
=
(
String
)
map
.
getOrDefault
(
"HR_STATUS"
,
"I"
);
String
username
=
(
String
)
map
.
get
(
"NAME"
);
String
eff_status
=
(
String
)
map
.
getOrDefault
(
"EFF_STATUS"
,
"I"
);
String
userId
=
String
.
valueOf
(
map
.
get
(
"USER_ID"
));
if
(
"A"
.
equals
(
hr_status
)
||
"A"
.
equals
(
eff_status
))
{
String
deptName
=
orgMapIdAndName
.
get
(
deptid
);
String
deptid
=
(
String
)
map
.
get
(
"DEPTID"
);
String
oaAccount
=
(
String
)
map
.
get
(
"OA_ACCOUNT"
);
String
username
=
(
String
)
map
.
get
(
"NAME"
);
map
.
put
(
"DEPT_NAME"
,
deptName
);
String
userId
=
String
.
valueOf
(
map
.
get
(
"USER_ID"
));
map
.
put
(
"search"
,
oaAccount
+
":"
+
userId
+
":"
+
username
+
":"
+
":"
+
deptName
+
":"
+
deptid
);
String
deptName
=
orgMapIdAndName
.
get
(
deptid
);
urlList
.
add
(
map
);
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
)
{
}
catch
(
JsonProcessingException
e
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
});
});
}
}
}
}
// 处理用户数据,根据机构编号,查机构名称DEPT_NAME
// 处理用户数据,根据机构编号,查机构名称DEPT_NAME
private
void
handleUserData
()
{
private
void
handleUserData
()
{
Query
query
=
new
Query
();
Query
query
=
new
Query
();
...
@@ -137,7 +140,7 @@ public class DataSyncActor extends AbstractActor {
...
@@ -137,7 +140,7 @@ public class DataSyncActor extends AbstractActor {
log
.
info
(
"机构数据未同步,为空"
);
log
.
info
(
"机构数据未同步,为空"
);
return
;
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 {
...
@@ -75,8 +75,9 @@ public class SyncDataController {
String
deptId
=
(
String
)
map
.
get
(
"DEPT_ID"
);
String
deptId
=
(
String
)
map
.
get
(
"DEPT_ID"
);
String
partDeptId
=
(
String
)
map
.
get
(
"PART_DEPT_ID"
);
String
partDeptId
=
(
String
)
map
.
get
(
"PART_DEPT_ID"
);
String
deptDesc
=
(
String
)
map
.
get
(
"DEPT_DESC"
);
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
<>();
HashMap
<
String
,
Object
>
hashMap
=
new
HashMap
<>();
longTreeNode
.
setExtra
(
hashMap
);
longTreeNode
.
setExtra
(
hashMap
);
nodeList
.
add
(
longTreeNode
);
nodeList
.
add
(
longTreeNode
);
...
@@ -92,13 +93,16 @@ public class SyncDataController {
...
@@ -92,13 +93,16 @@ public class SyncDataController {
tree
.
setId
((
String
)
treeNode
.
getId
());
tree
.
setId
((
String
)
treeNode
.
getId
());
tree
.
setParentId
((
String
)
treeNode
.
getParentId
());
tree
.
setParentId
((
String
)
treeNode
.
getParentId
());
tree
.
setName
(
treeNode
.
getName
());
tree
.
setName
(
treeNode
.
getName
());
Comparable
weight
=
treeNode
.
getWeight
();
tree
.
setWeight
(
weight
);
tree
.
putAll
(
treeNode
.
getExtra
());
tree
.
putAll
(
treeNode
.
getExtra
());
});
});
return
build
;
return
build
;
}
}
@GetMapping
(
"/getUserByOrgId"
)
@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及其子节点
// 查询orgID及其子节点
Queue
<
String
>
queue
=
new
LinkedList
<>();
Queue
<
String
>
queue
=
new
LinkedList
<>();
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
list
=
new
ArrayList
<>();
...
@@ -114,7 +118,7 @@ public class SyncDataController {
...
@@ -114,7 +118,7 @@ public class SyncDataController {
query
.
fields
().
exclude
(
"_id"
);
query
.
fields
().
exclude
(
"_id"
);
query
.
with
(
org
.
springframework
.
data
.
domain
.
Sort
.
by
(
org
.
springframework
.
data
.
domain
.
Sort
.
Direction
.
ASC
,
"DEPT_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"
);
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
);
query
.
with
(
pageable
);
List
<
Document
>
documents
=
mongoTemplate
.
find
(
query
,
Document
.
class
,
"sync_user_data"
);
List
<
Document
>
documents
=
mongoTemplate
.
find
(
query
,
Document
.
class
,
"sync_user_data"
);
...
@@ -123,14 +127,14 @@ public class SyncDataController {
...
@@ -123,14 +127,14 @@ public class SyncDataController {
}
}
@GetMapping
(
"/getAllSyncUser"
)
@GetMapping
(
"/getAllSyncUser"
)
public
Page
<
Document
>
getAllSyncUser
(
@RequestParam
(
required
=
false
)
String
search
,
@RequestParam
(
defaultValue
=
"0"
)
Integer
pageNumber
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
pageSize
)
{
public
Page
<
Document
>
getAllSyncUser
(
@RequestParam
(
required
=
false
)
String
search
,
@RequestParam
(
defaultValue
=
"0"
)
Integer
pageNumber
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
pageSize
)
{
Query
query
=
new
Query
();
Query
query
=
new
Query
();
query
.
fields
().
exclude
(
"_id"
);
query
.
fields
().
exclude
(
"_id"
);
if
(
search
!=
null
&&
!
search
.
isEmpty
())
{
if
(
search
!=
null
&&
!
search
.
isEmpty
())
{
query
.
addCriteria
(
Criteria
.
where
(
"search"
).
regex
(
search
));
query
.
addCriteria
(
Criteria
.
where
(
"search"
).
regex
(
search
));
}
}
Long
total
=
mongoTemplate
.
count
(
query
,
Document
.
class
,
"sync_user_data"
);
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
);
query
.
with
(
pageable
);
List
<
Document
>
documents
=
mongoTemplate
.
find
(
query
,
Document
.
class
,
"sync_user_data"
);
List
<
Document
>
documents
=
mongoTemplate
.
find
(
query
,
Document
.
class
,
"sync_user_data"
);
return
PageableExecutionUtils
.
getPage
(
documents
,
pageable
,
()
->
total
);
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