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 d2c810f0
authored
Nov 22, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加不在店统计数据定时任务
1 parent
4e72dbcd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
98 additions
and
2 deletions
src/main/java/cn/com/glsx/schedulerjob/task/modules/service/StatisticsInStoreSchedulerJobService.java
src/main/java/cn/com/glsx/schedulerjob/task/taskscheduler/StatisticsInStoreSchedulerJob.java
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/InStoreSchedulerJobServiceTest.java
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/MySimpleJobServiceTest.java
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/StatisticsInStoreSchedulerJobServiceTest.java
src/main/java/cn/com/glsx/schedulerjob/task/modules/service/StatisticsInStoreSchedulerJobService.java
0 → 100644
View file @
d2c810f
package
cn
.
com
.
glsx
.
schedulerjob
.
task
.
modules
.
service
;
import
cn.com.glsx.stdinterface.api.StatisticsInStoreClient
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.plat.core.web.R
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* @author liuyf
* @date 2021年01月26日 下午2:37:40
*/
@Slf4j
@Service
public
class
StatisticsInStoreSchedulerJobService
{
@Autowired
private
StatisticsInStoreClient
statisticsInStoreClient
;
public
void
calculateStatisticsInStoreDateEveryDay
()
{
log
.
info
(
"开始统计并插入不在店统计数据==="
);
R
<
Integer
>
statisticsR
=
statisticsInStoreClient
.
statisticsAndInsertInStoreDataEveryDay
();
log
.
info
(
"统计的返回结果==="
+
JSON
.
toJSONString
(
statisticsR
));
}
}
src/main/java/cn/com/glsx/schedulerjob/task/taskscheduler/StatisticsInStoreSchedulerJob.java
0 → 100644
View file @
d2c810f
package
cn
.
com
.
glsx
.
schedulerjob
.
task
.
taskscheduler
;
import
cn.com.glsx.schedulerjob.task.modules.service.StatisticsInStoreSchedulerJobService
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.dangdang.ddframe.job.api.simple.SimpleJob
;
import
com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob
;
import
com.glsx.plat.common.utils.DateUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
/**
* 统计并插入不在店统计任务
*/
@Slf4j
@Component
@ElasticSimpleJob
(
jobName
=
"StatisticsInStoreSchedulerJob"
,
cron
=
"0 30 4 * * ?"
)
public
class
StatisticsInStoreSchedulerJob
implements
SimpleJob
{
@Autowired
private
StatisticsInStoreSchedulerJobService
statisticsInStoreSchedulerJobService
;
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
log
.
info
(
"Thread ID: {}, 作业分片总数: {}, "
+
"当前分片项: {}.当前参数: {},"
+
"作业名称: {}.作业自定义参数: {}"
,
Thread
.
currentThread
().
getId
(),
shardingContext
.
getShardingTotalCount
(),
shardingContext
.
getShardingItem
(),
shardingContext
.
getShardingParameter
(),
shardingContext
.
getJobName
(),
shardingContext
.
getJobParameter
()
);
String
normalDate
=
DateUtils
.
formatNormal
(
new
Date
());
log
.
info
(
"---------------{}-开始----------------"
,
normalDate
);
statisticsInStoreSchedulerJobService
.
calculateStatisticsInStoreDateEveryDay
();
log
.
info
(
"---------------{}-结束--------------"
,
normalDate
);
}
}
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/InStoreSchedulerJobServiceTest.java
View file @
d2c810f
...
@@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringRunner;
...
@@ -11,7 +11,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@Slf4j
@Slf4j
@RunWith
(
SpringRunner
.
class
)
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
@SpringBootTest
(
classes
=
Application
.
class
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
class
InStoreSchedulerJobServiceTest
{
public
class
InStoreSchedulerJobServiceTest
{
@Autowired
@Autowired
InStoreSchedulerJobService
inStoreSchedulerJobService
;
InStoreSchedulerJobService
inStoreSchedulerJobService
;
...
...
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/MySimpleJobServiceTest.java
View file @
d2c810f
...
@@ -14,7 +14,7 @@ import org.springframework.test.context.junit4.SpringRunner;
...
@@ -14,7 +14,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@Slf4j
@Slf4j
@RunWith
(
SpringRunner
.
class
)
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
@SpringBootTest
(
classes
=
Application
.
class
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
class
MySimpleJobServiceTest
{
public
class
MySimpleJobServiceTest
{
@Autowired
@Autowired
private
MySimpleJobService
mySimpleJobService
;
private
MySimpleJobService
mySimpleJobService
;
...
...
src/test/java/cn/com/glsx/schedulerjob/task/modules/service/StatisticsInStoreSchedulerJobServiceTest.java
0 → 100644
View file @
d2c810f
package
cn
.
com
.
glsx
.
schedulerjob
.
task
.
modules
.
service
;
import
cn.com.glsx.Application
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.jupiter.api.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
@Slf4j
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
class
StatisticsInStoreSchedulerJobServiceTest
{
@Autowired
StatisticsInStoreSchedulerJobService
statisticsInStoreSchedulerJobService
;
@Test
public
void
calculateInStoreDateEveryDay
()
{
System
.
out
.
println
(
"statisticsInStoreSchedulerJobService start==="
);
statisticsInStoreSchedulerJobService
.
calculateStatisticsInStoreDateEveryDay
();
System
.
out
.
println
(
"statisticsInStoreSchedulerJobService end==="
);
}
}
\ 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