Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-task-scheduler
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e0939393
authored
Aug 27, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
分批保存数据
1 parent
6be13039
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletions
src/main/java/cn/com/glsx/schedulerjob/task/modules/service/MySimpleJobService.java
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/MySimpleJobServiceTest.java
src/main/java/cn/com/glsx/schedulerjob/task/modules/service/MySimpleJobService.java
View file @
e093939
...
@@ -23,6 +23,9 @@ public class MySimpleJobService {
...
@@ -23,6 +23,9 @@ public class MySimpleJobService {
@Autowired
@Autowired
private
StatisticsDriveClient
statisticsDriveClient
;
private
StatisticsDriveClient
statisticsDriveClient
;
// 分批处理流程
private
static
final
int
BATCH_COUNT
=
100
;
public
void
statisticsDriveDataEveryDay
()
{
public
void
statisticsDriveDataEveryDay
()
{
log
.
info
(
"开始统计数据==="
);
log
.
info
(
"开始统计数据==="
);
R
statisticsDriveR
=
statisticsDriveClient
.
statisticsDriveDataEveryDay
();
R
statisticsDriveR
=
statisticsDriveClient
.
statisticsDriveDataEveryDay
();
...
@@ -41,6 +44,18 @@ public class MySimpleJobService {
...
@@ -41,6 +44,18 @@ public class MySimpleJobService {
}
}
log
.
info
(
"开始保存数据===,数据集合的大小为"
+
statisticsDriveDtoList
.
size
());
log
.
info
(
"开始保存数据===,数据集合的大小为"
+
statisticsDriveDtoList
.
size
());
statisticsDriveClient
.
insertStatisticsDriveList
(
statisticsDriveDtoList
);
// 分批保存数据
int
fragSize
=
statisticsDriveDtoList
.
size
()
/
BATCH_COUNT
;
log
.
info
(
"开始分批保存,有"
+
fragSize
+
"个分片==="
);
for
(
int
i
=
0
;
i
<
fragSize
;
i
++)
{
List
<
StatisticsDriveDto
>
fragStatisticsDriveDtoList
;
if
(
i
!=
fragSize
-
1
)
{
fragStatisticsDriveDtoList
=
statisticsDriveDtoList
.
subList
(
i
*
BATCH_COUNT
,
(
i
+
1
)
*
BATCH_COUNT
);
}
else
{
fragStatisticsDriveDtoList
=
statisticsDriveDtoList
.
subList
(
i
*
BATCH_COUNT
,
statisticsDriveDtoList
.
size
());
}
statisticsDriveClient
.
insertStatisticsDriveList
(
fragStatisticsDriveDtoList
);
}
}
}
}
}
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/MySimpleJobServiceTest.java
View file @
e093939
...
@@ -34,4 +34,10 @@ class MySimpleJobServiceTest {
...
@@ -34,4 +34,10 @@ class MySimpleJobServiceTest {
System
.
out
.
println
(
"statisticsDriveR = "
+
JSON
.
toJSONString
(
statisticsDriveR
));
System
.
out
.
println
(
"statisticsDriveR = "
+
JSON
.
toJSONString
(
statisticsDriveR
));
}
}
@Test
public
void
test02
(){
int
size
=
623
/
100
;
System
.
out
.
println
(
"size = "
+
size
);
}
}
}
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment